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: 

How to execute a report program in background based on input parameter?

PraveenDwivedi
Participant
0 Kudos

Hi

I have report program with some input parameters.

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME.

PARAMETERS : p_rad1 RADIOBUTTON GROUP rb1 USER-COMMAND rad DEFAULT 'X'.

PARAMETERS : p_rad2 RADIOBUTTON GROUP rb1.  "selected for background processing

PARAMETERS: p_file TYPE string.

PARAMETERS: p_field1 TYPE c LENGTH 1 DEFAULT 'A'.

PARAMETERS: category(10) AS LISTBOX VISIBLE LENGTH 30 DEFAULT '50000067'.

PARAMETERS: p_field2 TYPE c LENGTH 1 DEFAULT 'D'.

PARAMETERS: p_date  TYPE sy-datum DEFAULT sy-datum.

PARAMETERS: p_chbx AS CHECKBOX USER-COMMAND flag DEFAULT ' '.

SELECTION-SCREEN END OF BLOCK b1.

<<< my logic to read the data and process it >>>

I have a "p_file" to upload data in flat file format before execution. And on selection of the radio button p_rad2 I need to execute this program in background and otherwise it is to be executed manually.

I tried using JOB_OPEN, JOB_SUBMIT, JOB_CLOSE but got stuck somewhere. Please can anybody guide me in detail on how to do this by any method?

Thanks

Praveen

1 ACCEPTED SOLUTION

Former Member

Hi Praveen ,

It is not possible to upload data from frontend while executing the program in background .

If you want to access data in background , you need to have the file in application server first.

Save your file on application server using tcode CG3Z and then use that file.

Thanks ,

Saddam

6 REPLIES 6

Former Member

Hi Praveen ,

It is not possible to upload data from frontend while executing the program in background .

If you want to access data in background , you need to have the file in application server first.

Save your file on application server using tcode CG3Z and then use that file.

Thanks ,

Saddam

0 Kudos

HI Saddam

Is it possible that the file is uploaded on the execution screen manually and then it goes to background execution

0 Kudos

if you want to upload file manually and then to background. you can break up program in two. first will get the input file manully. and then pass uploaded data to second program and run in background by using JOB_OPEN, JOB_CLOSE fm's.

Or

you can use a separate FM to run in background after getting file input manually.

CALL FUNCTION func IN BACKGROUND TASK

0 Kudos

I tried that but got stuck on how to pass the data from one program to another.

I tried this--

SUBMIT "program name"WITH pi_table = lt_data

         VIA JOB lv_jobname NUMBER lv_jobcount

                     TO SAP-SPOOL WITHOUT SPOOL DYNPRO AND RETURN.

where pi_table is a input parmeter in the second program. But I think this is not the way. Can you please help me the code?

Thanks

0 Kudos

Is pi_table a parameter or selection options on selection screen of the second program? It is your data itab, right?

So if want pass this itab to the second program, maybe need 'Export to shared memory', in your second program 'import shared memory' which is running in background job.

regards,

Archer

0 Kudos

Hi Archer

I was doubtful about it but after your suggestion I used this method.

1st program

CALL FUNCTION 'JOB_OPEN'


EXPORT lt_data TO MEMORY ID 'ABCD'.


SUBMIT "program2_name" VIA JOB lv_jobname NUMBER lv_jobcount TO SAP-SPOOL WITHOUT SPOOL DYNPRO AND RETURN.

CALL FUNCTION 'JOB_CLOSE'


2nd Program


IMPORT lt_data FROM MEMORY ID 'ABCD'.


here I used my data from program 1 to be executed in background