Enterprise Resource Planning Blog Posts by Members
Gain new perspectives and knowledge about enterprise resource planning in blog posts from community members. Share your own comments and ERP insights today!
cancel
Showing results for 
Search instead for 
Did you mean: 
22,766
Hi everyone.

 

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.
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 metafield = fields-field.
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.

 





 

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.



CLASS ZCL_LOCK_PO_FIELD IMPLEMENTATION.


* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Instance Public Method ZCL_LOCK_PO_FIELD->CONSTRUCTOR
* +-------------------------------------------------------------------------------------------------+
* | [--->] IM_HEADER TYPE REF TO IF_PURCHASE_ORDER_MM
* | [--->] IM_ITEM TYPE REF TO IF_PURCHASE_ORDER_ITEM_MM
* +--------------------------------------------------------------------------------------</SIGNATURE>
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
* +--------------------------------------------------------------------------------------</SIGNATURE>
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.
8 Comments
DoanManhQuynh
Active Contributor
0 Kudos
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?
0 Kudos
Hi Quynh.

 

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



 

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.

 
AlexandreH
Explorer
Hi,

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

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

 
carloswagner_moatto3
Active Participant

What a nice document dear Enio Rafael.

congrats for sharing here with all of us.

take care

Moçatto

 

former_member739448
Discoverer
0 Kudos
Nice,Very helpful article.

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

Regards,

Kellen
lrarellanoa
Discoverer
0 Kudos

Hi,

Thanks for the article.

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

ME22N

Is there a way to find the right field?

Thanks in advance

 
0 Kudos
In the end of function MEPOBADI_FS_ITEM include the implicit enhancement.

 
LOOP AT ch_fieldselection INTO w_fieldselection WHERE metafield '132'. " Disabled Batch Field
              w_fieldselection-fieldstatus '*' .
              MODIFY ch_fieldselection FROM w_fieldselection.
              CLEAR w_fieldselection.
          ENDLOOP.

 

 
Labels in this area