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 Identify program is running in background or Foreground mode?

jagesh_lakdawala
Active Participant
0 Likes
8,611

Hello Experts,

I have developed on Z report and from this report BDC for Transaction CO11 is runnning using CALL TRANSACTION statement.

On Selection screen there is a option for selecting the BDC mode either in Background or Forground or Error mode.

My question is:- how do I recognize this selected BDC mode in the function exit ZXMBCU02.

This exit triggers when transaction CO11 runs.

Because based on the selected BDC mode i have to apply some logic in this exit.

Please suggest.

Regards,

Jagesh

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
4,874

Hi,

You can check the value of system variable:

SY-BATCH-Will give you is program is running in the

background or not.

Hope it helps

Regards

Mansi

Hello Experts,

I have developed on Z report and from this report BDC for Transaction CO11 is runnning using CALL TRANSACTION statement.

On Selection screen there is a option for selecting the BDC mode either in Background or Forground or Error mode.

My question is:- how do I recognize this selected BDC mode in the function exit ZXMBCU02.

This exit triggers when transaction CO11 runs.

Because based on the selected BDC mode i have to apply some logic in this exit.

Please suggest.

Regards,

Jagesh

7 REPLIES 7
Read only

Former Member
0 Likes
4,874

Hi,

You can check sy-batch.

Regards,

Kritesh Shah

Read only

Former Member
0 Likes
4,875

Hi,

You can check the value of system variable:

SY-BATCH-Will give you is program is running in the

background or not.

Hope it helps

Regards

Mansi

Read only

0 Likes
4,874

Hi Mansi,

Thanks for your reply.

I have used the same SY-BATCH in the exit ZXMBCU02 but in debugging I found its value ' ' in both the cases.

Here my Report runs online and within the Program BDC for CO11 is running either in Background or Foreground mode as per the radio button selection.

So thats why i am confused in using the SY-BATCH system field.

Please suggest.

Regards

Jagesh

Read only

0 Likes
4,874

Hi Jagesh...

You can do the following..

1. Export the Batch Input Mode in to ABAP memory using the EXPORT statement.

2. Import that value in the user exit.

3. To execute your code only if its batch input mode, use the field SY-BINPT.

You can also check if this structure "BDCRUN" is used in that program, b'cas this is contained in the VA01 an VA02 transacation, this would contain all the data.

CALL FUNCTION 'BDC_RUNNING'

IMPORTING

bi_info = bi_info

EXCEPTIONS

OTHERS = 1.

bi_info will contain all the data.

GET PARAMETER ID 'SD_BACKGROUND_DEBUG' FIELD background_debug.

Best Regards,

Pradeep.

Read only

0 Likes
4,874

Hi Pradeep,

I have used this FM BDC_RUNNING and it is working fine.

Thanks for your suggestion and I am closing this Thread now.

Regards,

Jagesh

Read only

KN-Nampoothiry
Active Participant
0 Likes
4,874

Hi Jagdish,

As Kritesh and Mansi told, SY-BATCH is the most appropriate way to know whether your program is running in Background or Foreground Mode.

Moreover you have mentioned that in your selection screen there is an option to choose between forground and background. That could be useful if it is used to decide whether to create a session and schedule it ( if background is chosen ) or call transaction and do it right away (if Foreground is chosen ). If it used to decide whether it is currently running in Foreground/ background by specifying variant, then it is wrong.

Guess SY-BATCH Should solve the requirement.

If resolved, please close the issue becoz posts marked answered are more useful while searching tomorrow with similar requirement.

Thanks.

Read only

Former Member
0 Likes
4,874

U can do it in 2 ways ;

1) append a new field(CI) in any strucure and pass a flag to the exit for sy-batch(ie back ground)

check the flag in the exit and do ur code.

2)Or export to memory and u can do it (not recomended)..

Regards

Anoop Chandran