Wednesday, December 4, 2013

Day-12.

Arrays And Tables:

 Overview:
This module enables the student to understand the Arrays and Tables.
 Outline:
Topics covered,
 E-specification (IPE)
  • Compile Time Array
  • Pre-Runtime Array
  • Runtime Array
  • Alternate Array
  • Compile Time Table
  • Pre-Runtime Table
  • Opcode Related to Array
Objective:
        By the end of this module, the student should be able to write program related to:
  • IPE      
  • Arrays
  • Tables
  • Alternate Array and Alternate Tables
  • Opcode Related to Array:-MOVEA, SORTA, XFOOT,LOKUP
  E-specification (IPE)
E Specification line is broken into following parts.

Positions
Name
Entry
1-2
Page
Page number
3-5
Line
Line number
6
Form type
E
7-10

Blank
11-18
From file name
Blank
Record-address file name
Array or table file name
19-26
To file name
Blank
Name of an input or update file containing data records
Name of an output or combined file
27-32
Table or array name
Table or array name
33-35
Number of entries per record
Blank
1-9999
36-39
Number of entries per array or table
1-9999
40-42
Length of entry
1-256
43
Date Format
Blank
P
B
L
R
G
44
Decimal positions
Blank
0-9
45
Sequence
Blank
A
D
46-51
Table or array name (alternating format)
Table or array name
(alternating format)
52-54
Length of entry
1-256
55
Data Format
Blank
P
B
L
R
G
56
Decimal positions
Blank
0-9
57
Sequence
Blank
A
D
58-80
Comments
Optionals

Extension specification describes all record address files, table files, and array files used in program. Maximum of 200 arrays and tables can be used in a program.

Input Prompt:-- > IPE
·         From Filename: This entry can be
1.     Array or Table filename: - Name of the array or table name.
2.     Name of output or combined file: - file to which array or table written
3.     Record address file name: - Name of the record address file
      ·         To Filename:- This entry can be
1.     Name of an input or update file
2.     Name of output or combined file
·         Table Name: Name of table or array
·         Entries per record: Number of table or array entries in each table or array input record. it can be from 1-999.
·         Entries per Table: This entry identifies maximum number of array or table entries. it can be from 1-999.
·         Length of Entry: Length of each element in the array or table.
·          P/B/L/R: - This entry specify the data format for array or table
·         Decimal Position: - This entry specify number of decimal places for numeric array or table (0-9)
·         Sequence: - This entry is valid for compile and prerun arrays and tables.
1.     Blank: - No special sequence.
2.     A: - Ascending sequence.
3.     D: - Descending sequence.
·         Alternate Name:- Name of the second array of table
 

Columns . . . :    1  71            Edit                        PB01U01S/MYRPG
 SEU==>                                                                   ESPEC
 FMT **  ...+... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 
        *************** Beginning of data *************************************
0001.00                                                                        
'''''''                                                                        
        ****************** End of data ****************************************
                                                                               
                                                                               
                                                                                
 Prompt type . . .    E      Sequence number . . .  '''''''                    
                                                                               
   From          To        Table      - Entries per --      Length             
 Filename     Filename     Name       Record     Table     of Entry    P/B/L/R 
                                                                               
  Decimal       Sequence     Alternate      Length                 Decimal     
 Positions       (A,D)         Name        of Entry    P/B/L/R    Positions    
                                                                               
 Sequence       Comment                                                        
                                                                                
                                                                               
 F3=Exit   F4=Prompt   F5=Refresh          F11=Previous record                 
 F12=Cancel            F23=Select prompt   F24=More keys                       
                                                                               

Arrays

An array is a series of data elements with he same elements with the same field length and the same number of the decimal position if numeric and the same data type.
Types of array 
  1. Compile-time array:
  2. Pre-runtime array:
  3. Run-time array:
Compile-time array:
Array, which is loaded when your program is created. It becomes a permanent part of your program.

Pre-runtime array:

Array, which is loaded from an array file when your program begins running, before any input, calculation or output operations are processed.

Run-time array:

Array, which is loaded by your program while it is running.

 Example of Compile time array:-


Columns . . . :    1  71            Edit                         PB01U01S/MYRPG
 SEU==>                                                                    ARR1
 FMT E  .....E....FromfileTofile++Name++N/rN/tbLenPDSArrnamLenPDSComments++++++
        *************** Beginning of data *************************************
0001.00      E                    ARR     1  12  2                             
0002.00      C           ARR,4     DSPLY                                       
0003.00      C                           SETON                     LR                
0004.00 **                                                                     
0005.00 AA                                                                     
0006.00 BB                                                                      
0007.00 CC                                                                     
0008.00 DD                                                                     
0009.00 EE                                                                      
0010.00 FF                                                                     
0011.00 GG                                                                    
0012.00 HH                                                                      
0013.00 II                                                                     
0014.00 JJ                                                                     
0015.00 KK                                                                      
0016.00 LL                                                                     
                                                                               
 F3=Exit   F4=Prompt   F5=Refresh   F9=Retrieve   F10=Cursor   F11=Toggle       
 F16=Repeat find       F17=Repeat change          F24=More keys                
                                                                               
                                                                                                                                    
Entry per record is 1 here

Columns . . . :    1  71            Edit                         PB01U01S/MYRPG
 SEU==>                                                                    ARR2
 FMT E  .....E....FromfileTofile++Name++N/rN/tbLenPDSArrnamLenPDSComments++++++
        *************** Beginning of data *************************************
0001.00      E                    ARR     12 12  2                             
0002.00      C           ARR,4     DSPLY                                       
0003.00      C                           SETON                     LR                
0004.00 **                                                                     
0005.00 AABBCCDDEEFFGGHHIIJJKKLL                                             
                                                                               
                                                                                                                                                              
                                                                               
 F3=Exit   F4=Prompt   F5=Refresh   F9=Retrieve   F10=Cursor   F11=Toggle      
 F16=Repeat find       F17=Repeat change          F24=More keys                 
                                                                               

Entry per record is 12 here

Pre-runtime array:

An array file is must for pre-runtime array.
  1. Create a physical file.
Here we create a file FILE1 with two fields
    • Month Number (MNO)
    • Month Name (MNAME)
 DDS Of File
Columns . . . :    1  71            Edit                        PB01U01D/MYRPG
 SEU==>                                                                   FILE1
 FMT PF .....A..........T.Name++++++RLen++TDpB......Functions++++++++++++++++++
        *************** Beginning of data *************************************
0001.00                                                                        
0002.00      A          R FILE1R                                                
0003.00      A             MNO               2  0      COLHDG('MONTH NUMBER')     
0004.00      A             MNAME          9          COLHDG('MONTH NAME')       
        ****************** End of data ****************************************
                                                                               
                                                                               
                                                                                                                                                          
                                                                               
 F3=Exit   F4=Prompt   F5=Refresh   F9=Retrieve   F10=Cursor   F11=Toggle      
 F16=Repeat find       F17=Repeat change          F24=More keys                
                                                                               

RPG PROGRAM

Columns . . . :    1  71            Edit                        PB01U01S/MYRPG
 SEU==>                                                                  PREARR
 FMT F  .....FFilenameIPEAF....RlenLK1AIOvKlocEDevice+......KExit++Entry+A....U
        *************** Beginning of data *************************************
0001.00      FFILE1   IT  F      11           EDISK                            
0001.01       * 11 IS THE LENGTH OF THE FILE (FILE1) FOR THIS WE HAVE TO       
0001.02       * CONVERT ZONDED DECIMAL NUMRIC FIELD TO PACKED DECIMAL FIELD    
0001.03       *SO WE CONVERT THE FIELD MNO (FILE1) TO PACKED DECIMAL WITH      
0001.04       * FORMULA(2/2+1) = 2 .SO FILE LENGTH IS 2+9=11                   
0001.05       * WHERE 9 IS THE LENGTH OF THE FIELD MNAME                       
0001.06       *                                                                
0002.00      E     FILE1            ARR     1  12  2P0                           
0002.01       *DISPLAYING THE THIRED ELEMENT OF THE ARRAY                      
0003.00      C           ARR,3     DSPLY                                       
0004.00      C                          SETON                     LR                
        ****************** End of data ****************************************
                                                                                
                                                                                                                                                             
                                                                               
 F3=Exit   F4=Prompt   F5=Refresh   F9=Retrieve   F10=Cursor   F11=Toggle      
 F16=Repeat find       F17=Repeat change          F24=More keys                
                                                                               

Run-time array:

Run-time array coding is the same as compile- time array the only difference is that it does not have entries per record entry.

Columns . . . :    1  71            Edit                        PB01U01S/MYRPG
 SEU==>                                                                  RUNARR
 FMT E  .....E....FromfileTofile++Name++N/rN/tbLenPDSArrnamLenPDSComments++++++
        *************** Beginning of data *************************************
0001.00      E                    ARR        12  2 0                           
0001.01       *ARRAY IS DEFINE                                                 
0002.00      C                     Z-ADD1         X       20                   
0003.00       *DEFINEING A COUNT VARIABLE                                      
0004.00      C                     Z-ADD1         ARR,1                        
0005.00      C                     Z-ADD2         ARR,2                        
0006.00      C                     Z-ADD3         ARR,3                        
0007.00      C                     Z-ADD4         ARR,4                        
0008.00      C                     Z-ADD5         ARR,5                        
0009.00      C                     Z-ADD6         ARR,6                        
0010.00       *DISPLAYING THE ELEMENT OF ARRAY ONE BY ONE                      
0011.00      C                     DO   12                                      
0012.00      C    ARR,X     DSPLY                                       
0013.00      C                     ADD  1         X                            
0014.00      C                     ENDDO                                       
0015.00      C                     SETON                     LR  
       ****************** End of data ****************************************             
                                                                               
 F3=Exit   F4=Prompt   F5=Refresh   F9=Retrieve   F10=Cursor   F11=Toggle      
 F16=Repeat find       F17=Repeat change          F24=More keys                
                                                                               


Alternate Array    
We can load two arrays in alternate format by using position 46-47 of the extension specs. the arrays in this format are known as an alternate array. in alternate format, data are stored as first element of the first array followed by the first element of the second array. Second element of the first array followed by the second element of the second array and so on.

Compile Time Array in Alternate Format:

Columns . . . :    1  71            Edit                        PB01U01S/MYRPG
 SEU==>                                                                  ALTCOM
 FMT E  .....E....FromfileTofile++Name++N/rN/tbLenPDSArrnamLenPDSComments++++++
        *************** Beginning of data *************************************
0001.00      E                    ARR1    1  12  2 0 ARR2    9                 
0002.00       *DEFINE ARRAYS IN ALTERNATER FORMAT                              
0003.00       *ARR2 IS AN ALTERNATE ARRAY                                      
0004.00      C                     Z-ADD1         X       20                   
0005.00      C                     DO   12                                     
0006.00      C           UMONTH    IFEQ ARR1,X                                 
0007.00      C           ARR2,X    DSPLY                                        
0008.00      C                     LEAVE                                       
0008.01      C                     ENDIF                                       
0008.02      C                     ADD  1         X                             
0009.00      C                     ENDDO                                       
0010.00      C                     SETON                     LR                
0011.00 **                                                                     
0012.00 01JAN                                                                  
0013.00 02FEB                                                                  
0014.00 03MARCH                                                                
0015.00 04APRIL                                                                
0016.00 05MAY                                                                  
0017.00 06JUNE                                                                 
0018.00 07JULY                                                                  
0019.00 08AUGUEST                                                              
0020.00 09SEP                                                                  
0021.00 10OCT                                                                   
0022.00 11NOV                                                                  
0023.00 12DEC                                                                  
        ****************** End of data ****************************************
                                                                               
                                                                               
                                                                                
 F3=Exit   F4=Prompt   F5=Refresh   F9=Retrieve   F10=Cursor   F11=Toggle      
 F16=Repeat find       F17=Repeat change          F24=More keys                

 Note: UMONTH return the current month.

Pre-Runtime Array in Alternate Format:

Columns . . . :    1  71            Edit                        PB01U01S/MYRPG 
 SEU==>                                                                  PREAR1
 FMT F  .....FFilenameIPEAF....RlenLK1AIOvKlocEDevice+......KExit++Entry+A....U
        *************** Beginning of data *************************************
0001.00      FFILE1   IT  F      11           EDISK                            
0001.01       * 11 IS THE LENGTH OF THE FILE (FILE1) FOR THIS WE HAVE TO       
0001.02       * CONVERT ZONDED DECIMAL NUMRIC FIELD TO PACKED DECIMAL FIELD    
0001.03       *SO WE CONVERT THE FIELD MNO (FILE1) TO PACKED DECIMAL WITH      
0001.04       * FORMULA (2/2+1) = 2 .SO FILE LENGTH IS 2+9=11                   
0001.05       * WHERE 9 IS THE LENGTH OF THE FIELD MNAME                       
0001.06       *                                                                
0002.00      E      FILE1            ARR1    1  12  2P0 ARR2    9                 
0002.01      C                           Z-ADD1         X       20                   
0002.02       *                                                                
0002.03      C     UMONTH     LOKUPARR1,X                   49            
0002.04       *                                                                 
0002.05      C      *IN49            IFEQ *ON                                    
0003.00      C           ARR2,X    DSPLY                                       
0003.01      C                           ENDIF                                       
0004.00      C                           SETON                     LR                
       ****************** End of data ****************************************
                                                                              
 F3=Exit   F4=Prompt   F5=Refresh   F9=Retrieve   F10=Cursor   F11=Toggle      
 F16=Repeat find       F17=Repeat change          F24=More keys                
                                                                               

Note:   LOKUP opcode is used to search the array elements, if search is successful then indicator defined in the EQ get on.


Runtime Array in Alternate Format:

Columns . . . :    1  71            Edit                        PB01U01S/MYRPG
 SEU==>                                                                  ALTRUN
 FMT E  .....E....FromfileTofile++Name++N/rN/tbLenPDSArrnamLenPDSComments++++++
        *************** Beginning of data *************************************
0001.00      E                    ARR1       12  2 0 ARR2    9                 
0002.00      C                     Z-ADD1        X       20                   
0002.01      C                     Z-ADD1              ARR1,1                       
0002.02      C                     MOVEL'JAN'     ARR2,1                        
0003.00      C                     Z-ADD2              ARR1,2                       
0004.00      C                     MOVEL'FEB'     ARR2,2                       
0004.01      C                     Z-ADD3               ARR1,3                       
0004.02      C                     MOVEL'MARCH'   ARR2,3                       
0004.03      C                     Z-ADD4                  ARR1,4                       
0004.04      C                     MOVEL'APRIL'   ARR2,4                        
0005.00      C                     DO   12                                     
0006.00      C   ARR1,X    DSPLY                                       
0007.00      C   ARR2,X    DSPLY                                       
0008.00      C                     ADD  1         X                            
0009.00      C                     ENDDO                                       
0010.00      C                     SETON                     LR                
       ****************** End of data ****************************************                  
                                                      
 F3=Exit   F4=Prompt   F5=Refresh   F9=Retrieve   F10=Cursor   F11=Toggle      
 F16=Repeat find       F17=Repeat change          F24=More keys                 
                                         (C) COPYRIGHT IBM CORP. 1981, 2002.   

Tables

An table is a series of data elements with he same elements with the same field length and the same number of the decimal position if numeric and the same data type.
 Types of tables 
    1.     Compile-time table:
  1. Pre-runtime table:

Compile-time table:
table, which is loaded when your program is created. It becomes a permanent part of your program.

Pre-runtime table:

table, which is loaded from an array file when your program begins running, before any input, calculation or output operations are processed.

 Note: Table name start with TAB followed by up to 3 additional characters. Indexing is not possible in the table. 

 Compile-time table:          

Columns . . . :    1  71            Edit                        PB01U01S/MYRPG
 SEU==>                                                                  COMTAB
 FMT E  .....E....FromfileTofile++Name++N/rN/tbLenPDSArrnamLenPDSComments++++++
        *************** Beginning of data *************************************
0002.00      E                    TAB001 12  12  2 0                           
0003.00       *DECLEARING TABLE TAB001                                         
0004.00      C         TAB001       DSPLY                                        
0004.01       *DISPLAYING THE FIRST ELEMENT OF TABLE                           
0005.00      C        UMONTH    LOKUPTAB001                   40            
0005.01       *SEARCHING THE CURRENT MONTH IN THE TABLE TAB001                 
0006.00      C           *IN40        IFEQ *ON                                    
0006.01       * IF FOUND THEN DISPAYING THE NUMBER OF THE MONTH                
0007.00      C           TAB001    DSPLY                                        
0008.00      C                            ENDIF                                       
0009.00      C                            SETON                     LR                
0010.00 **                                                                     
0011.00 010203040506070809101112                                               
        ****************** End of data ****************************************
                                                                               
                                                                                
                                                                               
 F3=Exit   F4=Prompt   F5=Refresh   F9=Retrieve   F10=Cursor   F11=Toggle      
 F16=Repeat find       F17=Repeat change          F24=More keys                
                                         (C) COPYRIGHT IBM CORP. 1981, 2002.   

Entry per record is 12 here



Columns . . . :    1  71            Edit                        PB01U01S/MYRPG
 SEU==>                                                                  COMTA1
 FMT E  .....E....FromfileTofile++Name++N/rN/tbLenPDSArrnamLenPDSComments++++++
        *************** Beginning of data *************************************
0002.00      E                    TAB001  1  12  2 0                           
0003.00       *DECLEARING TABLE TAB001                                         
0004.00      C         TAB001          DSPLY                                       
0004.01       *DISPLAYING THE FIRST ELEMENT OF TABLE                           
0005.00      C           UMONTH    LOKUPTAB001                   40            
0005.01       *SEARCHING THE CURRENT MONTH IN THE TABLE TAB001                 
0006.00      C           *IN40           IFEQ *ON                                     
0006.01       * IF FOUND THEN DISPAYING THE NUMBER OF THE MONTH                
0007.00      C           TAB001        DSPLY                                       
0008.00      C                               ENDIF                                        
0009.00      C                               SETON                     LR                
0010.00 **                                                                     
0011.00 01                                                                      
0012.00 02                                                                     
0013.00 03                                                                     
0014.00 04                                                                     
0015.00 05                                                                     
0016.00 06                                                                     
0017.00 07                                                                     
0018.00 08                                                                      
0019.00 09                                                                     
0020.00 10                                                                     
0021.00 11                                                                      
0022.00 12                                                                     
        ****************** End of data ****************************************
    F3=Exit   F4=Prompt   F5=Refresh   F9=Retrieve   F10=Cursor   F11=Toggle      
 F16=Repeat find       F17=Repeat change          F24=More keys                


Entry per record is1 here

 Pre-runtime table:

Columns . . . :    1  71            Edit                        PB01U01S/MYRPG
 SEU==>                                                                  PRETAB
 FMT F  .....FFilenameIPEAF....RlenLK1AIOvKlocEDevice+......KExit++Entry+A....U
        *************** Beginning of data *************************************
0001.00      FFILE1   IT  F      11           EDISK                            
0001.01       * 11 IS THE LENGTH OF THE FILE (FILE1) FOR THIS WE HAVE TO       
0001.02       * CONVERT ZONDED DECIMAL NUMRIC FIELD TO PACKED DECIMAL FIELD    
0001.03       *SO WE CONVERT THE FIELD MNO (FILE1) TO PACKED DECIMAL WITH      
0001.04       * FORMULA(2/2+1) = 2 .SO FILE LENGTH IS 2+9=11                   
0001.05       * WHERE 9 IS THE LENGTH OF THE FIELD MNAME                       
0001.06       *                                                                 
0002.00      E    FILE1           TAB001  1  12  2P0                           
0002.01       * DEFINEING THE TABLE TAB001                                     
0002.02      C           UMONTH    LOKUPTAB001                   40            
0002.03       *SEARCHING THE CURRENT MONTH IN THE TABLE                        
0002.04      C           *IN40     IFEQ *ON                                    
0003.00      C           TAB001    DSPLY                                        
0003.01      C                     ENDIF                                       
0004.00      C                     SETON                     LR                
        ****************** End of data ****************************************
                                                                                
 F3=Exit   F4=Prompt   F5=Refresh   F9=Retrieve   F10=Cursor   F11=Toggle      
 F16=Repeat find       F17=Repeat change          F24=More keys                
                                                                                

Compile-time table in Alternate Format:


Columns . . . :    1  71            Edit                        PB01U01S/MYRPG
 SEU==>                                                                  COMALT
 FMT E  .....E....FromfileTofile++Name++N/rN/tbLenPDSArrnamLenPDSComments++++++
        *************** Beginning of data *************************************
0002.00      E                    TAB001  1  12  2 0 TAB002  9                 
0003.00       *DECLEARING TABLE TAB001 AND ALTERNATE TABLE TAB002              
0005.00      C           UMONTH    LOKUPTAB001    TAB002         40            
0005.01       *SEARCHING THE CURRENT MONTH IN THE TABLE TAB001                 
0006.00      C           *IN40     IFEQ *ON                                    
0006.01       * IF FOUND THEN DISPAYING THE NAME OF THE MONTH FROM TABLE TAB002
0007.00      C           TAB002   DSPLY                                       
0008.00      C                            ENDIF                                       
0009.00      C                            SETON                     LR                
0010.00 **                                                                     
0011.00 01JAN                                                                   
0012.00 02FEB                                                                  
0013.00 03MARCH                                                                
0014.00 04APRIL                                                                 
0015.00 05MAY                                                                  
0016.00 06JUNE                                                                 
0017.00 07JULY                                                                  
0018.00 08AUGUEST                                                              
0019.00 09SEP                                                                  
0020.00 10OCT                                                                  
0021.00 11NOV                                                                  
0022.00 12DEC                                                                  
        ****************** End of data ****************************************
                                                                                
                                                                               
                                                                               
 F3=Exit   F4=Prompt   F5=Refresh   F9=Retrieve   F10=Cursor   F11=Toggle      
 F16=Repeat find       F17=Repeat change          F24=More keys                
                                                                               

Pre-runtime table in Alternate Format:

Columns . . . :    1  71            Edit                        PB01U01S/MYRPG
 SEU==>                                                                  PREALT
 FMT F  .....FFilenameIPEAF....RlenLK1AIOvKlocEDevice+......KExit++Entry+A....U
        *************** Beginning of data *************************************
0001.00      FFILE1   IT  F      11           EDISK                            
0001.01       * 11 IS THE LENGTH OF THE FILE (FILE1) FOR THIS WE HAVE TO       
0001.02       * CONVERT ZONDED DECIMAL NUMRIC FIELD TO PACKED DECIMAL FIELD    
0001.03       *SO WE CONVERT THE FIELD MNO (FILE1) TO PACKED DECIMAL WITH      
0001.04       * FORMULA(2/2+1) = 2 .SO FILE LENGTH IS 2+9=11                   
0001.05       * WHERE 9 IS THE LENGTH OF THE FIELD MNAME                       
0001.06       *                                                                
0002.00      E    FILE1           TAB001  1  12  2P0 TAB002  9                 
0002.01       * DEFINEING THE TABLE TAB001 AND ALTERNATE TABLE TAB002          
0002.02      C         UMONTH    LOKUPTAB001    TAB002         40            
0002.03       *SEARCHING THE CURRENT MONTH IN THE TABLE TAB001                 
0002.04      C           *IN40        IFEQ *ON                                     
0002.05       *IF FOUND IN TABLE TAB001 THEN DISPLAY NAME OF MONTH FROM TAB002 
0003.00      C           TAB002    DSPLY                                       
0003.01      C                             ENDIF                                       
0004.00      C                             SETON                     LR                
        ****************** End of data ****************************************
                                                                          
 F3=Exit   F4=Prompt   F5=Refresh   F9=Retrieve   F10=Cursor   F11=Toggle      
 F16=Repeat find       F17=Repeat change          F24=More keys                
                                                                                                                                                                

Opcode Related to With Array:


  1. MOVEA:
The MOVEA opcode moves the values from the factor 2 to the result field. Either factor 2 or result field must be an array.

This opcode is used to: -
o    Move several contiguous char array elements to a single char field or vice versa.
o    Move contiguous array elements to contiguous elements of second array

Columns . . . :    1  71            Edit                        PB01U01S/MYRPG
 SEU==>                                                                  MOVEAA
 FMT E  .....E....FromfileTofile++Name++N/rN/tbLenPDSArrnamLenPDSComments++++++
        *************** Beginning of data *************************************
0001.00      E                    ARR1       12  1                              
0002.00      E                    ARR2       12  1                             
0003.00       *DEFINEING TWO RUNTIME ARRAYS AAR1 AND ARR2                      
0004.00      C                     MOVE 'HI'      FLD1    5                     
0005.00      C                     MOVEAFLD1      ARR1                         
0005.01       *MOVEING THE CHAR FIELD  FLD1 TO ARRAY ARR1                      
0008.00      C                     MOVEAARR1      ARR2                         
0008.01       *MOVING VALUES OF ARR1 TO ARR2                                   
0009.00      C                     MOVEAARR2      FLD2    5                    
0009.01       *MOVING VALUE OF ARR2 TO CHAR FIELD FLD3                         
0011.00      C       FLD2    DSPLY                                       
0011.01       *DSPLYING THE CHAR FIELD                                         
0012.00      C                   SETON                     LR                
        ****************** End of data ****************************************
                                                                               
                                                                               
                                                                                
 F3=Exit   F4=Prompt   F5=Refresh   F9=Retrieve   F10=Cursor   F11=Toggle      
 F16=Repeat find       F17=Repeat change          F24=More keys                
                                                                                

  1. SORTA:
The SORTA opcode is used to sort the array in ascending or descending sequence. This sequence is specified in the sequence entry of the E-spec where array is defined.
o    A-Ascending
o    D-Descending


Columns . . . :    1  71            Edit                        PB01U01S/MYRPG
 SEU==>                                                                    ASEN
 FMT E  .....E....FromfileTofile++Name++N/rN/tbLenPDSArrnamLenPDSComments++++++
        *************** Beginning of data *************************************
0001.00      E                    ARR1        6  2 0A                          
0002.00       *DEFINED THE ARRAY AAR1 WITH 'A'IN THE SEQUENCE ENTRY            
0002.01      C                     Z-ADD1         X       10                   
0003.00      C                     Z-ADD12        ARR1,1                       
0004.00      C                     Z-ADD11        ARR1,2                       
0005.00      C                     Z-ADD9         ARR1,3                        
0006.00      C                     Z-ADD8         ARR1,4                       
0007.00      C                     Z-ADD7         ARR1,5                       
0008.00      C                     Z-ADD1         ARR1,6                       
0009.00      C                     DO   6                                      
0010.00      C           ARR1,X    DSPLY                                       
0010.01       *DISPLAYING THE ARRAY WITHOUT SORTING                            
0011.00      C                     ADD  1         X                            
0012.00      C                     ENDDO                                       
0012.01      C                     SORTAARR1                                   
0012.02       *SORTING THE ARRAY                                               
0012.07      C                     ADD  1         X                            
0012.08      C                     ENDDO                                       
0013.00      C                     SETON                     LR                
        ****************** End of data ****************************************
                                                                               
                                                                                
 F3=Exit   F4=Prompt   F5=Refresh   F9=Retrieve   F10=Cursor   F11=Toggle      
 F16=Repeat find       F17=Repeat change          F24=More keys                
                                                                                                                                                                

Sorting the array in ascending order

Columns . . . :    1  71            Edit                        PB01U01S/MYRPG
 SEU==>                                                                    DSEN
 FMT E  .....E....FromfileTofile++Name++N/rN/tbLenPDSArrnamLenPDSComments++++++
        *************** Beginning of data *************************************
0001.00      E                    ARR1        6  2 0D                           
0002.00       *DEFINED THE ARRAY AAR1 WITH 'D'IN THE SEQUENCE ENTRY            
0002.01      C                     Z-ADD1         X       10                   
0003.00      C                     Z-ADD1         ARR1,1                        
0004.00      C                     Z-ADD2         ARR1,2                       
0005.00      C                     Z-ADD3         ARR1,3                       
0006.00      C                     Z-ADD4         ARR1,4                       
0007.00      C                     Z-ADD5         ARR1,5                       
0008.00      C                     Z-ADD6         ARR1,6                       
0009.00      C                     DO   6                                      
0010.00      C           ARR1,X    DSPLY                                       
0010.01       *DISPLAYING THE ARRAY WITHOUT SORTING                            
0011.00      C                     ADD  1         X                            
0012.00      C                     ENDDO                                       
0012.01      C                     SORTAARR1                                   
0012.02       *SORTING THE ARRAY                                               
0012.07      C                     ADD  1         X                            
0012.08      C                     ENDDO                                       
0013.00      C                     SETON                     LR                
        ****************** End of data ****************************************
                                                                               
                                                                               
 F3=Exit   F4=Prompt   F5=Refresh   F9=Retrieve   F10=Cursor   F11=Toggle      
 F16=Repeat find       F17=Repeat change          F24=More keys                
                                                                                


Sorting the array in descending order

3.    XFOOT:
The XFOOT opcode add the elements of an array together and put the result in the result field.

Columns . . . :    1  71            Edit                        PB01U01S/MYRPG
 SEU==>                                                                  XFOOT1
 FMT E  .....E....FromfileTofile++Name++N/rN/tbLenPDSArrnamLenPDSComments++++++
        *************** Beginning of data *************************************
0001.00      E                    ARR1       12  2 0                           
0002.00       * DECLERING ARRAY                                                 
0003.00      C                     Z-ADD1         ARR1,1                       
0004.00      C                     Z-ADD2         ARR1,2                       
0005.00      C                     Z-ADD3         ARR1,3                       
0006.00      C                     Z-ADD4         ARR1,4                       
0007.00      C                     Z-ADD5         ARR1,5                       
0008.00      C                     XFOOTARR1      FLD1    20                    
0008.01       *                                                                
0009.00      C           FLD1      DSPLY                                       
0010.00      C                     SETON                     LR                
        ****************** End of data ****************************************
                                                                               
                                                                                                                                                    
                                                                               
 F3=Exit   F4=Prompt   F5=Refresh   F9=Retrieve   F10=Cursor   F11=Toggle      
 F16=Repeat find       F17=Repeat change          F24=More keys                
                                                                               


No comments:

Post a Comment