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

Query

Former Member
0 Likes
1,238

Hi,

I want my prg to run in intervals of 15 mins... I want to capture the time of last time the prg ran...& in the consequent runs, I want it to assign the value of V_OP-ENDTIME to the prg.

I tried export to memory command ... but this did not help me because the exported var has the values only of the current run... so after 15 mins when the prg run it again has time = sy-uzeit.

Thank You,

SB.

11 REPLIES 11
Read only

anversha_s
Active Contributor
0 Likes
1,198

hi sb,

the simple method is,

Well, if you have a report program which needs to run the same way every 15 minutes, then setting up a job via SM36 is the easiest way.

There is built in functionality in SM36, which allows you to tell the system to run this job every 15 minutes. What it actually does is, creates one job, after this job is complete, it creates another job as "Scheduled" and it will start in 15 minutes.

Procedure :

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

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

rgds

anver

if hlped mark points

Read only

0 Likes
1,198

Hi Anversha,

Thankx for your reply ... my requirement is that I pick only the latest entries from database veiw V_OP... all new entries from the time the last time my prg was run ...

Thankx,

SB.

Read only

0 Likes
1,198

hi sb,

a sugestion.

can u try this field.

Time of last job change - > LASTCHTIME in the table V_OP

rgds

anver

Read only

0 Likes
1,198

Hi Anversha,

That field gives the info about when the last time that job was changed...for example was there a change in scheduling time ... or was there a change in frequency the job was run ... or any changes done to the job...

SO it's of no help to me ...

-SB

Read only

anversha_s
Active Contributor
0 Likes
1,198

if u r using it manullly thn try this.

In the submitted program, you must create a new job, submitting the program again in 15 minutes. When calling the JOB_CLOSE, you can specify the next time that the job is to run.

  • Kick job off 30 seconds from now.

sdate = sy-datum.

stime = sy-uzeit + 900. " 900 = 15 minutes

  • Schedule and close job.

call function 'JOB_CLOSE'

exporting

jobcount = l_jobcount

jobname = l_jobname

sdlstrtdt = sdate

sdlstrttm = stime

  • strtimmed = 'X'

rgds

anver

Read only

anversha_s
Active Contributor
0 Likes
1,198

hi,

is it possible to export

V_OP-ENDTIME - 15 minitues.

it will be the time of last run.

rgds

anver

Read only

anversha_s
Active Contributor
0 Likes
1,198

hi sb,

i tried this. its working.

Use table T9S00 to get last run date and run time for an object.

Give your report name to REPID and get last run date from DATUM and last run time from UZEIT of T9S00.

REPORT ZLASTRUNTIMES.

SELECT-OPTIONS: S_REPORTS TYPE T9S00-REPID.

DATA:

BEGIN OF IT_RUNTIME OCCURS 0,

REPID TYPE T9S00-REPID,

DATUM TYPE T9S00-DATUM,

UZEIT TYPE T9S00-UZEIT,

END OF IT_RUNTIME.

START-OF-SELECTION.

SELECT REPID DATUM UZEIT

FROM T9S00

INTO IT_RUNTIME

WHERE REPID IN S_REPORTS.

END-OF-SELECTION.

IF IT_RUNTIME[] IS NOT INITIAL.

WRITE:/5 REPORT, 20 DATE, 40 TIME.

LOOP AT IT_RUNTIME.

WRITE:/5 IT_RUNTIME-REPID,20 IT_RUNTIME-DATUM,40 IT_RUNTIME-UZEIT.

ENDLOOP.

ENDIF.

Note: Plz reward all helpful answers.

Thanks,

anver

Read only

0 Likes
1,198

Hi,

Here it says the database table T9S00 does not exist

Read only

0 Likes
1,198

hi,

ok lave it.

might be version probelm.

try this.

Create a time variable in table TVARV using STVARV transaction, update the variable in TVARV at the end of your report program with sy-uzeit. When you execute the program again, read the variable from TVARV.

rgds

anver

Read only

0 Likes
1,198

Well I want to select the latest entries from V_OP... I am writing a report on status of the jobs to a text file... so suppose the first time the prg runs is at 11:00 am then it runs at 11:15 ... so I want to get all the new values to the RELUNAM feild after 15 mins... I have used a ztime table here .. but I wanted some other way to solve this problem instaed of using a ztable... below is my code...

SELECT-OPTIONS: S_USERNM FOR TBTCP-AUTHCKNAM.

  • S_JOBNAM for V_OP-JOBNAME,

PARAMETER : P_DESTNM LIKE RLGRAP-FILENAME DEFAULT

'/sapusr/bi/logs/test.txt'.

SELECTION-SCREEN : END OF BLOCK B1.

----


  • S T A R T - O F - S E L E C T I O N *

----


START-OF-SELECTION.

  • Get Date & Time

PERFORM GET_DATE_TIME.

  • Perform to populate the status internal table

PERFORM GET_DATA.

  • Perform to prepare the output

PERFORM PREPARE_OUTPUT.

  • Perform to download data.

PERFORM DOWNLOAD_DATA.

&----


*& Form GET_DATE_TIME

&----


  • Get Date & Time

----


  • --> p1 text

  • <-- p2 text

----


FORM GET_DATE_TIME .

SELECT *

FROM ZTIME

INTO TABLE T_TIME.

IF SY-SUBRC = 0.

SORT T_TIME.

ENDIF.

LOOP AT T_TIME.

MOVE : T_TIME-PRVDATE TO V_PRVDATE,

T_TIME-PRVTIME TO V_PRVTIME.

ENDLOOP.

ENDFORM. " GET_DATE_TIME

&----


*& Form GET_DATA

&----


  • Perform to populate the status internal table

----


  • --> p1 text

  • <-- p2 text

----


FORM GET_DATA .

IF NOT T_TIME[] IS INITIAL.

SELECT *

FROM V_OP

INTO TABLE T_STATUS

WHERE RELUNAME IN S_USERNM AND

ENDDATE >= T_TIME-PRVDATE AND

ENDTIME > T_TIME-PRVTIME AND

( STATUS = C_STATUS_F OR

STATUS = C_STATUS_A ).

ENDIF.

IF SY-SUBRC = 0.

SORT T_STATUS BY ENDDATE ENDTIME DESCENDING .

LOOP AT T_STATUS.

IF SY-TABIX = 1.

  • Set the date & time as the ENDDATE & ENDTIME.

UPDATE ZTIME SET PRVTIME = T_STATUS-ENDTIME.

COMMIT WORK.

IF SY-SUBRC = 0.

WRITE: 'Successful'.

ENDIF.

UPDATE ZTIME SET PRVDATE = T_STATUS-ENDDATE.

COMMIT WORK.

IF SY-SUBRC = 0.

WRITE: 'Successful'.

ENDIF.

COMMIT WORK.

MOVE-CORRESPONDING T_STATUS TO T_TEMP.

ELSE.

MOVE-CORRESPONDING T_STATUS TO T_TEMP.

ENDIF.

APPEND T_TEMP.

CLEAR T_TEMP.

ENDLOOP.

ENDIF.

ENDFORM. " GET_DATA

&----


*& Form PREPARE_OUTPUT

&----


  • Perform to prepare the output

----


  • --> p1 text

  • <-- p2 text

----


FORM PREPARE_OUTPUT .

LOOP AT T_TEMP.

IF T_TEMP-STATUS = 'F'.

MOVE : T_TEMP-JOBNAME TO T_OUTPUT-JOBNAM,

'Successfully Completed' TO T_OUTPUT-STATUS,

'ON' TO T_OUTPUT-ON,

T_TEMP-ENDDATE TO T_OUTPUT-ENDDATE,

' AT' TO T_OUTPUT-AT,

T_TEMP-ENDTIME TO T_OUTPUT-ENDTIME.

ENDIF.

IF T_TEMP-STATUS = 'A'.

MOVE : T_TEMP-JOBNAME TO T_OUTPUT-JOBNAM,

'Job Failed' TO T_OUTPUT-STATUS,

'ON' TO T_OUTPUT-ON,

T_TEMP-ENDDATE TO T_OUTPUT-ENDDATE,

' AT' TO T_OUTPUT-AT,

T_TEMP-ENDTIME TO T_OUTPUT-ENDTIME.

ENDIF.

APPEND T_OUTPUT.

CLEAR T_OUTPUT.

ENDLOOP.

ENDFORM. " PREPARE_OUTPUT

&----


*& Form DOWNLOAD_DATA

&----


  • Perform to download data.

----


  • --> p1 text

  • <-- p2 text

----


FORM DOWNLOAD_DATA .

OPEN DATASET P_DESTNM FOR APPENDING IN TEXT MODE ENCODING DEFAULT

MESSAGE V_MSG.

IF SY-SUBRC <> 0.

MESSAGE I008. " File could not be opened.

EXIT.

ENDIF.

  • Transferring Data

LOOP AT T_OUTPUT.

TRANSFER T_OUTPUT TO P_DESTNM.

ENDLOOP.

CLOSE DATASET P_DESTNM.

ENDFORM. " DOWNLOAD_DATA

Read only

0 Likes
1,198

thanks