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

BAPI_SALESORDER_CHANGE

Former Member
0 Likes
1,662

Hi Please suggest me how to capture messages into return parameter and wt I need to pass into FM bapi_transaction_commit i.e wt all things need to be uncommented .

This is the coding iam using here :

DATA: salesdocument like BAPIVBELN-VBELN.

DATA: i_schdule type standard table of BAPISCHDL, " for gl date & load date

i_schdulex type standard table of BAPISCHDLX, " for partner role and partner function.

i_partner type standard table of BAPIPARNR,

i_partnerx type standard table of BAPIPARNRC,

i_return type standard table of BAPIRET2 with header line.

DATA: wa_schdule Like BAPISCHDL,

wa_schdulex Like BAPISCHDLX,

wa_partner Like BAPIPARNR,

wa_partnerx Like BAPIPARNRC,

wa_simulation like BAPIFLAG, " for simulation

wa_dlvblock like BAPISDH1, " for lifsk field

wa_dlvblockx like BAPISDH1X. " for update indicator

salesdocument = WA_HEADER_BAPI-VBELN.

  • Header

wa_dlvblock-DLV_BLOCK = wa_header_bapi-lifsk. " Delivery block

  • header X

wa_dlvblockX-DLV_BLOCK = 'X'. " Delivery block

wa_dlvblockX-UPDATEFLAG = 'U'.

  • simulation flag

wa_simulation-BAPIFLAG = 'U'.

  • IF NOT i_header_bapi IS INITIAL.

LOOP AT I_HEADER_BAPI INTO WA_HEADER_BAPI.

move WA_HEADER_BAPI-WADAT to wa_schdule-gi_date.

move WA_HEADER_BAPI-lddat to wa_schdule-load_date.

move WA_HEADER_BAPI-PARVW to wa_partner-PARTN_ROLE.

MOVE WA_HEADER_BAPI-KUNNR TO wa_partner-PARTN_NUMB.

append wa_schdule to i_schdule.

append wa_partner to i_partner.

CLEAR WA_HEADER_BAPI.

CLEAR I_HEADER_BAPI.

ENDLOOP.

wa_schdulex-UPDATEFLAG = 'U'.

wa_schdulex-gi_date = 'X'.

wa_schdulex-load_date = 'X'.

append wa_schdulex to i_schdulex.

wa_partnerx-UPDATEFLAG = 'U'.

wa_partnerx-PARTN_ROLE = 'X'.

wa_partnerx-P_NUMB_NEW = 'X'.

append wa_partnerx to i_partnerx.

CALL FUNCTION 'BAPI_SALESORDER_CHANGE'

EXPORTING

salesdocument = salesdocument

ORDER_HEADER_IN = wa_dlvblock

order_header_inx = wa_dlvblockX

SIMULATION = wa_simulation

  • BEHAVE_WHEN_ERROR = ' '

  • INT_NUMBER_ASSIGNMENT = ' '

  • LOGIC_SWITCH =

  • NO_STATUS_BUF_INIT = ' '

tables

return = i_return[]

  • ORDER_ITEM_IN =

  • ORDER_ITEM_INX =

PARTNERS = i_partner

PARTNERCHANGES = i_partnerx

  • 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 = i_schdule

SCHEDULE_LINESX = i_schdulex

  • ORDER_TEXT =

  • ORDER_KEYS =

  • CONDITIONS_IN =

  • CONDITIONS_INX =

  • EXTENSIONIN =

.

IF SY-SUBRC EQ 0.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

  • EXPORTING

  • WAIT =

  • IMPORTING

  • RETURN =

.

ENDIF.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,587

Also u can use like that

CALL FUNCTION 'BAPI_SALESORDER_CHANGE'

EXPORTING

SALESDOCUMENT = V_VBELN

ORDER_HEADER_INX = ORDERHEADERINX

TABLES

RETURN = RETURN

ORDER_ITEM_IN = ORDERITEMIN

ORDER_ITEM_INX = ORDERITEMINX.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

WAIT = 'X'

IMPORTING

RETURN = BAPIRETURN.

  • WRITE OUT RETURN

LOOP AT RETURN.

WRITE: / RETURN.

ENDLOOP.

WRITE: / BAPIRETURN.

SKIP.

Hi Please suggest me how to capture messages into return parameter and wt I need to pass into FM bapi_transaction_commit i.e wt all things need to be uncommented .

This is the coding iam using here :

DATA: salesdocument like BAPIVBELN-VBELN.

DATA: i_schdule type standard table of BAPISCHDL, " for gl date & load date

i_schdulex type standard table of BAPISCHDLX, " for partner role and partner function.

i_partner type standard table of BAPIPARNR,

i_partnerx type standard table of BAPIPARNRC,

i_return type standard table of BAPIRET2 with header line.

DATA: wa_schdule Like BAPISCHDL,

wa_schdulex Like BAPISCHDLX,

wa_partner Like BAPIPARNR,

wa_partnerx Like BAPIPARNRC,

wa_simulation like BAPIFLAG, " for simulation

wa_dlvblock like BAPISDH1, " for lifsk field

wa_dlvblockx like BAPISDH1X. " for update indicator

salesdocument = WA_HEADER_BAPI-VBELN.

  • Header

wa_dlvblock-DLV_BLOCK = wa_header_bapi-lifsk. " Delivery block

  • header X

wa_dlvblockX-DLV_BLOCK = 'X'. " Delivery block

wa_dlvblockX-UPDATEFLAG = 'U'.

  • simulation flag

wa_simulation-BAPIFLAG = 'U'.

  • IF NOT i_header_bapi IS INITIAL.

LOOP AT I_HEADER_BAPI INTO WA_HEADER_BAPI.

move WA_HEADER_BAPI-WADAT to wa_schdule-gi_date.

move WA_HEADER_BAPI-lddat to wa_schdule-load_date.

move WA_HEADER_BAPI-PARVW to wa_partner-PARTN_ROLE.

MOVE WA_HEADER_BAPI-KUNNR TO wa_partner-PARTN_NUMB.

append wa_schdule to i_schdule.

append wa_partner to i_partner.

CLEAR WA_HEADER_BAPI.

CLEAR I_HEADER_BAPI.

ENDLOOP.

wa_schdulex-UPDATEFLAG = 'U'.

wa_schdulex-gi_date = 'X'.

wa_schdulex-load_date = 'X'.

append wa_schdulex to i_schdulex.

wa_partnerx-UPDATEFLAG = 'U'.

wa_partnerx-PARTN_ROLE = 'X'.

wa_partnerx-P_NUMB_NEW = 'X'.

append wa_partnerx to i_partnerx.

CALL FUNCTION 'BAPI_SALESORDER_CHANGE'

EXPORTING

salesdocument = salesdocument

ORDER_HEADER_IN = wa_dlvblock

order_header_inx = wa_dlvblockX

SIMULATION = wa_simulation

  • BEHAVE_WHEN_ERROR = ' '

  • INT_NUMBER_ASSIGNMENT = ' '

  • LOGIC_SWITCH =

  • NO_STATUS_BUF_INIT = ' '

tables

return = i_return[]

  • ORDER_ITEM_IN =

  • ORDER_ITEM_INX =

PARTNERS = i_partner

PARTNERCHANGES = i_partnerx

  • 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 = i_schdule

SCHEDULE_LINESX = i_schdulex

  • ORDER_TEXT =

  • ORDER_KEYS =

  • CONDITIONS_IN =

  • CONDITIONS_INX =

  • EXTENSIONIN =

.

IF SY-SUBRC EQ 0.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

  • EXPORTING

  • WAIT =

  • IMPORTING

  • RETURN =

.

ENDIF.

10 REPLIES 10
Read only

Former Member
0 Likes
1,587

all the messages will be captured in i_return.

what you can do is

loop at i_return.

read table i_return with key message = 'E'.

if sy-subrc = 0.

message "".

exit.

endif.

endloop.

Hope it helps

Bhanu

Read only

0 Likes
1,587

hi bhanu thanku fr u r reply.

i will try it .

can u pls suggest me whether the code is correct.

Read only

Former Member
0 Likes
1,587

HI

For BAPIs there is no Exceptions, means sy-subrc always 0.

for this read u r returns internal table after BAPI call and if u found any messages with type 'E' or 'A' then roolback, If not, then Commit work

Kiran

Read only

Former Member
0 Likes
1,587

Hi Vinay,

From the return table of BAPI, you will have the message types as,

S Success, E Error, W Warning, I Info, A Abort.

Before you call FM bapi_transaction_commit, loop on return table (i_return) and check for message type in the loop.

if message type is E or A then dont call the commit fm or else you call fm bapi_transaction_commit.

Hope this will help you.

Regards,

Deepa Kulkarni

Read only

Former Member
0 Likes
1,587

Hi,

Basically you need to check for any 'E' or 'A' messages in the return table.

loop at it_return into wa_return where msgtyp = 'E' or

msgtyp = 'A' .

set a flag

endloop.

check if flag is initial.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.

no need to pass any parameters to this.

if you want a wait set it as 'X' (small delay before save)

Regards,

Anil

Read only

0 Likes
1,587

hi anil thanku fr u r reply.

is the loop is correct in the above code

Read only

Former Member
0 Likes
1,587

CALL FUNCTION 'BAPI_SALESORDER_CHANGE'

EXPORTING

salesdocument = p_vbeln

order_header_in = i_hdr

order_header_inx = i_hdrx

TABLES

return = i_ret "return message

schedule_lines = i_sched

schedule_linesx = i_schedx.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.

*display return message

LOOP AT i_ret.

WRITE / i_ret-message.

ENDLOOP.

Read only

Former Member
0 Likes
1,588

Also u can use like that

CALL FUNCTION 'BAPI_SALESORDER_CHANGE'

EXPORTING

SALESDOCUMENT = V_VBELN

ORDER_HEADER_INX = ORDERHEADERINX

TABLES

RETURN = RETURN

ORDER_ITEM_IN = ORDERITEMIN

ORDER_ITEM_INX = ORDERITEMINX.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

WAIT = 'X'

IMPORTING

RETURN = BAPIRETURN.

  • WRITE OUT RETURN

LOOP AT RETURN.

WRITE: / RETURN.

ENDLOOP.

WRITE: / BAPIRETURN.

SKIP.

Read only

0 Likes
1,587

thanku jani , i will try this code.

Read only

Former Member
0 Likes
1,587

i got the answer