Download as pdf or txt
Download as pdf or txt
You are on page 1of 10

27.11.

2021 21:39 Disable standard field in ME22N,ME21N | SAP Blogs

Community

Welcome Learners! 
Find out more
Join the new SAP BTP Learning group for guidance
and support to achieve your learnings goals.

Ask a Question Write a Blog Post Login

Technical Articles

Enio Rafael
December 5, 2018
| 2 minute read

Disable standard field in


ME22N,ME21N
 8  6  7,642
Follow

Hi everyone.
 Like
 

 RSS Feed I saw a lot of questions about how to disable a standard field in ME22N and
ME21N. So I decided to share my solution for this problem.

First of all, SAP don’t offer an standard way for reach this solution. And in my
case i wanted to include some specific code to decide disable or not that field.

Lets solve the problem!

In the end of function MEPOBADI_FS_ITEM include the implicit enhancement.

ENHANCEMENT 1 ZENH_LOCK_PO_STANDARD_FIELD. "active version

data fields type table of zmmt001 with header line.

data field_selection type MMPUR_FS.

https://blogs.sap.com/2018/12/05/disable-standard-field-in-me22nme21n/ 1/10
27.11.2021 21:39 Disable standard field in ME22N,ME21N | SAP Blogs

data parameters TYPE abap_parmbind_tab.

data param_line TYPE abap_parmbind.

data lock_po type ref to zcl_lock_po_field.

select *

from zmmt001

into table fields.

check not fields[] is initial.

create object lock_po


exporting

im_header = im_header

im_item = im_item.

loop at fields.

READ TABLE ch_fieldselection into field_selection with KEY meta


check sy-subrc is INITIAL.

call method lock_po->(fields-method)

CHANGING

field_selection = field_selection.

MODIFY TABLE ch_fieldselection from field_selection.

endloop.

ENDENHANCEMENT.

As you can see, there is a table called ZMMT001, which will store the field number
and the method that we wanna use to process.

https://blogs.sap.com/2018/12/05/disable-standard-field-in-me22nme21n/ 2/10
27.11.2021 21:39 Disable standard field in ME22N,ME21N | SAP Blogs

The class ZCL_LOCK_PO_FIELD looks like this

class ZCL_LOCK_PO_FIELD definition

public

final

create public .

public section.

methods CONSTRUCTOR

importing

!IM_HEADER type ref to IF_PURCHASE_ORDER_MM

!IM_ITEM type ref to IF_PURCHASE_ORDER_ITEM_MM .

methods NET_PRICE

changing

!FIELD_SELECTION type MMPUR_FS .

PROTECTED SECTION.

PRIVATE SECTION.

CONSTANTS:

BEGIN OF field_state,

enabled TYPE c VALUE '+',

disabled TYPE c VALUE '*',

invisible TYPE c VALUE '-',

END OF field_state.

DATA po_header TYPE mepoheader .

DATA po_item TYPE mepoitem .

ENDCLASS.

https://blogs.sap.com/2018/12/05/disable-standard-field-in-me22nme21n/ 3/10
27.11.2021 21:39 Disable standard field in ME22N,ME21N | SAP Blogs

CLASS ZCL_LOCK_PO_FIELD IMPLEMENTATION.

* <SIGNATURE>-----------------------------------------------------
* | Instance Public Method ZCL_LOCK_PO_FIELD->CONSTRUCTOR

* +---------------------------------------------------------------
* | [--->] IM_HEADER TYPE REF TO IF_PURCHASE_O
* | [--->] IM_ITEM TYPE REF TO IF_PURCHASE_O
* +---------------------------------------------------------------
METHOD constructor.

po_header = im_header->get_data( ). "//get header data

po_item = im_item->get_data( ). "//get item

ENDMETHOD.

* <SIGNATURE>-----------------------------------------------------
* | Instance Public Method ZCL_LOCK_PO_FIELD->NET_PRICE

* +---------------------------------------------------------------
* | [<-->] FIELD_SELECTION TYPE MMPUR_FS

* +---------------------------------------------------------------
METHOD net_price.

"//Make your tratatives here

* ....

"//Disable field

field_selection-fieldstatus = field_state-disabled.

ENDMETHOD.

ENDCLASS.

Thats it! if you have some thing to say, please, say.

Thanks,

Enio.

Alert Moderator

Assigned Tags

ABAP Development

MM Purchasing

https://blogs.sap.com/2018/12/05/disable-standard-field-in-me22nme21n/ 4/10
27.11.2021 21:39 Disable standard field in ME22N,ME21N | SAP Blogs

abap objects

disable field on Purchase Order

ME21

me22

Similar Blog Posts 


Proposal search for Standard field in SAP
By
Thanga Prakash Thanga Raj Nov 30, 2019

Custom Tab in ME21N/ME22N/ME23N purchase order transactions


By
Sandeep Kumar Apr 28, 2012

Calling custom developed Adobe Form from standard Transaction Code for Print Output in SAP ABAP
By
suman kolatum Feb 07, 2020

Related Questions 
Assing Screen variants to users Purchase order
By
Maria Merino Jul 23, 2020

Enable and Disable the Netprice field


By
Dhandayuthabani Pugazhendhi Dec 09, 2013

Disable long text "Term of payment" in me21n and me22n


By
Former Member Oct 31, 2014

Join the Conversation 


SAP TechEd
Tune in for tech talk. Stay for inspiration. Upskill your future.

SAP BTP Learning Group


SAP Business Technology Platform Learning Journeys.

Coffee Corner
Join the new Coffee Corner Discussion Group.

https://blogs.sap.com/2018/12/05/disable-standard-field-in-me22nme21n/ 5/10
27.11.2021 21:39 Disable standard field in ME22N,ME21N | SAP Blogs

8 Comments

You must be Logged on to comment or reply to a post.

Quynh Doan Manh


December 5, 2018 at 8:06 am

thankyou for sharing knowledge. May I ask where is this function (MEPOBADI_FS_ITEM) called? from its
name look like it only affect on item level, what about header?

Like 0 | Share

Enio Rafael | Blog Post Author


December 5, 2018 at 12:18 pm

Hi Quynh.

Yes, the function MEPOBADI_FS_ITEM is called for every item, as you can see in the print below

https://blogs.sap.com/2018/12/05/disable-standard-field-in-me22nme21n/ 6/10
27.11.2021 21:39 Disable standard field in ME22N,ME21N | SAP Blogs

About header, the function that you can use is MEPOBADI_FS_HEADER. As i could see, it works
exactly like item. So you can use the same implementation.

Thanks for the question,

Enio.

Like 0 | Share

Alexandre Henrat
December 5, 2018 at 12:46 pm

Hi,

For the record, the field-control logic is explained in OSS note 2287838

Like 1 | Share

Michael Bennett
December 14, 2018 at 5:46 am

Hi,

Would a transaction variant with screen variants allow you to do something similar without code? We lock
down many fields in ME29N using a screen variants as part of a transaction variant set by transaction
SHD0.

Regards,

Michael

Like 1 | Share

https://blogs.sap.com/2018/12/05/disable-standard-field-in-me22nme21n/ 7/10
27.11.2021 21:39 Disable standard field in ME22N,ME21N | SAP Blogs

Carlos Wagner Moçatto


December 21, 2018 at 11:26 am

What a nice document dear Enio Rafael.

congrats for sharing here with all of us.

take care

Moçatto

Like 1 | Share

Kellen Yan
April 22, 2021 at 6:45 am

Nice,Very helpful article.

But How to quickly find the corresponding number of ME21N field.

Regards,

Kellen

Like 0 | Share

LUIS RODRIGO ARELLANO ANONALES


May 6, 2021 at 4:27 pm

Hi,

Thanks for the article.

Can we use the functionality to lock fields at position level within the tabs? (i.e. Quantities/Weights tab)

https://blogs.sap.com/2018/12/05/disable-standard-field-in-me22nme21n/ 8/10
27.11.2021 21:39 Disable standard field in ME22N,ME21N | SAP Blogs

ME22N

Is there a way to find the right field?

Thanks in advance

Like 0 | Share

Harshit Varshney
July 29, 2021 at 5:34 am

https://blogs.sap.com/2018/12/05/disable-standard-field-in-me22nme21n/ 9/10
27.11.2021 21:39 Disable standard field in ME22N,ME21N | SAP Blogs

In the end of function MEPOBADI_FS_ITEM include the implicit enhancement.

LOOP AT ch_fieldselection INTO w_fieldselection WHERE metafield = '132'. " Disabled B


              w_fieldselection-fieldstatus = '*' .

              MODIFY ch_fieldselection FROM w_fieldselection.

              CLEAR w_fieldselection.

          ENDLOOP.

Like 0 | Share

Find us on

Privacy Terms of Use

Legal Disclosure Copyright

Trademark Çerez Tercihleri

Newsletter Support

https://blogs.sap.com/2018/12/05/disable-standard-field-in-me22nme21n/ 10/10

You might also like