Program Status Data Structure

From MidrangeWiki
Revision as of 23:04, 8 June 2005 by David (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Program Status Data Structure

This structure contains subfields that hold a lot of information about the current program and the job it's running in. It provides the easiest way to get the program name, the job name, user ID, exception information and more.

You declare it in the data definition section of the program like this:

     * Program Status Data Structure
    D                SDS

List the sub-fields you need below that. They're described in the ILE RPG language reference.

Declaring an externally described data structure allows you to use any of the information in the program status data structure without worrying about sub-field locations. You just add a declaration like this to your program:

     * Program Status Data Structure
    D PSDS          ESDS

Place the data structure template file in the library list during the compile. Create the template file by compiling PSDS from the source as a normal data file with no members. Use the subfields as you would any other variable in your program.

Program Status Data Structure Available Information

Numeric Data Length column contains the decimal places after the ",".

Value Contained Data Type Data Length Beginning Buffer Position Ending Buffer Position
Program Name Character 10 1 10
Program Status Zoned Decimal 5,0 11 15
Program Previous Status Zoned Decimal 5,0 16 20
Program Source Statement Character 8 21 28
Program Routine Character 8 29 36
Program Number Of Parameters Zoned Decimal 3,0 37 39
Program Message ID Character 7 40 46
Program MI Instruction Code Character 4 47 50
Program Work Character 30 51 80
Program Library Character 10 81 90
Program Error Data Character 80 91 170
Program RPG Message Character 4 171 174
Program Job Name Character 10 244 253
Program User ID Character 10 254 263
Program Job Number Zoned Decimal 6,0 264 269
Program Job Date Zoned Decimal 6 270 275
Program Run Date Zoned Decimal 6 276 281
Program Run Time Zoned Decimal 6 282 287



Here is a Sample Program Status Data Structure in RPG III Style:

     Dpsds            sds                  
     D pgmname                 1     10a   
     D pgmsts                 11     15s 0 
     D pgmprvsts              16     20s 0 
     D pgmsrcstmt             21     28a   
     D pgmroutine             29     36a   
     D pgmparms               37     39s 0 
     D pgmmsgid               40     46a   
     D pgmmi#                 47     50a   
     D pgmwork                51     80a   
     D pgmlib                 81     90a   
     D pgmerrdta              91    170a   
     D pgmrpgmsg             171    174a   
     D pgmjob                244    253a   
     D pgmuser               254    263a   
     D pgmjobnum             264    269s 0 
     D pgmjobdate            270    275s 0 
     D pgmrundate            276    281s 0 
     D pgmruntime            282    287s 0 



Here is a Sample Program Status Data Structure in RPG IV Style:

     Dpsds            sds                  
     D pgmname                       10a   
     D pgmsts                         5s 0 
     D pgmprvsts                      5s 0 
     D pgmsrcstmt                     8a   
     D pgmroutine                     8a   
     D pgmparms                       3s 0 
     D pgmmsgid                       7a   
     D pgmmi#                         4a   
     D pgmwork                       30a   
     D pgmlib                        10a   
     D pgmerrdta                     80a   
     D pgmrpgmsg                      4a   
     D pgmjob                        10a   
     D pgmuser                       10a   
     D pgmjobnum                      5s 0  
     D pgmjobdate                     6s 0  
     D pgmrundate                     6s 0  
     D pgmruntime                     6s 0