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 fails to change delivery date

Former Member
0 Kudos

We need to change a scheduled delivery date for a sales order line item.

Here is the code we are using:

DATA: WA_SALESORDER LIKE BAPIVBELN-VBELN,

WA_ORDER_HEADER_IN LIKE BAPISDH1,

WA_ORDER_HEADER_INX LIKE BAPISDH1X,

WA_ORDER_ITEM_IN LIKE BAPISDITM OCCURS 0 WITH HEADER LINE,

WA_ORDER_ITEM_INX LIKE BAPISDITMX OCCURS 0 WITH HEADER LINE,

WA_SCHEDULE_LINES LIKE BAPISCHDL OCCURS 0 WITH HEADER LINE,

WA_SCHEDULE_LINESX LIKE BAPISCHDLX OCCURS 0 WITH HEADER LINE,

WA_RETURN LIKE BAPIRET2 OCCURS 0 WITH HEADER LINE.

WA_SALESORDER = '0001706785'.

WA_ORDER_HEADER_IN-SALES_ORG = '0010'.

WA_ORDER_HEADER_IN-DISTR_CHAN = '0010'.

WA_ORDER_HEADER_IN-DIVISION = '10'.

WA_ORDER_HEADER_IN-SALES_OFF = '0010'.

WA_ORDER_HEADER_IN-SALES_GRP = '073'.

WA_ORDER_HEADER_INX-UPDATEFLAG = 'U'.

WA_SCHEDULE_LINES-ITM_NUMBER = '000001'.

WA_SCHEDULE_LINES-SCHED_LINE = '0001'.

WA_SCHEDULE_LINES-DLV_DATE = '20061005'.

WA_SCHEDULE_LINES-REQ_QTY = '3'.

APPEND WA_SCHEDULE_LINES. CLEAR WA_SCHEDULE_LINES.

WA_SCHEDULE_LINESX-ITM_NUMBER = '000001'.

WA_SCHEDULE_LINESX-SCHED_LINE = '0001'.

WA_SCHEDULE_LINESX-DLV_DATE = 'X'.

WA_SCHEDULE_LINESX-REQ_QTY = 'X'.

APPEND WA_SCHEDULE_LINESX. CLEAR WA_SCHEDULE_LINESX.

CALL FUNCTION 'BAPI_SALESORDER_CHANGE'

EXPORTING

SALESDOCUMENT = WA_SALESORDER

ORDER_HEADER_IN = WA_ORDER_HEADER_IN

ORDER_HEADER_INX = WA_ORDER_HEADER_INX

  • SIMULATION =

  • BEHAVE_WHEN_ERROR = ' '

  • INT_NUMBER_ASSIGNMENT = ' '

  • LOGIC_SWITCH =

TABLES

RETURN = WA_RETURN

  • ORDER_ITEM_IN =

  • ORDER_ITEM_INX =

  • PARTNERS =

  • PARTNERCHANGES =

  • PARTNERADDRESSES =

  • ORDER_CFGS_REF =

  • ORDER_CFGS_INST =

  • ORDER_CFGS_PART_OF =

  • ORDER_CFGS_VALUE =

  • ORDER_CFGS_BLOB =

  • ORDER_CFGS_VK =

  • ORDER_CFGS_REFINST =

SCHEDULE_LINES = WA_SCHEDULE_LINES

SCHEDULE_LINESX = WA_SCHEDULE_LINESX

  • ORDER_TEXT =

  • ORDER_KEYS =

  • CONDITIONS_IN =

  • CONDITIONS_INX =

  • EXTENSIONIN = .

.

LOOP AT WA_RETURN.

WRITE: / WA_RETURN-MESSAGE_V1, WA_RETURN-MESSAGE_V2,

WA_RETURN-MESSAGE_V3, WA_RETURN-MESSAGE_V4.

ENDLOOP.

REFRESH WA_RETURN.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

WAIT = ''

IMPORTING

RETURN = WA_RETURN.

LOOP AT WA_RETURN.

WRITE: / WA_RETURN-MESSAGE_V1, WA_RETURN-MESSAGE_V2,

WA_RETURN-MESSAGE_V3, WA_RETURN-MESSAGE_V4.

ENDLOOP.

RESULTS OF THIS CODE:

The structure containing results contains four entries. None are errors:

"ORDER_HEADER_IN has been processed successfully"

"SCHEDULE_IN has been processed successfully"

"Purchase order number in document number: 0001225849 already exists"

"Standard Order 0001225865 has been saved"

We're not sure why we get the third message, but it is only a warning so we don't believe it causes the update to fail. The delivery date change is not applied to the sales order.

We also tried it without specifying the requested qty field, and we still fail to update the delivery date.

There is only one line item in the sales order and only one schedule line item. We are on release level 4.6C.

Does anyone have suggestions as to why the above did not work or what else we could try?

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Tim,

Try adding two more lines in your code -

WA_SCHEDULE_LINES-DATE_TYPE = 'D'.

WA_SCHEDULE_LINESX-UPDATEFALG = 'U'.

at the correct place i.e before append.

Cheers.

8 REPLIES 8

Former Member
0 Kudos

Hi Tim,

Try adding two more lines in your code -

WA_SCHEDULE_LINES-DATE_TYPE = 'D'.

WA_SCHEDULE_LINESX-UPDATEFALG = 'U'.

at the correct place i.e before append.

Cheers.

0 Kudos

Thanks, this looked promising, but after adding the code we get this error:

"Period indicator D is not defined"

which seems related to the new date_type field assignment.

0 Kudos

It has to be 1 not D for a date

0 Kudos

In VA03 try to display a schedule line and you will see this indicator in first column.

D Day format

T Day format

W Week format

M Month format

However you may just comment out this line and try it should work . Seems update was not happening as you had missed the updateflag.

Cheers.

0 Kudos

I think there might be a conversion somewhere, but the field BAPISCHDL-DATE_TYPE refers to a domain PRGRS which has the following domain values

1 Day

2 Week

3 Month

4 Posting period

5 Planning calendar period

Srinivas

0 Kudos

Hi Srinivas,

It comes from table TPRG , but during creating / changeing schedule lines we donot enter this as it is defaulted so I guess it should work without it as well as TIM is using date format only and no week / month format.

Cheers

0 Kudos

I agree.

0 Kudos

Hi,

I am a colleague of Tim & here is where we are running into a dead wall!

The Date_type field value did not solve the issue. It give a message that the Goods issue date is in the future with reference to the Delivery Date. Our question is how do you change the delivery date only or in conjunction with the GI date?

Easwar