Enterprise Resource Planning Blogs 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,414
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
Labels in this area