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: 

back ground

Former Member
0 Kudos

hi all,

i need to run a report in back ground,it should trigger whne i press a button in another report.how can i do that and i want to do that by using FM for background.plz let me know.imm points are awarded.thank u

2 REPLIES 2

naimesh_patel
Active Contributor
0 Kudos

Hello,

Try this code

  • Opens a Job with name P_JOBNM

CALL FUNCTION 'JOB_OPEN'

EXPORTING

JOBGROUP = 'SPOOL'

JOBNAME = P_JOBNM

IMPORTING

JOBCOUNT = W_JOBNO

EXCEPTIONS

CANT_CREATE_JOB = 1

INVALID_JOB_DATA = 2

JOBNAME_MISSING = 3

OTHERS = 4.

  • Submitting Report, via job number and return

SUBMIT RSMON000_ALV

VIA JOB P_JOBNM NUMBER W_JOBNO

TO SAP-SPOOL

AND RETURN.

  • Closes the Job

CALL FUNCTION 'JOB_CLOSE'

EXPORTING

JOBCOUNT = W_JOBNO

JOBNAME = P_JOBNM

STRTIMMED = 'X'

EXCEPTIONS

CANT_START_IMMEDIATE = 1

INVALID_STARTDATE = 2

JOBNAME_MISSING = 3

JOB_CLOSE_FAILED = 4

JOB_NOSTEPS = 5

JOB_NOTEX = 6

LOCK_FAILED = 7

OTHERS = 8.

IF SY-SUBRC = 0.

MESSAGE S398(00) WITH 'Job' P_JOBNM 'was scheduled..!'.

ENDIF.

ENDIF.

Regards,

Naimesh

Message was edited by: Naimesh Patel

Former Member
0 Kudos

Try this

  • Open Job

CALL FUNCTION 'JOB_OPEN'

EXPORTING

JOBNAME = p_job

IMPORTING

JOBCOUNT = jobnumber

EXCEPTIONS

CANT_CREATE_JOB = 1

INVALID_JOB_DATA = 2

JOBNAME_MISSING = 3

OTHERS = 4.

IF SY-SUBRC = 0.

write: / text-001, p_uname.

else.

message id sy-msgid type sy-msgty number sy-msgno

with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

write: / sy-msgid, sy-msgty, sy-msgno,

sy-msgv1, sy-msgv2, sy-msgv3, sy-msgv4.

ENDIF.

  • Submit job

submit ZSDBSL16

with s_vkorg in s_vkorg

*with s_vkbur in s_vkbur

with s_auart in s_auart

with s_audat in s_audat

with s_vtweg in s_vtweg

with s_spart in s_spart

with p_date = p_date

with p_uname = p_uname

via job p_job number jobnumber and return.

  • Close job

call function 'JOB_CLOSE'

EXPORTING

jobcount = jobnumber

jobname = p_job

strtimmed = 'X'

targetsystem = ' '

IMPORTING

job_was_released = job_started

EXCEPTIONS

cant_start_immediate = 1

invalid_startdate = 2

jobname_missing = 3

job_close_failed = 4

job_nosteps = 5

job_notex = 6

lock_failed = 7

others = 8.