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

creating sales order using ' BAPI_SALESORDER_CREATEFROMDAT1'

Former Member
0 Likes
2,943

Hi ,

i have a problem in creating sales order using ' BAPI_SALESORDER_CREATEFROMDAT1 ' .

order number is created and every thing unless the order quantity isn't created for material item .

my inputs are .

in "ORDER_HEADER_IN"

(DOC_TYPE , SALES_ORG , DISTR_CHAN , DIVISION ,SALES_OFF )

in " ORDER_ITEMS_IN"

(MATERIAL ,PLANT ,REQ_QTY )

in "ORDER_PARTNERS"

(PARTN_ROLE , PARTN_NUMB)

so the order created but as i say the the order quqntity isn't created for the material so the "net value and maertial net valve )

aren't calcoluted .

<< Moderator message - Everyone's problem is important. But the answers in the forum are provided by volunteers. Please do not ask for help quickly. >>

waiting .

thanks for all

Edited by: Rob Burbank on Jan 7, 2011 4:28 PM

16 REPLIES 16
Read only

Clemenss
Active Contributor
0 Likes
2,754

Hi Ahmed,

we created an IDOC interface to create orders, the code

TABLES
      return                        = lt_return
      order_items_in                = lt_order_items_in
      order_items_inx               = lt_order_items_inx
      order_partners                = lt_order_partners
      order_schedules_in            = lt_order_schdl
      order_schedules_inx           = lt_order_schdlx
      order_conditions_in           = lt_order_conditions

says that we created one schedule line with the required quantity for each item line. If I remember correct, that was the issue.

Regards,

Clemens

Read only

Former Member
0 Likes
2,754

hi mr.Clemens Li

sorry i don't get your point . please demonstrate it ,and remeber my main problem is for order quantity for material.

thanks .

Read only

Clemenss
Active Contributor
0 Likes
2,754

Hi Mr. Ahmed Tohamy,

my point is just create a schedule line with each item line. The relevant code we used was (excerpt)

perform bapi_map_filled using:
      lv_matnr      'MATERIAL'   space
        changing ls_in    ls_inx,
      lv_tax_class1 'TAX_CLASS1' gc_true
        changing ls_in    ls_inx,
      lv_qty        'TARGET_QTY' space
        changing ls_in    ls_inx, "QTY to item line
      lv_qty        'REQ_QTY'    space
        changing ls_schdl ls_schdlx,"QTY to schedule line
      lv_itm_number 'ITM_NUMBER' space
        changing ls_in    ls_dummy,
      lv_itm_number 'ITM_NUMBER' space
        changing ls_schdl ls_dummy,
      lv_ref_doc_ca 'REF_DOC_CA' space
        changing ls_in    ls_inx,
      lv_orderid    'ORDERID'    space
        changing ls_in    ls_inx,
      lv_ref_doc    'REF_DOC'    space
        changing ls_in    ls_inx.
*...
    append:
      ls_in       to pt_order_items_in,
      ls_inx      to pt_order_items_inx,
      ls_schdl    to pt_order_schdl,
      ls_schdlx   to pt_order_schdlx.

Here the quantity is put to item line and schedule line, we always mark the correspoing X structure fields:

*&---------------------------------------------------------------------*
*&      Form  bapi_map_filled
*&---------------------------------------------------------------------*
*       if the value passed is not initial, it is moved to the field
*       and the corresponding (BAPI-) X-field is marked
*       if no x-structure is required, a dummy structure is passed
*       if p_initial parameter is filled, initial fields will be marked
*       in x-structure. Purpose: transfer of initial values to BAPI
*----------------------------------------------------------------------*
form bapi_map_filled using    p_value      type any
                              p_fieldname  type fieldname
                              p_initial    type flag
                     changing p_structure  type any
                              p_structurex type any.
  field-symbols:
    <any> type any,
    <c>   type c.
  check:
     not ( p_value is initial and p_initial is initial ).
  assign:
    component p_fieldname of structure p_structure to <any>,
    component p_fieldname of structure p_structurex to <c>.
  <any> = p_value.
  check <c> is assigned.
  <c> = gc_true.
endform.                    " bapi_map_filled

Also, we did something to create conditions (i.e. tax) but I think that was project-specific.

We used BAPI_SALESORDER_CREATEFROMDAT2, I do not know about BAPI_SALESORDER_CREATEFROMDAT1.

Regards,

Clemens

Read only

Former Member
0 Likes
2,754

use BAPI_SALESORDER_CREATEFROMDAT12 with the sections proposed by NAGA PRAKASH.

In the inx structure pass a C for Create , U for Change . D for Delete for teh first field and then pass an X for all the fields being filled in the "IN" structures.

Sometimes the Schedule Line structrue also needs to be filled in

Then the partner functions structure - it should be AG for the Sold To party

Do not fill in the others - like Ship To party etc.

System should default these when creating the Sales Order.

Once the order is created, you need to call BAPI_TRANSACTION_COMMIT fn mod - so that the sales order is available in the database.

Youc an test this by calling the BAPI_SALESORDER_CREATEFROMDAT2 and BAPI_TRANSACTION_COMMIT in sequence from SE37 menu

Also search the forum for BAPI_SALESORDER_CREATEFROMDAT2 - you should see good previous posts..

Read only

Former Member
0 Likes
2,754

Thanks For , Now the order creaded correctly .

But where can i get the returned ( net price value for each material) and (Total net value for Order). which can get them from

"BAPI_SALESORDER_CREATEFROMDAT1'" in table " Order_Item_Out"

thanks.

Read only

brad_bohn
Active Contributor
0 Likes
2,754

Why don't you just look at the fields in the table????

Read only

Former Member
0 Likes
2,754

HIi , Brad Bohn

Which table can i find that output ?

Read only

Former Member
0 Likes
2,754

Sales Doc tables VBAK VBAP etc

Read only

Former Member
0 Likes
2,754

hi, Venkatabby

thank you for your interest , but my question is >>>>

Which output table in BAPI ......> ' BAPI_SALESORDER_CREATEFROMDAT2 ' not database table .

Read only

Former Member
0 Likes
2,754

Hi Ahmed,

Populate the following parametrs of the BAPI_SALESORDER_CREATEFROMDAT1

Under Import Parametres :

order_header_in

order_header_inx

Under Tables Parametres :

order_items_in

order_items_inx

order_partners

order_schedules_in

order_schedules_inx

Thanks,

Naga Prakash

Read only

0 Likes
2,754

hi mr.Prakash Naga

BAPI "BAPI_SALESORDER_CREATEFROMDAT1 "

hasn't (order_header_inx , order_items_inx ,order_schedules_in ,order_schedules_inx )

so how can i populate it .

please check it and feed back me.

thank you

Read only

0 Likes
2,754

Hey Ahmed,

Change in BAPI , the parametes i mentioned can be found in BAPI_SALESORDER_CREATEFROMDAT2..U can also use this BAPI to create Sales Orders

Thanks,

Naga Prakash

Read only

0 Likes
2,754

hi mr.Prakash Naga

thank you for your interest . I try your solution and use that BAPI , and the order is created but my main problem is still exist , as the order created without quantity for material.

please try it and give me the solution .

thank you

Read only

Former Member
0 Likes
2,754

Hi,

LS_ORDER_HEADER_IN_BAPI-DOC_TYPE = 'ZORF'.

LS_ORDER_HEADER_IN_BAPI-SALES_ORG = '5000'. "Sales organization

LS_ORDER_HEADER_IN_BAPI-DISTR_CHAN = '10'. "Distribution Channel

LS_ORDER_HEADER_IN_BAPI-DIVISION = '96'. "division

LS_ORDER_HEADER_IN_BAPI-PURCH_NO = P_EBELN. "Purchase order number

LOOP AT LT_SO_ITEM INTO LS_SO_ITEM.

LS_ORDER_ITEMS_IN_BAPI-MATERIAL = LS_SO_ITEM-MATERIAL. "Material Number

LS_ORDER_ITEMS_IN_BAPI-PLANT = P_WERKS. "Plant

LS_ORDER_ITEMS_IN_BAPI-STORE_LOC = 'SL01'. "Storage Location

LS_ORDER_ITEMS_IN_BAPI-REQ_QTY = LS_SO_ITEM-REQ_QTY * 1000. "Quantity

LS_ORDER_ITEMS_IN_BAPI-COND_TYPE = 'ZDIM'. "Discount condition Type

LS_ORDER_ITEMS_IN_BAPI-COND_VALUE = LS_SO_ITEM-COND_VALUE2."Condition Value

APPEND LS_ORDER_ITEMS_IN_BAPI TO LT_ORDER_ITEMS_IN_BAPI.

CLEAR : LS_ORDER_ITEMS_IN_BAPI.

ENDLOOP.

LS_ORDER_PARTNERS_BAPI-PARTN_ROLE = 'AG'. "Customer Code

LS_ORDER_PARTNERS_BAPI-PARTN_NUMB = P_KUNNR.

APPEND LS_ORDER_PARTNERS_BAPI TO LT_ORDER_PARTNERS_BAPI.

CLEAR : LS_ORDER_PARTNERS_BAPI.

LS_ORDER_PARTNERS_BAPI-PARTN_ROLE = 'WE'. "Ship to party Code

LS_ORDER_PARTNERS_BAPI-PARTN_NUMB = P_KUNNR.

APPEND LS_ORDER_PARTNERS_BAPI TO LT_ORDER_PARTNERS_BAPI.

CLEAR : LS_ORDER_PARTNERS_BAPI.

*---Bapi call to create sales order

CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDATA'

EXPORTING

ORDER_HEADER_IN = LS_ORDER_HEADER_IN_BAPI

IMPORTING

SALESDOCUMENT = LV_SALES_ORDER_NO

RETURN = LS_RETURN_SALES

TABLES

ORDER_ITEMS_IN = LT_ORDER_ITEMS_IN_BAPI

ORDER_PARTNERS = LT_ORDER_PARTNERS_BAPI.

IF LV_SALES_ORDER_NO IS NOT INITIAL.

COMMIT WORK.

endif.

Regards,

Thiru

Read only

0 Likes
2,754

hi mr.thirukumaran rajendran

for LS_ORDER_ITEMS_IN_BAPI-STORE_LOC the system get it outomaticlly and in creating from va01 system display it so i can't entered it from my data and what's the importance of

"LS_ORDER_ITEMS_IN_BAPI-COND_TYPE" and "LS_ORDER_ITEMS_IN_BAPI-COND_VALUE" .

other thing i follow your steps for that and it isn't solve my main problem for order quantity for material.

please check it .

thank you .

Edited by: Ahmed Tohamy on Jan 8, 2011 12:51 PM

Read only

Former Member
0 Likes
2,754

Thanks For All who Help Me .