P. 1
RPGLE Training Pgms

RPGLE Training Pgms

|Views: 155|Likes:
Published by api-3851615

More info:

Published by: api-3851615 on Oct 19, 2008
Copyright:Attribution Non-commercial


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





Main Procedure:(Program name is MAIN)---Option 15 to create Module dprocb1 pr da 2p 0 db 2p 0 dc 3p 0 dprocb2 pr da 2p 0 db 2p 0 dc 3p 0 c dsply a 20 c dsply b 20 c z-add 0 c 30 c z-add 0 d 30 c callp

procb1(a:b:c) c c dsply c callp procb2(a:b:d) c d dsply c seton lr Sub Procedure1(Program name is ADD)--Option 15 to create Module hnomain dprocb1 pr da 2p 0 db 2p 0 dc 3p 0 pprocb1 b export dprocb1 pi da1 2p 0 db1 2p 0 dc1 3p 0 c a1 add b1 c1 pprocb1 E Sub Procedure2(Program name is SUB)--Option 15 to create Module hnomain dprocb2 pr da1 2p 0 db1 2p 0 dc1 3p 0 pprocb2 b export dprocb2 pi da1 2p 0 db1 2p 0 dc1 3p 0 c a1 sub b1 c1 pprocb2 e


Binding Directory:(Collection of Modules or Service Programs)
All the subprocedures(Example ADD,SUB)I am going to bind with one name(example Binding1) so hereafter while creating Program I am going to bind all the modules,Just I am going to use this Binding1(Binding Directory name). To Create a Binding Directory: CRTBNDDIR BNDDIR(BINDING1) To Add modules in this Binding Directory: 1.ADDBNDDIRE BNDDIR(BINDING1) OBJ((ADD *MODULE)) 2.ADDBNDDIRE BNDDIR(BINDING1) OBJ((SUB *MODULE)) similarly u can add many modules to this Binding Birectory. How to use this Binding Directory in Program: CRTPGM PGM(PGM1) MODULE(MAIN) BNDDIR(BINDING1)

Service Program:(Collection of Modules)
In Normal Binding the Module and in use of Binding Directory,there is a problem if u change the module... Example:If u change the module means the programs which all using this module is also wants to change.... It is very difficult to find whatall Programs using this module and update it using UPDPGM. So in order to avoid this Service Programs is Created. Its also Not executable and it can be used in CRTPGM and Binding Directory. To Create Service Program: CRTSRVPGM SRVPGM(SRVPGM1) MODULE(ADD SUB) EXPORT(*ALL) Explanation: EXPORT(*ALL)---is important becauz it automatically create one signature. Based on this signature only the Program will fetch the Procedures(from ADD and SUB Module) SIGNATURE------while creating service program itself it will create signature(Hexadecimal value created based on procedures)Here u binded 2 modules(means 2 procedures)so based on these 2 procedures siganture will be created.If u r using 3 or many procedures means based on these procedures signature will be created. Example of signature is 0000000000000000000F0EEE00437647.

To see the signature: DSPSRVPGM SRVPGM(SRVPGM1) To update Service Program: If any modules updated means U can update ur service Program using UPDSRVPGM. How to use this service program in your Program: CRTPGM PGM(PGM1) MODULE(MAIN) BNDSRVPGM(SRVPGM1) So finally Our main aim to create a Main Procedures (Based on our requirements)and use the service Program whenever its necessary. Drawbacks in Using EXPORT(*ALL)While Creating Service Program:Consider Service Program is Created Using EXPORT(*ALL)with 3 procedures(Procedure name and Module Name can be same) and its Binded in CRTPGM as PGM1,PGM2.....So many Programs is using this Service Program...If I change the service program with one more Procedures(4 Procedures)means Then all the Programs(example may be 100 Pgms) have to be changed becauz its referenced by old service program with old signature but not based on one more added Procedure new signatureis created so for the same service Program 2 signature is created. So signature violation Error will Occur. In Order to avoid this Binder Language is Used. In This Binder Language for Old 3 Procedures One Signature is created and for added 4 Procedures One signature is Created. So whenever Service Program is Updated with additional Module we have to modify only Binder Language as follows.. STRPGMEXP ------------Default Current Signature EXPORT SYMBOL(PROCB1) EXPORT SYMBOL(PROCB2) EXPORT SYMBOL(PROCB3) endpgmexp STRPGMEXP PGMLVL(*PRV) ----Old Signature For Older Service program(means Signature will be there based on theses 2 Procedures) EXPORT SYMBOL(PROCB1) EXPORT SYMBOL(PROCB2) endpgmexp

Is a memory allocation for the execution of job.It holds system Resources,variables,files open etc All ILE Programs will run only in Activation Group. While creating Program using F10,U can see the activation group. 3 types of Action Group: 1.*NEW 2.*CALLER 3.Named Activation Group(Default QILE is the named Activation Group)

Here is an simple example How the variables are reused if we use Activation Group: *NEW HDFTACTGRP(*NO) ACTGRP(*new) dcounter s 10p 0 export c eval counter=counter + 1 c counter dsply c seton


Compile this Program using 14---becaus in H spec u specified Activation group. Then call it The output is 1 Then call now the output is 1 and Then also 1 and goes on .....becauz each time while execution its taking in new activation Group. Named Activation Group:. HDFTACTGRP(*NO) ACTGRP('JAGADESH') dcounter s 10p 0 export c eval counter=counter + 1 c counter dsply c seton lr Compile this Program using 14---becaus in H spec u specified Activation group. Then call it The output is 1 Then call now the output is 2 and Then 3 and goes on .....becauz each time while execution its taking in same activation Group (JAGADESH). To clear the Activation group: RCLACTGRP ACTGRP(JAGADESH) or SIGNOFF *CALLER Mostly this Activation Group can be used only for calling Program so that whatever called Program uses Activation group....The calling program can also use the same activation Group. The Advantage of using this is both can run in one activation group and varibales Reused,Open files reuse etc.

COPYBOOK(Type is RPGLE,TXT or anytype)But if u use RPGLE means Its easier to expand)
some Important code,variable declaration,exfmt,Repeated code can be used in copybook. It will expand at the time of compilation. The main aim of copybook is to avoid writing repeated code in ur program. Example:(name of the copybook is jaga) C Z-ADD 5 A 20 C Z-ADD 6 B 20 C Z-ADD 0 C 20 Program: C/COPY JAGADESH1/QUINNOX,JAGA C EVAL C=A+B





Here in this program I havent declared any variables...I used only copybook...Its expanded at the time of compilation.

Here no need of Factor1,Factor2,result etc As u like u can code.. and semicolon is mandatory... Example: fJaga if e disk USROPN c c/FREE open jaga; read jaga; dsply eno; /END-FREE ---------------------this is very important it should start from 8th line as /END-FREE c* read jaga 55 c SETON LR

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)//-->