Application Development 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: 

Different Behaviour in foreground & background for BAPI_CUSTOMERREURN_CREATE

Former Member
0 Kudos

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.

5 REPLIES 5

Former Member
0 Kudos

Hi John,

Could you please check whether you have to pass the Unit also when you are passing the Quantity.

Thanks and Regards,

Vinay Mutt

0 Kudos

Hi,Vinay,

     I didn't pass the unit,but I think the Unit is not necessary,beacuse the result is correct when I run program foreground,the Quantity is not zero.

     Thanks anyway.

gaurab_banerji
Active Participant
0 Kudos

Check the amount/currency settings are same for foreground user and the background/batch user.

0 Kudos

Hi,Gaurab,

    

     yes, I have checked the settings,there is no difference between foreground user and background user.

     Thanks anyway.

Jelena
Active Contributor
0 Kudos

I bet there is some other difference or there is more to it that you're seeing. Are you checking the messages coming back from BAPI? I used it before in a program that ran in background and had 0 issues.