Stop AS/400 job purge program

Tags:
AS/400
AS/400 jobs
SQLRPGLE
I have a requirement where i have to submit a PGM in batch. This program is a SQLRPGLE program that deletes record from a file. I have scheduled it at 8pm and I want to stop its purging at 10pm. This means this job will run for 2 hours every day after which it should be stopped. How can I achieve this without manual intervention ie, i want to stop the purge program at 10pm. Is there any command in SBMJOB for this? As it is in batch, I also do not know Job# & name which is creating more trouble.


Software/Hardware used:
as400
1

Answer Wiki

Thanks. We'll let you know when a new response is added.

Hi,

I believe purging of records would be done in loop.
You could save the Start time of the Job during initialization subroutine and store to Work Variable. 
And, At the end of the loop you could retrieve current system date and compare against the start time. If the Difference is 2 hrs, You could consider exiting Loop and Proceed with Exit Routine.
If you are purging the records in SQL with single DELETE statement, I would suggest to have the DELETE query with particular set of records once, and then delete the next set of records. Consider Comparing Time Difference between each set.
Eg: DELETE FROM FILE WHERE RRN BETWEEN 1 AND 10000, 
      Compare the Date, If difference isnt 2 hrs, Repeat the loop to delete next set.
If You’re not willing to do this way, You should have CL Driver to submit a Job, And Track the submitted Job Details. 
Click Here for Sample code to Retrieve Job Details
Have DELAY Command for 2 Hours. And, End the Job after Two hours.
DLYJOB DLY(7200)
Pradeep.

Discuss This Question: 6  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.
  • philpl1jb

    "If You’re not willing to do this way, You should have CL Driver to submit a Job, And Track the submitted Job Details. 
    Have DELAY Command for 2 Hours. And, End the Job after Two hours."
    Note:  END must be set to IMMEDIATE
    Results can be unpredictable .. you may remove part of a record set and leave part of it intact. 

    While having some loop control stop the program is more reliable.
    I usually put the time of stop in a data area and gave the operators another command which would reset the value in the data area to cause a stop as soon as the current loop ends. 

    If that's of interest you might want to discuss how to get a data area but not lock it.

    If you're purging records you will want to consider using RGZPFM at some point to rebuild the files and reclaim the space.
    54,090 pointsBadges:
    report
  • ToddN2000
    My suggestion is in the SQLRPGLE program, if the delete is done in a RPGLE loop, retrieve system time just after the delete command. Compare this to your cutoff time of 10:00:00 or 22:00:00 if 24 hour clock. Then loop back and delete another record.
    132,840 pointsBadges:
    report
  • Supriyoas400
    hanks for your answers, but i have one doubt : Since it's a sql command through which i am deleting records, control will not come out till deletion command is executed completely.So how will i check or compare timings ? Also since this is a batch job, how will my driver CL will know which job to end because there can be many jobs running simultaneously?
    250 pointsBadges:
    report
  • deepu9321
    You can write CL Program which will submit your Purging Process to different Batch Job. And, Retrieve the Submitted Job Details (Click Here for Sample CL Program to retrieve Job Details).

    Use DLYJOB DLY(7200) Command to have your CL Driver Program in DLYW status for 2 hours. 

    Then, You could consider ENDJOB Command with OPTION(*IMMED) by passing retrieved job details.

    Pradeep.
    4,980 pointsBadges:
    report
  • philpl1jb

    Since it's a sql command through which i am deleting records, control will not come out till deletion command is executed completely.  If the program contains just a single SQL command then you are correct.  Pradeep showed a way to change the SQL to just work with a subset of the data

    DELETE FROM FILE WHERE RRN BETWEEN :Start AND :Stop

    You would probably have more rules on the Where clause.

    You would add a loop in your program

    Dou StopNow

       Start = Stop + 1

       Stop = Start + 10000

      Delete ....

      Then some logic to set StopNow

    Enddo


    54,090 pointsBadges:
    report
  • ToddN2000
    Does the purging have to be done using SQL? What is the purge criteria? It may be possible to run multiple SQL purges to accomplish the task within a loop.
    132,840 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.

Following

Share this item with your network: