Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Generate Background job

Hi,

In my scenario a report is getting displays which gives the complete details based on the input.Instead of dispalying as a report i have to schedule a background job,in which job log gives the details of the report.How to do it?Plz post some sample code

Former Member
replied

In the at user-command section of your report, you shold call the following FMs in sequence to create a background job.

1) call FM JOB_OPEN

2) Submit the report name in background mode

3) JOB_CLOSE

Sample code:

CALL FUNCTION 'JOB_OPEN'

EXPORTING

JOBNAME = JOBNAME

JOBGROUP = 'FIEB'

IMPORTING

JOBCOUNT = JOBCOUNT

EXCEPTIONS

CANT_CREATE_JOB = 01

INVALID_JOB_DATA = 02

JOBNAME_MISSING = 03.

IF SY-SUBRC NE 0.

MESSAGE E015 RAISING SESSION_NOT_PROCESSABLE.

ENDIF.

SUBMIT RSBDCSUB AND RETURN

USER SY-UNAME

VIA JOB JOBNAME NUMBER JOBCOUNT

  • with mappe = group

WITH MAPPE = BI-NAME

WITH VON = SY-DATUM

WITH BIS = SY-DATUM

WITH Z_VERARB = 'X'.

BDCSTRTDT = SY-DATUM.

BDCSTRTDT = SPACE.

BDCSTRTTM = SPACE.

BDCIMMED = 'X'.

  • bdcstrttm = runtime.

CALL FUNCTION 'JOB_CLOSE'

EXPORTING

JOBNAME = JOBNAME

JOBCOUNT = JOBCOUNT

STRTIMMED = BDCIMMED

SDLSTRTDT = BDCSTRTDT

SDLSTRTTM = BDCSTRTTM

EXCEPTIONS

CANT_START_IMMEDIATE = 01

JOBNAME_MISSING = 02

JOB_CLOSE_FAILED = 03

JOB_NOSTEPS = 04

JOB_NOTEX = 05

LOCK_FAILED = 06.

IF SY-SUBRC NE 0.

MESSAGE E015 RAISING SESSION_NOT_PROCESSABLE.

ENDIF.

CLEAR BDCIMMED.

BDCSTRTDT = SPACE.

BDCSTRTTM = SPACE.

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question