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

Order schedule lines not created using BAPI_SALESORDER_CREATEFROMDAT2

Former Member
0 Likes
2,562

Hi experts,

I am creating sales order using BAPI_SALESORDER_CREATEFROMDAT2. I want to update the Order quantity in VBAP-KWMENG.I got the information from SDN when including the Schedule line in BAPI 'BAPI_SALESORDER_CREATEFROMDAT2 '.

I tried by using Update flag = 'I'.I am not able to update, what are the values to be passed and how to update the field.

Is there any other way..Please suggest me..

Thanks&Regards,

Karthik.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,852

Hi, In the BAPI if you look at the tables parameter you will find ORDER_ITEMS_IN and ORDER_ITEMS_INX as well as ORDER_SCHEDULES_IN and ORDER_SCHEDULES_INX. To update KWMENG you will have to pass that value to ORDER_ITEMS_IN-TARGET_QTY and update the same in the table ORDER_ITEMS_INX (ORDER_ITEMS_INX-TARGET_QTY) with 'X'.

For updating schedule line go for ORDER_SCHEDULES_IN-SCHED_LINE and update X for the same in ORDER_SCHEDULES_INX.

Try looking into the following code, I am filling in both the Item data as well as the Schedule line data.


  loop at t_mdata into fs_mdata.
    fs_item-itm_number  = fs_mdata-posnr.
    fs_itemx-itm_number = c_flag.
    fs_item-material    = fs_mdata-matnr.
    fs_itemx-material   = c_flag.
    fs_item-target_qty  = fs_mdata-kwmeng.
    fs_itemx-target_qty = c_flag.
    fs_item-item_categ  = fs_mdata-pstyv.
    fs_itemx-item_categ = c_flag.
    fs_itemx-updateflag = c_flag.
      APPEND fs_item TO t_item.
      APPEND fs_itemx TO t_itemx.

    fs_sline-ITM_NUMBER  = fs_mdata-posnr.
    fs_slinex-ITM_NUMBER = c_flag.
    fs_sline-SCHED_LINE  = c_sline.
    fs_slinex-SCHED_LINE = c_flag.
    fs_sline-REQ_QTY     = fs_mdata-kwmeng.
    fs_slinex-REQ_QTY    = c_flag.
      APPEND fs_sline TO t_sline.
      APPEND fs_slinex TO t_slinex.
  endloop.                             " Loop t_mdata

c_flag contains 'X'.

fs_item is of structure ORDER_ITEMS_IN.

fs_sline is of structure ORDER_SCHEDULES_IN.

10 REPLIES 10
Read only

Former Member
0 Likes
1,852
I got the information from SDN when including the Schedule line in BAPI 'BAPI_SALESORDER_CREATEFROMDAT2 '.
I tried by using Update flag = 'I'

Where you made Update flag ?i mean which field?

Try with TESTRUN = ' ' which is deafult space no need to do with Update flag.

Amit.

Read only

0 Likes
1,852

Hi,

Thanks for ur immediate reply,I am Passing the TESTRUN = ' '. I passed only the update flag in ORDER_SCHEDULES_INX-UPDATEFLAG = 'I'.

What are the values to be passed to the structure ORDER_SCHEDULES_IN.

Thanks&Regards,

Karthik.

Read only

Former Member
0 Likes
1,852

ORDER_SCHEDULES_IN STRUCTURE BAPISCHDL OPTIONAL.

Have you defined table like BAPISCHDL & BAPISCHDLX and using it ?

If possible share the code, to know the exact problem.

Read only

Former Member
0 Likes
1,853

Hi, In the BAPI if you look at the tables parameter you will find ORDER_ITEMS_IN and ORDER_ITEMS_INX as well as ORDER_SCHEDULES_IN and ORDER_SCHEDULES_INX. To update KWMENG you will have to pass that value to ORDER_ITEMS_IN-TARGET_QTY and update the same in the table ORDER_ITEMS_INX (ORDER_ITEMS_INX-TARGET_QTY) with 'X'.

For updating schedule line go for ORDER_SCHEDULES_IN-SCHED_LINE and update X for the same in ORDER_SCHEDULES_INX.

Try looking into the following code, I am filling in both the Item data as well as the Schedule line data.


  loop at t_mdata into fs_mdata.
    fs_item-itm_number  = fs_mdata-posnr.
    fs_itemx-itm_number = c_flag.
    fs_item-material    = fs_mdata-matnr.
    fs_itemx-material   = c_flag.
    fs_item-target_qty  = fs_mdata-kwmeng.
    fs_itemx-target_qty = c_flag.
    fs_item-item_categ  = fs_mdata-pstyv.
    fs_itemx-item_categ = c_flag.
    fs_itemx-updateflag = c_flag.
      APPEND fs_item TO t_item.
      APPEND fs_itemx TO t_itemx.

    fs_sline-ITM_NUMBER  = fs_mdata-posnr.
    fs_slinex-ITM_NUMBER = c_flag.
    fs_sline-SCHED_LINE  = c_sline.
    fs_slinex-SCHED_LINE = c_flag.
    fs_sline-REQ_QTY     = fs_mdata-kwmeng.
    fs_slinex-REQ_QTY    = c_flag.
      APPEND fs_sline TO t_sline.
      APPEND fs_slinex TO t_slinex.
  endloop.                             " Loop t_mdata

c_flag contains 'X'.

fs_item is of structure ORDER_ITEMS_IN.

fs_sline is of structure ORDER_SCHEDULES_IN.

Read only

0 Likes
1,852

Hi,

I passed all the as you said.The BAPI return "SALES_SCHEDULES_IN has been processed successfully" but i cant get the quantity field updated.

I have tried all the fields of table ITEM_IN (target_qty COMP_QUANT RNDDLV_QTY) and set the flag for the corresponding in item_in as 'X' but still the order quantity field in sales order remains empty. How can I add the value in order quantity.

Thanks&Regards

karthk

Edited by: karthi keyan on Aug 25, 2008 1:22 PM

Read only

0 Likes
1,852

Did you take the update flag as 'X' or 'I' ?

Read only

0 Likes
1,852

I take it as 'I'. What it mean by 'X',can u plz tell..

Thanks&Regards,

Karthik

Read only

0 Likes
1,852

Frankly, I dont know what is the meaning of 'I' in the update flag, but I always used 'X' for updating the values just like we do in other cases. Its working for me fine.

Read only

0 Likes
1,852

Hi,

I tried with 'X' also but it is not updating the order quantity field. I am struggling a lot please help...

Thanks&Regards,

Karthik.

Read only

0 Likes
1,852

Karthik, could you please post the part of code where in you are filling the item details?

And also i am not sure if you have gone through this link,

[http://www.saptechies.com/bapi_salesorder_createfromdat2/]