Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 8808

Re: Upload a file in background job

$
0
0

hi,

   try like this.. sure it ll work..

 

hat you can do is to upload the presentation server data to application server by T-Code cg3z  and then in


background job you can read the application server file by open dataset, read dataset and close dataset


command.


And There are two ways for you to handle,

one manually setting up the job through SM36 which is better and convinient,

secondly through program using FM's JOB_OPEN, SUBMIT, JOB_CLOSE.

 

Find below steps in doing both:

Procedure 1:

1. Goto Trans -> SM36

2. Define a job with the program and variant if any

3. Click on start condition in application tool bar

4. In the pop-up window, click on Date/Time

5. Below you can see a check box "Periodic Job"

6. Next click on Period Values

7. Select "Other Period"

8. Now give '15' for Minutes

9. Save the job

 

Procedure 2 via Program:

 

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

 

DATA: 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.

 

********************************************

You can use SM36 and use the "Job Wizard" to define a background job in simple step by step procedure

 

Or

 

Goto SM37 and specify a job name.

Next specify the ABAP Program Name of the report you want to execute under Job Step.

Then click on "Extended Job Selection" and goto the Period Tab.

There select "Only Periodic Jobs" and then specify the frequency of execution based on Months, Weeks, Days, Hours or Minutes.

 

2)you can execute the report in background in SM37 , there are two options , one is as said using f9 or you can make SY-BATCH eq 'X'.

 

if x run the report or exit from the program.

 

so this way you can execute the report in background and check the spool in sm37

 

In order to restrict the user to run it only in background , you can as well check for SY-BATCH condition.

 

The other way is try to remove "execute in foreground" option from the menu and this can be done with the function module .

 

data: begin of int_exc occurs 0,

code like sy-ucomm,

end of int_exc.

data wf_repid .

 

initialization.

 

clear int_exc.

 

int_exc-code = 'ONLI'.

append int_exc.

int_exc-code = 'PRIN'.

append int_exc.

 

move: sy-repid to wf_repid .

 

call function 'RS_SET_SELSCREEN_STATUS'

exporting

p_status = '%_00'

p_program = 'wf_repid'

tables

p_exclude = int_exc.

 

 

 

 

Regards,

gopi


Viewing all articles
Browse latest Browse all 8808

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>