Skip to Content

Transfer Custom Tab item level data of PR to custom tab in header level while PO creation.

Hi Abapers,

I have added 3 fields present in CI_EBANDB as well as in CI_EKKODB.

I have added in me51n/me52n/me53n a custom tab with these 3 fields at item level for PR.

I have also added in me21n/me22n/me23n a custom tab with these 3 fields at header level for PO.

Now my requirement is while creating PO in reference to PR, the custom tab values at line item level of PR should go and sit to the input fields of custom tab in PO at header level.

Please someone help me with this requirement.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

5 Answers

  • Jan 05, 2017 at 07:06 AM

    Did you look at some BAdI like ME_PROCESS_PO_CUST?

    Regards,
    Raymond

    Add comment
    10|10000 characters needed characters exceeded

  • Jan 05, 2017 at 12:23 PM

    hi raymond.

    Seen the badi but want to know in which method i need to implement this code.

    Add comment
    10|10000 characters needed characters exceeded

  • Jan 08, 2017 at 07:51 AM

    hi Raymond,

    I need to capture the pr line item details when po is created in reference to that pr from me21n. Then i need to update a custom tab fields in po header level with some values from the captured pr line item details. Can you please tell me how and from which badi/exit i can do this. If you can share a bit of code it would be nice. I have done it for po header and line items details in method check & post. Will the same code work to get the pr line item details. Also would like to know how to set data in header level custom tab.

    Add comment
    10|10000 characters needed characters exceeded

  • Jan 10, 2017 at 08:50 AM

    Hi everyone,

    i have done that successfully transferring data from PR to PO header level when PO is created in reference to PR from ME21n/ME22n/ME23n.

    Now if user wants, they can also change it accordingly if they want on these 3 fields. But now PO is not allowing any new data on these 3 fields to get saved once they are copied from PR. I am sharing my complete code in ME_PROCESS_PO_CUST~PROCESS_HEADER. Please need help on this badly.

    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
    AND FRGZU <> 'X'.
    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' ).

    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.
    ENDIF.
    ENDIF.
    ENDIF.
    ENDIF.
    ENDIF.
    ENDIF.

    Add comment
    10|10000 characters needed characters exceeded

  • Jan 10, 2017 at 10:54 AM

    Solved the issue. Need to write the same code in ME_PROCESS_PO_CUST~CHECK

    Add comment
    10|10000 characters needed characters exceeded