Friday, April 18, 2014

Library, Source Physical File, Member, Record and Record Format



It is very important to understand the above jargons. All terms are related to each other in a following hierarchy.



Record & Record Format:
          The data in a file is called Record. it should be in some specific format and that format is called Record Format.

For example: On a page of paper, you have following data.



All the above detail/ data on the page is record.

Whole page is written in a pre-defined rules and that rules are specified in a template or format as mention below.

Example of Record Format.



If I want to code the above format as PF then I may code as following:

R       PFLETTERR                                       
                    SALUTATION      15A             TEXT('SALUTATION')    
                    BLNK_LINE1       80A             TEXT('BLANK LINE 1')  
                    DETAILS             500A           TEXT('DETAILS')       
                    BLNK_LINE2       80A             TEXT('BLANK LINE2')    
                    THANKS             15A             TEXT('THANKING YOU')  
                    BLNK_LINE3       80A             TEXT('BLANK LINE3')   
                    REGRADS          15A             TEXT('YOURS SINCERELY')
                    NAME                  30A             TEXT('NAME')          


Now a proper Example of Record Format & Records

Record Format – PF1R



PF1



In PF1R image:


  • it is restricted that each record (that means each line of data) will have only two columns.
  • It is restricting or telling us that any data (even blanks) in the 1st col: will be consider as CUSTOMER ID and anything in 2nd col: will be COUSTOMER NAME

In PF1 image:


  • PF1 has 3 lines of data that means it has 3 Records
  • It is a two column PF just as described by its format (PF1R).
  • First col: has ID and 2nd col: has Name.

Member:

          Member is the collection of record(s). it contains line of data in a proper
In the above PF1 example.
  • ·        PF1 is a Member
  • ·        It has 3 Records
  • ·        Record Format PF1R is for all the records in the Member PF


Source Physical File:
            Source physical file is a file which contains the sources of different types of objects. 
  • ·         It is the collection of file member(s).
  • ·         There can be up to 32767 members
  • ·        Used CRTSRCPF command to create library

·          

Library:
Library is a collection of files. Read more about Library (Here
  • ·        Used CRTLIB command to create library


Thursday, April 17, 2014

A Simple Loop Program

Here it is a simple program that print counting upto 10. it is a one of the basic programs but still it has so many advance topics and techniques. let us see the full coding first.

0001.00 DCOUNTER          S              2P 0                                                               
0002.00 D                                                                                                   
0003.00 C                   FOR       COUNTER = 1 TO 10                                                     
0004.00 C     COUNTER       DSPLY                                                                           
0005.00 C                   ENDFOR                                                                          
0006.00 C                   SETON                                            LR                              

Now, Let us parse the program line by line

0001.00 DCOUNTER          S              2P 0                                             
It is the very first line of the program.
0001.00 = line number
D = shows that it is Data Specification (RPGLE program is consists of specification such as H, F, D, I, C, . . . ). D-spec is used to declare variables
counter = variable name
S = it shows that variable is data structure (DS), single(S), constant(C)...
2 = variable length
P = data type ( few data type are character(A), Packed Decimal(P), zoned(S). 0 is showing that there is NO decimal Place

0002.00 D      (blank line)


0003.00 C                   FOR       COUNTER = 1 TO 10


C = indicate that following line is Calculation (C) Specification related. every calculation, looping, branching, program-calling is done here in C-Spec.
this line tells the compiler that a 'for-loop' has to be execute from 1 to 10.

0004.00 C     COUNTER       DSPLY

it display the value of 'counter' variable

0005.00 C                   ENDFOR      

this line complete the for loop and every thing between 'FOR' and 'ENDFOR' is part/ body of for loop. 

FOR-LOOP Syntax


FOR

.
.
.
.
ENDFOR 

0006.00 C                   SETON                                            LR        

it set on the last record(LR) indicator. which tells the compiler that end now.
A very importantand must have line in the RPG PGM. Without having this line compiler will generate following error while compiling the PGM and PGM will not compile.

 Msg id  Sv Number Seq     Message text                                               *RNF7023 40      0         The Compiler cannot determine how the program can end.        

Images




         

Saturday, January 18, 2014

AS/400 Library

A library (*LIB) on the AS/400 is an object that is used as a system directory to keep track of other objects. 
OR
In AS/400 a library is an object that can contain other objects (executable objects, source files, etc.).
Library is used to find other OS/400 objects in the database. To find an OS/400 object you need the name of the library and the name of the object.  

The AS/400 identifies objects by their qualified name, which takes the form of LIBRARY/OBJECT.  

Some important Points:

  • The AS/400 library is organized as a single-level hierarchy.
  • An object can exist in only one library.
  • Two or more objects can have the same name but they must be different types of objects.
  • A library cannot reference other libraries except for the library called QSYS. This is the only library that can access other libraries.

Certain types of the AS/400 object (database file, storage areas and executable program objects) can be compiled, copied, and stored into/from many different libraries concurrently, with the Library List hierarchy determining which instance of the object to use during execution of any application that utilizes that object name. 

Generally speaking all libraries created by IBM for use by the operating system begin with the letter 'Q'.

Some IBM Standard Libraries:

QSYS -          System Parent Library
QSYS2 -        System Library for CPI's
QHLPSYS -  Online Documentation Library for Users
QTCP -          TCP Connectivity Utilities
QAFP -          Advanced Function Printing
QGPL -         General Purpose Library
QTEMP -      Job specific temporary Library (deleted when the job ends)


References:

  • http://en.wikipedia.org/wiki/AS/400_library
  • http://pic.dhe.ibm.com/infocenter/iseries/v7r1m0/index.jsp?topic=%2Frbam6%2Frbam6objects.htm

Thursday, January 16, 2014

Predefined values and default library / directory locations for AS/400 Object Types

Objects can stored in libraries and integrated file system’s directories.
Some objects stored only in a specific Default library.
Some type of object allow the user to specify the library name at the time of object creation. If library name is not provided by the user then object will be created in current library *CURLIB by default.
One can change the current library by using the command CHGCURLIB
In case there is no current library in effect at the time of object creation then QGPL library will be used.
The other types of objects, identified by N/A (not applicable) in the Default user library column, cannot be stored in libraries or directories.
With the exception of the Dump System Object (DMPSYSOBJ) command, you cannot specify the object type in the format shown in the hexadecimal format column with commands.
  
Value
Object type
Default user library or directory
*ALRTBL
Alert table
*CURLIB
*AUTL
Authorization list
QSYS
*BLKSF
Block special file
Current directory
*BNDDIR
Binding directory
*CURLIB
*CFGL
Configuration list
QSYS
*CHRSF
Character special file
Current directory
*CHTFMT
Chart format
*CURLIB
*CLD
C/400 locale description
*CURLIB
*CLS
Class
*CURLIB
*CMD
Command
*CURLIB
*CNNL
Connection list
QSYS
*COSD
Class-of-service description
QSYS
*CRG
Cluster resource group
QUSRSYS
*CRQD
Change request description
*CURLIB
*CSI
Communications side information
*CURLIB
*CSPMAP
Cross-system product map
*CURLIB
*CSPTBL
Cross-system product table
*CURLIB
*CTLD
Controller description
QSYS
*DDIR
Distributed file directory
N/A
*DEVD
Device description
QSYS
*DIR
Directory
Current directory
*DOC
Document
QDOC
*DSTMF
Distributed stream file
N/A
*DTAARA
Data area
*CURLIB
*DTADCT
Data dictionary
library with same name as data dictionary
*DTAQ
Data queue
*CURLIB
*EDTD
Edit description
QSYS
*EXITRG
Exit registration
QUSRSYS
*FCT
Forms control table
*CURLIB
*FIFO
First-in-first-out special file
Current directory
*FILE
File
*CURLIB
*FLR
Folder
QDOC
*FNTRSC
Font resources
*CURLIB
*FNTTBL
Font mapping table
*CURLIB
*FORMDF
Form definition
*CURLIB
*FTR
Filter
*CURLIB
*GSS
Graphics symbol set
*CURLIB
*IGCDCT
Double-byte character set (DBCS) conversion dictionary
*CURLIB
*IGCSRT
Double-byte character set (DBCS) sort table
*CURLIB
*IGCTBL
Double-byte character set (DBCS) font table
QSYS
*IMGCLG
Image Catalog
QUSRSYS
*IPXD
Internetwork packet exchange description
QSYS
*JOBD
Job description
*CURLIB
*JOBQ
Job queue
*CURLIB
*JOBSCD
Job schedule
*CURLIB
*JRN
Journal
*CURLIB
*JRNRCV
Journal receiver
*CURLIB
*LIB
Library
QSYS
*LIND
Line description
QSYS
*LOCALE
Locale
*CURLIB
*MEDDFN
Media definition
*CURLIB
*MENU
Menu description
*CURLIB
*MGTCOL
Management collection
NA, or QPFRDATA if library specified using QYPSCSCA API
*MODD
Mode description
QSYS
*MODULE
Compiler unit
*CURLIB
*MSGF
Message file
*CURLIB
*MSGQ
Message queue
*CURLIB
*M36
AS/400® Advanced 36 machine
*CURLIB
*M36CFG
AS/400 Advanced 36 machine configuration
*CURLIB
*NODGRP
Node group
*CURLIB
*NODL
Node list
*CURLIB
*NTBD
NetBIOS description
QSYS
*NWID
Network interface description
QSYS
*NWSCFG
Network server configuration
QUSRSYS
*NWSD
Network server description
QSYS
*OUTQ
Output queue
*CURLIB
*OVL
Overlay
*CURLIB
*PAGDFN
Page definition
*CURLIB
*PAGSEG
Page segment
*CURLIB
*PDFMAP
Portable Document Format map
*CURLIB
*PDG
Print Descriptor Group
*CURLIB
*PGM
Program
*CURLIB
*PNLGRP
Panel group definition
*CURLIB
*PRDAVL
Product availability
QSYS
*PRDDFN
Product definition
QSYS
*PRDLOD
Product load
QSYS
*PSFCFG
Print Services Facility™ configuration
*CURLIB
*QMFORM
Query management form
*CURLIB
*QMQRY
Query management query
*CURLIB
*QRYDFN
Query definition
QGPL
*RCT
Reference code translate table
QGPL
*SBSD
Subsystem description
*CURLIB
*SCHIDX
Search index
QGPL
*SOCKET
Local socket
N/A
*SPADCT
Spelling aid dictionary
QGPL
*SQLPKG
Structured Query Language package
*CURLIB
*SQLUDT
User-defined SQL type
*CURLIB
*SQLXSR
SQL XML schema repository
*CURLIB
*SRVPGM
Service program
*CURLIB
*SSND
Session description
QGPL
*STMF
Bytestream file
Current directory
*SVRSTG
Server storage space
QUSRSYS
*SYMLNK
Symbolic link
Current directory
*S36
System/36 machine description
QGPL
*TBL
Table
*CURLIB
*TIMZON
Time zone description
QSYS
*USRIDX
User index
*CURLIB
*USRPRF
User profile
QSYS
*USRQ
User queue
*CURLIB
*USRSPC
User space
*CURLIB
*VLDL
Validation list
*CURLIB
*WSCST
Workstation user customization object
*CURLIB