How to get the file name in RPG when file error/exception occured

425 pts.
Tags:
AS/400
INFDS
iSeries
RPF
My program processes bulk of file updates, and I'm trying to figure out the file name that was failed in processing. However the limitation for INFDS is, we cannot use the same DS name for all the files declared in a program. And it's hectic to declare unique DS for each INFDS. Is there any alternate way to figure out the error file name, so that I can display it in the user message.

-Kar



Software/Hardware used:
Iseries
ASKED: June 17, 2011  8:49 AM
UPDATED: June 15, 2012  11:58 AM

Answer Wiki

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

The IFDS gives a great deal of info on the file but on an error you can get some info from the program data structure (PSDS).

This structure is defined with an S in position 23
D PSDS SDS.

40 42 Character 3
Exception type (CPF for a OS/400 system exception or MCH for a machine exception).
43 46 Character 4
Exception number. For a CPF exception, this field contains a CPF message number. For a machine exception, it contains a machine exception number.

175 184 Character 10
Name of file on which the last file operation occurred (updated only when an error occurs). This information always contains the full file name.
209 243 Character 35
Status information on the last file used. This information includes the status code, the RPG IV opcode, the RPG IV routine name, the source listing line number or statement number, and record name. It is updated only when an error occurs.
Note:
The opcode name is in the same form as *OPCODE in the INFDS
The source listing line number is replaced by the source listing statement number if OPTION(*SRCSTMT) is specified instead of OPTION(*NOSRCSTMT). The full statement number is included when it applies to the root source member. If the statement number is greater than 6 digits (that is, it includes a source ID other than zero), the first 2 positions of the 8-byte feedback area will have a “+ ” indicating that the rest of statement number is stored in positions 356-357.
Phil

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
  • Kar
    Phil, that was an excellent delivery...... I'll try the "last file operation in PSDS" Thanks a lot.! In addition, could you please let me know how to get the session/job that has locked the file/record, due to which my program crashes...! From PSDS & INFDS , I think there is no such parameter to identify the locking job... My error message to the user includes "File Name + User/Session (if possible)", please teach me how to obtain locking part... -karol
    425 pointsBadges:
    report
  • TomLiotta
    The PSDS should have enough exception data in positions 91-170 to tell who has the lock. The message ID is likely to be CPF5027, and the exception data should say something like "Record &6 in use by job &9." The record and job info should be filled in. You could create a (service program) procedure that takes the PSDS as a parm and extracts whatever you need. Code like that ought to be maintained in a single location. Tom
    125,585 pointsBadges:
    report
  • TomLiotta
    Also, the definition of each INFDS only requires a single line of code:
    D OPNFDBK1        ds           228
    That defines a DS covering the first 228 bytes of an INFDS. You can have as many of those as needed to cover each file. You would have the various subfields defined in a BASED() DS. Then when you need info from any one of the different DSes, you set the basing pointer to cover the one that you need. You should only need to check one at a time. Tom
    125,585 pointsBadges:
    report
  • philpl1jb
    Great idea. I'm looking forward to your video tutorial on this subject.
    48,575 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