‎2006 Jun 29 2:36 PM
hello,
I have implemented a BADi for purchase order for updating the commodity code/weight and Volume from material configuration.
It works fine with updating for weight and volume. But when trying to update the Commodity code I got a "time out" because it stops just before the call "CALL Method->Set_foreign_trade".
Do I miss something???
See the codes below.
METHOD if_ex_me_process_po_cust~process_item .
DATA: ls_mepoitem TYPE mepoitem.
DATA: it_conf TYPE TABLE OF conf_out.
DATA: wa_conf TYPE conf_out.
DATA: gs_zvcsd_conf TYPE zvcsd_conf.
DATA: im_data TYPE mepoitem.
DATA: l_data_new TYPE mepoitem.
DATA: lv_mtart TYPE mtart.
DATA: len TYPE i.
DATA: ls_mepo_eipo TYPE mepo_eipo.
DATA: ls_mepo_eipo_new TYPE mepo_eipo.
----
Get data
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ls_mepoitem = im_item->get_data( ).
check entry from control table zvcsd_conf
SELECT SINGLE * FROM zvcsd_conf INTO gs_zvcsd_conf
WHERE matnr EQ ls_mepoitem-matnr.
CHECK sy-subrc = 0.
SELECT SINGLE mtart
FROM mara
INTO lv_mtart
WHERE matnr EQ ls_mepoitem-matnr.
CHECK lv_mtart EQ 'KMAT'.
CALL FUNCTION 'VC_I_GET_CONFIGURATION_IBASE'
EXPORTING
instance = ls_mepoitem-cuobj
language = sy-langu
TABLES
configuration = it_conf
EXCEPTIONS
instance_not_found = 1
OTHERS = 2.
CHECK sy-subrc = 0.
check weight is set from control table
IF NOT gs_zvcsd_conf-zweight IS INITIAL.
READ TABLE it_conf INTO wa_conf WITH KEY atnam = 'VCSD_ZNTGEW'.
IF sy-subrc = 0.
len = STRLEN( wa_conf-atwrt ).
IF len LE 7.
REPLACE ',' WITH '.' INTO wa_conf-atwrt.
ELSE.
REPLACE '.' WITH ' ' INTO wa_conf-atwrt.
REPLACE ',' WITH '.' INTO wa_conf-atwrt.
CONDENSE wa_conf-atwrt NO-GAPS.
ENDIF.
ls_mepoitem-ntgew = wa_conf-atwrt.
ls_mepoitem-brgew = wa_conf-atwrt.
ENDIF.
ENDIF.
check volume is set from control table
IF NOT gs_zvcsd_conf-zvolum IS INITIAL.
READ TABLE it_conf INTO wa_conf WITH KEY atnam = 'VCSD_ZVOLUM'.
IF sy-subrc = 0.
len = STRLEN( wa_conf-atwrt ).
IF len LE 7.
REPLACE ',' WITH '.' INTO wa_conf-atwrt.
ELSE.
REPLACE '.' WITH ' ' INTO wa_conf-atwrt.
REPLACE ',' WITH '.' INTO wa_conf-atwrt.
CONDENSE wa_conf-atwrt NO-GAPS.
ENDIF.
ls_mepoitem-volum = wa_conf-atwrt.
ls_mepoitem-voleh = gs_zvcsd_conf-voleh.
ENDIF.
ENDIF.
----
Set weight and volume
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
l_data_new = ls_mepoitem.
CALL METHOD im_item->set_data( im_data = l_data_new ).
End of get data
Get commodity code from configuration
IF NOT gs_zvcsd_conf-zstawn IS INITIAL.
READ TABLE it_conf INTO wa_conf WITH KEY atnam = 'VCSD_STAWN'.
IF sy-subrc = 0.
ls_mepo_eipo_new-stawn = wa_conf-atwrt.
ENDIF.
ENDIF.
----
Get foreign trade data
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
CALL METHOD im_item->get_foreign_trade
RECEIVING
re_data = ls_mepo_eipo.
ls_mepo_eipo-po_item = ls_mepoitem-ebelp.
ls_mepo_eipo-stawn = ls_mepo_eipo_new-stawn.
----
set foreign trade
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
CALL METHOD im_item->set_foreign_trade
EXPORTING
im_data = ls_mepo_eipo.
ENDMETHOD.
‎2006 Jun 29 3:51 PM
Hi,
looks quite good, just a small hint:
check the sy-subrc after method im_item->get_foreign_trade.
Maybe you had no foreign trade data / there was a problem while reading and thus you can't update the view.
Regards,
Christian
‎2006 Jun 30 9:18 AM
hello Christian,
I added the check sy-subrc = 0. And the sy-subrc is 0, but it didn't help.
check sy-subrc = 0.
ls_mepo_eipo-po_item = ls_mepoitem-ebelp.
ls_mepo_eipo-stawn = ls_mepo_eipo_new-stawn.
set foreign trade
CALL METHOD im_item->set_foreign_trade
EXPORTING im_data = ls_mepo_eipo.
‎2006 Jun 30 11:19 AM
Hi,
at least it was a chance...
I don't think from looking at the code we can get any more hints, you should start to debug this more detailed.
Goal: to find the exact statement / loop, which causes the high runtime. Maybe you don't need to debug the method set_foreign_trade step-by-step. You can trigger the debugger from SM50.
First have a look, if SM50 shows an obvious problem, e.g. something like waiting for RFC or a select statement for a hugh table. Then you should start the debugger in menu Program -> Program -> debug. I expect you are in an endless loop - at least that would be the most common reasons for a time-out. Try to find the loop (by some F7-jumps).
Regards,
Christian
‎2006 Jul 12 1:29 PM
hello Christian,
Thank you for your comments and the quick response.
I have solved my problem now. I found two sap notes regarding this situation.
841803 -
ME_PROCESS_PO_CUST: Endless loop with SET_FOREIGN_TRADE
803749 -
ME_PROCESS_PO_CUST - Endless Loop
I also have found out an other thing. When I'm using the SAP Notes Search and type the key word "SET_FOREIGN_TRADE" and "ME_PROCESS_PO_CUST" I found nothing. Then I try to create a Customer Message and as you already knew that you have to enter a some words in the "Search term*" before you are allowed to create a customer message. The system shows the note 841803. Strange, rite?
So my conclusion is, if I can't find any note from SAP Notes Search then I will try to create an customer message.
Best regards
Linh Nguyen