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

Reverse Multiple Posting No.

Former Member
0 Likes
1,061

Dear All experts,

i have problem to reverse multiple posting no. in one time. Eg i have 3 posting no need to revese, when first n second posting no are reversed but third got error , so this will cosinder fail. so i need recover back the first and second posting no.

i tried to use BAPI to reverse it eg :

CALL FUNCTION 'BAPI_GOODSMVT_CANCEL'

EXPORTING

materialdocument = materialdocument

matdocumentyear = matdocumentyear

goodsmvt_pstng_date = matdocumentdate

TABLES

return = return_o.

when finish reverse all three posting no. without error , then i only go throw "Commit Work" . CAN I ? the way i doing is correct ? or any idea to solve this problem?

THanks

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
994

How can i do BAPI more than 1 times witout "commint work" ? only do the commit work for the last record.

THanks

6 REPLIES 6
Read only

Former Member
0 Likes
994

This message was moderated.

Read only

kesavadas_thekkillath
Active Contributor
0 Likes
994

Try like this.

Make changes wherever needed


loop at itab into wa.

CALL FUNCTION 'BAPI_GOODSMVT_CANCEL'
EXPORTING
materialdocument = wa-mblnr
matdocumentyear = wa-mjahr
goodsmvt_pstng_date = wa-budat
TABLES
return = lt_return.

if lt_return[] is not initial.
append lines of lt_return to lt_messages.
endif.

clear lt_return[].

endloop.


read table lt_messages into wa1 with key type = 'E'.
if sy-subrc = 0.
	"Error Found
else.
	"Commit work
endif.

Read only

Former Member
0 Likes
995

How can i do BAPI more than 1 times witout "commint work" ? only do the commit work for the last record.

THanks

Read only

0 Likes
994

hi,

just a change in code

put the read statement inside the loop.

read table lt_return into wa1 with key type = 'E'.

if sy-subrc = 0.

"Error Found

else.

"Commit work

endif.

They way for what your are asking is impossible because bapi accepts only one material document at a time.

Read only

Former Member
0 Likes
994

Yeah , thank for your reply . how i going to recover back those reversed data ? do i need to repost it again and get the new migo no. ? Bc i need to reverse more than 1 migo no. in one time , and cnt 100% all migo can reverse successfully without. how i going to prevent this happen ?

Read only

0 Likes
994

hi,

Once there is no error record found and commit has happened successfully, then there is no need to repost the successfull records,

but when you get error in return table collect all the error records and repost again.