Welcome to Scribd. Sign in or start your free trial to enjoy unlimited e-books, audiobooks & documents.Find out more
Standard view
Full view
of .
Look up keyword
Like this
0 of .
Results for:
No results containing your search query
P. 1
RPG400 Tutorial

RPG400 Tutorial

Ratings: (0)|Views: 1,211|Likes:
Published by VISHNU400

More info:

Published by: VISHNU400 on Feb 07, 2012
Copyright:Attribution Non-commercial


Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less





Report Program Generator is a structural programming language originated in S/36 andS/38 systems. It was available in two versions, viz., RPG-I and RPG-II. When RPG/400was introduced in AS/400 it was the third version of the same also known as RPG-III. Itwas mainly used for report generation as the name suggests but it has become the firstchoice on AS/400 to build application.It is a fixed format, column based language, i.e, everything in this language is codedbased on the columns in a fixed format of 7 available specifications. That means aspecific intruction has to be typed in specific column only. This column arrangement alsodoes not remain the same through out the program. The column arrangement is differentdeclaration or operation.These are called as HFELICO. It is totally indicator oriented, i.e, extensive use of indicators is made in this language. The HFELICO stands for the following :H – Header Specifications used to specify the date format etc. within a givenprogram. There cannot be more than one H spec. in an RPG program.F – File Specifications used to declare the files used in an RPG program alongwith their attributes.E – Extension Specifications used to define arrays or tables. A maximum of 256arrays can be used in one RPG program.L – Line specifications used to define the no. of lines in a report etc.I – Input Specifications used to define the working data structures.C – Calculation specifications used for the main logic control. The arithmeticcalculation and logical data processing is done in this spec.O – Output specifications used to define the format of the program generatedreports.The most important thing to be remembered is that the order of these specificationscannot be altered. They should be present in the same order as they have been mentionedhere above. The following are the pages showing the coding sheets for the respectivespecifications.
 Another feature of RPG/400 is it has indicator oriented logic. Indicator is a predefinedlogical field which can either be OFF or ON. The status is changed system or bydeveloper. Most of the conditioning in programs is done using these indicators.There is a set of pre-defined indicators. In case of indicators changed by system the statusof indicator depends on the success or failure of any operation.For example 75 is one of the general purpose indicator. If it assigned by developer to aREAD operation. It is set off by system when system could read a record. Thus it helpsto decide whether requested record found. It also helps to repeat a loop till the end of file.Or in following chart we have 1P and OA indicator program can instruct system to printheading on the top of first every successive page when 1P or OA is ON.As mentioned earlier, there are many indicators used in this language to control the flowof the program. They can be categorized and tabulated as follows:
1. 1P First Page Indicator Only when thefirst page of report isencountered.Print theheadings onthe first page.2. OA OG,OVOverflow Indicators Page-break Print theheadings onthe subsequentpages.3. 01 99 General PurposeIndicatorsCould beexplicitlycontrolled.Conditional.4. L1 L9 Level Break Indicators When a keyvalue changesReport sub-total printing.5. LR Last Record Indicator When EOFoccurs.Print reportsummary orterminate theprogram.6. M1 M9 Match Field Indicator When a match-field is read.To assign anddetect andmatching
field.7. MR Match Record When a matchoccurs.Print datafrom multiplefiles.8. U1 U8 External Indicators When turnedexternally.Conditionalfileprocessing.9. KA KN,KP – KYFunction Key Indicators When a functionkey is pressed.Function Keyprocessing.
Note : A thumb rule with these indicators is that whenever a high level indicator isset on all the lower levels automatically get on. For example, when LR is on allother indicators (like L1 – L9) are automatically switched on.
There are basically two programming styles with RPG –1)
RPG Logic Cycle2)
User Logic.RPG logic cycle is best suited for report generation as it is totally controlled by thesystem whereas the user logic is best suited for user application because it is at the solediscretion of the user.1)
RPG Logic Cycle : A logic cycle is a series of steps performed by RPG to process anindividual record. In this style of programming, the system takes entire control of thefiles used and the files are opened, read and closed automatically. In this process,there are two cycles which take place, viz.,a)
One file is designated as Primary file which is processed (READ) by systemimplicitly without any READ operation on that file.b)
No loop is used to READ successive records of primary file.c)
The first cycle is the opening where the files are opened, read and records areprocessed for the first time.d)
The subsequent cycle where the rest of the records are processed, therefore,the file opening is not required here.During the cycle the calculations are done twice:a)
Detail Time : The calculations are performed after the read of every individualrecord.b)
Total Time : The calculations are performed for a group of records together.During the cycle the printing operations are performed 4 times:a)
Heading Time : The headings, titles, etc. are printed during the heading timefor eg. Company Name, Column Headings etc.

Activity (5)

You've already reviewed this. Edit your review.
1 thousand reads
1 hundred reads
anuppdas liked this
Andres liked this

You're Reading a Free Preview

/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->