blog:iseries:rpg

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
blog:iseries:rpg [2020/03/07 04:16]
tom
blog:iseries:rpg [2020/03/07 04:37]
tom [Strings]
Line 57: Line 57:
 %Editc(Number:​ '​X':​ *CURSYM) %Editc(Number:​ '​X':​ *CURSYM)
   : edit code (numeric)   : edit code (numeric)
-<code rpgfree>  ​* Common codes (the X, above, or used in O specs)+  ​* Common codes (the X, above, or used in O specs)
   * 1-4 have no negative sign   * 1-4 have no negative sign
   * 5-9 are user-defined @ system level   * 5-9 are user-defined @ system level
Line 63: Line 63:
   * J is most common (commas, dec separator, - for neg, shows zeros)   * J is most common (commas, dec separator, - for neg, shows zeros)
   * K (commas, dec separator, - for neg, zeros suppressed)   * K (commas, dec separator, - for neg, zeros suppressed)
-  * Y - for dates</​code>​+  * Y - for dates 
 |Edit Code Description|No Sign|CR Sign|-Sign (R)|-Sign (L)| |Edit Code Description|No Sign|CR Sign|-Sign (R)|-Sign (L)|
 |Commas and zero balances|1|A|J|N| |Commas and zero balances|1|A|J|N|
Line 74: Line 75:
 |Date edit|Y| |Date edit|Y|
 |Suppress leading zeros|Z|  |Suppress leading zeros|Z|
 +
 %Editw %Editw
-  : edit word<code rpgfree> ​ * first zero ends zero-suppression (leading zeros after that position are printed)+  : edit word 
 +  * first zero ends zero-suppression (leading zeros after that position are printed)
   * first asterisk also ends zero-suppression,​ but causes leading asterisks in the ouput   * first asterisk also ends zero-suppression,​ but causes leading asterisks in the ouput
-    * '​b*bbbbbb.bb'​ (each b is a blank/space character) applied to 12345 prints ***123.45+    * <​nowiki>​'​b*bbbbbb.bb'​ (each b is a blank/space character) applied to 12345 prints ***123.45</​nowiki>​
   * a currency symbol followed by a zero floats   * a currency symbol followed by a zero floats
     * '​bb,​bbb,​b$0.bb'​ applied to 12 prints $.12     * '​bb,​bbb,​b$0.bb'​ applied to 12 prints $.12
Line 85: Line 88:
   * any other character prints that exact character   * any other character prints that exact character
     * '​bb/​bb/​bb'​ aplied to 12345 prints b1/23/45     * '​bb/​bb/​bb'​ aplied to 12345 prints b1/23/45
-    * '​0bb/​bb/​bb'​ aplied to 12345 prints b01/23/45</​code>​+    * '​0bb/​bb/​bb'​ aplied to 12345 prints b01/23/45
 %Elem %Elem
   : # of elements or occurrences   : # of elements or occurrences
Line 118: Line 121:
   : 1st position of look_for within look_in   : 1st position of look_for within look_in
 %Size %Size
-  : size of a variable or text string (not length)<​code rpgfree> ​   DIM(%SIZE(OTHER_FIELD)) +  : size of a variable or text string (not length) 
-    Use %size and %substr to extract 3 concatenated fields WITHOUT hard-coding the field sizes+<code rpgfree> ​   DIM(%SIZE(OTHER_FIELD)) 
 +    ​// Use %size and %substr to extract 3 concatenated fields WITHOUT hard-coding the field sizes
         eval      #cono = %subst($$id:​1:​%size(#​cono))         eval      #cono = %subst($$id:​1:​%size(#​cono))
         eval      #cusn = %subst($$id:​%size(#​cono)+1:​%size(#​cusn))         eval      #cusn = %subst($$id:​%size(#​cono)+1:​%size(#​cusn))
         eval      #dseq = %subst($$id:​%size(#​cono)+%size(#​cusn)+1:​%size(#​dseq))</​code>​         eval      #dseq = %subst($$id:​%size(#​cono)+%size(#​cusn)+1:​%size(#​dseq))</​code>​
 %Subdt(date:​ unit) %Subdt(date:​ unit)
-  : "date substring"​ - portion of a date<​code rpgfree>+  : "date substring"​ - portion of a date 
 +<code rpgfree>
     %SUBDT(value:​*MSECONDS|*SECONDS|*MINUTES|*HOURS|*DAYS|*MONTHS|*YEARS)     %SUBDT(value:​*MSECONDS|*SECONDS|*MINUTES|*HOURS|*DAYS|*MONTHS|*YEARS)
     %SUBDT(value:​*MS|*S|*MN|*H|*D|*M|*Y)</​code>​     %SUBDT(value:​*MS|*S|*MN|*H|*D|*M|*Y)</​code>​
 %Subst %Subst
-  : substring(string:​start:​length)<​code rpgfree> ​   // After the EVAL the original value of A contains ’ab****ghijklmno’+  : substring(string:​start:​length) 
 +<code rpgfree> ​   // After the EVAL the original value of A contains ’ab****ghijklmno’
      ​%SUBST(A(3:​4))= ’****’;</​code>​      ​%SUBST(A(3:​4))= ’****’;</​code>​
 %Time %Time
Line 238: Line 244:
 <code rpgfree> <code rpgfree>
 DName+++++++++++ETDsFrom+++To/​L+++IDc.Keywords+++++++++++++++++++++++++ DName+++++++++++ETDsFrom+++To/​L+++IDc.Keywords+++++++++++++++++++++++++
-D custRecKeys ​     ds                            likerec(custRec : *key)</​code>​+D custRecKeys ​    ​ds                  likerec(custRec : *key)</​code>​
  
 <code rpgfree>/​free <code rpgfree>/​free
Line 252: Line 258:
 chain (’abc’ : ’AB’) custRec custRecDs;</​code>​ chain (’abc’ : ’AB’) custRec custRecDs;</​code>​
  
--------------------------------------------------------------------------------+----
 ===== CHECK & CHECKR ===== ===== CHECK & CHECKR =====
  
Line 728: Line 734:
 ==== ACTIVATION GROUPS ==== ==== ACTIVATION GROUPS ====
  
-   * QILE is default activation group for modules +  ​* QILE is default activation group for modules 
-   ​* QSRVPGM is default activation group for service pgms +  * QSRVPGM is default activation group for service pgms 
-   ​* default ACTGRPs limit the ILE funcions +  * default ACTGRPs limit the ILE funcions 
-   ​* can't bind objects +    * can't bind objects 
-   ​* pgm CALLs can only call other pgms, not procedures +    * pgm CALLs can only call other pgms, not procedures 
-   ​* allows partitioning of job resources (file overrides, committment definitions,​ and open files) +  * allows partitioning of job resources (file overrides, committment definitions,​ and open files) 
-   ​* can control job activation and deactivation,​ improving performance +  * can control job activation and deactivation,​ improving performance 
-   ​* allows use of shared ODPs +  * allows use of shared ODPs 
-   ​* if using mixed ILE and non-ILE, use default activation group +  * if using mixed ILE and non-ILE, use default activation group 
-   ​* when an ILE pgm ends, the system doesn'​t always remove the storage for that pgm activation from the job +  * when an ILE pgm ends, the system doesn'​t always remove the storage for that pgm activation from the job 
-   ​* manual use of RCLACTGRP can improve performance+  * manual use of RCLACTGRP can improve performance
  
 ==== BINDING DIRECTORIES ==== ==== BINDING DIRECTORIES ====
Line 942: Line 948:
 ===== Literals ===== ===== Literals =====
 <code rpgfree> <code rpgfree>
- H DATFMT(*ISO) + H DATFMT(*ISO) 
- * Examples of literals used to initialize fields + * Examples of literals used to initialize fields 
- DName+++++++++++ETDsFrom+++To/​L+++IDc.Keywords+++++++++++++++++++++++++++++ + DName+++++++++++ETDsFrom+++To/​L+++IDc.Keywords+++++++++++++++++++++++++++++ 
- D DateField   S   D   ​INZ(D'​1988-09-03'​) + D DateField   S   D   ​INZ(D'​1988-09-03'​) 
- D NumField   S 5P 1 INZ(5.2) + D NumField   S 5P 1 INZ(5.2) 
- D CharField   S 10A ​  ​INZ('​abcdefghij'​) + D CharField   S 10A ​  ​INZ('​abcdefghij'​) 
- D UCS2Field   S 2C   ​INZ(U'​00610062'​) + D UCS2Field   S 2C   ​INZ(U'​00610062'​) 
- * Even though the date field is defined with a 2-digit year, the + * Even though the date field is defined with a 2-digit year, the 
- * initialization value must be defined with a 4-digit year, since + * initialization value must be defined with a 4-digit year, since 
- * all literals must be specified in date format specified + * all literals must be specified in date format specified 
- * on the control specification. + * on the control specification. 
- D YmdDate   S   D   ​INZ(D'​2001-01-13'​) + D YmdDate   S   D   ​INZ(D'​2001-01-13'​) 
- D  ​ DATFMT(*YMD) + D  ​ DATFMT(*YMD) 
- * Examples of literals used to define named constants + * Examples of literals used to define named constants 
- D DateConst   C   CONST(D'​1988-09-03'​) + D DateConst   C   CONST(D'​1988-09-03'​) 
- D NumConst   C   CONST(5.2) + D NumConst   C   CONST(5.2) 
- D CharConst   C    CONST('​abcdefghij'​) + D CharConst   C    CONST('​abcdefghij'​) 
- * Note that the CONST keyword is not required. + * Note that the CONST keyword is not required. 
- D Upper   C        '​ABCDEFGHIJKLMNOPQRSTUVWXYZ'​ + D Upper   C        '​ABCDEFGHIJKLMNOPQRSTUVWXYZ'​ 
- * Note that the literal may be continued on the next line + * Note that the literal may be continued on the next line 
- D Lower   C   '​abcdefghijklmn- + D Lower   C   '​abcdefghijklmn- 
- D  ​ opqrstuvwxyz'</​code>​+ D  ​ opqrstuvwxyz'</​code>​
  
 ==== float literals ==== ==== float literals ====
Line 1041: Line 1047:
 ===== Monitor ​ (for errors) ===== ===== Monitor ​ (for errors) =====
 <code rpgfree> <code rpgfree>
-                       ​monitor ​                                                  ​* start monitor +                 ​monitor ​                                    ​* start monitor 
-     ​                  ​eval      ivinue = ivinue + movc95 ​         * eval equation +   ​              ​eval      ivinue = ivinue + movc95 ​         * eval equation 
-     ​                  ​on-error ​ 0103                                         ​* field too small +   ​              ​on-error ​ 0103                              * field too small 
-     ​                  ​eval      ivinue = *hival ​                           * reset +   ​              ​eval      ivinue = *hival ​                  ​* reset 
-     ​                  ​endmon ​                                                  ​* end monitor+   ​              ​endmon ​                                     * end monitor
 </​code>​ </​code>​
 ------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Line 1136: Line 1142:
 Create commands create 2 names - an SQL name (128 char max) and a system name (10 char max) Create commands create 2 names - an SQL name (128 char max) and a system name (10 char max)
 Create Table (PF) Create Table (PF)
-  %%Create Table xxx As Select...%%+<code sql>Create Table xxx As Select...</​code>​
   : creates a table using a subset of field from an existing table   : creates a table using a subset of field from an existing table
-  %%Create Table xxx Like MyTable...%%+<code sql>Create Table xxx Like MyTable...</​code>​
   : all fields in referenced table used in created table   : all fields in referenced table used in created table
 Create View Create View
Line 1176: Line 1182:
   : a set of actions that are run automatically whenever a specified event occurs to a specified base table   : a set of actions that are run automatically whenever a specified event occurs to a specified base table
 UDT UDT
-   <code sql>​CREATE DISTINCT TYPE US_DOLLAR AS DECIMAL (9,​2)</​code>​+<code sql>​CREATE DISTINCT TYPE US_DOLLAR AS DECIMAL (9,​2)</​code>​
   : can then create tables with field types of US_DOLLAR (or string, integer, etc.)   : can then create tables with field types of US_DOLLAR (or string, integer, etc.)
 view  view 
Line 1368: Line 1374:
 | TRIMR | %TRIMR | | TRIMR | %TRIMR |
  
-------------------------------------------------------------------------------- 
 ===== Strip Leading Zeros ===== ===== Strip Leading Zeros =====
  
  • blog/iseries/rpg.txt
  • Last modified: 2020/03/07 04:37
  • by tom