cancel
Showing results for 
Search instead for 
Did you mean: 

WDA: Call a report from a method.

Former Member
0 Kudos

Hello,

I need to call a report from one of the methods of a WDA application. The report is called when a user clicks SAVE button. Also, the report has parameters.

The idea is to run the report as a background job.

Do I need to use SUBMIT?

How can this be done?

Thank you.

Accepted Solutions (1)

Accepted Solutions (1)

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

Yes, I think you can do this. I would suggest using the SUBMIT statement, but you will need to setup a background job. You can do this using the following code.



data:   sdate type sy-datum,
        stime type sy-uzeit,
        l_valid,
        ls_params like pri_params,
        l_jobcount like tbtcjob-jobcount,
        l_jobname  like tbtcjob-jobname.

* Get Print Parameters
  call function 'GET_PRINT_PARAMETERS'
       exporting
            no_dialog      = 'X'
       importing
            valid          = l_valid
            out_parameters = ls_params.

* Open Job
  l_jobname = 'ZRICH_0005'.
  call function 'JOB_OPEN'
       exporting
            jobname  = l_jobname
       importing
            jobcount = l_jobcount.

* Submit report to job
  submit zrich_0005
<b>     with p_fld = 'X'   " Pass parameters like this</b>
       via job     l_jobname
           number  l_jobcount
       to sap-spool without spool dynpro
           spool parameters ls_params
              and return.

* Kick job off 30 seconds from now.
  sdate = sy-datum.
  stime = sy-uzeit + 30.

* Schedule and close job.
  call function 'JOB_CLOSE'
       exporting
            jobcount  = l_jobcount
            jobname   = l_jobname
            sdlstrtdt = sdate
            sdlstrttm = stime
*            strtimmed = 'X'
            .

Regards,

RIch Heilman

Former Member
0 Kudos

Hi Rich,

You reply definitely helps and works perfectly except one additional requirement that I have.

Report that I run has some input params. How do I pass them?

Thank you.

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

Check the above program, notice in the SUBMIT statement that there is a WITH extension. This is one way of passing the parameters, for example P_FLD is a parameter of the submitted program. You can also pass values to SELECT-OPTIONS if need be. Use create a range and pass like this.

submit <report> 
      <b>with S_FLD in R_FLD</b>
           and return.

Regards,

Rich Heilman

Answers (0)