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

Execution to be continued based on condition

Former Member
0 Likes
460

Hi,

My program has to be wait in particular line based on condition.

The condition is If this program is running already in another instance, this program has to be wait

till that instance is finished its processing

How can i do this ?

Regards

Ramakrishna L

3 REPLIES 3
Read only

uwe_schieferstein
Active Contributor
0 Likes
420

Hello Rama

Based on this particular condition your report has to set a lock entry.

For example, the lock object E_RSCATGLX is explictly used to "Lock Report RSCATGLX Against Parallel Execution".

You could "abuse" this lock object by simply using your report name as argument.

Thus, you logic could look like this:


...
START-OF-SELECTION.

DO.
  CALL FUNCTION 'ENQUEUE_E_RSCATGLX'
     EXPORTING
          RSCATGLX = <name of your report>
EXCEPTIONS
              FOREIGN_LOCK
              SYSTEM_FAILURE.
  IF ( syst-subrc = 0 ).
    EXIT.  " leave DO loop
  ELSE.
    WAIT UP TO 5 SECONDS.
  ENDIF.

ENDDO.
...

Of course you should define a time-out (e.g. 100x 5 seconds) to avoid an endless loop in case that the foreign lock is never removed.

Regards

Uwe

Read only

0 Likes
420

data : prg type INDX-SRTFD value 'ZTEST1_CHECJ'.

if count ne 1.

endif.

do.

CALL FUNCTION 'ENQUEUE_ESINDX'

EXPORTING

MODE_INDX = 'E'

MANDT = SY-MANDT

RELID = 'ZZ'

SRTFD = prg " program name

  • SRTF2 =

  • X_RELID = ' '

  • X_SRTFD = ' '

  • X_SRTF2 = ' '

  • _SCOPE = '2'

  • _WAIT = ' '

  • _COLLECT = ' '

EXCEPTIONS

FOREIGN_LOCK = 1

SYSTEM_FAILURE = 2

OTHERS = 3

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

else.

exit.

ENDIF.

can i use this ?

If it is use can i give function module name in the SRTFD field instead of program name?

Regards

Ramakrishna L

Read only

Former Member
0 Likes
420

Along with this you should also use the parameter wait = 'X' in the call function which waits for some time to check if the lock gets released and rest the above process is fine.