Skip to Content
0
Former Member
May 25, 2016 at 02:28 AM

Different Behaviour in foreground & background for BAPI_CUSTOMERREURN_CREATE

92 Views

Hi experts:

when I use BAPI_CUSTOMERRETURN_CREATE to create sales return order.i'll receive correct order if I excute program in foreground,but if I run program in background job,the order's quantity is zero and cannot be change.

I can't know why,please help me.

Thanks very much!

here is my program:

WA_HEADER_IN-DOC_TYPE = WA_TAB1-AUART.
WA_HEADER_IN-SALES_ORG = WA_TAB1-VKORG.
WA_HEADER_IN-DISTR_CHAN = WA_TAB1-VTWEG.
WA_HEADER_IN-DIVISION = WA_TAB1-SPART.
WA_HEADER_IN-REQ_DATE_H = WA_TAB1-VDATU.
WA_HEADER_IN-ORD_REASON = '011'.

WA_HEADER_INX-DOC_TYPE = 'X'.
WA_HEADER_INX-SALES_ORG = 'X'.
WA_HEADER_INX-DISTR_CHAN = 'X'.
WA_HEADER_INX-DIVISION = 'X'.
WA_HEADER_INX-REQ_DATE_H = 'X'.
WA_HEADER_INX-ORD_REASON = 'X'.

IT_PARTNERS-PARTN_ROLE = 'AG'.
IT_PARTNERS-PARTN_NUMB = WA_TAB1-KUNNR1.
APPEND IT_PARTNERS.


LOOP AT IT_DATA2 INTO WA_DATA2 WHERE BTYPE = WA_TAB1-BTYPE
AND KUNNR = WA_TAB1-KUNNR
AND VDATU = WA_TAB1-VDATU.
WA_DATA2-KWMENG = 0 - WA_DATA2-KWMENG.
IF WA_DATA2-KBETR < 0.
WA_DATA2-KBETR = 0 - WA_DATA2-KBETR.
ENDIF.
IF WA_DATA2-DISCO > 0.
WA_DATA2-DISCO = 0 - WA_DATA2-DISCO.
ENDIF.
CLEAR: IT_ITEMS_IN,IT_ITEMS_INX.

IT_ITEMS_IN-ITM_NUMBER = WA_DATA2-POSNR.
IT_ITEMS_IN-MATERIAL = WA_DATA2-MATNR.
IT_ITEMS_IN-PLANT = WA_DATA2-WERKS.
IT_ITEMS_IN-STORE_LOC = WA_DATA2-LGORT.
IT_ITEMS_IN-HG_LV_ITEM = WA_DATA2-UEPOS.

IF WA_DATA2-VBELN = 'Y' .
IT_ITEMS_IN-ITEM_CATEG = 'ZRQN'.
ELSEIF WA_DATA2-VBELN = 'X' .
IT_ITEMS_IN-ITEM_CATEG = 'ZRCN'.
ENDIF.

APPEND IT_ITEMS_IN.

IT_ITEMS_INX-UPDATEFLAG = 'I'.
IT_ITEMS_INX-ITM_NUMBER = WA_DATA2-POSNR.
IT_ITEMS_INX-MATERIAL = 'X'.
IT_ITEMS_INX-PLANT = 'X'.
IT_ITEMS_INX-STORE_LOC = 'X'.
IT_ITEMS_INX-HG_LV_ITEM = 'X'.
IF WA_DATA-VBELN = 'X' OR WA_DATA2-VBELN = 'Y'.
IT_ITEMS_INX-ITEM_CATEG = 'X'.
ENDIF.
APPEND IT_ITEMS_INX.

IT_SCHEDULES_IN-ITM_NUMBER = WA_DATA2-POSNR.
IT_SCHEDULES_IN-REQ_QTY = WA_DATA2-KWMENG. "quantity
APPEND IT_SCHEDULES_IN.

IT_SCHEDULES_INX-UPDATEFLAG = 'I'.
IT_SCHEDULES_INX-ITM_NUMBER = WA_DATA2-POSNR.
IT_SCHEDULES_INX-REQ_QTY = 'X'.
APPEND IT_SCHEDULES_INX.

ENDLOOP.