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

capturing messages from background session

Former Member
0 Likes
1,807

Hi,

I'm running an ABAP report in which I call a function module in several different tasks. This function module is eventually submitting RSNAST00 for generating the outputs. I want to capture the messages for the log like they appear in the job log if RSNAST00 is scheduled in the background job using SM36.

Since I'm using SUBMIT and RETURN, it runs in a new internal session. Also I do not get back anything in the EXPORTING LIST TO MEMORY.

Is there any way to capture the system messages that have been generated during that RSNAST00 run.

Thanks in anticipation,

Satya

1 ACCEPTED SOLUTION
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
1,329

Do you need these messages right away, or do you really want to see them in a job log like in SM37. Reason why I ask, is you can create a background job on the fly and submit it, then the error jog would be visible from SM37. So do you need the error log coming back to you at runtime?

Example for submitting job in background.



report zrich_0001 .

data:   l_valid,
        ls_params like pri_params,
        l_jobcount like tbtcjob-jobcount,
        l_jobname  like tbtcjob-jobname.

start-of-selection.

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

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

* Submit report to job
  submit RSNAST00
       via job     l_jobname
           number  l_jobcount
       to sap-spool without spool dynpro
           spool parameters ls_params
                       and return.

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

Regards,

Rich Heilman

8 REPLIES 8
Read only

Former Member
0 Likes
1,329

Use this function module BP_JOBLOG_READ

Read only

0 Likes
1,329

Hi,

The problem is the my Z program says 100 records. split in 5 sessions of 20 each.

I call a 'Z' function module starting in new task

within that i say SUBMIT RSNAST00 with ...

....

and return.

I dont have the job number here.

There are some problems when you try to use the FM JOB_OPEN, JOB_SUBMIT AND JOB_CLOSE in a BACKGROUND PROCESS.

Is there a way I can get the job number during SUBMIT

Thanks

Satya

Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
1,330

Do you need these messages right away, or do you really want to see them in a job log like in SM37. Reason why I ask, is you can create a background job on the fly and submit it, then the error jog would be visible from SM37. So do you need the error log coming back to you at runtime?

Example for submitting job in background.



report zrich_0001 .

data:   l_valid,
        ls_params like pri_params,
        l_jobcount like tbtcjob-jobcount,
        l_jobname  like tbtcjob-jobname.

start-of-selection.

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

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

* Submit report to job
  submit RSNAST00
       via job     l_jobname
           number  l_jobcount
       to sap-spool without spool dynpro
           spool parameters ls_params
                       and return.

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

Regards,

Rich Heilman

Read only

0 Likes
1,329

BP_JOBLOG_READ will give you the "job log" for the job, but will not give you the actual output of the lists, which is what I think you are after, right?

Regards,

Rich Heilman

Read only

0 Likes
1,329

In order to have a job number it must be scheduled to run in a batch job either thru SM36 or on the fly with the code above.

Let me try to get a handle on your problem.

You have a "Z" program which uses paraellel processing and in that call to the function module, it submits the "NAST" program and you need to get the output of the NAST program and bring it back to the "Z" program?

Regards,

Rich HEilman

Read only

0 Likes
1,329

Hi,

The main program ZRSNAST00 is running in a background job.

it then calls Z_PROCESS_RSNAST00 function module in 5 different tasks

within the Z_PROCESS_RSNAST00 function module RSNAST00 is to be submitted.

My question is that since its already into a background session which is using a batch job and that job is not yet closed. Will the JOB_OPEN function module not fail in certain or all cases?

Rich, if you can help me on this.

Thanks and regards,

Satya

Read only

0 Likes
1,329

You know, I don't know if it would fail or not. I have to think that a background job spawning other background jobs would be allowed. But you may run out of Background processes if you only have a couple. I would try it out.

I will try it with my example program.

Regards,

Rich Heilman

Read only

0 Likes
1,329

Ok, I submitted this program in background, it creates 4 more jobs calling my test program ZRICH_0005. In that program, I am just issuing a message.

No problems.



report zrich_0001 .

data:   l_valid,
        ls_params like pri_params,
        l_jobcount like tbtcjob-jobcount,
        l_jobname  like tbtcjob-jobname.

parameters: p_check.

start-of-selection.

  do 4 times.

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

* Open Job
    clear l_jobname.
    l_jobname = sy-index.
    shift l_jobname left deleting leading space.
    concatenate 'ZRICH_0005' l_jobname into l_jobname.

    call function 'JOB_OPEN'
         exporting
              jobname  = l_jobname
         importing
              jobcount = l_jobcount.

* Submit report to job
    submit zrich_0005
         via job     l_jobname
             number  l_jobcount
         to sap-spool without spool dynpro
             spool parameters ls_params
                         and return.

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

  enddo.

Regards,

Rich Heilman