Application Development and Automation 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: 
Read only

BAPI_SALESDOCU_CREATEFROMDATA1 with multiple line items

Former Member
0 Likes
1,203

Hi Experts,

I trying to create a sales document using BAPI_SALESDOCU_CREATEFROMDATA1, below my code :

CALL FUNCTION 'BAPI_SALESDOCU_CREATEFROMDATA1'
       EXPORTING
            sales_header_in     = header
            sales_header_inx    = headerx
       IMPORTING
            salesdocument_ex    = v_vbeln
       TABLES
            return              = return
            sales_items_in      = item
            sales_items_inx     = itemx
            sales_schedules_in  = lt_schedules_in
            sales_schedules_inx = lt_schedules_inx
            sales_partners      = partner.
WRITE: / 'Dcoument de vente: '.

I have many entries in my internal table( item) , but the Pabi create the document for a single line.

thanks for your help

best regards

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
896

Hi Noura Mouaddib,

You have to supply item no as well. The following is a part of code for Item tab :


*********************Item Data*****************************

    LOOP AT RECORD WHERE VBELN = IT_VBELN-VBELN.

      CLEAR : IT_ITEM,IT_ITEMX,IT_CONDITION,IT_CONDITIONX.

      W_POSNR = W_POSNR + 1.

*********************Item Data Table***********************

      TRANSLATE RECORD-MABNR TO UPPER CASE.

      IT_ITEM-ITM_NUMBER = W_POSNR * 10."here we have to supply item no
      IT_ITEM-MATERIAL = RECORD-MABNR.

      IF RECORD-ARKTX IS NOT INITIAL.

        IT_ITEM-SHORT_TEXT = RECORD-ARKTX.

      ENDIF.

Note : I have used BAPI :- 'BAPI_SALESORDER_CREATEFROMDAT2' to create SO.

Thanks & Regards,

Faheem.

4 REPLIES 4
Read only

Former Member
0 Likes
896

Stating the obvious:

1. enough entries in itemx to match the entries in item?

2. any messages in return?

Read only

0 Likes
896

thanks for your reply

No i have no runtim message

IMPORTING
            salesdocument_ex    = v_vbeln

generate a sales document number correctly

itemx have such values 'X'

Read only

Former Member
0 Likes
897

Hi Noura Mouaddib,

You have to supply item no as well. The following is a part of code for Item tab :


*********************Item Data*****************************

    LOOP AT RECORD WHERE VBELN = IT_VBELN-VBELN.

      CLEAR : IT_ITEM,IT_ITEMX,IT_CONDITION,IT_CONDITIONX.

      W_POSNR = W_POSNR + 1.

*********************Item Data Table***********************

      TRANSLATE RECORD-MABNR TO UPPER CASE.

      IT_ITEM-ITM_NUMBER = W_POSNR * 10."here we have to supply item no
      IT_ITEM-MATERIAL = RECORD-MABNR.

      IF RECORD-ARKTX IS NOT INITIAL.

        IT_ITEM-SHORT_TEXT = RECORD-ARKTX.

      ENDIF.

Note : I have used BAPI :- 'BAPI_SALESORDER_CREATEFROMDAT2' to create SO.

Thanks & Regards,

Faheem.

Read only

0 Likes
896

Hi Faheem.

first I had the same problem using BAPI :- 'BAPI_SALESORDER_CREATEFROMDAT2'

the struct of my internal table (item or itab)

TYPES: BEGIN OF ty_line,
     p_vkorg      TYPE VKORG, "Sales organization.
     p_vtweg      TYPE VTWEG, "Distribution channel
     p_spart      TYPE SPART, "Division
     p_auart      TYPE AUART, "Sales document type.
     p_sold       TYPE KUNNR, "Client D.O. AG
     p_ship       TYPE KUNNR, "Client Livré WE
     p_fact       TYPE KUNNR, "Client Facturé RE
     p_paye       TYPE KUNNR, "Client Payeur RG
     p_purch(6)   TYPE C,     "Purchas no
     p_AUGRU      TYPE AUGRU, "motife
     p_matnr      TYPE MATNR, "Material
     p_menge      TYPE KWMENG,"Quantity

END OF ty_line.

below a part of my code

LOOP AT itab.
      header-doc_type = itab-p_auart.
    ......
     partner-partn_role = 'AG'.
    ......
   APPEND partner.
     .......
     item-itm_number = '000010'.
     item-material = itab-p_matnr.
     ........
  APPEND item.
     .......
   APPEND lt_schedules_in.

 ENDLOOP.

********************
.......
.......

CALL FUNCTION 'BAPI_SALESDOCU_CREATEFROMDATA1'
       EXPORTING
            sales_header_in     = header
            sales_header_inx    = headerx
       IMPORTING
            salesdocument_ex    = v_vbeln
       TABLES
            return              = return
            sales_items_in      = item
            sales_items_inx     = itemx
            sales_schedules_in  = lt_schedules_in
            sales_schedules_inx = lt_schedules_inx
            sales_partners      = partner.

best regards