Execution of One RPG program based on completion of another RPG Program

195 pts.
Tags:
AS/400
as/400 rpg iseries
We need to execute a series of RPG programs in a sequence but before executing the program we should assure that previous program was completed normally. If previous program not completed normally, user should be adviced that he can execute this program because previsous program was not complted normally. What is the best way to achieve this?

Software/Hardware used:
AS/400, RPG

Answer Wiki

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

In my view, The best way for doing this is, Calling RPG programs from a CL Program.

As the Complete flow shouldnt end in error due to the problem in one RPG program, You should be using MONMSG for every CALL statement in CL Program. If any message occurs on CALL statement(i.e., any error in RPG program), Then MONMSG should pass the control to send message to user, Based on User Responce, Next RPG Program should be called.

Pradeep.

Discuss This Question: 11  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.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • philpl1jb
    There are lots of ways to do this here is the outline for one. Can you put the calls to both programs into the same CL - Call first program - If Successfull -- Call second program - Else -- Send message - End
    49,540 pointsBadges:
    report
  • CharlieBrowne
    What is the definition of sucessful? Program did not crash? Or program did not able to perform all reauired functions because of a data issue? If these programs cannot be put in a single CL because work needs to be done inbetween the jobs, I would create a file or *DTAARA that would be updated when a job completed sucessfully. Each program would check the file to see if it was OK to run. If they are submitting from a menu, you can check the file when the SBMJOB is about to happen. Also you should send out a message if one of the jobs fail. It should include the reason for the failure.
    41,370 pointsBadges:
    report
  • Teandy
    As an extra safety precaution, I would submit the jobs to a single threaded jobq. That way if one job crashes, the others will not run.
    5,860 pointsBadges:
    report
  • DanTheDane
    Look at this old thread which adresses your question: "CL/400 with restart option" http://itknowledgeexchange.techtarget.com/itanswers/cl400-with-restart-option/ DanF
    2,555 pointsBadges:
    report
  • WoodEngineer
    One technique we use in our shop is to call the program with a result parm. A single character parm is typically big enough. The program can load the parm with various results which you can check in your CL and determine if the next program should be called. You could tailor a message to the user based on the value of the returned parm.
    6,295 pointsBadges:
    report
  • Cursorposition
    Hi All, Thanks for all suggestions. I got the idea of what I need to do to achieve this.
    195 pointsBadges:
    report
  • TomLiotta
    Thanks for all suggestions. There are good possibilities that haven't been mentioned yet. But the most important question from CharlieBrowne hasn't been answered -- "What is the definition of sucessful?" When that's clear, it'll be much easier to know what to do. Tom
    125,585 pointsBadges:
    report
  • Cursorposition
    Our meaning of successful is to ensure the job completed normally without any error message. For the information of every one, we submit these jobs from an interactive menu screen rather then executing the jobs in batch process. I would like to by Charlie's idea of using DTAARA and verify the status in DTAARA before executing the program. Any other better alternative is welcome.
    195 pointsBadges:
    report
  • philpl1jb
    Thanks for the feedback. DATA AREA, excellent choice for the process that you've described. Phil
    49,540 pointsBadges:
    report
  • Yorkshireman
    As you are submitting a series of (individual) jobs, rather than a single job comprising the individual processes, you must ensure that your mechanism is able to handle recoveries correctly. Suppose a job crashes and leaves your data area at status 'error' - all jobs for evermore will not start. If these are in fact sequential processes, then as others have said, you have more security by controlling the execution and recovery within a single itemp of Control Language Program code (CLP - clue is in the name) Incidentally, an excellent choiuce for a return code is 7 bytes - you can retuirn a meesage ID, which gives you an immediate mens of informing the user of, what, 2500 bytes of helpful text, which can also be recorded in the joblog. If you wish to apply multiple parallel processes and ensure synchronicity you will need to be more imaginative. Rather than the existence of a data area, set locks onto an object for the duration of a process. Following processes check for the object being locked. If so, they wait. As the lock will dissolve if the locking job fails, recovery/restart is automatic. You will arange for completion codes to be used to ensure that a failing job doesn't then allow others to start. Naturally, you will be providing some form of audit file which records the start and end and results of each process - by timestamp, and this may form the basis of some control activity, or indeed be the entire control. Much simpler to write some trashy JCl that manages the whole thing in one go though.
    5,580 pointsBadges:
    report
  • TomLiotta
    we submit these jobs from an interactive menu screen rather then executing the jobs in batch process. A "submitted" job is a batch job. I assume that the statement means that each step is submitted interactively rather than having a complete 'process' that controls when or if the next step starts. A SBMJOB command includes a MSGQ() parameter. When the job completes, either a CPF1241 normal completion or a CPF1240 ended abnormally message will be sent to the message queue that you name on that parameter. The message data for those messages includes the fully-qualified name of the job. Also, when a SBMJOB command runs, it returns a CPC1221 message to the job that does the submit. That message also contains a fully-qualified job name in its message data. So, by creating a message queue for this sequence of steps and using its name on the SBMJOB commands, your interactive process can know which jobs are related to which steps, which ones have been submitted, which ones haven't completed yet, which ones completed normally and which ones ended abnormally. Depending on exactly how you wanted all of it handled, a pretty robust external control could be set up. (Or a simple one.) Essentially none of the submitted programming would need any changing at all. The interactive menu would be where changes were made. Tom
    125,585 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.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

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

Following