Skip to Content
0
Former Member
Oct 11, 2005 at 03:10 PM

BAPI_SALESORDER_CHANGE fails to change delivery date

1375 Views

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?