10-24-2013 1:16 PM
Hello Gurus,
i wanted to maek some custom actions in PO ME22N transction by adding some buttons into Screen and trigering COPY data action.
I chose EXIT_SAPMM06E_018 to be able to performe my requirements.
During the code i initialize PO header and then the reading of it.
Then im getting line items with the PO document header.
Afterwards the loop starts to run where i need to assign Custom field ZAUFNR into mepoitem-ZAUFNR structure.
In conclusion the SET_DATA method is beeing trigered. Everything seems ok, but the line item fields arent getting copied and transfered to other line items.
Bellow is my code. I think im missing something.
Please advise, what could be my problem.
if I_UCOMM = 'ZCOPY'.
* BREAK-POINT.
DATA:
L_ITEM TYPE REF TO CL_PO_ITEM_HANDLE_MM,
L_HEADER TYPE REF TO CL_PO_HEADER_HANDLE_MM,
LS_MEPOITEM TYPE mepoitem,
LS_HEADER TYPE mepoheader,
L_RESULT TYPE MMPUR_BOOL,
LT_ITEMS TYPE purchase_order_items,
LS_ITEM TYPE purchase_order_item.
*--------------------------------------------------------------------*
* data have to be transported to business logic
*--------------------------------------------------------------------*
CREATE OBJECT L_HEADER
EXPORTING
im_po_number = gl_ekpo-ebeln
EXCEPTIONS
failure = 1
OTHERS = 9.
IF sy-subrc NE 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
*--------------------------------------------------------------------*
* initialize PO Header READ
*--------------------------------------------------------------------*
L_HEADER->PO_INITIALIZE( ).
CALL METHOD L_HEADER->PO_READ
EXPORTING
im_tcode = 'ME23N'
im_trtyp = 'A'
im_aktyp = 'A'
im_po_number = gl_ekpo-ebeln
IMPORTING
ex_result = L_RESULT
EXCEPTIONS
OTHERS = 9.
CHECK L_RESULT EQ 'X'.
IF sy-subrc NE 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
*--------------------------------------------------------------------*
* GET PO Header
*--------------------------------------------------------------------*
CALL METHOD L_HEADER->get_data
IMPORTING
ex_data = ls_header
EXCEPTIONS
failure = 1
OTHERS = 2.
*--------------------------------------------------------------------*
* GET and SET PO Line Items
*--------------------------------------------------------------------*
REFRESH: LT_ITEMS.
LT_ITEMS = L_HEADER->if_purchase_order_mm~get_items( ).
LOOP AT LT_ITEMS INTO LS_ITEM.
L_ITEM ?= LS_ITEM-ITEM.
L_ITEM->my_parent ?= L_HEADER.
IF LS_ITEM-ITEM IS BOUND.
CALL METHOD L_ITEM->GET_DATA
IMPORTING
EX_DATA = LS_MEPOITEM.
MOVE gl_ekpo-ZAUFNR TO LS_MEPOITEM-ZAUFNR.
CALL METHOD LS_ITEM-ITEM->SET_DATA
EXPORTING
IM_DATA = LS_MEPOITEM.
ENDIF.
ENDLOOP.
endif.
Regards
Laurynas
10-24-2013 1:54 PM
Hi Laurynas,
User exit ZXM06U40 ( EXIT_SAPMM06E_018 ) is used to import data from
customer subscreen.
To pass data to screen, you need to use the exit EXIT_SAPMM06E_016 (Include ZXM06U41) or
EXIT_SAPMM06E_017 (ZXM06U42) .
You may need to export the line item data in EXIT_SAPMM06E_018 using
export LS_MEPOITEM to memory id 'MEP'.
and import it in the exit EXIT_SAPMM06E_016 or EXIT_SAPMM06E_017. Then use the set_data method.
10-24-2013 1:54 PM
Hi Laurynas,
User exit ZXM06U40 ( EXIT_SAPMM06E_018 ) is used to import data from
customer subscreen.
To pass data to screen, you need to use the exit EXIT_SAPMM06E_016 (Include ZXM06U41) or
EXIT_SAPMM06E_017 (ZXM06U42) .
You may need to export the line item data in EXIT_SAPMM06E_018 using
export LS_MEPOITEM to memory id 'MEP'.
and import it in the exit EXIT_SAPMM06E_016 or EXIT_SAPMM06E_017. Then use the set_data method.
10-25-2013 8:03 AM
Hi,
i moved my code into EXIT_SAPMM06E_017, but nothing happens.
During the run it should take the Field Internal order and the value should be copied to all other items. But it doesnt happen that way. maybe there is somewhere a different syntax problem
Regards
Laurynas
10-25-2013 8:22 AM
Please use exit EXIT_SAPMM06E_016. In exit 18 export the data to memory as suggested above so that you can update EKPO internal table in custom subscreen after updating export it so that you can access it in 18 exit and update the data
10-25-2013 10:11 AM
Hi,
i did this, but it reads the data from the last item and copies it into the on screen selected one.
By the way the second items field wasnt changed at all, where he had to be replaced by the on screen item field.
I thing something different is missing.
Regards.
10-25-2013 10:17 AM
Lets first do this way. You put a break point in 16 exit and modify the contents of EKPO internal table in debugging and then check whether it reflects everywhere if yes then you need to correct your code.
10-28-2013 6:56 AM
Hi
the values that are geeting passed are wrong. My code passes last item from Purchase order no matter how much items there are.
I think i must distinguish one ON SCREEN item that is active to be sent to other items.
Unfortunately i dont know how to read only one active item.
Regards
Laurynas.
10-28-2013 7:18 AM
Yes it will transport the last item since you must have exported that structure in loop to memory.
Option 1.
In EXIT_SAPMM06E_018
export lt_items to memory ID 'MIT'
Move the following code to EXIT_SAPMM06E_016 (Include ZXM06U41) or
EXIT_SAPMM06E_017 (ZXM06U42) .
import lt_items from memory id 'MIT'.
LOOP AT LT_ITEMS INTO LS_ITEM.
L_ITEM ?= LS_ITEM-ITEM.
L_ITEM->my_parent ?= L_HEADER.
IF LS_ITEM-ITEM IS BOUND.
CALL METHOD L_ITEM->GET_DATA
IMPORTING
EX_DATA = LS_MEPOITEM.
MOVE gl_ekpo-ZAUFNR TO LS_MEPOITEM-ZAUFNR.
CALL METHOD LS_ITEM-ITEM->SET_DATA
EXPORTING
IM_DATA = LS_MEPOITEM.
ENDIF.
ENDLOOP.
Make the required declaration in the second user exit.
Option 2.
data Lt_MEPOITEM TYPE table of mepoitem,
LOOP AT LT_ITEMS INTO LS_ITEM.
L_ITEM ?= LS_ITEM-ITEM.
L_ITEM->my_parent ?= L_HEADER.
IF LS_ITEM-ITEM IS BOUND.
CALL METHOD L_ITEM->GET_DATA
IMPORTING
EX_DATA = LS_MEPOITEM.
MOVE gl_ekpo-ZAUFNR TO LS_MEPOITEM-ZAUFNR.
append ls_mepoitem to lt_mepoitem.
ENDIF.
ENDLOOP.
export lt_mepoitem to memory ID 'MEP'.
And in EXIT_SAPMM06E_016 (Include ZXM06U41) or
EXIT_SAPMM06E_017 (ZXM06U42) .
import lt_mepoitem from memory ID 'MEP'.
loop at lt_mepoitem to ls_mepoitem.
CALL METHOD LS_ITEM-ITEM->SET_DATA
EXPORTING
IM_DATA = LS_MEPOITEM.
ENDLOOP.
endloop.
Make the required declaraions for ls_item.
10-28-2013 7:34 AM
10-28-2013 8:53 AM
Hi Thanks for the suggetions.
I did go for the second option, and on the EXIT_SAPMM06E_016 (Include ZXM06U41)
im getting the error that LS_MEPOITEM may not be converted to number.
Here is my code and error.
if GL_UCOMM = 'ZCOPY'.
BREAK-POINT.
DATA: LS_MEPOITEM TYPE mepoitem,
LT_MEPOITEM TYPE TABLE OF mepoitem,
LS_ITEM TYPE purchase_order_item.
IMPORT LT_MEPOITEM FROM MEMORY ID 'MEP'.
*CALL METHOD LS_ITEM-ITEM->SET_DATA
* EXPORTING
* IM_DATA = LS_MEPOITEM.
LOOP AT LT_MEPOITEM to LS_MEPOITEM.
CALL METHOD LS_ITEM-ITEM->SET_DATA
EXPORTING
IM_DATA = LS_MEPOITEM.
ENDLOOP.
ENDIF.
Regards
Laurynas
10-28-2013 8:56 AM
10-28-2013 9:10 AM
One more addition.
EXIT_SAPMM06E_018
export lt_items to memory ID 'MIT'
export lt_mepoitem to memory ID 'MEP'.
EXIT_SAPMM06E_016 (Include ZXM06U41)
IMPORT LT_MEPOITEM FROM MEMORY ID 'MEP'.
import lt_items from memory ID 'MIT'.
LOOP AT LT_ITEMS INTO LS_ITEM.
CALL METHOD LS_ITEM-ITEM->SET_DATA
EXPORTING
IM_DATA = LS_MEPOITEM.
ENDIF.
ENDLOOP.
10-28-2013 11:24 AM
Hi,
Thanks for your help, but there is something wrong with the export to MIT
10-28-2013 11:41 AM
10-29-2013 10:10 AM
Hello,
here it is. The first part is in:
### EXIT_SAPMM06E_018 (ZXM06U40) ###
if I_UCOMM = 'ZCOPY'.
BREAK-POINT.
DATA: L_ITEM TYPE REF TO CL_PO_ITEM_HANDLE_MM,
L_HEADER TYPE REF TO CL_PO_HEADER_HANDLE_MM,
LS_MEPOITEM TYPE mepoitem,
LT_MEPOITEM TYPE table of mepoitem,
LS_HEADER TYPE mepoheader,
L_RESULT TYPE MMPUR_BOOL,
LT_ITEMS TYPE purchase_order_items,
LS_ITEM TYPE purchase_order_item.
*--------------------------------------------------------------------*
* data have to be transported to business logic
*--------------------------------------------------------------------*
CREATE OBJECT L_HEADER
EXPORTING
im_po_number = gl_ekpo-ebeln
EXCEPTIONS
failure = 1
OTHERS = 9.
IF sy-subrc NE 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
*--------------------------------------------------------------------*
* initialize PO Header READ
*--------------------------------------------------------------------*
L_HEADER->PO_INITIALIZE( ).
CALL METHOD L_HEADER->PO_READ
EXPORTING
im_tcode = 'ME23N'
im_trtyp = 'A'
im_aktyp = 'A'
im_po_number = gl_ekpo-ebeln
IMPORTING
ex_result = L_RESULT
EXCEPTIONS
OTHERS = 9.
CHECK L_RESULT EQ 'X'.
IF sy-subrc NE 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
*--------------------------------------------------------------------*
* GET PO Header
*--------------------------------------------------------------------*
CALL METHOD L_HEADER->get_data
IMPORTING
ex_data = ls_header
EXCEPTIONS
failure = 1
OTHERS = 2.
*--------------------------------------------------------------------*
* GET and SET PO Line Items
*--------------------------------------------------------------------*
REFRESH: LT_ITEMS.
LT_ITEMS = L_HEADER->if_purchase_order_mm~get_items( ).
LOOP AT LT_ITEMS INTO LS_ITEM.
IF LS_ITEM-ITEM IS BOUND.
L_ITEM ?= LS_ITEM-ITEM.
L_ITEM->my_parent ?= L_HEADER.
CALL METHOD L_ITEM->GET_DATA
IMPORTING
EX_DATA = LS_MEPOITEM.
MOVE E_CI_EKPO-ZAUFNR TO LS_MEPOITEM-ZAUFNR.
APPEND LS_MEPOITEM to LT_MEPOITEM.
* CALL METHOD LS_ITEM-ITEM->SET_DATA
* EXPORTING
* IM_DATA = LS_MEPOITEM.
ENDIF.
ENDLOOP.
* export lt_items to memory ID 'MIT'.
EXPORT LT_MEPOITEM TO MEMORY ID 'MEP'.
endif.
The other part is in:
###### EXIT_SAPMM06E_016 (ZXM06U41) ######
if GL_UCOMM = 'ZCOPY'.
BREAK-POINT.
DATA: LS_MEPOITEM TYPE mepoitem,
LT_MEPOITEM TYPE TABLE OF mepoitem,
LS_ITEM TYPE purchase_order_item,
LT_ITEMS TYPE purchase_order_items.
IMPORT LT_MEPOITEM FROM MEMORY ID 'MEP'.
* import lt_items from memory ID 'MIT'.
LOOP AT LT_ITEMS INTO LS_ITEM.
CALL METHOD LS_ITEM-ITEM->SET_DATA
EXPORTING
IM_DATA = LS_MEPOITEM.
ENDLOOP.
**CALL METHOD LS_ITEM-ITEM->SET_DATA
** EXPORTING
** IM_DATA = LS_MEPOITEM.
* LOOP AT LT_MEPOITEM into LS_MEPOITEM.
* CALL METHOD LS_ITEM-ITEM->SET_DATA
* EXPORTING
* IM_DATA = LS_MEPOITEM.
* ENDLOOP.
ENDIF.
Thanks and best regards
Laurynas
10-29-2013 10:33 AM
Actually i have gone through your and code i believe it is not the correct way. Basically you want is when default and Z field of line item it shall get copied to all if i am right can you simply put your code in EXIT_SAPMM06E_013 and modify XEKPO[] table data. Only constraint i can see is it may happen this exit gets triggered on save.
10-30-2013 11:23 AM
The whole code is ok till the moment when the METHOD SET_DATA is called.
The loop overwrites all items with read value, but then the data somewhow isnt passed to ekpo table (outside of User exit)
By the way, the data should be changed and the changes visible before trigering save button.
View of LS_MEPOITEM
Only last Item has been put into it.
View of LT_MEPOITEM
Maybe there is a FM or BAPI which could import the LT_MEPOITEM data and change the values?
Regards
Laurynas
10-29-2013 10:35 AM
Hi
Check the below link for memory issue
http://help.sap.com/saphelp_nw04/Helpdata/EN/fc/eb3bde358411d1829f0000e829fbfe/content.htm
Br,