04-09-2007 2:11 PM
Hi frnz
I am creating sales orders with CALL TRANSACTION Method.I need to create more than 20 line items for one sales order. When i executed the below code it works fine for only 2 records but not for more than 2 records. Why is it happening?. Can any one help me out in changing the code.
gt_final_temp[] = gt_final1[].
SORT gt_final_temp BY member_id
sold_to
ship_to.
DELETE ADJACENT DUPLICATES
FROM gt_final_temp
COMPARING member_id
sold_to
ship_to.
LOOP AT gt_final_temp INTO wa_final.
CLEAR bdcdata.
REFRESH bdcdata.
Screen 0101
PERFORM bdc_dynpro USING 'SAPMV45A' '0101'.
PERFORM bdc_field USING: 'VBAK-AUART' p_auart,
'VBAK-VKORG' p_vkorg,
'VBAK-VTWEG' p_vtweg,
'VBAK-SPART' p_spart,
'BDC_OKCODE' '/00'.
Screen 4001
PERFORM bdc_dynpro USING 'SAPMV45A' '4001'.
PERFORM bdc_field USING: 'VBKD-BSTDK' wa_final-bstdk,
'KUAGV-KUNNR' wa_final-sold_to,
'KUWEV-KUNNR' wa_final-ship_to,
'RV45A-KETDAT' wa_final-vdatu,
'BDC_OKCODE' '/00'.
MOVE 1 TO indx.
Add line items
LOOP AT gt_final1 INTO wa_final1
WHERE member_id = wa_final-member_id AND
sold_to = wa_final-sold_to AND
ship_to = wa_final-ship_to.
PERFORM bdc_dynpro USING 'SAPMV45A' '4001'.
CLEAR fnam.
CONCATENATE 'RV45A-MABNR(' indx ')' INTO fnam.
PERFORM bdc_field USING fnam wa_final1-matnr.
quantity = wa_final1-kwmeng.
CLEAR fnam.
CONCATENATE 'RV45A-KWMENG(' indx ')' INTO fnam.
PERFORM bdc_field USING fnam quantity.
PERFORM bdc_field USING 'BDC_OKCODE' '/00'.
indx = indx + 1.
CLEAR wa_final1.
ENDLOOP.
PERFORM bdc_dynpro USING 'SAPMV45A' '4001'.
PERFORM bdc_field USING 'BDC_OKCODE' '=SICH'.
CALL TRANSACTION 'VA01' USING bdcdata
MODE 'N'
MESSAGES INTO messtab.
Thanks
Satya
04-09-2007 4:35 PM
I am creating sales orders with CALL TRANSACTION method. If there is any errored out sales order I am creating session for that sales order. My program is creating sessions for all sales orders which has more than 2 line items, because it is taking only first two line items.
How can i manage with multiple line items. Can any one help me. I am not clear please let me know?.
04-09-2007 4:55 PM
Your selection of a solution is the problem... do NOT use CALL TRANSACTION for this purpose.
Use a BAPI... BAPI_SALESORDER_CREATEFROMDAT2
04-09-2007 5:17 PM
Really i appreciate your response. But the program is in production. I have got the change request. now i need to do something to that code in order to create sales orders with multiple line items.
If some one knows in creating multiple line items for sales order, please let me know how i can change the above code?
04-09-2007 5:23 PM
Unfortunate that such a bad design was moved into a Production system.
I would be shocked if anyone could give a "full-proof" solution to a "hokey" implementation like this.
I would highly suggest a redesign and a rewrite.... you will be chasing issues with this solution for as long as it exists int the PROD system.
Sorry...