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

How to delay a certain ABAP statement.

Former Member
0 Likes
3,971

hi exps..

this is the scenario..

I have three lines of code....

1. first line abap statement.

2. second line abap statement.

3. third line abap statement.

Problem:

Is it possible to delay the execution of Second line untill the execution of THIRD line is complete...without changing the position of them.

Will WAIT UP TO x SECONDS work for this. I think it will delay all the succeeding statements.am i right or not...?

Any solution...pls.

hi exps..

this is the scenario..

I have three lines of code....

1. first line abap statement.

2. second line abap statement.

3. third line abap statement.

Problem:

Is it possible to delay the execution of Second line untill the execution of THIRD line is complete...without changing the position of them.

Will WAIT UP TO x SECONDS work for this. I think it will delay all the succeeding statements.am i right or not...?

Any solution...pls.

11 REPLIES 11
Read only

Former Member
0 Likes
2,662

REPORT YDELAY.

  • This program delays n seconds

DATA: TIM LIKE SY-UZEIT, N TYPE I VALUE 30.

TIM = SY-UZEIT.

TIM = TIM + N.

DO.

GET TIME.

IF TIM < SY-UZEIT.

EXIT.

ENDIF.

ENDDO.

Read only

Former Member
2,662

Hi

U r right..

WAIT UP TO x SECONDS will delay the excution of succeding statements..

Regs

Manas Ranjan Panda

Read only

Former Member
0 Likes
2,662

Hi Saravanan,

Its not possible to execute the third line of a stament without executing the second one, because the ABAP compiler executes line after line. In this case, you should change the flow logic of your code.

Regards,

Eric

  • Reward any helpful answer

Read only

Former Member
0 Likes
2,662

HI,

WAIT UP TO x SECONDS will delay all the succeeding statements

Try this one

<b>

PERFORM n OF form1 form2 form3 ... .</b>

<b>Effect</b>

Calls the subroutine with the index n from the list of subroutines in the statement. At runtime, n must contain a value between 1 (first name) and the total number of subroutines listed in the PERFORM statement (last name). The list can contain up to 256 subroutines.

Or else, you can write <b>PERFORM form ON COMMIT</b>. fro second one, and execute this after the 3rd one comeplte the process

Regards

Sudheer

Read only

Peter_Inotai
Active Contributor
0 Likes
2,662

You can check in the debugger, second line is executed after first line.

Howver if you have statments, which trigger update process, it will happen in the background, so it might still run, when your second statement is executed.

You can try 'SET UPDATE TASK LOCAL.' and 'COMMIT WORK AND WAIT.'

See this example to process idocs:

      SET UPDATE TASK LOCAL.

      CALL FUNCTION 'EDI_DATA_INCOMING'
           EXPORTING
                pathname = l_pathname
                port     = port
           EXCEPTIONS
                OTHERS   = 1.

      IF sy-subrc = 0.

        COMMIT WORK AND WAIT.

        FORMAT COLOR COL_POSITIVE.
        WRITE: / sy-vline, <fs_dir_list>-name,
        'Inbound processing was called, check the generated IDoc.'(l00),
                   AT sy-linsz sy-vline.
        ULINE.
      ELSE.
        FORMAT COLOR COL_NEGATIVE.
        WRITE: / sy-vline, <fs_dir_list>-name,
        'Error in inbound processing'(l03),
                   AT sy-linsz sy-vline.
      ENDIF.

Read only

Former Member
0 Likes
2,662

Is it possible to <b>delay the execution of Second line untill the execution of THIRD line is complete</b>...without changing the position of them

--- From the above do you mean that, you need to execute 3rd line before 2nd line, is it???

Kind Regards

Eswar

Read only

0 Likes
2,662

hi easwar,

what u have grasped is exactly correct.

It may look funny.but my situation wants this.

ie, my badi method is executing before the full database update is done (commit work).

But i want this the other way.

ie, my code in the badi method is to be executed after the commit work.(after ful database update)

I think now u understood the real problem

solution pls.....

Read only

0 Likes
2,662

Try changing your COMMIT WORK to COMMIT WORK AND WAIT. This waits until the commit is complete before continuing.

Read only

0 Likes
2,662

Hi Saravanan

As per my understanding, the approach you have taken might be wrong. Flow of a program/code in ABAP/SAP doesnt work that way.

You can expect better solutions if you can provide inputs on the actual requirement. I beleive knowing the exact requirement can lead to other alternative methods if any...

Kind Regards

Eswar

Read only

0 Likes
2,662

Hi Saravanan,

I think you can call a function module <b>in update task</b> inside your badi's code. In that way, all the code within the function module will be executed after a commit work is executed. I remember the new function module should have Update module flag and Start delayed flag checked in its attributes tab.

This could maybe work. Good luck!!!

Indegheto

Read only

Former Member
0 Likes
2,662

Pls. try with below code.

1. first line abap statement.

in second line write

2. PERFORM Subroutine_name ON COMMIT.

3. third line abap statement.

Form

here you write second ABAP statement.

endform.

Now after performing third statement, at the time commit of the program it will go to the perform statement and process the secon statemnet.

Pls. reward points if it is useful answer.