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: 

Background infinite loop

Former Member
0 Kudos
911

Hi,

I am trying to schedule a report to run as background job using FM job_close.However my schedule job is in infinite looping, which means it create infinite jobs in SM37. I am wondering is that I am miss out something on my coding,kindly give me a helping hand on that. Thanks.

FORM JOB.

DATA: lv_name TYPE TBTCJOB-JOBNAME value 'test',

lv_JOBCOUNT TYPE TBTCJOB-JOBCOUNT,

lv_TBTCJOB-AUTHCKNAM TYPE TBTCJOB-AUTHCKNAM .

CALL FUNCTION 'JOB_OPEN'

EXPORTING

  • DELANFREP = ' '

  • JOBGROUP = ' '

JOBNAME = lv_name

  • SDLSTRTDT = NO_DATE

  • SDLSTRTTM = NO_TIME

JOBCLASS = 'C'

IMPORTING

JOBCOUNT = lv_JOBCOUNT

  • CHANGING

  • RET =

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.

lv_TBTCJOB-AUTHCKNAM = sy-uname.

CALL FUNCTION 'JOB_SUBMIT'

EXPORTING

  • ARCPARAMS =

AUTHCKNAM = lv_TBTCJOB-AUTHCKNAM

  • COMMANDNAME = ' '

  • OPERATINGSYSTEM = ' '

  • EXTPGM_NAME = ' '

  • EXTPGM_PARAM = ' '

  • EXTPGM_SET_TRACE_ON = ' '

  • EXTPGM_STDERR_IN_JOBLOG = 'X'

  • EXTPGM_STDOUT_IN_JOBLOG = 'X'

  • EXTPGM_SYSTEM = ' '

  • EXTPGM_RFCDEST = ' '

  • EXTPGM_WAIT_FOR_TERMINATION = 'X'

JOBCOUNT = lv_JOBCOUNT

JOBNAME = lv_name

  • LANGUAGE = SY-LANGU

  • PRIPARAMS = 'MY20'

REPORT = 'ZMMPUPOR00_0407_EDIOUTSTANDING'

VARIANT = 'TEST3'

  • IMPORTING

  • STEP_NUMBER =

EXCEPTIONS

BAD_PRIPARAMS = 1

BAD_XPGFLAGS = 2

INVALID_JOBDATA = 3

JOBNAME_MISSING = 4

JOB_NOTEX = 5

JOB_SUBMIT_FAILED = 6

LOCK_FAILED = 7

PROGRAM_MISSING = 8

PROG_ABAP_AND_EXTPG_SET = 9

OTHERS = 10

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

CALL FUNCTION 'JOB_CLOSE'

EXPORTING

  • AT_OPMODE = ' '

  • AT_OPMODE_PERIODIC = ' '

  • CALENDAR_ID = ' '

  • EVENT_ID = ' '

  • EVENT_PARAM = ' '

  • EVENT_PERIODIC = ' '

JOBCOUNT = lv_JOBCOUNT

JOBNAME = lv_name

  • LASTSTRTDT = NO_DATE

  • LASTSTRTTM = NO_TIME

  • PRDDAYS = 0

  • PRDHOURS = 0

  • PRDMINS = 0

  • PRDMONTHS = 0

  • PRDWEEKS = 0

  • PREDJOB_CHECKSTAT = ' '

  • PRED_JOBCOUNT = ' '

  • PRED_JOBNAME = ' '

  • SDLSTRTDT = NO_DATE

  • SDLSTRTTM = NO_TIME

  • STARTDATE_RESTRICTION = BTC_PROCESS_ALWAYS

STRTIMMED = 'X'

  • TARGETSYSTEM = ' '

  • START_ON_WORKDAY_NOT_BEFORE = SY-DATUM

  • START_ON_WORKDAY_NR = 0

  • WORKDAY_COUNT_DIRECTION = 0

  • RECIPIENT_OBJ =

  • TARGETSERVER = ' '

  • DONT_RELEASE = ' '

  • IMPORTING

  • JOB_WAS_RELEASED =

  • CHANGING

  • RET =

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 ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

ENDFORM.

Beside that, I had problem to save my smartforms to local file, is any expert there can teach me the way?I am using 4.6c system.

5 REPLIES 5

Former Member
0 Kudos
285

It could be a couple of things:

You don't seem to be looping in the form, but you may be in an infinite loop when calling the form (DO/ENDDO with no exit).

On the other hand, you are submitting report

ZMMPUPOR00_0407_EDIOUTSTANDING. If that happens to be the report of this program, then it is submitting itself over and over again.

Rob

0 Kudos
285

Hi Rob,

Thanks for your reply.

I think we should submit our report name to the job_submit,right? If this is the case, what should we put? I try not to put in the program and, it will still be creating multiple jobs in sm37.How am I go around with it?

0 Kudos
285

What is your requirement? Do you want to submit your own program from the same program? Can you not simply define a background job for your program in SM36? If you have to do this from your program, then the flow has to be as follows and you need to add a new parameter say p_back no-display mode.


if p_back = 'X'.
*-- Do the rest of the logic of your program here
else.
  job open.
  submit job with p_back = 'X' via job.
  job close.
endif.

Srinivas

0 Kudos
285

Hi Srinivas,

My requirement is to schedule the report to run as background job in one program.

0 Kudos
285

You have a program A. You want to submit another program B in the background via a job. Then you should not get any infinite jobs being created.

You have a program A. User runs it online and gives some input and you then want to transfer the execution of program A to background. Then you will have to use my solution with the p_back no-display option.

You have program A and you want to schedule it as a job. Then use SM36.

Which scenario is yours?

Srinivas