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

Wait up to ...

Former Member
0 Likes
720

Hi all,

I am creating a batch using a BAPI and immediately creating characteristics with a value for that batch. The problem is the batch sucessfully getting created but the characteristic value is not updated. If i go in debug mode, i see that my program is absolutely fine and working well. In debug mode its updating the characteristic value too.

So i used WAIT UP TO 4 SECONDS after each BAPI. Now characteristic value is also updated. But the problem is when my server is slow, the wait time is not sufficient and my program is failing.

My doubt is, i am using BAPI_TRANSACTION_COMMIT then why should i explicitly write a Wait statement. Is there any permanent solution for this problem.

Peice of my code is attached below for reference.

CALL FUNCTION 'BAPI_BATCH_CREATE'

EXPORTING

material = l_material

plant = afvgd-werks

batchcontrolfields = lw_batchcontrolfields

IMPORTING

batch = l_newbatch

TABLES

return = li_return_createbatch.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

wait = 'X'.

WAIT UP TO 4 SECONDS.

CALL FUNCTION 'BAPI_OBJCL_CREATE'

EXPORTING

objectkeynew = l_material_char_create

objecttablenew = lc_objecttable

classnumnew = l_classnum

classtypenew = lc_classtype

TABLES

allocvaluesnum = li_allocvaluesnum_create

return = li_return_create.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

wait = 'X'.

WAIT UP TO 4 SECONDS.

Hi all,

I am creating a batch using a BAPI and immediately creating characteristics with a value for that batch. The problem is the batch sucessfully getting created but the characteristic value is not updated. If i go in debug mode, i see that my program is absolutely fine and working well. In debug mode its updating the characteristic value too.

So i used WAIT UP TO 4 SECONDS after each BAPI. Now characteristic value is also updated. But the problem is when my server is slow, the wait time is not sufficient and my program is failing.

My doubt is, i am using BAPI_TRANSACTION_COMMIT then why should i explicitly write a Wait statement. Is there any permanent solution for this problem.

Peice of my code is attached below for reference.

CALL FUNCTION 'BAPI_BATCH_CREATE'

EXPORTING

material = l_material

plant = afvgd-werks

batchcontrolfields = lw_batchcontrolfields

IMPORTING

batch = l_newbatch

TABLES

return = li_return_createbatch.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

wait = 'X'.

WAIT UP TO 4 SECONDS.

CALL FUNCTION 'BAPI_OBJCL_CREATE'

EXPORTING

objectkeynew = l_material_char_create

objecttablenew = lc_objecttable

classnumnew = l_classnum

classtypenew = lc_classtype

TABLES

allocvaluesnum = li_allocvaluesnum_create

return = li_return_create.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

wait = 'X'.

WAIT UP TO 4 SECONDS.

3 REPLIES 3
Read only

Former Member
0 Likes
602

Hi,

Try using SET UPDATE TASK LOCAL. before each BAPI Call.

For more detail do F1 on SET and check SET UPDATE TASK LOCAL. option.

Hope this helps.

Manish

Read only

Former Member
0 Likes
602

Yes, there is no sense in waiting when you are doing an explicit commit.

YOu can make a select statement on the master table of the batch data inside an indefinite loop.

If it gives a sy-subrc = 0., then exit that loop.

after the bapi calls:

do.

select single * from mchb where <condition>.

if sy-subrc = 0.

exit.

endif.

enddo.

Regards,

ravi

Read only

Former Member
0 Likes
602

Hi,

You can increase your wait time to 15 seconds. however, when executed in background there will not be any problem.

thanks,

sksingh