Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

User exit/BADi PO creation

former_member125661
Contributor
0 Likes
3,909

I am looking for a user exit where I can update a Z table with PO line items after a PO is created using Me21/Me21n. (After commit ) . Please let me know if you can help.

Thanks in advance,

shareen

I am looking for a user exit where I can update a Z table with PO line items after a PO is created using Me21/Me21n. (After commit ) . Please let me know if you can help.

Thanks in advance,

shareen

10 REPLIES 10
Read only

Former Member
0 Likes
2,913

Hi Shareen,

Before you save the PO, Check the Program name of that screen in Status bar.

Take that Program name, and find the Package of that program.

Take that Package name and goto SE84 Transaction.

Expand Enhancements in the left panel, double click on enhancements.

Provide the Package Name and execute it will show you all the available userexits.

Take out the once which will trigger at Save event.

Write the code into that and get the item details into your internal table.

Update data to ZTable from the internal table.

Regards,

Satish

Read only

Tamas_Hoznek
Product and Topic Expert
Product and Topic Expert
0 Likes
2,913

If it is sufficient to have an exit for ME21N only, then I'd suggest using BAdI ME_PROCESS_PO_CUST.

If it must be working with ME21 then the SMOD enhancement MM06E005 (and specifically the function module EXIT_SAPMM06E_013) is probably what you need. This will work with both ME21 and ME21N if I'm not mistaken.

Read only

0 Likes
2,913

EXIT_SAPMM06E_013 is fired before a PO number is generated. So i cannot use it. I need to update the Ztable with the PO number and certain item level fields.

Read only

0 Likes
2,913

Shareen,

Then you need to find a BADI which will trigger after Save.

Put break-point in method GET_INSTANCE of class CL_EXITHANDLER.

Now create a PO, after saving find which BADIs are triggereing and see those BADIs which are capturing EKPO details or not.

Regards,

Satish

Read only

Tamas_Hoznek
Product and Topic Expert
Product and Topic Expert
0 Likes
2,913

Bummer... I didn't know that off the top of my head.

Well, then in EXIT_SAPMM06E_013 you could try registering a subroutine call to execute ON COMMIT, pass all the data you need for your update and retrieve the assigned PO number there by querying memory parameter BES... hopefully it will be set by the time it runs.

Read only

Tamas_Hoznek
Product and Topic Expert
Product and Topic Expert
0 Likes
2,913

That works usually OK, except it's not really going to help in case there was a BAdI called while posting happens in the update task... the process won't stop at the BREAK-POINT then.

Read only

0 Likes
2,913

Tamas,

Cool... Thanks for the info

Satish

Read only

0 Likes
2,913

Guys..finally got this working.

Found a BADI method that is triggered after a PO is created :

ME_PROCESS_PO_CUST~CLOSE .

This is what I did :

METHOD IF_EX_ME_PROCESS_PO_CUST~CLOSE.

  DATA: L_POITEMT TYPE PURCHASE_ORDER_ITEMS ." MMPR_UEKPO.
  DATA: L_LIFNR TYPE LIFNR .
  DATA: LV_ZSLOC_CUSTCLOTH TYPE ZSLOC_CUSTCLOTH .
* DATA: L_POITEM LIKE LINE OF L_POITEMT .
  DATA: L_POITEM_TAB TYPE STANDARD TABLE OF EKPO .
  DATA: L_POITEM TYPE EKPO .
  DATA: LV_EBELN TYPE EBELN .


  CHECK SY-TCODE EQ 'ME21N' .

  IF SY-UCOMM EQ 'MESAVE' OR SY-UCOMM EQ 'OPT1'.

    GET PARAMETER ID 'BES' FIELD LV_EBELN .

    SELECT *  INTO TABLE L_POITEM_TAB FROM EKPO WHERE EBELN EQ LV_EBELN .

*  CALL METHOD IM_HEADER->GET_ITEMS->GET_DATA
*    RECEIVING
*      RE_ITEMS = L_POITEMT.
*
*
*  CALL METHOD L_POITEMT->GET_DATA
*    RECEIVING
*      RE_DATA = L_POITEM_TAB .
*      .

    LOOP AT L_POITEM_TAB INTO L_POITEM.

      SELECT SINGLE LIFNR INTO L_LIFNR FROM EKKO WHERE EBELN EQ L_POITEM-EBELN .

      CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
        EXPORTING
          INPUT  = L_LIFNR
        IMPORTING
          OUTPUT = L_LIFNR.

      IF L_POITEM-WERKS EQ '2010' AND ( L_LIFNR EQ '6001943' OR
                                        L_LIFNR EQ '6001887' OR
                                        L_LIFNR EQ '6002706' ).

        CLEAR LV_ZSLOC_CUSTCLOTH .


        CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
          EXPORTING
            INPUT  = L_POITEM-EBELN
          IMPORTING
            OUTPUT = L_POITEM-EBELN.

        LV_ZSLOC_CUSTCLOTH-EBELN = L_POITEM-EBELN.
        LV_ZSLOC_CUSTCLOTH-EBELP = L_POITEM-EBELP.
        LV_ZSLOC_CUSTCLOTH-ERDAT = SY-DATUM.
        LV_ZSLOC_CUSTCLOTH-ERZET = SY-UZEIT .
        LV_ZSLOC_CUSTCLOTH-LGORT = L_POITEM-LGORT.

        SELECT SINGLE VBELN VBELP INTO (LV_ZSLOC_CUSTCLOTH-VBELN,LV_ZSLOC_CUSTCLOTH-VBELP) FROM EKKN WHERE EBELN EQ L_POITEM-EBELN AND
                                                                                EBELP EQ L_POITEM-EBELP.
        IF SY-SUBRC EQ 0.

          MODIFY ZSLOC_CUSTCLOTH FROM LV_ZSLOC_CUSTCLOTH .

        ENDIF.

      ENDIF.

    ENDLOOP.

  ENDIF .

Read only

former_member125661
Contributor
0 Likes
2,913

Thanks for useful comments from everyone.This issue is solved now

Read only

0 Likes
2,913

This will work fine as long as this functionality is not required in ME21. As far as I remember, this BAdI is only called for Enjoy POs, but not in ME21.