cancel
Showing results for 
Search instead for 
Did you mean: 

BAPI Commit Problem

Former Member
0 Kudos

Hello ABAP-Collegues!

I´m experiencing some Problems regarding Bapi´s.

CASE:

I´m Using BAPI_GOODSMVT_CREATE to create several goods movements (GOODS RECEPTION). Sometimes I have to make 3 different bookings for the same reception (Reception, return delivery, scrapping).

The Problem is that before I can make a 'return delivery' the reception has to be booked. Ín my Programm, the reception-BAPI is created before (when required) the return delivery-BAPI. Unfortunately this doesn´t mean that the reception is BOOKED before the return delivery...

My code:

loop at i_tobook.

  • clear tables, structures, fill them up again

CALL FUNCTION 'BAPI_GOODSMVT_CREATE'

EXPORTING

goodsmvt_header = h_goodsmvt_header

goodsmvt_code = h_goodsmvt_code

IMPORTING

materialdocument = h_materialdocument

TABLES

goodsmvt_item = i_goodsmvt_item

return = i_return.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

  • EXPORTING

  • WAIT =

  • IMPORTING

  • RETURN =

.

  • begin-> I tried adding this, problem is not solved!!!

if h_materialdocument NE ''.

clear: h_MBLNR, h_MJAHR, h_MBLNR2.

h_MBLNR = h_materialdocument.

h_MJAHR = Sy-datum(4).

DO 150 TIMES.

select single mblnr from mkpf into h_MBLNR2

where MBLNR = h_MBLNR and

MJAHR = h_MJAHR.

if sy-subrc = 0.

exit.

else.

WAIT UP TO 1 seconds.

endif.

enddo.

endif.

  • end-> I tried adding this, problem is not solved!!!

endloop.

*************

I really need the bookings with BAPI_GOODSMVT_CREATE to be COMPLETELY FINISHED before I can create the next BAPI_GOODSMVT_CREATE.

Any Help would be very appreciated!

Greetz!

Pieter

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Peter,

Try to use a background job with one step for each process ( like reception, return). Start the next step on successfull completion of first step. Also use 'Wait' in BAPI transaction commit.

Apart from it, you may want to see qRFC with send queue to check if it maight help you.

Former Member
0 Kudos

Hello!

Thanx for all the replies...

I think I´ll go with the Solution of Sharad Agrawal.

(I also thought about it doing that myself, but really wanted to figure out why this BAPI_TRANSACTION_COMMIT function doesn´t work the way it should. That said, I find it disappointing that the 'commit work an wait'-Statement (BAPI_TRANSACTION_COMMIT with wait parameter) doesn´t do what it is supposed to do... Try and create several BAPI_GOODSMVT_CREATE (MASS-TEST) and you will see what I mean...)

Happy Programming!

Greetz!

Pieter

lajitha_menon
Contributor
0 Kudos

The function module BAPI TRANSACTION_COMMIT should work with the wait parameter. If not, you can raise a customer message to SAP.

cheers

Former Member
0 Kudos

BAPI_TRANSACTION_COMMIT Should work as advertised. Did you try:


select single mblnr
  from mkpf <b>BYPASSING BUFFER</b>
  into h_MBLNR2
  where MBLNR = h_MBLNR and
        MJAHR = h_MJAHR.

Rob

Former Member
0 Kudos

On final thing - before you do your select, you set

h_MJAHR = Sy-datum(4).

Are you sure that the current fiscal year matches the current calendar year? In many cases it won't.

Rob

Former Member
0 Kudos

Wow!

Thanks Rob!

I kind of overlooked that part!

Former Member
0 Kudos

That's the problem with programming. You can easily get into a certain mindset and stop looking for different causes of the problem.

Rob

Former Member
0 Kudos

Hi Rob!

Word! (Write letters ´n´ Stuff)

I checked my code, and actually the Sy-datum thing was OK because I´m booking goods receptions... They should be booked on the day this Proggie runs -> therefore sy-datum

Just wanted to let you know...

Thanks for all the help!

I´m a Belgian living in Germany... being helped by Canadian!

I´ve also spotted a lot of other nationalities here

SDN surely is a multicultural environment!

PS:Big up to Canada!

Greetz!

Pieter

Former Member
0 Kudos

Thanks - it really is an international community.

But my point was that even though you are booking when the program runs, the fiscal year my not be the same as sy-datum(4). You can use FM DATE_TO_PERIOD_CONVERT to ensure you are posting to the correct fiscal year.

Rob

Former Member
0 Kudos

HI, Bob

I was also faced same problem after BAPI_goods_mvmt_create , I received MBLNR number but still data is not available in MSEG table.

We had put wait command for 50 Seconds.

Regards,

Yogesh

Former Member
0 Kudos

When yo do the select, try adding 'BYPASSING BUFFER'.

Rob

manuel_bassani
Contributor
0 Kudos

Hi Pieter,

try to use


CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
 EXPORTING
 WAIT = 'X'
* IMPORTING
* RETURN =

It forces to wait until commit work is completely executed.

Regards, Manuel

Please remember to reward points and to close the thread when your problem is solved.

Former Member
0 Kudos

Hi Manuel!

Thanx for replying!

Unfortunately it didn´t solve my Problem...

Kind Regards,

Pieter

manuel_bassani
Contributor
0 Kudos

have you already tried to put BAPI_TRANSACTION_COMMIT after endloop statement?

the problem of "...do 150 times... enddo ..." is that it may work, but it strongly depends by the server workload.

Regards, Manuel

Former Member
0 Kudos

Hello Manuel,

That wouldn´t work.

f.e.:

Material A has no Stock

I create a BAPI for a goods reception for Material A of 10 Pieces.

Then, I create a BAPI for a return delivery for Material A of 10 Pieces.

-> Since Material A has no Stock, this BAPI will return an error (first BAPI isn´t BOOKED yet)

Would be kind of funny when it did, though...

Thanx for looking into it!

lajitha_menon
Contributor
0 Kudos

hi,

The wait parameter should work if added to the call of BAPI_TRANSACTION_COMMIT, as suggested by Manuel. Otherwise, is it passing any errors in RETURN?

PG