Difference between revisions of "Program Status Data Structure"

From MidrangeWiki
Jump to: navigation, search
m (Add to Programming Category)
 
(7 intermediate revisions by 3 users not shown)
Line 9: Line 9:
 
     D                SDS
 
     D                SDS
  
List the sub-fields you need below that. They're described in the [http://publib.boulder.ibm.com/infocenter/iseries/v5r3/ic2924/books/c092508409.htm#HDRPSDSDT9 ILE RPG language reference].
+
List the sub-fields you need below that. They're described in the [http://publib.boulder.ibm.com/infocenter/iseries/v5r3/topic/books/sc092508.pdf 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:
 
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:
Line 20: Line 20:
 
==Program Status Data Structure Available Information==
 
==Program Status Data Structure Available Information==
 
Numeric Data Length column contains the decimal places after the ",".
 
Numeric Data Length column contains the decimal places after the ",".
<table border="normal">
+
 
 +
Certain fields can be specified by their name as the beginning buffer position, instead of an offset. These are noted as Alternate Location in the table:
 +
<table border="normal" class="sortable">
 
   <tr>
 
   <tr>
 +
    <th>Seq</th>
 
     <th>Value Contained</th>
 
     <th>Value Contained</th>
 
     <th>Data Type</th>
 
     <th>Data Type</th>
Line 27: Line 30:
 
     <th>Beginning Buffer Position</th>
 
     <th>Beginning Buffer Position</th>
 
     <th>Ending Buffer Position</th>
 
     <th>Ending Buffer Position</th>
 +
    <th>Alternate location</th>
 
   </tr>
 
   </tr>
 
   <tr>
 
   <tr>
 +
    <td>1</td>
 
     <td>Program Name</td>
 
     <td>Program Name</td>
 
     <td>Character</td>
 
     <td>Character</td>
Line 34: Line 39:
 
     <td align="right">1</td>
 
     <td align="right">1</td>
 
     <td align="right">10</td>
 
     <td align="right">10</td>
 +
    <td alight="left">*proc</td>
 
   </tr>
 
   </tr>
 
   <tr>
 
   <tr>
 +
    <td>2</td>   
 
     <td>Program Status</td>
 
     <td>Program Status</td>
 
     <td>Zoned Decimal</td>
 
     <td>Zoned Decimal</td>
Line 43: Line 50:
 
   </tr>
 
   </tr>
 
   <tr>
 
   <tr>
 +
    <td>3</td>
 
     <td>Program Previous Status</td>
 
     <td>Program Previous Status</td>
 
     <td>Zoned Decimal</td>
 
     <td>Zoned Decimal</td>
Line 50: Line 58:
 
   </tr>
 
   </tr>
 
   <tr>
 
   <tr>
 +
    <td>4</td>
 
     <td>Program Source Statement</td>
 
     <td>Program Source Statement</td>
 
     <td>Character</td>
 
     <td>Character</td>
Line 57: Line 66:
 
   </tr>
 
   </tr>
 
   <tr>
 
   <tr>
 +
    <td>5</td>
 
     <td>Program Routine</td>
 
     <td>Program Routine</td>
 
     <td>Character</td>
 
     <td>Character</td>
Line 62: Line 72:
 
     <td align="right">29</td>
 
     <td align="right">29</td>
 
     <td align="right">36</td>
 
     <td align="right">36</td>
 +
    <td align="left">*routine</td>
 
   </tr>
 
   </tr>
 
   <tr>
 
   <tr>
 +
    <td>6</td>
 
     <td>Program Number Of Parameters</td>
 
     <td>Program Number Of Parameters</td>
 
     <td>Zoned Decimal</td>
 
     <td>Zoned Decimal</td>
Line 69: Line 81:
 
     <td align="right">37</td>
 
     <td align="right">37</td>
 
     <td align="right">39</td>
 
     <td align="right">39</td>
 +
    <td align="left">*parms</td>
 
   </tr>
 
   </tr>
 
   <tr>
 
   <tr>
 +
    <td>7</td>
 
     <td>Program Message ID</td>
 
     <td>Program Message ID</td>
 
     <td>Character</td>
 
     <td>Character</td>
Line 78: Line 92:
 
   </tr>
 
   </tr>
 
   <tr>
 
   <tr>
 +
    <td>8</td>
 
     <td>Program MI Instruction Code</td>
 
     <td>Program MI Instruction Code</td>
 
     <td>Character</td>
 
     <td>Character</td>
Line 85: Line 100:
 
   </tr>
 
   </tr>
 
   <tr>
 
   <tr>
 +
    <td>9</td>
 
     <td>Program Work</td>
 
     <td>Program Work</td>
 
     <td>Character</td>
 
     <td>Character</td>
Line 92: Line 108:
 
   </tr>
 
   </tr>
 
   <tr>
 
   <tr>
 +
    <td>10</td>
 
     <td>Program Library</td>
 
     <td>Program Library</td>
 
     <td>Character</td>
 
     <td>Character</td>
Line 99: Line 116:
 
   </tr>
 
   </tr>
 
   <tr>
 
   <tr>
 +
    <td>11</td>
 
     <td>Program Error Data</td>
 
     <td>Program Error Data</td>
 
     <td>Character</td>
 
     <td>Character</td>
Line 106: Line 124:
 
   </tr>
 
   </tr>
 
   <tr>
 
   <tr>
 +
    <td>12</td>
 
     <td>Program RPG Message</td>
 
     <td>Program RPG Message</td>
 
     <td>Character</td>
 
     <td>Character</td>
Line 113: Line 132:
 
   </tr>
 
   </tr>
 
   <tr>
 
   <tr>
 +
    <td>13</td>
 
     <td>Program Job Name</td>
 
     <td>Program Job Name</td>
 
     <td>Character</td>
 
     <td>Character</td>
Line 120: Line 140:
 
   </tr>
 
   </tr>
 
   <tr>
 
   <tr>
 +
    <td>14</td>
 
     <td>Program User ID</td>
 
     <td>Program User ID</td>
 
     <td>Character</td>
 
     <td>Character</td>
Line 127: Line 148:
 
   </tr>
 
   </tr>
 
   <tr>
 
   <tr>
 +
    <td>15</td>
 
     <td>Program Job Number</td>
 
     <td>Program Job Number</td>
 
     <td>Zoned Decimal</td>
 
     <td>Zoned Decimal</td>
Line 134: Line 156:
 
   </tr>
 
   </tr>
 
   <tr>
 
   <tr>
 +
    <td>16</td>
 
     <td>Program Job Date</td>
 
     <td>Program Job Date</td>
 
     <td>Zoned Decimal</td>
 
     <td>Zoned Decimal</td>
Line 141: Line 164:
 
   </tr>
 
   </tr>
 
   <tr>
 
   <tr>
 +
    <td>17</td>
 
     <td>Program Run Date</td>
 
     <td>Program Run Date</td>
 
     <td>Zoned Decimal</td>
 
     <td>Zoned Decimal</td>
Line 148: Line 172:
 
   </tr>
 
   </tr>
 
   <tr>
 
   <tr>
 +
    <td>18</td>
 
     <td>Program Run Time</td>
 
     <td>Program Run Time</td>
 
     <td>Zoned Decimal</td>
 
     <td>Zoned Decimal</td>
Line 156: Line 181:
 
</table>
 
</table>
 
<br><br>
 
<br><br>
 +
 
==Here is a Sample Program Status Data Structure in RPG III Style:==
 
==Here is a Sample Program Status Data Structure in RPG III Style:==
 
<pre>
 
<pre>
Line 182: Line 208:
 
<pre>
 
<pre>
 
     Dpsds            sds                   
 
     Dpsds            sds                   
     D pgmname                      10a   
+
     D pgmname                      10a  
 +
or   d pgmname          *proc
 +
    D pgmname                       
 
     D pgmsts                        5s 0  
 
     D pgmsts                        5s 0  
 
     D pgmprvsts                      5s 0  
 
     D pgmprvsts                      5s 0  
 
     D pgmsrcstmt                    8a   
 
     D pgmsrcstmt                    8a   
 
     D pgmroutine                    8a   
 
     D pgmroutine                    8a   
 +
or  D pgmroutine        *routine
 
     D pgmparms                      3s 0  
 
     D pgmparms                      3s 0  
 +
or  D pgmparms          *parms
 
     D pgmmsgid                      7a   
 
     D pgmmsgid                      7a   
 
     D pgmmi#                        4a   
 
     D pgmmi#                        4a   
Line 193: Line 223:
 
     D pgmlib                        10a   
 
     D pgmlib                        10a   
 
     D pgmerrdta                    80a   
 
     D pgmerrdta                    80a   
     D pgmrpgmsg                      4a  
+
     D pgmrpgmsg                      4a
 +
    D Filler_01                    69a 
 
     D pgmjob                        10a   
 
     D pgmjob                        10a   
 
     D pgmuser                      10a   
 
     D pgmuser                      10a   
Line 201: Line 232:
 
     D pgmruntime                    6s 0   
 
     D pgmruntime                    6s 0   
 
</pre>
 
</pre>
 +
==Categories==
 +
[[Category:RPG]]
 +
[[Category:Quick Reference]]
 +
[[Category:Programming]]

Latest revision as of 13:52, 2 June 2008

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 ",".

Certain fields can be specified by their name as the beginning buffer position, instead of an offset. These are noted as Alternate Location in the table:

Seq Value Contained Data Type Data Length Beginning Buffer Position Ending Buffer Position Alternate location
1 Program Name Character 10 1 10 *proc
2 Program Status Zoned Decimal 5,0 11 15
3 Program Previous Status Zoned Decimal 5,0 16 20
4 Program Source Statement Character 8 21 28
5 Program Routine Character 8 29 36 *routine
6 Program Number Of Parameters Zoned Decimal 3,0 37 39 *parms
7 Program Message ID Character 7 40 46
8 Program MI Instruction Code Character 4 47 50
9 Program Work Character 30 51 80
10 Program Library Character 10 81 90
11 Program Error Data Character 80 91 170
12 Program RPG Message Character 4 171 174
13 Program Job Name Character 10 244 253
14 Program User ID Character 10 254 263
15 Program Job Number Zoned Decimal 6,0 264 269
16 Program Job Date Zoned Decimal 6 270 275
17 Program Run Date Zoned Decimal 6 276 281
18 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 
or   d pgmname           *proc
     D pgmname                        
     D pgmsts                         5s 0 
     D pgmprvsts                      5s 0 
     D pgmsrcstmt                     8a   
     D pgmroutine                     8a   
or   D pgmroutine        *routine
     D pgmparms                       3s 0 
or   D pgmparms          *parms
     D pgmmsgid                       7a   
     D pgmmi#                         4a   
     D pgmwork                       30a   
     D pgmlib                        10a   
     D pgmerrdta                     80a   
     D pgmrpgmsg                      4a
     D Filler_01                     69a  
     D pgmjob                        10a   
     D pgmuser                       10a   
     D pgmjobnum                      5s 0  
     D pgmjobdate                     6s 0  
     D pgmrundate                     6s 0  
     D pgmruntime                     6s 0  

Categories