2017 Jan 19 2:29 PM
Hi Abapers,
I need to copy custom tab item level data of PR to header level custom tab while creating PO with reference to PR from me21n. I have done that successfully using Badi me_process_po_cust method process header. Data is coming perfectly. Problem is that it is fixed. User wants to change these fields and save it while creating PO from me21n if they are not satisfied with the data which came from PR. Right now i am tranferring the data correctly from PR to PO but not able to change it from me21n. Please someone help me with this issue. My code is very simple and if anyone wants to see it i can share it. Its been a long time i am fighting with this issue. Please help me.
2017 Jan 20 6:38 AM
Did you set some attribute in your implementing class instance to memorize 'copy performed' so no longer copy those data allowing user to change the result?
Regards,
Raymond
2017 Jan 20 7:19 AM
Hi Raymond,
I am sharing my code from IF_EX_ME_PROCESS_PO_CUST~PROCESS_HEADER. Please let me know where to change or set some attributes. As far my knowledge i did not set any attributes for this badi implementation.
SPAN { font-family: "Courier New"; font-size: 10pt; color: #000000; background: #FFFFFF; } .L0S31 { font-style: italic; color: #808080; } .L0S32 { color: #3399FF; } .L0S33 { color: #4DA619; } .L0S52 { color: #0000FF; } .L0S55 { color: #800080; } .L0S70 { color: #808080; }
DATA: LS_POHEADER TYPE MEPOHEADER,
LV_ITEM TYPE MEPOITEM,
IT_ITEM TYPE STANDARD TABLE OF MEPOITEM,
IT_PO_ITEMS TYPE PURCHASE_ORDER_ITEMS,
WA_EBAN TYPE EBAN.
DATA: LV_PLANT TYPE EWERK.
DATA: LV_DATE TYPE SY-DATUM.
FIELD-SYMBOLS: <FS_PO_ITEMS> TYPE PURCHASE_ORDER_ITEM.
CONSTANTS: PO_DATE TYPE CHAR10 VALUE '01.12.2016'.
IF ( SY-TCODE EQ 'ME21N' OR SY-TCODE EQ 'ME22N' OR SY-TCODE EQ 'ME23N' OR SY-TCODE EQ 'ME29N' ).
CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'
EXPORTING
DATE_EXTERNAL = PO_DATE
IMPORTING
DATE_INTERNAL = LV_DATE.
CALL METHOD IM_HEADER->GET_DATA
RECEIVING
RE_DATA = LS_POHEADER.
IT_PO_ITEMS = IM_HEADER->GET_ITEMS( ). " Get PO items object
LOOP AT IT_PO_ITEMS ASSIGNING <FS_PO_ITEMS>. " Get Purchasing Document Item
LV_ITEM = <FS_PO_ITEMS>-ITEM->GET_DATA( ).
APPEND LV_ITEM TO IT_ITEM.
CLEAR LV_ITEM.
ENDLOOP.
SORT IT_ITEM.
CLEAR LV_ITEM.
READ TABLE IT_ITEM INTO LV_ITEM WITH KEY EBELN = LS_POHEADER-EBELN.
IF SY-SUBRC = 0.
LV_PLANT = LV_ITEM-WERKS.
CLEAR WA_EBAN.
SELECT SINGLE * FROM EBAN INTO WA_EBAN WHERE BANFN = LV_ITEM-BANFN.
IF SY-SUBRC = 0.
IF ( LS_POHEADER-BSART = 'ZCPS' OR
LS_POHEADER-BSART = 'ZSER' OR
LS_POHEADER-BSART = 'ZIMS' OR
LS_POHEADER-BSART = 'ZMP' OR
LS_POHEADER-BSART = 'ZCIS' )
AND LV_PLANT = '1100'.
IF LS_POHEADER-AEDAT > LV_DATE.
IF ( ME->Z_TRTYP = 'H' OR ME->Z_TRTYP = 'V' ).
* CALL METHOD IM_HEADER->IS_CHANGEABLE( ).
LS_POHEADER-ZZENGR_INCHRG_NAME = WA_EBAN-ZZENGR_INCHRG_NAME.
LS_POHEADER-ZZDEPARTMENT = WA_EBAN-ZZDEPARTMENT.
LS_POHEADER-ZZNATUREOFWORK = WA_EBAN-ZZNATUREOFWORK.
CALL METHOD IM_HEADER->SET_DATA
EXPORTING
IM_DATA = LS_POHEADER.
* CALL METHOD IM_HEADER->SET_CHANGED.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
In check method also i tried but not working as my_ibs_firewall_on & my_cust_firewall_on is failing and i do not want to hard code to bypass them as it is performed by standard.
2017 Jan 20 8:13 AM
Once you successfully update the ZZ fields (im_header->set_data) set some instance attribute as you already did for ME->Z_TRTYP and no longer overwrite those fields again when this attribue is already set.
As an alternative you could add some get_previous_data and get_presistent_data call to trigger your update (from process_item) only when purchase requisistion number changed or added)
2017 Jan 20 10:32 AM
Yes Raymond,
Put a check for initial before this 3 fields.
LS_POHEADER-ZZENGR_INCHRG_NAME = WA_EBAN-ZZENGR_INCHRG_NAME.
LS_POHEADER-ZZDEPARTMENT = WA_EBAN-ZZDEPARTMENT.
LS_POHEADER-ZZNATUREOFWORK = WA_EBAN-ZZNATUREOFWORK.
Now user can change the value and save it.
Thank you for your valuable help.