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

problem with Job_close

Former Member
0 Likes
2,065

Hi

my job is not executing immediatly.

please check what i've written in JOB_CLOSE.

CALL FUNCTION 'JOB_CLOSE'

EXPORTING

JOBCOUNT = JOBCOUNT1

JOBNAME = JOBNAME1

  • PRDDAYS = 0

  • PRDHOURS = 0

  • PRDMINS = 0

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

INVALID_TARGET = 8

OTHERS = 9.

Is this OK for job to be run immediatly?

regards,

Pra

7 REPLIES 7
Read only

anversha_s
Active Contributor
0 Likes
1,066

hi,

<u>Below is a sample code</u> for the same. Note the ZTEMP2 is the program i am scheduling with 15mins frequency.

D

ATA: P_JOBCNT LIKE TBTCJOB-JOBCOUNT,
      L_RELEASE(1) TYPE c.
 
   CALL FUNCTION 'JOB_OPEN'
     EXPORTING
       JOBNAME                = 'ZTEMP2' 
    IMPORTING
      JOBCOUNT               = P_JOBCNT
    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 ZTEMP2 VIA JOB 'ZTEMP2' NUMBER P_JOBCNT
          TO SAP-SPOOL WITHOUT SPOOL DYNPRO 
          WITH DESTINATION = 'HPMISPRT'
          WITH IMMEDIATELY = SPACE
          WITH KEEP_IN_SPOOL = 'X' AND RETURN.
 
   CALL FUNCTION 'JOB_CLOSE'
     EXPORTING
       JOBCOUNT                          = P_JOBCNT
       JOBNAME                           = 'ZTEMP2' 
       STRTIMMED                         = 'X'
       PRDMINS                          = 15
    IMPORTING
      JOB_WAS_RELEASED                  = L_RELEASE
    EXCEPTIONS
      CANT_START_IMMEDIATE              = 1
      INVALID_STARTDATE                 = 2
      JOBNAME_MISSING                   = 3
      JOB_CLOSE_FAILED                  = 4
      JOB_NOSTEPS                       = 5
      JOB_NOTEX                         = 6
      LOCK_FAILED                       = 7
      INVALID_TARGET                    = 8
      OTHERS                            = 9.
   IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
   ENDIF.

Hope the above helps you.

Rgds

Anver

Read only

0 Likes
1,066

Hi anversha,

Thanks for your response.

My requirement is as like your sample program flow only. I am doing it as like you only.

why i am submitting calling program in b/g is to avoid the calling program list display...i want to have only called program list output.

But I need to run this report immediatly to show my called list output.

i've used strimmed = 'X' to start immediately...in sm37 it is showing job is released not finished.

Do i need to add any more additions? please suggest

Regards,

Pra

Read only

Former Member
0 Likes
1,066

Praneet,

Can you try like below,

call function 'JOB_CLOSE'

exporting

jobcount = jobcount1

jobname = jobname1

laststrtdt = starttime-laststrtdt

laststrttm = starttime-laststrttm

prddays = 1

prdhours = 0

prdmins = 0

prdmonths = 0

prdweeks = 0

strtimmed = starttimeimmediate

targetsystem = host

exceptions

cant_start_immediate = 01

invalid_startdate = 02

jobname_missing = 03

job_close_failed = 04

job_nosteps = 05

job_notex = 06

lock_failed = 07

others = 99.

if sy-subrc eq 0.

"error processing

endif.

Read only

Former Member
0 Likes
1,066

Hi,

Look at this program

CALL FUNCTION 'JOB_OPEN'
          EXPORTING
              JOBNAME = 'Zbackup_BD_online'
              JOBCLASS = 'C'
          IMPORTING
              JOBCOUNT = ZJOBCOUNT
          EXCEPTIONS
              CANT_CREATE_JOB = 01
              INVALID_JOB_DATA = 02
              JOBNAME_MISSING = 03
              OTHERS = 99.
       CALL FUNCTION 'JOB_SUBMIT'
           EXPORTING
              AUTHCKNAM = SY-UNAME
              JOBCOUNT = ZJOBCOUNT
              JOBNAME = 'Zbackup_BD_online'
              EXTPGM_NAME = 'brbackup'
             EXTPGM_PARAM = zparam
EXTPGM_SYSTEM = zhost
              EXTPGM_WAIT_FOR_TERMINATION = 'X'
              EXTPGM_STDOUT_IN_JOBLOG = 'X'
              EXTPGM_SET_TRACE_ON = 'X'
              EXTPGM_STDERR_IN_JOBLOG = 'X'
           EXCEPTIONS
              INVALID_JOBDATA = 02
             JOBNAME_MISSING = 03
             JOB_NOTEX = 04
             JOB_SUBMIT_FAILED = 05
             LOCK_FAILED = 06
             PROGRAM_MISSING = 07
             PROG_ABAP_AND_EXTPG_SET = 08
             BAD_XPGFLAGS = 09
             OTHERS = 99.

CALL FUNCTION 'JOB_CLOSE'
            EXPORTING
              JOBCOUNT = ZJOBCOUNT
              JOBNAME = 'Zbackup_BD_online'
              STRTIMMED = 'X'
            IMPORTING
              JOB_WAS_RELEASED = zreleased
            EXCEPTIONS
               INVALID_STARTDATE = 01
               JOBNAME_MISSING = 02
               JOB_CLOSE_FAILED = 03
               JOB_NOSTEPS = 04
               JOB_NOTEX = 05
               LOCK_FAILED = 06
               OTHERS = 99.

This JOB_CLOSE function module Release the job in SE37, it won't close the SM37 job, as soon as the Job completed then the Job will shown the status. This Function module only initiate the job,

Regards

Sudheer

Read only

0 Likes
1,066

Sudheer,

My question how can make this program to run immediatley??

Regards,

Pra

Read only

0 Likes
1,066

HI Praneet,

Try the code like this,

CALL FUNCTION 'JOB_OPEN'

EXPORTING

jobname = ws_c_session

IMPORTING

jobcount = ws_c_jobnum

EXCEPTIONS

cant_create_job = 1

invalid_job_data = 2

jobname_missing = 3

OTHERS = 4.

IF sy-subrc <> 0.

WRITE 😕 text-006.

EXIT.

ENDIF.

CALL FUNCTION 'GET_PRINT_PARAMETERS'

EXPORTING

no_dialog = 'X'

user = sy-uname

IMPORTING

  • OUT_ARCHIVE_PARAMETERS =

out_parameters = params

valid = ws_valid.

IF ws_valid <> space.

params-pdest = 'LOCL'. "Destination

params-primm = ''. "Print Immediately

params-prnew = 'X'. "New Spool Request.

params-armod = '1'. "Print: Archiving Mode - Print Only

params-linct = 65. "Rows

params-linsz = 255. "Cols

params-paart = 'X_65_255'.

params-prrec = sy-uname. "User name

params-prsap = ''. "Print: SAP Cover Page

params-prunx = ''. "PRINT: Host spool cover page

params-prcop = '001'. "number of copies

SUBMIT (progname)

WITH file = i_file_list-name

WITH rb1 = space

WITH rb2 = c_x

WITH p_launch = c_x

TO SAP-SPOOL

WITHOUT SPOOL DYNPRO

SPOOL PARAMETERS params

AND RETURN.

ENDIF.

CALL FUNCTION 'JOB_CLOSE'

EXPORTING

jobcount = ws_c_jobnum

jobname = ws_c_session

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.

Use Job_open, then call the program using SUBMIT and then close job.

Regards

Subramanian

Read only

Former Member
0 Likes
1,066

SUBMIT (progname)

WITH file = i_file_list-name

WITH rb1 = space

WITH rb2 = c_x

WITH p_launch = c_x

TO SAP-SPOOL

WITHOUT SPOOL DYNPRO

SPOOL PARAMETERS params

AND RETURN.

Among these...rb1,rb2 and p_launch are standard parameters??