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 to update Sales Order

Former Member
0 Kudos

Hi Friends ,

Can you please tell me how can i remove Deliver Block ( Header ) by using BAPI .

Currently i'm using "BAPI_SALESORDER_CHANGE" but unable to update .

can anyone explain how to use it in detail

Sonal

1 ACCEPTED SOLUTION

Former Member
0 Kudos

<b>Here is my code -</b>

data : header_data like BAPISDH1,

header_data1 like BAPISDH1X.

data : return like BAPIRET2 occurs 0 with header line.

parameters : doc_no type BAPIVBELN-VBELN.

header_data-DLV_BLOCK = space .

header_data1-DLV_BLOCK = 'X'.

header_data1-UPDATEFLAG = 'U'.

CALL FUNCTION 'BAPI_SALESORDER_CHANGE'

EXPORTING

salesdocument = doc_no

ORDER_HEADER_IN = header_data

order_header_inx = header_data1

  • SIMULATION =

  • BEHAVE_WHEN_ERROR = ' '

  • INT_NUMBER_ASSIGNMENT = ' '

  • LOGIC_SWITCH =

tables

return = 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 =

  • SCHEDULE_LINESX =

  • ORDER_TEXT =

  • ORDER_KEYS =

  • CONDITIONS_IN =

  • CONDITIONS_INX =

  • EXTENSIONIN =

.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

  • EXPORTING

  • WAIT =

IMPORTING

RETURN = return

.

if sy-subrc <> 0.

write : / return-MESSAGE,return-MESSAGE_V1.

else.

write : 'ok'.

endif.

<b>What else needs to be done ?</b>

12 REPLIES 12

Former Member
0 Kudos

Clear DLV_BLOCK field in the structure BAPISDH1 and set the field DLV_BLOCK in the structure BAPISDH1X to X.

-Kiran

Message was edited by: Kiran Raorane

0 Kudos

yes i set .

plz tell what all needs to be done ?

Sonal

0 Kudos

What messages were returned by the BAPI in the RETURN table?

If you do not have a entry with type E call the bapi BAPI_TRANSACTION_COMMIT

-Kiran

0 Kudos

in return table it is showing sucessful updated but its not updating ( not removing the delivery block )

what is "E"

and why "BAPI_TRANSACTION_COMMIT" ??

Sonal

0 Kudos

Use the COMMIT Bapi and it will save the data to the database.

-Kiran

*Please reward useful answers

0 Kudos

Former Member
0 Kudos

You have to fill the following parameters:

BAPI_SALESDOCUMENT_CHANGE

SALESDOCUMENT = <SalesOrder>

ORDER_HEADER_IN-DLV_BLOCK = SPACE.

ORDER_HEADER_INX-UPDATEFLAG = 'U'.

ORDER_HEADER_INX-DLV_BLOCK = 'X'.

And after this you have to call

BAPI_TRANSACTION_COMMIT.

Former Member
0 Kudos

Hi

just as Kiran said:

BAPISDH1-DLV_BLOCK = SPACE.

BAPISDH1X-DLV_BLOCK = 'X'.

CALL FUNCTION 'BAPI_SALESORDER_CHANGE'

EXPORTING

.............................

ORDER_HEADER_IN = BAPISDH1

ORDER_HEADER_INX = BAPISDH1X

.............................

And remember to call BAPI for commit BAPI_TRANSACTION_COMMIT

Max

0 Kudos

what to pass in BAPI_TRANSACTION_COMMIT ???

Sonal

Former Member
0 Kudos

<b>Here is my code -</b>

data : header_data like BAPISDH1,

header_data1 like BAPISDH1X.

data : return like BAPIRET2 occurs 0 with header line.

parameters : doc_no type BAPIVBELN-VBELN.

header_data-DLV_BLOCK = space .

header_data1-DLV_BLOCK = 'X'.

header_data1-UPDATEFLAG = 'U'.

CALL FUNCTION 'BAPI_SALESORDER_CHANGE'

EXPORTING

salesdocument = doc_no

ORDER_HEADER_IN = header_data

order_header_inx = header_data1

  • SIMULATION =

  • BEHAVE_WHEN_ERROR = ' '

  • INT_NUMBER_ASSIGNMENT = ' '

  • LOGIC_SWITCH =

tables

return = 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 =

  • SCHEDULE_LINESX =

  • ORDER_TEXT =

  • ORDER_KEYS =

  • CONDITIONS_IN =

  • CONDITIONS_INX =

  • EXTENSIONIN =

.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

  • EXPORTING

  • WAIT =

IMPORTING

RETURN = return

.

if sy-subrc <> 0.

write : / return-MESSAGE,return-MESSAGE_V1.

else.

write : 'ok'.

endif.

<b>What else needs to be done ?</b>

0 Kudos

Add this code after the SALES_DOCUMENT Change BAPI

READ TABLE return WITH KEY type = 'E' BINARY SEARCH.

IF sy-subrc EQ 0.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

wait = 'X'.

ENDIF.

Pass X in the wait field for the COMMIT BAPI.

-Kiran

0 Kudos

Please award points and close the thread if your problem is solved.

Thanks, Kiran