How to direct program in *PPSR

425 pts.
Tags:
AS/400
AS/400 errors
AS/400 programming
Hi All, In a program, a loop doing some operations... and I got some program error/file error and in *PSSR I want to handle the error then to resume the program to flow with the next record. But, how to pass the control to the loop to read from the next continution record. In Main routine, MAIN LOOP TEMPFILE1 JOBNUM  CHAIN TEMPFILE1   WRITE File1   UPDATE File 2   DELTE File 3 ENDLOOP ENDSR --- *PPSR // Here I want to instruct the program to execute from the point it breaks?? how to write the code here.. Ex: If JOBNUM = 100 has failed due to record locks, and I want to contine from JOBNUM=101 record... Could you pls instruct me how to do code exactly to get the flow contine. ENDSR

Software/Hardware used:
Iseries

Answer Wiki

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

Discuss This Question: 4  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
  • TomLiotta
    That type of processing should not be done in a *PSSR. Do the error handling where the error occurs. Use the *PSSR for handling errors that are unanticipated. For example, you might use an error-extender on your operation codes, like UPDATE(E). Then follow the UPDATE(E) statement with IF %ERROR and code your error handling for UPDATE there (or use EXSR to execute an error subroutine for UPDATE). After the error-handling, use ITER to iterate the loop again. Or wrap the WRITE, UPDATE or DELETE statements in a MONITOR block and code your error-handling in one or more ON-ERROR blocks. You could use ITER to iterate again or do other processing after dropping out of the ON-ERROR block to have the loop iterate normally. Technically, you could use TAG/GOTO to get back to where the error came from, but you'll need to know where you came from in that case. For a more detailed discussion, see Detailed RPG IV Object Program Cycle in the ILE RPG Reference. It can get complicated under various circumstances. But don't use a *PSSR for this. Code an appropriate routine as long as you're going to code a routine anyway. Note that you might code a *PSSR to work in a generic way. Then you might have a specific error-handler subroutine just for you WRITE, UPDATE or DELETE statements. And the only thing you might have in those specific routines could just be EXSR *PSSR. By getting into your *PSSR as a normally executed subroutine, none of the usual default handling is done by the system. Your specific subroutines could then return right back to where they were executed from. Further, you could improve those specific subroutines in the future as you learned what you really wanted them to do. Tom
    125,585 pointsBadges:
    report
  • Yorkshireman
    If you check some manuals - read the RPG manual, say Any of the RPG IV operation codes can be used in the program exception/error subroutine. The ENDSR operation must be the last specification for the subroutine, and the factor 2 entry on the ENDSR operation specifies the return point following the running of the subroutine. For a discussion of the valid entries for factor 2, see “File Exception/Error Subroutine (INFSR)” on page 93. so you specify where the function is to contunue processing. Naturally you will be emitting some sort of message or indication to the joblog, operators, or on a history/incident mechanism before disregarding an error.
    5,580 pointsBadges:
    report
  • WoodEngineer
    Try using MONITOR and ON-ERROR op codes in your loop. That should allow you to do what you want. *PSSR is from the days when the RPG cycle ruled and is rather limited.
    6,715 pointsBadges:
    report
  • TomLiotta
    so you specify where the function is to continue processing. That is true, but the values that can be specified are limited. They all refer to specific points in "Cycle processing". There wouldn't seem to be an appropriate "Cycle" point that handles a particular iteration of a looping structure. A *PSSR is certainly valid. But it always needs to be remembered that if one exists, it will be called for any error that is not explicitly handled -- including errors encountered by the *PSSR itself. Because of that, a *PSSR should always be coded so that it only runs once during any invocation of the program. It should be written so that the program invocation ends when the *PSSR ends. It might also be thought that every program should have a *PSSR just because unanticipated errors happen in all systems pretty much every day. Programs should react intelligently when unanticipated errors arise. 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