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

Foreground and Background

raja_ksravankumarreddy
Product and Topic Expert
Product and Topic Expert
0 Likes
2,446

In my application a program can executed either in foreground or in background. when the program is executed in

the foreground , I dont want to execute certain portion of the code. Similaly, when the job is executed as a background job,

I dont want to execute certain portion of the code. Is it possible? If yes, please share the details.

Thank you in advance.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,029

Hi Raja,

You could do as per your requirement.

There is a system table field known as sy-batch. this field is initial if the program is getting executed in foreground. if sy-batch is not initial then, it means that the program is getting executed in background.

so use a simple if condition.

if sy-batch is initial.

<portion of code to be run in foreground>.

else.

<portion of code to be executed in background>.

endif.

Reward points if this helps,

Kiran

In my application a program can executed either in foreground or in background. when the program is executed in

the foreground , I dont want to execute certain portion of the code. Similaly, when the job is executed as a background job,

I dont want to execute certain portion of the code. Is it possible? If yes, please share the details.

Thank you in advance.

7 REPLIES 7
Read only

JozsefSzikszai
Active Contributor
0 Likes
2,029

hi Raja,

you can check sy-batch during runtime. If it is 'X' it means the program wuns in background.

hope this helps

ec

Read only

Former Member
0 Likes
2,029

IF syst-batch = 'X'.

.....

ENDIF.

Regards,

John

Read only

Former Member
0 Likes
2,029

Hi,

Check the portion with the system variable "sy-batch" .

This variable is 'X' when executing in background.

Jayant Sahu

Read only

Former Member
0 Likes
2,029

Hi,

Possible. When a program is run in the background the system variable SY-BATCH is set to 'X'.

Hence by checking this variable you can segregate the code.

Regards,

Aditya

Read only

Former Member
0 Likes
2,030

Hi Raja,

You could do as per your requirement.

There is a system table field known as sy-batch. this field is initial if the program is getting executed in foreground. if sy-batch is not initial then, it means that the program is getting executed in background.

so use a simple if condition.

if sy-batch is initial.

<portion of code to be run in foreground>.

else.

<portion of code to be executed in background>.

endif.

Reward points if this helps,

Kiran

Read only

Former Member
0 Likes
2,029

Hi,

Check the below code...

IF sy-batch = 'X'.

Do back ground processing.

ELSE.

Do foreground processing.

ENDIF.

Rgds,

Bujji

Read only

Former Member
0 Likes
2,029

also Func modules for uploading/downloading to/from appli server dosent work in background...........