The business requirement for this piece of coding was the following: a user-specific delivery address is to be created with transaction MEAN. The assignment of the address number to a user is stored in a z-table. When a purchase requisition is created, the address number is read from the table and written to the field adrn2 in the structure mereq_item.
Please note: to simplify the example, a hard coded value was used for the address number.
First check whether field to be changed is contained in MEREQ_ITEM_S_CUST_ALLOWED. If not, create append structure and add field adrn2.
Implementation of Method IF_EX_ME_PROCESS_REQ_CUST~PROCESS_ITEM:
DATA: ls_item_mereq TYPE MEREQ_ITEM.
* get item data
ls_item_mereq = im_item->get_data( ).
* change delivery address
if ls_item_mereq-adrn2 is initial.
ls_item_mereq-adrn2 = '0000022297'.
im_item->set_data( ls_item_mereq ) .
MOVE: 'X' TO ls_datax-adrn2.
im_item->set_datax( ls_datax ) .
endif.