As400questions Sangeet
As400questions Sangeet
   -   ‘U’ in position 18 of data structure statement can define Data Area Data
       Structures.
- For NE condition always use AND & for EQ conditions use OR (multiple cases).
RPG400 limitations:
   1. http://as400.holgerscherer.de/indexeng.html
   2.
                                                                                            1
RPG400 Program Cycle
                                                                                         2
Procedure:
       Is a set of self-contained HLL statements that performs a particular task?
Module:
       It is a object that results from compiling a Source.
Service Program:
    - It is the OS/400 object that combines one or more modules.
    - It can’t be called directly.
Files:
PF:
      -   A PF can have only one Record Format. It describes the way actually data is
          stored.
      -   A PF can’t share the format of a Logical File.
LF:
      -   A Logical file contains no data. Used to arrange data from one or more PF’s.
      -   For Every LF described you must have to specify a 1) Record Format Name & 2)
          Either PFILE (for simple & multiple format LF’s) or JFILE keyword (for Join
          LF’s).
      -   Using Join Logical File 32 PF’s can be joined. These files must be specified in
          JFILE.
      -    Select & Omit specifications appear after key specification.
      -   Depending upon the keywords like VALUE, RANGE, and CMP either record are
          selected or omitted.
              o E.g. S ITEMNBR                 VALUES (1000 2000 3000 4000 +
                                               5000 6000)
              o E.g. S ITEMNBR                 RANGE (1000 5000)
              o E.g. S ITEMNBR                 CMP (LE 5000 )
                                                                                        3
SEQUENTIAL FILE:
  - It is the file where the order of records in the file is based on the order of records
     placed in the file.
  - Can be processed randomly by RRN.
   -   Database files are PF, LF, & files used as model files (in which no data exists).
   -   Device files are Diskette (DKTF), tape (TAPF) and printer (PRTF).
Display File:
   - Display File is an Object in the system.
   - It defines the format of the information to be presented on a display station.
   - Can be created in 2 ways;
           o Using SDA
           o CRTDSPF in command line & writing the DDS.
   -   Assume means, when two record formats are used (say main screen & one window sub
       file) then if you use in the window sub file, window will be displayed with previous screen.
   -   Keep is used, when say there 3or 4 record formats in a single display file and where ever
       (in record format) you define keep, that will remain irrespective of what is there in
       background.
   -   CLRL (clear line). It is having default as *YES.
CA (Command Attention): Record is returned to the program but the record doesn’t
contain the data entered by user & no field validation is performed.
                                                                                                  4
CPYF (Copy File) Concepts:
When you copy from one file to another, the target file may have a different
Record layout than the original file.
FMTOPT (*MAP):
- Means copy the fields from file A to file B based on their names.
- This option is used by itself if all the fields in file A are also in file B,
  but may or may not be in the same buffer position in the file.
- In addition, the attributes of the fields in file B can be different from file A and CPYF
will Map the data to the target format.
- Attribute in File B can have same attributes of File A or can have different lengths, but
according to name CPYF will MAP it.
Ex.
FileA                                          FileB
        R   REC1                                       R REC2
            NAME       10A                               CITY          3A/5A
            CITY        3A                               NUM           2S 0/ 3S 0
            NUM         2S 0                             NAME          10A/ 8A
        K   NUM                                        K NAME
FMTOPT (*DROP):
- Means that any fields in file A that are not also in file B should Simply not be copied--
they are dropped.
FMTOPT (*NOCHK):
- Means that CPYF should work the way it would normally work had the formats of the
two files been identical. Since they are not identical, CPYF will give you a formatting
error and fail. Adding *NOCHECK allows you to force CPYF to do a byte-copy anyway,
and ignore the format variance. You can end up with good data or bad data depending on
the target layout.
   -    CQE stands for Classic Query Engine. But SQE stands for Sequel Query Engine.
   -    Examples of CQE is: OPNQRY
   -    Examples of SQE are: QM400, SQ400.
   -    SQE = 4 x Efficiency of CQE.
                                                                                              5
Difference between Packed (P) & Zoned (S):
   -   Packed is commonly used to reduce the amount of disk space used in a file.
   -   A packed field uses ½ byte per digit & a ½ byte sign (round up length).
   -   For e.g. if 15,5 P uses 7.5 (for digits) + 0.5 (sign) = 8bytes
   -   Where in for the above example Signed field will take complete 15 bytes.
   -   From a programming standpoint, anytime you do any arithmetic on a numeric
       field if it is a not packed field, the compiler will generate code to Pack the data
       before doing the math.
   -   If the data is already packed, the compiler will not generate that code & directly
       jump right into math.
   -   Packed takes less space where in Zoned takes full length.
   -   Zoned more acts like Character.
   -   In CL *DEC always is PACKED. And in RPG if you don’t specify either zoned
       or packed the default is packed.
       Suppose your program is using a File, of which say the record Format Description
is changed but you are not aware of the same. So the program can’t process the file. The
system normally notifies your program of this condition. This condition is known as
Level check.
Locking Concepts:
File: File is locked only when “Renaming, Copying or any changes that are done in
attributes of the file. Otherwise they’re no locks.
Record: While writing/updating a particular record, only that record is locked. All other
records in the file are accessible for any other operation.
                                                                                            6
Difference between INFSR & *PSSR:
- INFSR:      Controls File exceptions or errors.
- *PSSR:      If there is an error in any of the MOVE statement, then program goes into
Abnormal End i.e. *PSSR routine. And in most of the cases it will display a return code
& error message.
- In Dynamic call, when the command is issued to the OS, the called program is found by
name & loaded into the memory. If another dynamic call is issued on the same program
then one more copy of the program is loaded in to the memory so on & so forth.
   -   But in Bind by reference the location of the program in memory is found & that
       version is used. Copy of the program is needed in bind by reference no matter
       how many times it is used.
   -   When this is defined in factor2, RPG/400 program implicitly retrieves data from
       the Data Area at program start & writes data to the data area when program ends.
   -   No Need of use IN & OUT to read & update data area.
                                                                                          7
Explanation:
Z-ADD will move zeros to Resulting field & then move value of Factor 2 to Resulting
Field.
Z-SUB will do the same way. Moving zeros to Resulting field & then subtracting the
value present in Factor2. (i.e. Result Field – Factor2 = -ve of Factor2).
                                                                                             8
     -
                                                                                           9
FTP Concepts:
To down load source directly from the CL program to local PC in text format.
Steps:
   1. In your local PC, in any of the drive create a “.bat” file say ftptrail.bat which
   contains the following code.
   - cd \
   - cd ftpfolder
   - ftp -s:ftp.txt
    2. Create another file with name say ftp.txt that contains the executable commands in
    FTP prompt say;
    open 192.168.71.29
    user mumtrg mumtrg
    cd laxmanlib
    lcd c:\ftpfolder
    get qrpgsrc.mank5
    bye
3. Now write a CL program with the following structure;
        PGM
        MONMSG
        STRPCO
        STRPCCMD PCCMD (‘C:\FTPFOLDER\FTPTRAIL.BAT’)
        ENDPGM
4. Compile that code & call it a FTP screen will be popped up, wait for a second to finish
the FTP commands, then it will ask you to ‘Press any key to Return”.
6. To get all the sources present in a Source PF under a library is use “mget” instead of
“get”.
QBATCH, QINTER, QSPL, QCMN, QCTL etc. are the basic subsystems.
   -   If the text is in the AS400 folder (QDLS) then, Do CPYFRMPCD (copy from PC
       Document) + F4.
   -   If the text is in other area, then CPYFRMSTMF (copy from Stream file)+F4
                                                                                            10
How to find all the details of the PF’s in a given Source PF with attributes:
  - There is a system API or you can say, it is a system PF, where in all the PF’s
      created by user (all) are stored with attributes & all the other details.
  - We can use it as a simple PF; the unique key is “LIBRARY NAME”.
  - So once you know the PF & key, then you can play with that.
  - The name is QSYS/QADBIFLD.
If you Know Library Name to Find What Source Files are there :
    - Say the library Name is ‘LaxmanLib’.
    - Type DSPFD + F4
    - Enter the details, give File Name as  *ALL & Library Name as  Laxmanlib
    - Type of Information will be  *BASATR
    - Refer Snap Shot
                                                                                     11
    -   Simply you can type WRKOBJPDM & give your library name. It will give all
        the objects in your library. And make position to “Q”.
- Main disadvantage is, you can’t use a “SELECT” statement in this command.
In AS400, you have to use SLEEP API to have milliseconds delay. The prototype is
given below.
If you want microseconds delay in AS400, then you have to use USLEEP API. The
prototype is given below.
                                                                                                      12
How to Use EXTPGM & EXTPROC in RPGLE with Examples:
   -   For EXTPGM, a return value is required; the program calling the 2nd program
       should pass one extra variable to the calling program. Refer sample code;
   -   For EXTPROC, we have to use EXPORT & Procedure Interface in the calling
       Proc.
                                                                                     13
-   Compile both called program & calling procedure with option 15 i.e. makes it
    Module. (*MOD).
-   Then using command CRTPGM, create the called program. In this case it is
    FREE2.
-   Refer screen shots.
FREE2:
ADD1:
                                                                                   14
   Creating Program & calling:
   SINGLE PAGE:
   Both SFLSIZE and SFLPAGE are equal. In Single Page SFL following keywords
   cannot be used
   a) SFLDROP      b) SFLFOLD         c) SFLROLVAL
   SFLFOLD & SFLDROP is handled by the system just like Load all Sub-file but not
   by the program.
                                                                                   15
   SFLRCDNBR (Sub file record no.): It is used to display that sub file page in which
   given relative record number is to be displayed /specified .If this keyword is not used
   then the sub file would display the 1st page by default.
   SFLCSRRRN (Sub file Cursor Relative Record No.): Generally after declaring the
   SFLCSRRRN, where ever you place the cursor in the Sub file Record part & hit
   enter, the RRN value of that particular record is retrieved into the defined variable.
   - And after that open the DDS in Edit mode (option 2), declare the variable in
       hidden state with attributes 5 S 0H(hidden).
       If a window has to be populated only at some positions in the simple display file
& Sub file then use this key word.
   3) CHGPF:
   - Open the PF in Edit Mode & insert the required field with attributes.
   - Save but don’t compile.
   - Write CHGPF in command line + F4, enter the details + enter.
   - It will come to QDDSSRC screen. Then update with DFU.
                                                                                         16
4) EXFMT in RPG is same s WRITE & READ in COBOL/400.
- EXFMT is valid for only Workstation (WORKSTN) file defined as Full
   procedural (F) or Externally Defined File (E).
           a)        Application software
           b)        Operating system software
           c)        Licensed internal code (LIC)
                                                                                       17
     18) What is the Maximum length of Record format? 32766 bytes
24) DSPFFD: Will give total number of fields in PF, Length of each field and Record
format Number etc.,
    - If you specify either SETLL of SETGT with *LOVAL and then READ it will
       read the 1st record.
    - If you use either SETLL /SETGT with *HIVAL and then READP it will READ
       the Last Record.
25) DSPPGMREF:
    - It is a CL command, and when it is used in RPG, it will give the objects used by
      the called program and the details of the objects. (i.e. no of record formats, in
      which library it is used, etc.)
    - It is also gives the details of the calling program in addition to files & data areas.
    - It won’t give details of Data structures.
                                                                                           18
28) STRPCCMD: (Start PC Command)
    - Directly from AS400 server you can open notepad/calculator etc.
    - But prior to that you have to run this command on the command line STRPCO
      (Start PC Organizer).
RPG program
F PF1   IF          E           K DISK   A
F                               K COMMIT
F DSPF1 CF         E              WORKSTN
C                READ
                 WRITE
        05       COMIT
        06        ROLBK
   V2 = -123
   V1 = %ABS (V2-321)  444
   V3 = -1234.567
   V1 = %ABS (V3)  1234.567
   30) In OPNQRYF if you want that records retrieved from OPNQRYF should be
   written back to file then following code has to be written. For this we have to use
CPYFRMQRYF
                                                                                         19
PGM
DCLF FILE (PATNI2/CP534LF)
MONMSG MSGID (CPF0000) EXEC (GOTO CMDLBL (ERR1))
OPNQRYF FILE (PATNI1/CP534LF) FORMAT (PATNI2/CP534LF CP534R)
QRYSLT (‘INSMR=”S”) OPNID (QRY1)
OVRDBF FILE (CP534LF) TOFILE (PATNI2/CP534LF)
CPYFRMQRYF FROMOPNID (QRY1) TOFILE (PATNI2/OPPA + MBROPT
(*REPLACE) CRTFILE (*NO)
CLOF OPNID (QRY1)
GOTO END1
ERR: SNDPGMMSG MSG (‘Error’)
END: SNDPGMMSG MSG (‘Added’)
ENDPGM
- If PF to which you are writing this is not there then specify CRTFILE (*YES). \
- If you want to append existing rows, specify ADD in MBROPT (*ADD)
----------------------------------------------------------------------------------------------------
In a CLP program a user created CMD written in CL can accept less then given,
expect parameter only if it is No Mandatory PARM. This has been done in Taiwan
source.
-----------------------------------------------------------------------------------------------------
*CPF2103  Library already exist in Library list
CLP CPF9801  Object existence check, used with CHKOBJ command
-----------------------------------------------------------------------------------------------------
    In ILE RPG  Declaration type -> PR defines a prototype for a call and PI
     defines a procedure interface.
C  defines constant
DS  defines Data Structure
S  Standard loan field, Array, Table
-----------------------------------------------------------------------------------------------------
 In RETRN opcode
If RETURN is executed the following things occur
- If Halt Indicator is ON then it would abnormally end program and return to caller
- If Half Indicator is ON, If LR on the Program ends normally, Closes all files
    locked DS, Array, T is written and an external indicator is SETON.
- If Halt is ON and LR OFF then procedure return to calling routine. Data is
    preserved for next time it is run. Files DS are not written out.
*PARM opcode is/should always be followed by PLIST, CALL, CALLB
255 parameters  CALL
399 parameters  CALLB/PLIST
                                                                                                       20
  An externally described file in position 22/flat file can be read if specified as
   program described file in F. If DS is specified in Result, Data is directly moved to
   DS.
F FLAT1 I F             F              DISK
I DS1     DS
C              READ         FLAT1           DS1
                                                                                     21
IBM Supplied libraries
QSYS: System libraries are maintained
QHLPSYS: Online doc. for some system
QTEMP: User temp lib
QSPL: Spooling lib
Message Handling
SNDMSG
SNDBRKMSG
DSPMSG
MSGF
Device File
*PRTF
*DSPF
*TAPF
*DKTF
Data Type
P  PACKED
S  ZONED
A  CHARACTER
F  FLOATING
B  BINARY
H  HEXADECIMAL
L  DATE
T TIME
Z  TIMESTAMP
                                                               22
View data in PF
1) STRSQL
2) STRQRY
3) RUNQRY
4) DSPPFM
5) STRDFU
To provide a LOOKUP on a particular field in display file .you have to follow the
following steps
1) Declare two hidden fields of length 10 one for record level field and 2nd for field
    level field. These 2 fields have to be declared for each record separately.
 To use the fields declared in RPG/RPGLE
Check for field level should be equal to field name on which you have to show
lookup window
How to restore user name in CLP program so that name can be used in pgm
- For Reading records from a file without locking then what you have to use
Specify N in H/N/P position at C-Spec so that records can be read without locking.
To open the file OPEN opcode, so that user can handle open/close event of file you
have to specify UC in file condition.
                                                                                                    23
- Difference Between IF and SELEC
Select eliminates the need for nested IF/ELSE group, which confused when 3 OR 4
level used
Multiple ENDIF operation is not required with select group. Only one ENDSL (or
END) operation ends the group
-------------------------------------------------------------------------------------------------------
Important Points:
- In Free format, we can’t use CALL statement. For that case we have to use
  EXTPGM keyword.
Creating Commands:
-   Write a CL program where in you put the command that you want to create the
    shortcut.
-   Structure of the CL is;
    PGM
    WRKQRY
    ENDPGM
-   Suppose if you want the short cut of the WRKQRY is say “WQ”.
-   Create one more program with type CMD in the name of WQ (program name).
    And write a statement as CMD in the program.
-   Compile both the programs in QGPL, and call the first one i.e CL program.
-   After you can always use that Short command as WQ for WRKQRY.
                                                                                                    24
Debugging Issues
1) For debugging ILE PGM just use put *source  Debugging views option and
   using STRDBG you can debug the program.
   For debugging the inner call PGM use shift+F2  and by using option 1 add the
   call program to list…After PGM is loaded to list use option 5 to display source
   and set the break point
   In case of debugging ILE program through OPM Program i.e., ILE program
    called in OPM program
-   Compile the program with Debugging view = *SCRDBG
-   STRDBG to debug OPM object then use Shift+F2 to add module in list and by
    using option 5 set breakpoint in ILE PGM
2) For Debugging COBOL-ILE programs we shall use STRDBG. But while compile
   you should take care of the following parameters. ;
      a. Compile the code with Compiler Option as *SOURCE.
      b. Press Page Down & enter the Debug View as *LIST.
      c. Once the code is compiled, then continue with STRDBG.
3) While Compiling JAVA-COBOL, use the following command as the first line of
   Cobol Program;
   “PROCESS MAP NOMONOPRC NOSTDTRUNC OPTIONS THREAD
   (SERIALIZE) “, before the IDENTIFICATIONDIVISION. And the code should
   end with GOBACK rather than STOPRUN.
                                                                                   25
CPYTOIMPF:
COMP:
Arrays:
   -   Runtime
   -   Compile Time
   -   Pre Run Time
                  1. Run time Array is loaded while your program is running.
                  2. Compile Time is when your program is Created. And is a
                     permanent part of your program.
                  3. Pre run Time is loaded from an Array File.
   Defining Arrays:
   - Array name + comma (,)+ Index
   - Array name with comma & index can be max up to 6 characters.
   - Index is a Numeric field with Zero Decimal positions or Numeric constant.
                                                                                      26
Use of H-Spec Keyword (H OPTION(*SRCSTMT)):
   Main Aim: To update all the records such that sum of (RT1.RT2, RT3) should be
   added to TDR when SEX=M
   These are 2 pgm  CLLE pgm  OPNQRYCLE and OPQRYPGM
OPNQRY CLE
   PGM
   DCL &SX *CHAR LEN (1)
   DCLF FILE (TWANLIB/PRM1)
   MONMSG MSGID (CPF0000) EXEC (GOTO CMDLBL (ERR1))
   CHGVAR VAR (&SX) VALUE (‘M’)
   OPNQRYF FILE (TWANLIB/PRM1) FORMAT (TWANLIB/PRM1/PARM1R)
   QRYSLT (‘SEX = ‘M’)
   OVRDBF FILE (PRM1) TOFILE (TWANLIB/PRM1)
   MONMSG MSGID (CPF4174) EXEC (GOTO CMDLBL (CLOSE1))
   CALL PGM (TWANLIB/OPNQRYF PGM)
   CLOSE:
   CLOF OPNID (PRM1)
   SNDPGMMSG MSG (‘DONE’)
   GOTO END1
   ERR1: SNDPGMMSG MSG (‘ERROR’)
                                                                                           27
END1:
ENDPGM
QCMDCHK  Performs syntax checking for single command and optionally prompt
for the command
                                                                                                    28
Eg:
CALL QCMDCHK (‘CRTCLPGM PGM (OGPL/(23)’ 22)
MONMSG MSGID (CPF00006) EXEC (GOTO ERROR)
CPF0006 Syntax Error
 Selective prompting
 In DSP file
Specify SFLPGMQ (10)  PGMQ
        SFLMSGID
        SFLMSGKEY
In Sub file control i.e. message sub file control
In RPG 
Specify *PSSR i.e., program status data structure and specify VARNM for program
to stored
Move PGM NM to PGMQ var and call SNDMSGCLP program the message, which
you want to show
*IP you want to display more than 1 message in PGMQ change Message location
from 24 to 23/22…
---------------------------------------------------------------------------------------------------
Cobol Programs
0001.00        *------------------------*
0002.00         IDENTIFICATION DIVISION.
0003.00        *------------------------*
0004.00         PROGRAM-ID.                     PTEST1.
0005.00        *---------------------*
0006.00         ENVIRONMENT DIVISION.
0007.00        *---------------------*
0008.00         CONFIGURATION SECTION.
0009.00         SOURCE-COMPUTER. IBM-AS400.
0010.00         OBJECT-COMPUTER. IBM-AS400.
0011.00         INPUT-OUTPUT SECTION.
0012.00         FILE-CONTROL.
0013.00            SELECT IN-F            ASSIGN TO DATABASE-ZAA03P
0014.00                         ORGANIZATION IS INDEXED
0015.00                         ACCESS MODE IS SEQUENTIAL
0016.00                         RECORD KEY IS EXTERNALLY-DESCRIBED-KEY.
0017.00
0018.00            SELECT OUT-F             ASSIGN TO DATABASE-TAA99P
                                                                                                 29
0019.00                     ORGANIZATION IS INDEXED
0020.00                     ACCESS MODE IS SEQUENTIAL
0021.00                     RECORD KEY IS EXTERNALLY-DESCRIBED-KEY.
0022.00    **************************************
0023.00     DATA DIVISION.
0024.00    *--------------*
0025.00     FILE SECTION.
0026.00    *--------------*
0027.00     FD IN-F         LABEL RECORD IS STANDARD.
0028.00     01 RRVFCT-R.
0029.00       COPY          DDS-ALL-FORMATS OF ZAA03P.
0030.00     FD OUT-F           LABEL RECORD IS STANDARD.
0031.00     01 OUT-R.
0032.00       COPY          DDS-ALL-FORMATS OF TAA99P.
0033.00    *---------------------------------*
0034.00     WORKING-STORAGE                    SECTION.
0035.00    *---------------------------------*
0036.00     77 SW                   PIC 9(1) VALUE ZEROS.
0037.00     77 CNT                   PIC 9(5) VALUE ZEROS.
0038.00    *01 C-DATE                PIC 9(8) VALUE 19000000.
0039.00 K2000 01 C-DATE                     PIC 9(8).
0040.00     01 FILLER REDEFINES C-DATE.
0041.00       03 C-FILLER               PIC X(2).
0042.00       03 C-YMD                 PIC 9(6).
0043.00     01 END-DATA                    PIC X(3) VALUE "NO ".
0044.00       88 END-OF-DATA                       VALUE "YES".
0045.00    *-----------------------------*
0046.00     PROCEDURE DIVISION.
0047.00    *-----------------------------*
0048.00     SIJAK.
0049.00       OPEN         INPUT IN-F
0050.00               OUTPUT OUT-F.
0051.00 K2000      CALL "ZZCURDAY" USING                  C-DATE.
0052.00    * ACCEPT C-YMD                   FROM      DATE.
0053.00       PERFORM IN-READ THRU                     IN-EXIT.
0054.00       MOVE          A3PLAN TO              TAPLAN.
0055.00       PERFORM MAIN-RTN THRU                     MAIN-EXIT UNTIL END-
OF-DATA.
0056.00       PERFORM WRIT-RTN THRU                     WRIT-EXIT.
0057.00     END-RTN.
0058.00       CLOSE IN-F               OUT-F.
0059.00       STOP        RUN.
0060.00    *=====================*
0061.00     IN-READ.
0062.00       READ IN-F              AT END MOVE "YES" TO END-DATA
0063.00                             GO TO IN-EXIT.
                                                                          30
0064.00         IN-EXIT. EXIT.
0065.00
0066.00
0067.00         MAIN-RTN.
0068.00            IF      (TAPLAN           NOT = A3PLAN)
0069.00                   PERFORM            WRIT-RTN THRU WRIT-EXIT.
0070.00            ADD         1         TO       CNT.
0071.00
0072.00            PERFORM IN-READ THRU                          IN-EXIT.
0073.00         MAIN-EXIT.            EXIT.
0074.00
0075.00         WRIT-RTN.
0076.00            MOVE           ZEROS TO             TACNT1 TACNT2 TACNT3
TACNT5.
0077.00            MOVE           CNT TO                TACNT4.
0078.00            MOVE           C-DATE TO               TADATE.
0079.00            WRITE          OUT-R.
0080.00            MOVE           ZEROS TO SW CNT.
0081.00            MOVE           A3PLAN TO TAPLAN.
0082.00         WRIT-EXIT.           EXIT.
0083.00        *=======================*
---------------------------------------------------------------------------------------------------
0055.00         IN-READ.
0056.00            READ IN-F              AT END MOVE "YES" TO END-DATA
0057.00                                  GO TO IN-EXIT.
0058.00         IN-EXIT. EXIT.
0059.00
0060.00
0061.00         MAIN-RTN.
0062.00            IF      (A4PLAN          NOT = TAPLAN)
0063.00                   PERFORM            WRIT-RTN THRU WRIT-EXIT.
0064.00            ADD         1         TO       CNT.
0065.00
0066.00            PERFORM IN-READ THRU                          IN-EXIT.
0067.00         MAIN-EXIT.            EXIT.
0068.00
0069.00         WRIT-RTN.
0070.00            MOVE TAPLAN                  TO         SAPLAN.
0071.00            READ OUT-F                INVALID MOVE 1 TO SW.
0072.00
0073.00            MOVE CNT                 TO          TACNT3.
0074.00            IF     SW = 0
0075.00                  REWRITE OUT-R INVALID DISPLAY ' ERROR='
TAPLAN
0076.00            ELSE MOVE                 ZEROS TO TACNT5 TACNT1 TACNT2
TACNT4
                                                                                                      31
0077.00                  MOVE           SAPLAN TO TAPLAN
0078.00                  WRITE          OUT-R INVALID MOVE 1 TO SW.
0079.00            MOVE           ZEROS TO SW CNT.
0080.00            MOVE           A4PLAN TO TAPLAN.
0081.00         WRIT-EXIT.           EXIT.
0082.00        *=======================*
--------------------------------------------------------------------------------------------------
0008.00         CONFIGURATION SECTION.
0009.00         SOURCE-COMPUTER. IBM-AS400.
0010.00         OBJECT-COMPUTER. IBM-AS400.
0011.00         INPUT-OUTPUT SECTION.
0012.00         FILE-CONTROL.
0013.00            SELECT IN-F            ASSIGN TO DATABASE-ZAA02P
0014.00                         ORGANIZATION IS INDEXED
0015.00                         ACCESS MODE IS SEQUENTIAL
0016.00                         RECORD KEY IS EXTERNALLY-DESCRIBED-KEY.
                                                                                                32
   FAQ’s:
   1) Types of DS
   2) Types of DATAAREA
   3) Explain RPG LOGIC CYCLE
   4) Explain something on indicators
   5) Chain and SETLL
   6) DELETE LF member command.
   7) SFLINZ and SFLRNA
   8) EXCPT and UPDAT
Queries:
2. What is the CCSID for Arabic? Will it contain Shift In-Shift Out characters?
   -   CCSID is 420.
   -   Arabic is a single-byte CCSID without shift-in/shift-out.
   -   When you create DSPF in 5250, fields should be defined as “right-to-left” in
       input.
   -   In BCDIC Arabic characters will take 1 byte.
   -   In UTF-8, it is 2bytes.
                                                                                      33
   3. Is EXTFILE & EXTMBR works same as OVRDBF?
   - EXTFILE and EXTMBR do NOT work like OVRDBF.
   - These two OPEN the file directly without applying an Override. This improves
      open performances, as the system doesn’t have to go and check for override.
   - If override is applied, it must be applied to the file named on the EXTFILE
      keyword as the file in position 7 of the F-spec ignores overrides when EXTFILE
      and EXTMBR is used.
   4. What is QRPLOBJ?
   - System takes the backup of the programs in this.
   - Any program can be compiled while running. When the compilation is successful,
      the existing object is renamed to “Q…” & moved to QRPLOBJ.
   - The active job still uses the older version & the renamed or new one will be in
      QRPLOBJ until SIGNOFF/ RCLRSC command is issued.
   -   QRPLOBJ is cleared by IPL.
The LDA is just a space object created when the job is initiated.
When a space is created using the CRTS MI instruction, you can specify that the new
space does not have a
"context". A "context" is a library.
The Work Control Block (WCB) has a pointer to the *LDA so the access is pretty
direct/quick--even faster
than data areas.
                                                                                      34
ASP (Auxiliary Storage Pool):
Prior to the introduction of raid this was the only tool we had to provide
some sort of online recovery of data.
From a subsystem standpoint we are more interested in memory pools then ASP's
                                                                                 35
SQL RPGLE: (How to Use Cursor):
   -    Declare cursor
   -    Open Cursor
   -    Fetch the record
   -    Close Cursor
Find attached the sample code that tells the use of Cursor to fetch & process the record.
FCntpf if e          k disk
D*
DSCMPNY           S         15
DSSAL             S          5 0
D*
C/ EXEC SQL
C+ Declare cntcur cursor
C+ for select CMPNY, SAL from LAXMANLIB/CNTPF
C+ where name = 'SANGEET'
C/End-Exec
C*
C/EXEC SQL
C+ OPEN CNTCUR
C/End-Exec
C*
C/EXEC SQL
C+ FETCH CNTCUR INTO: SCMPNY,:SSAL
C/End-Exec
C*
C/EXEC SQL
C+ CLOSE CNTCUR
C/End-Exec
C*
C SCMPNY           DSPLY
C SSAL             DSPLY
C                   EVAL      *INLR='1'
                                                                                            36
How To Copy From One AS400 Box to Other Box:
FTP return codes are 3 digits followed by a space/blank and then an error message.
The first digit tells you whether the response is good, bad, or incomplete.
There are 5 possible values for the first digit:
 "1" = Positive preliminary – request initiated and another reply should follow.
 "2" = Positive completion – request was successfully completed.
 "3" = Positive intermediate – subcommand accepted, but the requested action is being held
pending receipt of further information.
 "4" = Transient negative completion – subcommand not accepted, but the error condition is
temporary and the action may be requested again.
 "5" = Permanent negative completion – subcommand not accepted, and the request did not take
place.
The third digit provides a more specific meaning and ranges from 0 to 9.
The actual message text can vary for different server systems and companies. Some companies
create their own messages using exit programs to control client actions.
    -   An open data path is the path through which all input and output operations for a file are
        performed.
    -   Usually a separate open data path is defined each time a file is opened.
    -   If you specify SHARE(*YES) for the file creation or on an override, the first program's open
        data path for the file is shared by subsequent programs that open the file concurrently.
    -   Sharing an open data path improves performance because the OS/400 system does not have
        to create a new open data path.
37