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: 

Sales order

Former Member
0 Kudos

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

4 REPLIES 4

Former Member
0 Kudos

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?.

Former Member
0 Kudos

Your selection of a solution is the problem... do NOT use CALL TRANSACTION for this purpose.

Use a BAPI... BAPI_SALESORDER_CREATEFROMDAT2

0 Kudos

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?

0 Kudos

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...