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: 

BAPI_SALESORDER_CHANGE

Former Member
0 Kudos

Hi All,

I am using BAPI_SALESORDER_CHANGE to add a new line item to SO. when a new line item is added the 'Order Quantity' is not displayed what im passing in Target_qty field of BAPI str. ORDER_ITEM_IN. Also i tried populating schedule line REQ_QTY field but no go.

Please suggest on this.

Thanks.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Yes im doing the same.....no go....is it mandatory to populate Schedule line str. for this?

tried even that but erroring....

13 REPLIES 13

Former Member
0 Kudos

Hi

Did u set the update the flags in BAPISDITMX & BAPISCHDLX.

Regards,

Raghu.

Former Member
0 Kudos

I am leaving the UPDATEFLAG in itm and schd structures blank or (I) since I am adding a line item using the BAPI.

Former Member
0 Kudos

Hi

Set the UPDATEFLAG = 'I' and other for fields which are passing in item BAPISDITM ,for this case u need to set 'X' in BAPISDITMX.

Regards,

Raghu.

Former Member
0 Kudos

Try below code

order_header_inx-updateflag = 'U'.

order_item_in-itm_number  = <item number>
order_item_inx-itm_number = <item number>.
order_item_inx-updateflag = 'I'.
 
order_item_in-target_qty  = wa_vbap-kwmeng.
order_item_inx-target_qty = 'X'.
 
schedule_lines-itm_number = <item number>
schedule_lines-sched_line = <Schedule LIne No> .
schedule_lines-req_qty    = <Quantity>.
 
schedule_linesx-itm_number  = <item number>
schedule_linesx-sched_line  = <Schedule LIne no>
schedule_linesx-updateflag  = 'I'.
schedule_linesx-req_qty     = 'X'.

Regards

Vinod

Former Member
0 Kudos

Yes im doing the same.....no go....is it mandatory to populate Schedule line str. for this?

tried even that but erroring....

0 Kudos

Schedule line structure is to be populated to update the target qty at item level.

Also check whether you are filling up the mandatory pricing conditions in "conditions_in" and "conditions_inx"

Regards

Vinod

Edited by: Vinod Kumar on Apr 7, 2010 4:05 PM

Former Member
0 Kudos

Well,

What should be the Schedule line number i need to be passing to add this line item....

0 Kudos

Populate schedule line number as 0001.

Regards

Vinod

Former Member
0 Kudos

It just gives erroe msg saying

E V1 335 System error: Schedule line 0001 for item 800000 does not exist

E V4 219 Sales document 0200000781 was not changed

0 Kudos

Hope your code is as below

order_item_in-itm_number  = '800000'
order_item_inx-itm_number = '800000'
order_item_inx-updateflag = 'I'.
order_item_in-target_qty  = wa_vbap-kwmeng.
order_item_inx-target_qty = 'X'.

schedule_lines-itm_number = '800000'
schedule_lines-sched_line = '0001'
schedule_lines-req_qty    = <Quantity>.
 
schedule_linesx-itm_number  = '800000'
schedule_linesx-sched_line  = '0001'
schedule_linesx-updateflag  = 'I'.
schedule_linesx-req_qty     = 'X'.

Regards

Vinod

Former Member
0 Kudos

yes

i am passing all the above said fields...

0 Kudos

While creating the sales order through VA01 or changing SO through VA02, is the system generating schedule lines (VBEP Table)?

Regards

Vinod

andrea_olivieri
Contributor
0 Kudos

Hi,

I implemented this simple abap in my trial system.


REPORT  zsdnbapiordrchg.

DATA: lvbak TYPE vbak.

DATA:
v_vbeln TYPE bapivbeln-vbeln,
v_order_header_inx TYPE bapisdh1x,
i_item TYPE TABLE OF bapisditm WITH HEADER LINE,
i_itemx TYPE TABLE OF bapisditmx WITH HEADER LINE,
i_schedule_lines TYPE TABLE OF bapischdl WITH HEADER LINE,
i_schedule_linesx TYPE TABLE OF bapischdlx WITH HEADER LINE,
i_return TYPE TABLE OF bapiret2 WITH HEADER LINE.
DATA: lposnr TYPE vbap-posnr.


PARAMETERS: pvbeln TYPE vbak-vbeln OBLIGATORY.

SELECT SINGLE * FROM vbak INTO lvbak WHERE vbeln = pvbeln.
CHECK sy-subrc = 0.

SELECT MAX( posnr ) FROM vbap INTO lposnr
  WHERE vbeln = pvbeln.

ADD 10 TO lposnr.

v_order_header_inx-updateflag = 'U'.

v_vbeln             = pvbeln.
i_item-itm_number   = lposnr.
i_item-material     = 'T-FV100-EM'.
* i_item-sales_unit = 'KG'.
* i_item-plant      = '1100'.

*i_itemx-itm_number   = lposnr.
*i_itemx-updateflag   = 'I'.
*i_itemx-material     = 'X'.
*i_itemx-plant        = 'X'.
*i_itemx-sales_unit   = 'X'.

i_schedule_lines-itm_number = lposnr.
i_schedule_lines-sched_line = 1.
i_schedule_lines-req_date = sy-datum.
i_schedule_lines-req_qty = 1000.

i_schedule_linesx-itm_number = lposnr.
i_schedule_linesx-sched_line = 1.
i_schedule_linesx-updateflag = 'I'.
i_schedule_linesx-req_date = 'X'.
i_schedule_linesx-req_qty = 'X'.


APPEND i_item.
*APPEND i_itemx.
APPEND i_schedule_lines.

APPEND i_schedule_linesx.

CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
  EXPORTING
    salesdocument    = v_vbeln
    order_header_inx = v_order_header_inx
  TABLES
    return           = i_return
    order_item_in    = i_item
    order_item_inx   = i_itemx
    SCHEDULE_LINES   = i_schedule_lines
    SCHEDULE_LINESX  = i_schedule_linesx.

LOOP AT i_return WHERE type = 'A' OR type = 'E'.
  EXIT.
ENDLOOP.

IF sy-subrc ne 0.
  CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
ENDIF.

Now it should works.

Regards,

Andrea