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: 

About JOBS

former_member204025
Participant
0 Kudos

Hi guys!

I'd like to know if there is any way, to program a JOB in the same program. What we have been practicing is about having 2 programs, prog1 and prog2.

In prog 2 I write:

function open_job.

.....

submit 'PROG1......' VIA jobname......

FUNCTION CLOSE_JOB

..........

But now, I would like to know if using only one program I can create a Job for the same program.

Please let me know if I can do that and how.

Thanks!

Gaby

1 ACCEPTED SOLUTION

sarbajitm
Contributor
0 Kudos

Hi,

It is possible to submit the same report from the report itself

for sending the output to sap-spool for printing.

Like I've faced a requirement like this where I've to convert the output to

pdf and i did it with the following code snippet:

SUBMIT (l_repid) TO SAP-SPOOL
      WITHOUT SPOOL DYNPRO
      SPOOL PARAMETERS lstr_print_parms
      WITH SELECTION-TABLE it_selec
      AND RETURN .

for pdf

SUBMIT rstxpdft4 VIA SELECTION-SCREEN
               WITH spoolno EQ lwa_spool-rqident
               WITH download EQ 'X'
               AND RETURN.

where l_repid sets to sy-repid.

May be from this you get a bit of hints,I hope.

Regards.

Sarbajit.

6 REPLIES 6

former_member156446
Active Contributor
0 Kudos

>

> if using only one program I can create a Job for the same program.

> Gaby

Are you not falling into an infinite loop?

Scenario:

Prog 1 ...

open_job..

exceuted in background ( in the process of execution, the open_job again executed ) and again and again.......

0 Kudos

Oh I see... I think you are right.

Thanks

Former Member
0 Kudos

they can be a way.. never checked though

check the status of the last(latest) job of this program from TBTCP or TBTCO or V_OP and

see if the status is finished then only submit this program via job name

else .

exit.

endif.

again, i am not saying that this is fullproof..

venkat_o
Active Contributor
0 Kudos

Hi Gaby, <li>I do not think that is going to be possible in the same program. Steps to write program to schedule programs in background. ================================================ <li>Create the job using function module JOB_OPEN. <li>You must use SUBMIT, for example, if the user of your program supplies the selection criteria for an ABAP report interactively, at runtime. With JOB_SUBMIT function module, you could specify only an existing variant for the report. <li>Close the job and pass it to the background processing system for execution with the function module JOB_CLOSE. Thanks Venkat.O

former_member209217
Active Contributor
0 Kudos

Hi,

Its not a good idea to schedule a job for a program in the program itself.

There should be a conditional check at some point of time (like the number of times the job should run) so that the job should be finished, other wise it will be an infinite loop

Regards,

Lakshman.

Edited by: Lakshman N on Oct 7, 2009 7:16 AM

sarbajitm
Contributor
0 Kudos

Hi,

It is possible to submit the same report from the report itself

for sending the output to sap-spool for printing.

Like I've faced a requirement like this where I've to convert the output to

pdf and i did it with the following code snippet:

SUBMIT (l_repid) TO SAP-SPOOL
      WITHOUT SPOOL DYNPRO
      SPOOL PARAMETERS lstr_print_parms
      WITH SELECTION-TABLE it_selec
      AND RETURN .

for pdf

SUBMIT rstxpdft4 VIA SELECTION-SCREEN
               WITH spoolno EQ lwa_spool-rqident
               WITH download EQ 'X'
               AND RETURN.

where l_repid sets to sy-repid.

May be from this you get a bit of hints,I hope.

Regards.

Sarbajit.