02-17-2005 12:29 AM
Hello,
I have a report program that has a checkbox option to 'Execute in background'. This should also generate a spool file in SAP. I would just like to ask for options on how to do about this.
I have thought of using the SUBMIT command and I read that this command can also generate a spool file. So it is like calling the program itself. Is this possible? Or do I need to make a cloned program and call submit the parameters to the cloned program?
Is there a function module that does this?
I'd appreciate your help on this. Thanks in advance!
Regards,
Kristine
02-17-2005 3:41 AM
Hello,
To create a Job Step, the FM 'JOB_OPEN' could be used.
To add a JOBSTEP, In your case an ABAP program, "SUBMIT" could be used.
To close the job step, use FM "JOB_CLOSE".
SAMPLE Code:
CALL FUNCTION 'JOB_OPEN'
EXPORTING
DELANFREP = ' '
JOBGROUP = ' '
jobname = 'XYZ'
sdlstrtdt = sy-datum "Current date
sdlstrttm = sy-uzeit
IMPORTING
jobcount = g_jobcount
EXCEPTIONS
cant_create_job = 1
invalid_job_data = 2
jobname_missing = 3
OTHERS = 4
.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
-
SUBMIT z_PROGRAM AND RETURN
USER sy-uname " User for runtime authorizations
WITH p_para EQ p_para
"..... Selection screen parameters
VIA JOB g_jobname NUMBER g_jobcount
" Job name and job number
" from JOB_OPEN
TO SAP-SPOOL " Print and archiving options from
" GET_PRINT_PARAMETERS
" Both sets of options come from
" GET_PRINT_PARAMETERS
SPOOL PARAMETERS g_s_user_print_params
ARCHIVE PARAMETERS g_s_user_arc_params
WITHOUT SPOOL DYNPRO.
-
CALL FUNCTION 'JOB_CLOSE'
EXPORTING
AT_OPMODE = ' '
AT_OPMODE_PERIODIC = ' '
CALENDAR_ID = ' '
EVENT_ID = ' '
EVENT_PARAM = ' '
EVENT_PERIODIC = ' '
jobcount = g_jobcount
jobname = g_jobname
LASTSTRTDT = NO_DATE
LASTSTRTTM = NO_TIME
PRDDAYS = 0
PRDHOURS = 0
PRDMINS = 0
PRDMONTHS = 0
PRDWEEKS = 0
PREDJOB_CHECKSTAT = ' '
PRED_JOBCOUNT = ' '
PRED_JOBNAME = ' '
sdlstrtdt = g_datum
sdlstrttm = g_uzeit
STARTDATE_RESTRICTION = BTC_PROCESS_ALWAYS
STRTIMMED = ' '
TARGETSYSTEM = ' '
START_ON_WORKDAY_NOT_BEFORE = SY-DATUM
START_ON_WORKDAY_NR = 0
WORKDAY_COUNT_DIRECTION = 0
RECIPIENT_OBJ =
TARGETSERVER = ' '
IMPORTING
job_was_released = g_job_released
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
.
You can get the Print Parameters from FM: 'GET_PRINT_PARAMETERS'.
All the above FMs have detailed documentation which will help you.
Hope this helps you.
Regards, Murugesh AS
02-17-2005 1:56 AM
hi kristine,
there are a couple of ways to do that - try reading the SAP help file - follow this link:
http://help.sap.com/saphelp_46c/helpdata/en/d3/2e974d35c511d1829f0000e829fbfe/frameset.htm
and click on ABAP User Dialogs -> Lists -> Printing Lists
and yes, you can SUBMIT the current running program - but it might be better if you had a generic print program that you submit your list to.
sorry if i'm not too specific... but i'll assist you if you need some more help.
ryan.
02-17-2005 3:41 AM
Hello,
To create a Job Step, the FM 'JOB_OPEN' could be used.
To add a JOBSTEP, In your case an ABAP program, "SUBMIT" could be used.
To close the job step, use FM "JOB_CLOSE".
SAMPLE Code:
CALL FUNCTION 'JOB_OPEN'
EXPORTING
DELANFREP = ' '
JOBGROUP = ' '
jobname = 'XYZ'
sdlstrtdt = sy-datum "Current date
sdlstrttm = sy-uzeit
IMPORTING
jobcount = g_jobcount
EXCEPTIONS
cant_create_job = 1
invalid_job_data = 2
jobname_missing = 3
OTHERS = 4
.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
-
SUBMIT z_PROGRAM AND RETURN
USER sy-uname " User for runtime authorizations
WITH p_para EQ p_para
"..... Selection screen parameters
VIA JOB g_jobname NUMBER g_jobcount
" Job name and job number
" from JOB_OPEN
TO SAP-SPOOL " Print and archiving options from
" GET_PRINT_PARAMETERS
" Both sets of options come from
" GET_PRINT_PARAMETERS
SPOOL PARAMETERS g_s_user_print_params
ARCHIVE PARAMETERS g_s_user_arc_params
WITHOUT SPOOL DYNPRO.
-
CALL FUNCTION 'JOB_CLOSE'
EXPORTING
AT_OPMODE = ' '
AT_OPMODE_PERIODIC = ' '
CALENDAR_ID = ' '
EVENT_ID = ' '
EVENT_PARAM = ' '
EVENT_PERIODIC = ' '
jobcount = g_jobcount
jobname = g_jobname
LASTSTRTDT = NO_DATE
LASTSTRTTM = NO_TIME
PRDDAYS = 0
PRDHOURS = 0
PRDMINS = 0
PRDMONTHS = 0
PRDWEEKS = 0
PREDJOB_CHECKSTAT = ' '
PRED_JOBCOUNT = ' '
PRED_JOBNAME = ' '
sdlstrtdt = g_datum
sdlstrttm = g_uzeit
STARTDATE_RESTRICTION = BTC_PROCESS_ALWAYS
STRTIMMED = ' '
TARGETSYSTEM = ' '
START_ON_WORKDAY_NOT_BEFORE = SY-DATUM
START_ON_WORKDAY_NR = 0
WORKDAY_COUNT_DIRECTION = 0
RECIPIENT_OBJ =
TARGETSERVER = ' '
IMPORTING
job_was_released = g_job_released
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
.
You can get the Print Parameters from FM: 'GET_PRINT_PARAMETERS'.
All the above FMs have detailed documentation which will help you.
Hope this helps you.
Regards, Murugesh AS