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

How to submit for background?

Former Member
0 Likes
1,067

Hi all,

Below is the code of my program,which is going to be submitted for background.I want to debug that program when it is submitted for background.I have gone through forums also.But I am not clear.All are asking to go to either SM37 or SM50.But in SM50 how to figure out my program.Because there are no of PID's without my report name.Suppose my report name is 'ZTEST'.But I am unable to find my report name.But there are no PID's and TY ='BGD' but not my report name.

I went to SM37 also.Many people in the forum asked to select the jobname and type 'JDBG' in command box and click enter.When I did that it is not taking me to any debugging but staying in the same initial screen of SM37 only.Does Selecting job means giving job name 'TEST_JOB'(Job name defined in the below program)?

And final doubt is when I have to go for those 2 transactions?After executing the below program.If i do so means that program is will be in finished mode.Then how to debug it.

REPORT ZTTSR014 LINE-SIZE -0.

TABLES : VBAP.

DATA : BEGIN OF ITAB OCCURS 0,

VBELN LIKE VBAP-VBELN,

POSNR LIKE VBAP-POSNR,

MATNR LIKE VBAP-MATNR,

END OF ITAB.

SELECTION-SCREEN : BEGIN OF BLOCK MAINBLOCK WITH FRAME TITLE MAIN.

SELECT-OPTIONS : VBELN1 FOR VBAP-VBELN.

SELECTION-SCREEN : END OF BLOCK MAINBLOCK.

SY-BATCH = 'X'.

CALL FUNCTION 'BP_JOBVARIANT_SCHEDULE' "#EC *

EXPORTING

TITLE_NAME = 'TEST_TITLE'

JOB_NAME = 'TEST_JOB'

PROG_NAME = 'ZTEST'

EXCEPTIONS

NO_SUCH_PROGRAM = 1

OTHERS = 2

.

IF SY-SUBRC <> 0.

ENDIF.

*--Calling function module to display the

CALL FUNCTION 'BP_JOBVARIANT_OVERVIEW' "#EC *

EXPORTING

TITLE_NAME = 'TEST_TITLE'

JOB_NAME = 'TEST_JOB'

PROG_NAME = 'ZTEST'

EXCEPTIONS

NO_SUCH_JOB = 1

OTHERS = 2

.

if SY-SUBRC <> 0.

endif.

SELECT VBELN POSNR MATNR FROM VBAP INTO TABLE ITAB WHERE VBELN IN VBELN1.

loop at itab.

write:/ ITAB-VBELN,ITAB-POSNR,ITAB-MATNR.

endloop.

Hi all,

Below is the code of my program,which is going to be submitted for background.I want to debug that program when it is submitted for background.I have gone through forums also.But I am not clear.All are asking to go to either SM37 or SM50.But in SM50 how to figure out my program.Because there are no of PID's without my report name.Suppose my report name is 'ZTEST'.But I am unable to find my report name.But there are no PID's and TY ='BGD' but not my report name.

I went to SM37 also.Many people in the forum asked to select the jobname and type 'JDBG' in command box and click enter.When I did that it is not taking me to any debugging but staying in the same initial screen of SM37 only.Does Selecting job means giving job name 'TEST_JOB'(Job name defined in the below program)?

And final doubt is when I have to go for those 2 transactions?After executing the below program.If i do so means that program is will be in finished mode.Then how to debug it.

REPORT ZTTSR014 LINE-SIZE -0.

TABLES : VBAP.

DATA : BEGIN OF ITAB OCCURS 0,

VBELN LIKE VBAP-VBELN,

POSNR LIKE VBAP-POSNR,

MATNR LIKE VBAP-MATNR,

END OF ITAB.

SELECTION-SCREEN : BEGIN OF BLOCK MAINBLOCK WITH FRAME TITLE MAIN.

SELECT-OPTIONS : VBELN1 FOR VBAP-VBELN.

SELECTION-SCREEN : END OF BLOCK MAINBLOCK.

SY-BATCH = 'X'.

CALL FUNCTION 'BP_JOBVARIANT_SCHEDULE' "#EC *

EXPORTING

TITLE_NAME = 'TEST_TITLE'

JOB_NAME = 'TEST_JOB'

PROG_NAME = 'ZTEST'

EXCEPTIONS

NO_SUCH_PROGRAM = 1

OTHERS = 2

.

IF SY-SUBRC <> 0.

ENDIF.

*--Calling function module to display the

CALL FUNCTION 'BP_JOBVARIANT_OVERVIEW' "#EC *

EXPORTING

TITLE_NAME = 'TEST_TITLE'

JOB_NAME = 'TEST_JOB'

PROG_NAME = 'ZTEST'

EXCEPTIONS

NO_SUCH_JOB = 1

OTHERS = 2

.

if SY-SUBRC <> 0.

endif.

SELECT VBELN POSNR MATNR FROM VBAP INTO TABLE ITAB WHERE VBELN IN VBELN1.

loop at itab.

write:/ ITAB-VBELN,ITAB-POSNR,ITAB-MATNR.

endloop.

6 REPLIES 6
Read only

Former Member
0 Likes
995

Hi

You can run your program in background using a variant (for populating VBELN1).

As far as I know, you cannot debug your program when submitted as a background job.

Regards,

Raj

Read only

Former Member
0 Likes
995

Hi,

One way of debuging programs which are already running in background is via transaction SM50. This displays a

list of process running in the server. In order to debug the program go to Menu option: <b>Program/Mode>Program>Debugging</b>.

Regards

Sudheer

Read only

Former Member
0 Likes
995

Hi you need to open a job and then submit your report via this job name and account, and finally close this job and run it immediately. In this way you can debug your background running report. See below codes:

report ztest.

data: jobname like tbtcjob-jobname.

data: jobcount like tbtcjob-jobcount,

host like msxxlist-host.

data: begin of starttime.

include structure tbtcstrt.

data: end of starttime.

data: l_valid,

ls_params like pri_params,

SELECTION-SCREEN : BEGIN OF BLOCK MAINBLOCK WITH FRAME TITLE MAIN.

SELECT-OPTIONS : p_VBELN1 FOR VBAP-VBELN.

SELECTION-SCREEN : END OF BLOCK MAINBLOCK.

  • Get print parameters

CALL FUNCTION 'GET_PRINT_PARAMETERS'

EXPORTING

no_dialog = 'X'

destination = 'LP01'

immediately = space

IMPORTING

valid = l_valid

out_parameters = ls_params.

  • Job open

jobname = 'ZTTSR014'. "your report name

CALL FUNCTION 'JOB_OPEN'

EXPORTING

jobname = jobname

IMPORTING

jobcount = jobcount

EXCEPTIONS

cant_create_job = 01

invalid_job_data = 02

jobname_missing = 03.

IF sy-subrc <> 0.

"handle exception.

ENDIF.

  • Submit your report so as to run it in background

SUBMIT ZTTSR014 AND RETURN

WITH VBELN1 = p_VBELN1 "pass your parameters

TO SAP-SPOOL

SPOOL PARAMETERS ls_params WITHOUT SPOOL DYNPRO

VIA JOB jobname

NUMBER jobcount.

IF sy-subrc <> 0.

" handle exceptions

ENDIF.

  • Close job

  • start it immediately

CALL FUNCTION 'JOB_CLOSE'

EXPORTING

event_id = starttime-eventid

event_param = starttime-eventparm

event_periodic = starttime-periodic

jobcount = jobcount

jobname = jobname

  • laststrtdt = starttime-laststrtdt

  • laststrttm = starttime-laststrttm

prddays = 0

prdhours = 0

prdmins = 0

prdmonths = 0

prdweeks = 0

  • sdlstrtdt = starttime-sdlstrtdt

  • sdlstrttm = starttime-sdlstrttm

strtimmed = 'X'

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 <> 0.

"handle exceptions.

ENDIF.

Read only

Former Member
0 Likes
995

Hi Sudhir,

Thats what I am saying.How to do in SM50.In SM50 how to debug.I am not able to trace out my program name.So could you explain in detailed?

After executing that program in se38 I am getting status as 'finished'.Now I want to see result of that program.I tried using spool request number also.But it says contains nothing.So how to see the result also.

Thanks

Balaji

Read only

0 Likes
995

if no data is selected thro the program - no spool will be created i suppose. you can definitely able to find the spool number in SP01 transaction for the background jobs if some output has come. please check the code.

Also you should have authorisation to debug the code in SM50. Since the program has finished running, you are not able to debug.

regards

vivek

<b>Reward points if this helps</b>

Read only

Former Member
0 Likes
995

Hi Balaji,

You can put a endless loop in it before the code that you want to debug.

While sy-subrc = 0.
check sy-subrc = 0.
endwhile.

then run your program in background. go to SM50, select the back ground process that you program is currently running in. From the menu, choose Program/Session, Program, Debugging. You will see that the debugger will fire and your program will be stuck in the endless loop. Just change the value of sy-subrc to 1 and step thru the code, it will come out of the loop and you can continue debugging.

Cheers,

Vikram

Pls reward for helpful replies!!