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 inside a loop

Former Member
0 Likes
3,586

Hello Friends,

i am facing a strange behaviour..... I am doing some coading in user-exit.... all thing is happeing inside a loop. things looks pretty fine, but sometimes, when the control reach to the bapi BAPI_ALM_ORDER_MAINTAIN (which i am using to create the operations ), so when control reachs to this bapi, it did not proceed rather the control goes back to the loop at lt_tab ....... and sometimes it works fine, that after BAPI_ALM_ORDER_MAINTAIN it proceed normal..........

So far is one issue, but sometimes its also happend that, when control goes back to loop, if procees then outside the loop, and then automatically comes again to BAPI_ALM_ORDER_MAINTAIN.. and proceed further.... dont know what is going on...

Any one has any idea, what is happening ?

Regards,

19 REPLIES 19
Read only

Former Member
0 Likes
2,714

Hi,

Where did you put your COMMIT WORK.

Just put it after the BAPI call.

Regards,

Atish

Read only

0 Likes
2,714

the commit work is placed after the bapi called, but this is not the issue...

As I said, in debug mode it did not happend always, but sometimes, it happends that, when control reach to the bapi call, it goes back to the loop at lt_lab ....

Any idea, why ?

Regards,

Read only

Former Member
0 Likes
2,714

Hi Shan,

use

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

WAIT = 'X'

IMPORTING

RETURN = RETURN.

after your BAPI.

Regards, Dieter

Read only

0 Likes
2,714

HI Dieter,

Danke

Actually I am using this BAPI after my bapi ( order maintain ), but instead of using wait = 'X' I am using explicit command, like wait 1 seconds, etc...

Any idea, what is the reason that, the control goes back to loop at it_tab back ?

Regards,

Read only

0 Likes
2,714

Hi,

Just increase the WAITING TIME lets say 5 seconds or something, and you will not face that issue then.

Regards,

Atish

Read only

0 Likes
2,714

Hi shan,

wait = x does'nt mean wait a special.

it's the same as COMMIT WORK AND WAIT.

Means wait until update process is finished.

Look at the docu of the FM of the Docu of COMMIT WORK AND WAIT.

regards, Dieter

Read only

0 Likes
2,714

Hi All,

thanks for your reply,

I will do this as dieter mentioned to set the wait to 'X', but pls anyone tell me why this is happenig ? have any one also faced such thing ?

I want to know the reason, why the contol goes back to the start of loop ?

Regards,

Read only

0 Likes
2,714

hi,

There are many transactions which require more time to happen the COMMIT so it is better to increase the time if you find the earlier time is not sufficient.

Regards,

Atish

Read only

0 Likes
2,714

Hi shan,

can you show the code of LOOP ... ENDLOOP?

Regards, Dieter

Read only

0 Likes
2,714

Hi All,

Its nice suggestion to increase the wait time to 5 sec, but then I have probelm with performance, because its a big code piece, and I am calling atleast 6, or 7 times this BAPI commit, as I am inserting / updating , various tables, and calling bapi like bapi_maintani_order etc..... so lets say, if loops goes 3 tims, then wait 5 sec after each bapi, is a big performance hole....

Comming to you dieter, the piece of code is nothing more then..

Loop at it_tab.

.....

.....

CALL FUNCTION 'BAPI_ALM_ORDER_MAINTAIN'

....

..

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.

wait UP TO 1 seconds.

....

Endloop.

Regards,

Read only

0 Likes
2,714

Hello All,

Unfortunatelly, the problem is not solved, ..... when control reach to the bapi, it goes back to the start of loop..... any one has any idea, why,

is there any one who faced this issue before ?

Regards,

Read only

0 Likes
2,714

Hi shan,

please set some break-point after

CALL FUNCTION 'BAPI_ALM_ORDER_MAINTAIN'

and

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.

and loop at the sy-tabix, sy-index. do they have right values?

why don't you use 'BAPI_TRANSACTION_COMMIT' with wait = 'X'.

which i have mentioned above?

Regards, Dieter

Read only

0 Likes
2,714

hi,

what i believe is BAPI is not execting with sucess and returning with errors. also, u pl check any Return or Exit after bapi call inside bapi call.

Jogdand M B

Read only

0 Likes
2,714

Very very strange :

I have debuged the bapi BAPI_ALM_ORDER_MAINTAIN, and with inside this bapi when control reach to the bapi IBAPI_PROC_METHOD_TABLE_EXEC, it goes back to my starting loop, and when inside this loop the table index reach to end, the control goes back to bapi IBAPI_PROC_METHOD_TABLE_EXEC, and processing is resumed from where it ends ???????

I am getting mad, what is going on

Any idea, ..

Regards,

Message was edited by:

Shah H

Read only

0 Likes
2,714

Hi Shah,

is it possible that you loop for an itab which you use as an

parameter in the FM BAPI_ALM_ORDER_MAINTAIN?

please show your LOOP-Statement and

your call of the FM BAPI_ALM_ORDER_MAINTAIN.

Regards, Dieter

Read only

0 Likes
2,714

no, no, I am looping over the it_tab lt_afvgd.

Okey here is a peice of code....

LOOP AT lt_afvgd.

IF sy-ucomm eq 'GO'.

                • SOME FUNCTONALITY *****

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

clear: wa_methods,

it_methods.

  • Create operations

MOVE '1' TO wa_methods-REFNUMBER.

MOVE 'OPERATION' TO wa_methods-objecttype.

MOVE 'CREATE' TO wa_methods-method.

MOVE orderNr to wa_methods-objectkey.

APPEND wa_methods TO it_methods.

MOVE '1' TO wa_methods-REFNUMBER.

MOVE '' TO wa_methods-objecttype.

MOVE 'SAVE' TO wa_methods-method.

MOVE orderNr to wa_methods-objectkey.

APPEND wa_methods TO it_methods.

clear l_aufpl.

Select single AUFPL INTO l_aufpl

from afko

where

aufnr = orderNr.

clear l_aplzl.

Select MAX( APLZL ) into l_APLZL

from AFVC

where

AUFPL = l_aufpl.

clear l_vornr.

Select single vornr into l_vornr

from AFVC

where

AUFPL = l_aufpl AND

APLZL = l_APLZL.

add '1' to l_vornr.

clear: wa_operation,

et_numbers,

IT_RETURN,

it_operation.

CALL FUNCTION 'Z_GET_OPER_NAME'

EXPORTING

L_VIDEONORM = ls_ZENCO_TAB_CTRL-videonorm

L_QC_LEVEL = ls_ZENCO_TAB_CTRL-qc_level

IMPORTING

LV_OPERATION_TEXT = lv_oper_text

.

MOVE l_vornr TO wa_operation-activity. " Must give

MOVE 'Z114' TO wa_operation-CONTROL_KEY.

MOVE '' TO wa_operation-sub_activity.

MOVE '' TO wa_operation-standard_text_key.

  • MOVE 'QC Setup' TO wa_operation-description.

MOVE lv_oper_text TO wa_operation-description.

MOVE '' TO wa_operation-vendor_no.

MOVE 3 TO wa_operation-quantity.

MOVE 'KG' TO wa_operation-base_uom.

APPEND wa_operation TO it_operation.

CALL FUNCTION 'BAPI_ALM_ORDER_MAINTAIN'

TABLES

it_methods = it_methods

  • it_header = it_header

  • IT_HEADER_UP =

  • IT_HEADER_SRV = IT_HEADER_SERV

  • IT_HEADER_SRV_UP =

  • IT_USERSTATUS = IT_USERSTATUS "not working

  • IT_PARTNER =

  • IT_PARTNER_UP =

it_operation = it_operation

  • IT_OPERATION_UP =

  • IT_RELATION =

  • IT_RELATION_UP =

  • IT_COMPONENT =

  • IT_COMPONENT_UP =

  • IT_TEXT = it_text

  • IT_TEXT_LINES = it_text_line

  • EXTENSION_IN =

RETURN = IT_RETURN

et_numbers = et_numbers.

  • CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.

  • wait UP TO 2 seconds.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

WAIT = 'X'

  • IMPORTING

  • RETURN =

.

if sy-subrc eq 0.

......some more functionality .......................

endif.

Endloop.

Message was edited by:

Shah H

Message was edited by:

Shah H

Read only

0 Likes
2,714

Hi,

then problem is with IBAPI_PROC_METHOD_TABLE_EXEC. so before executing this fm chek all parameters of this BAPI. or with the runtime set of information excute that module in se37. then check... surely this is the problem . check and modifiy values provided to BAPI.

Jogdand M B

Read only

0 Likes
2,714

Any one has any idea ?

Why the bapi goes back to loop again ?

Regards,

Read only

0 Likes
2,714

Hi ,

I tried, this, but still facing the same issue.....

Any one know what is the reason ?

Regards,