Application Development 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: 

when we use the sy-batch statement

Former Member
0 Kudos

hi ,

when we use the sy-batch statement.

regards,

venkat.

9 REPLIES 9

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

You would use SY-BATCH any time you want to know if the current program is running in the background. For example, say you have a function module which downloads a file to the frontend, but we know that we can't do this in background, so you could code something in the functino module which would not allow the user to do it, something like.

if sy-batch = 'X'.
   raise exception cannot_call_in_background.
endif.

Regards,

Rich Heilman

former_member187255
Active Contributor
0 Kudos

Pandu,

SY-BATCH is used to check whether the Transaction or report are executed in frontend or background as batch job.

IF SY-BATCH EQ 'X'.
     "do this......
ENDIF.

Chandra.

Former Member
0 Kudos

Hi,

another reason to use it is in ALV.

IF SY-BATCH = ' '.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

...

ELSE.

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

...

Regards, Dieter

0 Kudos

Hi Dieter,

this is not necessary because ALV Grid is running in batchmode. There is no need to differ like you did. Did you ever tried to run a ALV GRid report in backgrind. Its working well.

0 Kudos

That's right Rainer, actually the REUSE_ALV_GRID_DISPLAY will actually convert over to the list display if it finds that it is being ran in the background. No need to check this and handle in your programs.

Regards,

Rich Heilman

0 Kudos

Hi Rainer,

thanks for this Info. i have test it and it works with grid in background.

We have changed to ECC6, and the Report are written under 4.6C perhaps

that's the reason why i have checked sy-batch?

Thanks again, also to rich.

Regards, Dieter

0 Kudos

We started using the ALV Grid in 4.6C and investigated on that and therefore we dont have any report using the list-variant of ALV.

So it must be before 4.6c and i'm sure in the beginning you have to differ.

Former Member
0 Kudos

sy-batch is a system field and is an identifier whether report s run in background

sy-batch = 'X' means ---> execution in back ground.

This can be used to avoid GUI operations while running in back ground.

if sy-batch is not initial.

call function 'GUI_UPLOAD'

else

open dataset 'cxxxx'

endif.

*reward if useful*

Former Member
0 Kudos

some of the programs should run only background so we keep condition like'

if not sy-batch = 'X'.

error message " Please run the program only in background".

endif.

Thanks

Seshu