cancel
Showing results for 
Search instead for 
Did you mean: 

Find reference to source Purchase Order when creating Purchase Order by Adopt (Copy) function

juan_suros
Contributor
0 Kudos

I would like to reference the source Purchase Order in a new Purchase Order created by adoption.

Sequence of steps:

1) In ME21N, I activate [Document Overview On]

2) run the selection for Purchase Orders.

3) Select the line items I want in the new PO and press the [Adopt] button.

4) A new PO is created.

I would like to make a reference in this new document to the source document. I will probably use a BADI at header or item level in the PO.

In this scenario, how may I find a reference to the "source document" in ABAP code?

Accepted Solutions (1)

Accepted Solutions (1)

nomssi
Active Contributor
0 Kudos

if you implement the cusomer-exit EXIT_SAPMM06E_012 you will have the reference document in parameter I_REKKO.

JNN

Answers (1)

Answers (1)

juan_suros
Contributor
0 Kudos

Yes, Thank you. That is what I was looking for.

The following code will get this reference in any code in the MEPO library code area, including transactions, badis, and exits:

DATA: ref TYPE string. 
FIELD-SYMBOLS: <rekko> TYPE ekko. 

ref = '(SAPLMEPO)REKKO'.    "REKKO (EKKO aus Referenz) 
ASSIGN: (ref) TO <rekko>. 

IF <rekko> IS ASSIGNED.   
  IF <rekko>-ebeln IS NOT INITIAL. 
*   <rekko>-ebeln   "<== is the reference Purchase Order from which this PO was ADOPTed.   
  ENDIF. 
ENDIF.
UNASSIGN: <rekko>.