Você está na página 1de 250

As400 Stuff

Table of Contents:
1. 2. 3. 4. *. -. .. 1. 2. 10. 11. 12. 13. 14. 1*. 1-. 1.. 11.

Basic........................................................................................................................13 Define library?...................................................................................................13 Define object?....................................................................................................13 What is the difference between O !" # ! and $ %&#?....................................14 What are the disad'anta(es of usin( )& o'er $ %?..........................................14 +ow you can read and write sin(le co,,and in )&?.........................................14 +ow to retrie'e a date in )&?.............................................................................1* +ow to co/y a record in e0istin( object to another object?...............................1* +ow you will a'oid ,ulti/le users u/datin( the sa,e records?........................1#0/lain W$3O45 D! and DS O45D?..................................................................1+ow to create $ %" $ %&#" )&" )&&#" 6" &6" $7" and dis/lay file?...............1What are the ad'anta(es of usin( AS8400 syste,?........................................1. What are the 'arious ty/es of Security in AS8400?.........................................11 #0/lain user /rofile and (rou/ /rofile?...........................................................12 What is &oc9? +ow you achie'e in AS8400?....................................................21 +ow you will release the loc9?........................................................................21 #0/lain about $:7)S$&O)?............................................................................21 +ow you e0ecute )& co,,and in $ %&#?......................................................21 What;s new in <4$4 and $ % =<?....................................................................21

12. )an you clear u/ the confusion in the different releases of $ % =< and OS8400 and =&#?...................................................................................................................22 ILE Concepts.........................................................................................................2* 1. 2. 3. 4. *. =nte(rated &an(ua(e #n'iron,ent >=&#?............................................................2* What is a !odule?..............................................................................................30 What is a Ser'ice ro(ra,?...............................................................................30 What is a bindin( Directory?..............................................................................31 Why =,/ort and #0/ort?....................................................................................31 a(e 1 of 250

As400 Stuff -. .. 1. 2. 10. 11. 12. 13. 14. 1*. 1-. 1.. 11. 12. 20. 21. 22. 23. 1. 2. 3. 4. *. -. .. 1. 2. 10. What is Acti'ation %rou/?..................................................................................31 7a,e So,e =&# A =@s? And tell so,ethin( about the,?....................................32 What are acti'ation (rou/s?..............................................................................33 +ow do = create and use a ser'ice /ro(ra,.......................................................34 !odules A +ow to write and reuse the,.........................................................3. What are the =&# $ % codin( /ro(ra,,in( considerations?..........................32 What O/codes are added in =&#?....................................................................41 What are the beha'ioral differences b8w O ! $ %8400 and =&#?...................41 =&# ad'anta(es o'er $ %?..............................................................................42 Define binder /ro(ra,?..................................................................................42 +ow to the create ,odule?.............................................................................42 What are the differences in )A&&" )A&&4 and )A&& ?....................................44 What is the difference between 4ind by 'alue and 4ind by reference?..........44 Define /ass by 'alue and /ass by reference?.................................................4* What are ro(ra, #ntry rocedure > # ? and Bser #ntry rocedure >B# ??. .4* Define )o/yboo9 in $ %&#?............................................................................4* +ow to create a ser'ice /ro(ra, and what are the ste/s in'ol'ed in this?....4#0/lain /rocedure used in $ %&#?.................................................................4Define source /hysical file?...............................................................................4. hysical 6iles and &o(ical 6ile............................................................................41 &ist the differences between /hysical file and lo(ical file..................................41 What are the four le'els of entries in /hysical file?...........................................42 What are the si0 le'els of entries in lo(ical file?................................................*0 #0/lain 5DB S#C and 5D6:<A&...........................................................................*0 What are the different between nonAjoin lo(ical files and join lo(ical files........*1 +ow ,any record for,ats can ha'e /hysical D lo(ical file................................*1 What is the ad'anta(e o/en Euery file?............................................................*1 #0/lain nonAjoin lo(ical file?...........................................................................*1 a(e 2 of 250

Database..................................................................................................................4.

As400 Stuff 11. 12. 13. 14. 1*. 1-. 1.. 11. 12. 20. 21. 22. 23. 24. 2*. 2-. 2.. 21. 22. 30. 31. 32. =t is /ossible to insert record to 5O=7 &6?........................................................*2 #0/lain join lo(ical file?..................................................................................*2 #0/lain self join?.............................................................................................*2 #0/lain nor,aliFation?....................................................................................-2 #0/lain the co,,and ADD 6)S:?.................................................................-2 +ow to send the ,essa(e to the screen S7D %!!S%?.................................-2 +ow you can list all the &6 of a 6?.................................................................-2 What is use of DS 66D and DS 6D?...............................................................-3 #0/lain inner join or natural join and left outer join?......................................-3 +ow to create a tri((er in AS8400?.................................................................-1 +ow will be establishin( $#6#$#7:=A& =7:#%$=:G in as8400 syste,s?..........-1 What $B7SC&S:! will do?...............................................................................0 What is a field reference file?..........................................................................0 What are the 'arious ways creatin( access /ath?...........................................0 +ow ,any record for,ats 6" &6" DS 6 and S6&?............................................1 Define 3&=S:?...................................................................................................1 Define &=S:?...................................................................................................1 Define co,/osite 9ey?....................................................................................1 =s it /ossible to create a lo(ical file whose hysical file is not in sa,e library? .1 )an you delete the record s/ace /er,anently in 6 throu(h )&?...................1 What is the difference between addin( 9eys D constraints into a /hysical file? .1 +ow to insert ,ore than one record to a /f at a ti,e? >4ul9 insert to a /f?. . ..2

33. +ow to see nu,ber of lo(ical files de/endin( on a /f? )an we declare ,ore than 20 lo(ical files fro, a sin(le /f? =s it /ossible?................................................2 34. = want to chan(e the attribute of field or want to add new field in e0istin( 6 but condition is for,at le'el identifier should not chan(e" is it /ossible?.................2 3*. 3-. !a0i,u, how ,any fields we can create under a record for,at of 6?.........2 +ow can we write &6 usin( flat file?.................................................................3 a(e 3 of 250

As400 Stuff 3.. 31. 32. 40. Why we create the hysical 6ile !e,ber?.......................................................3 )+% 6 to co,/ile the 6 without usin( the dataH............................................3 !ulti for,at &o(ical file #0a,/leH...................................................................4 Access ath I 6 and &6...................................................................................*

41. :ell ,e the differences between D42 )&= >call &e'el =nterface? and e,bedded SC&? .* 42. 43. 44. 4*. 4-. 1. 4.. 41. 42. *0. *1. *2. *3. *4. **. *-. *.. *1. *2. %eneral /oints in D428400...............................................................................6ile /ointer I after a failed chain o/eration....................................................12 What are :ri((ers?.........................................................................................12 What is the /ur/ose of BS$O 7 9eyword?.....................................................13 What is &#<#& )+#)3?...................................................................................13 What e0actly the O<$D46 does?.......................................................................13 What is the o/en Euery file?...........................................................................14 What is the different between O 7C$G6 and SC&$ %?..................................1* What are the 'arious ste/s in creatin( O 7C$G6?.........................................1* +ow the records are accessed for usin( O 7C$G6?.......................................11 What is the difference between 6!:D:A and O 7C$G6?...............................11 &ist out the Differences between a &6 and co,,and O 7C$G6?...................11 O 7C$G6 A Short e0/lanation with sa,/les in )& .........................................12 O 7C$G #0a,/le...........................................................................................24 SC&$ %&# #0a,/le........................................................................................2SC& )ursorH.....................................................................................................2. Sa,/le i,bedded SC&$ %&# /ro(ra,...........................................................22 #,bedded SC&H............................................................................................103 What is the journal?......................................................................................103 a(e 4 of 250

O<$D46....................................................................................................................13 O 7C$G6..................................................................................................................14

SC&$ %&#................................................................................................................2-

5ournal....................................................................................................................103

As400 Stuff -0. -1. -2. What are the 'arious ste/s creatin( journal?...............................................103 #0/lain )o,,it,ent )ontrol?......................................................................104 )an anybody tell why 5ournalin( is co,/ulsory before )o,,it,ent )ontrol? 104

-3. )o,,it,ent control =,/le,entation and controllin( co,,it,ent control fro, e0ternal /ro(ra,...........................................................................................104 Data Areas" Cueues" Arrays D StructuresH.............................................................104 1. What is the data area?.......................................................................................104 2. 3. 4. *. -. .. 1. 2. 10. 11. 12. 13. 14. 1*. 1-. 1.. Define &DA" %DA" and = ?...............................................................................10What is the data Eueue?..................................................................................10. #0/lain CS7DD:AC and C$)<D:AC?..............................................................10. What are the ,andatory /ara,eters for declarin( a Data Eueue?..................10. What is the co,,and to create ,enu?...........................................................101 What is the difference between )A&& and :ransfer )ontrol >:6$):&??............101 #0/lain !ulti Di,ensional Array?.....................................................................101 Define data structure and ty/es of data structure?.........................................101 +ow do = declare an array with a dyna,ic nu,ber of ele,ents?.................110 Data structure array basics..........................................................................111 )lear u/ the confusion o'er ,ulti/leAoccurrence data structures................111 Data area" Data Cueue and !essa(e CueueH...............................................113 %rou/ 5obs and %rou/ data areaH.................................................................113 Data Structure Array and #0a,/leH..............................................................11* Difference between Data area and data EueueH...........................................11* Difference between dataAstructure array and ,ulti occurrence data structure 11*

11. $ % data structure arrays i,/ro'e,ent o'er ,ulti/leAoccurrence data structures...............................................................................................................11* 12. 20. )o,/ile ti,e array" /re run ti,e array run ti,e array................................11* $76..01 data structure not allowed............................................................11-

DEBUG.............................................................................................................11.
a(e 5 of 250

As400 Stuff 1. 2. 3. 4. *. -. .. 1. 1. 2. 3. 4. *. -. +ow to Debu( a 4atch =&# $ %?......................................................................11. Debu( 'alue of /ointer?...................................................................................111 +ow do = debu( =&# /ro(ra,s? S:$=SD4 doesn;t wor9J...................................111 +ow can = debu( an =&# /ro(ra, in batch?......................................................112 +ow can = debu( an O ! /ro(ra, in batch?...................................................120 +ow can = tell if ,y /ro(ra, is runnin( in batch or interacti'e?......................121 +ow to debu( jobs in !S%W without endin( it?...............................................123 +ow do you do debu(s for =&# /ro(ra,s and +andle #0ce/tions?..................123 Programming Concepts.......................................................................................124 %eneral $ % =< ro(ra, )ycle........................................................................124 What are Static bind and Dyna,ic binds?.......................................................12* )$:47D$ % D )$:$ % %!............................................................................12+idden 6ieldsH..................................................................................................12&ast state,ent of any $ % /(, is &$?............................................................12=s )onstant can be define as a 9ey field?.........................................................12-

.. Which 9eyword is used both in subfile and subfile control record for,at of a DS 6?.....................................................................................................................12. 1. 2. 10. 11. 12. 13. 14. Define interacti'e jobs and batch jobs?...........................................................12. W+A: =S :+# D=66#$#7)# 4#:W##7 ;)O&+D%; A7D ;A&=AS;?.........................12. What;s the difference between )O7S: and <A&B#?.....................................12. )& I #O6H......................................................................................................121 &e'el )hec9 #rrorH........................................................................................121 Si(nificance of $eturn and K=7&$ L KO7.......................................................121 *Entry significance of factor 1, factor 2 and result fields............121

1*. #D:)D# D #D:W$D" O<#$&AG" $S:DS " )o,,and Attention 9ey and )o,,and 6unction 3ey and <alidity chec9H..........................................................121 1-. 1.. 11. 12. What is the difference between )A and )6 9eys?.........................................122 What is SDS?...............................................................................................122 What is the file infor,ation data structure?.................................................131 )& ara,eter 4asics.....................................................................................132 a(e 6 of 250

As400 Stuff 20. 21. 22. 23. 24. 2*. 2-. 2.. )allin( /ro(ra, :S:)A&& codeH....................................................................143 Dis/lay ro(ra, $eferences >DS %!$#6?..................................................14* Difference between KO,it and Kno /assH.....................................................14What do we ,ean by e0ternaliFin(?.............................................................141 What will 6O$ o/code will do?......................................................................141 What are the 'arious sta(es for a job after it is sub,itted?.........................142 What is an acti'ation (rou/?........................................................................142 What are the state,ents that are affected by acti'ation (rou/?.................1*0

21. +ow to see source of co/yboo9s include in a /ro(ra, while co,/ilin( or debu((in(?............................................................................................................1*0 22. 30. 31. 32. 33. 34. 3*. 3-. #0/lain 9eyword in =&#?................................................................................1*0 +ow you can schedule a job to run /eriodically?..........................................1*0 +ow you can i,/ort and e0/ort a data ty/e between 2 /ro(ra,s?.............1*0 7a'i(ation between two screens..................................................................1*0 Define indicator D !O<#A?...........................................................................1*1 Define =:#$ 8 &#A<#8DO8Dow?......................................................................1*1 #0/lain Assu,e and O'erlay?.......................................................................1*2 Why e0ternaliFe?..........................................................................................1*2

3.. What is the disad'anta(e of usin( <alidity )hec9 9eyword? +ow to o'erco,e these disad'anta(es?............................................................................................1*2 31. )hainH........................................................................................................1*3 32. Which of the followin( o/erations does 7O: Fero the field 6&DA defined as 4"0? 1*3 40. +ow can you chec9 for a records e0istence without causin( and =8O >)+A=78$#AD?? With the hel/ of 6ile =nfor,ation Data Structure" we can chec9 e0istence of records in a /hysical file. :he code is described belowH.....................1*3 41. 42. 43. 44. What is the difference between BDA:# and the syste, date?.....................1*3 Describe the difference between the DOWxx and DOUxx operations?.....................1*3 Define the purpose of the ITER operation?..........................................................1*3 List the steps/commands necessary to accomp ish the fo owin!"............................1*3 a(e 7 of 250

As400 Stuff 4*. What is the /ur/ose of the followin(?...........................................................1*4

6O$D+D$1 =6 # 3 D=S3 O$D+D$6 3$#7A!#O$D+D$61........................................1*4 =n order to rena,e the record for,at of a data base file in a /ro(ra," we can use the abo'e ste/s. ur/ose of rena,in( isH =f the record for,at na,e is si,ilar in two files and if both are used in a sa,e /ro(ra," the /ro(ra, will not co,/ile. +ence we ha'e to rena,e either of the file......................................................................1*4 4-. 4.. 41. 42. *0. *1. What is the /ur/ose of the followin( )8)O G C$ %S$)"O$D#$$.................1*4 What is the /ur/ose of the followin(? A )S$&O) >61$OW 61)O&?...............1*4 What is the difference between SFLCLR and SFLINZ?................................................1*4 Define the purpose/use for SFLRNA?......................................................................1*4 How can ou detect and hand!e a record !oc" situation?................................................1*4 How can ou detect o#erf!ow for a print pro$ra% that prints %u!tip!e !ines per c c!e?..........1**

*2. How wou!d ou desi$n the process for a ni$ht! & hi$h #o!u%e chec" producin$ process that needs to se!ect on! records that are f!a$$ed to be processed?..........................................................1** *3. +ow would you join 3 se/arate fields" a first na,e" ,iddle initial and last na,e to(ether as 1 field with /ro/er s/acin(? Gou can describe in either $ % and8or $ % =&# >=nte(rated &an(ua(e #n'iron,ent?..............................................1** *4. When %!A calls %!4 for the first ti,e %!4 e0ecutes the K=7MS$. %!4 uses the $#:$7 o/eration to return to %!A. When %!A call %!4 the second ti,e is the K=7MS$ e0ecuted?................................................................................1** **. Show 2 ways to con'ert a date fro, GG!!DD to !!DDGG >!B&: o/eration not acce/table?......................................................................................................1** '() Define the purpose of Factor * the +peration Code and ,IN*' in fo!!owin$ code HI L+ -. C ,/0D 1est2D3 %%ddDate *'.....................................................................................1**1. *2. -1. -2. -3. -4. -*. --. Describe the function of S#:&& o/eration in $ % lan(ua(e?........................1*Describe the function of S#:%: o/eration in $ % lan(ua(e?.......................1*Define a 4ob .ueue?...........................................................................................1*. Define a +utput .ueue?.......................................................................................1*. What is the function of C5/S5LF co%%and?............................................................1*. What is the function of C5/F co%%and?.................................................................1*. What is the function of CR1D65+74 co%%and?.......................................................1*. Define Subs ste%?.............................................................................................1*. a(e 8 of 250

As400 Stuff -.. -1. -2. .0. .1. .2. .3. .4. .*. .-. ... .1. .2. 10. 11. 12. 13. 14. 1*. 1-. 1.. 11. 12. 20. 22. 23. 24. 2*. 2-. What are different t pes of Subste%s?.....................................................................1*. Define a 7atch 4ob?............................................................................................1*. Describe about .uer /899?...................................................................................1*. What is the CL5 co%%and to access a .uer /899?.....................................................1*. 5urpose of +#errides?.........................................................................................1*. Define Data Structure?........................................................................................1*1 What is the purpose of Data structure?.....................................................................1*1 List and e:p!ain the different t pe of data structures?...................................................1*1 What is the purpose of D/NSL1 "e word?..............................................................1*1 What is the difference between access path and D na%ic se!ect?....................................1*2 Wh wou!d ou prefer +5N.R/F than !o$ica! fi!e?...................................................1*2 What is the difference between 5ac"ed deci%a! and Zoned deci%a!?...............................1*2 What is defau!t data t pe 2if ou define deci%a!s ;9;3 in 5h sica! fi!e?..............................1*2 What is defau!t data t pe for the fie!ds2sub fie!ds3 defined in data structures in R5<?...........1*2 When do ou e:p!icit! open fi!es and c!ose fi!es in an R5< pro$ra%?.............................1*2 What is Spoo! fi!e& wh is it re=uired?.....................................................................1*2 What is 4ob& What are the attributes of a 4ob?............................................................1*2 What is Sub>S ste%?..........................................................................................1*2 What is a De#ice fi!e?.........................................................................................1*2 How can a data area be !oc"ed after bein$ updated?....................................................1-0 What are the t pes of ob?ect authorities?..................................................................1-0 What is the use of +@R5R1F?..............................................................................1-0 What is Subfi!e?................................................................................................1-0 What are a!! the contents of subfi!e?........................................................................1-0 Can %ore than one subfi!e record be disp!a ed on one !ine?...........................................1-0 How do ou specif the nu%ber of records to ro!! in a subfi!e?.......................................1-0 How wi!! ou disp!a a particu!ar pa$e in subfi!e?......................................................1-0 How to pic" up the chan$ed records e#er ti%e in a subfi!e after the first chan$e %ade?.......1-0 What is the use of SFL-ND "e word?.....................................................................1-0 a(e 9 of 250

As400 Stuff 2.. 21. 22. 100. 101. 102. 103. 104. 10*. 10-. 10.. 101. 102. 110. 111. 112. 113. 114. 11*. 11-. 11.. 111. 112. 120. How to to$$!e between sin$!e !ine and 0u!ti > !ine disp!a of a particu!ar record in a subfi!e?.1-1 -:p!ain the difference between definin$ Subfi!e and 0essa$e>subfi!e?.............................1-1 What are the different t pes of #ariab!es a#ai!ab!e in CL?.............................................1-1 How do ou pass para%eters in CL?....................................................................1-1 What is difference between CA1& 1CA1& 7CA1?...................................................1-1 What are the different t pes of %essa$es in CL?......................................................1-1 How to trap errors in CL?..................................................................................1-1 What is the %a:i%u% !en$th of a #ariab!e na%e in CL?............................................1-1 What are the !i%itations of CL 2co%pare to R5<3 ?..................................................1-1 What is the use of Header Specification in R5</899?...............................................1-1 When wi!! D605 and D-76< opcodes be i$nored?................................................1-2 Specif different indicators used in R5<?..............................................................1-2 What are Contro! !e#e! indicators?.......................................................................1-2 What is the use of - specification in R5<?............................................................1-2 What is the use of L specs in R5<?......................................................................1-2 In which specification the report !a out can be defined?............................................1-2 How %an fi!es can be defined in F specs?............................................................1-2 How %an printer fi!es can be defined in F specs?...................................................1-2 <i#e three %ain purposes of Fi!e specification?.......................................................1-2 How do ou specif pa$e o#erf!ow indicator for printer fi!es in R5<?...........................1-2 What is a 5ri%ar Fi!e?....................................................................................1-2 Can an inde:ed fi!e be accessed in arri#a! se=uence in R5< pro$ra%?...........................1-2 What is a 5ro$ra% Described fi!e in R5<?.............................................................1-2 What is e:terna!! described fi!e?........................................................................1-2

121. Can ou specif a disp!a fi!e to be used in the fo!!owin$ %odes Input& +utput& or Co%bined %odes? 1-3 122. 123. What is %atch fie!d indicator?............................................................................1-3 What are a!! the co%pi!er directi#e state%ents?.......................................................1-3

124. Durin$ e:ecution& an R5</899 pro$ra% auto%atica!! fo!!ows a se=uence of operations for each record that is processed) 1he bui!t>in pro$ra% c c!e inc!udes the fo!!owin$ !o$ica! steps).........1-3 a(e 10 of 250

As400 Stuff 12*. 12.. 121. What are the different +pcodes a#ai!ab!e in R5< for Database access?.........................1-3 How do hand!e fi!e e:ception/error......................................................................1-3 What is +5N.R/F& 0+N0S< co%%ands...........................................................1-3

122. What are the uses of 6A):O$1" 6A):O$2 and $#SB&: field for the $ % o/eration code A$!?...........................................................................................1-3 130. +ow will you find a strin( usin( D!?..........................................................1-4 4y usin( 67DS:$ D!............................................................................................1-4 131. +ow do you read chan(ed records bac9ward in subfile?..............................1-4 7O: OSS=4&#........................................................................................................1-4 132. What is the difference between nor,al B DD:A to 6 and u/datin( usin( D6B /ro(ra,?................................................................................................................1-4 4oth are sa,e only difference is D6B allows you to add or chan(e selected fields ...............................................................................................................................1-4 133. What is the synta0 for &=S:?.......................................................................1-4 K#7:$G &=S: A$!...............................................................................................1-4 134. Which are the Strin( !ani/ulation O/codes?...............................................1-4 :#S:7" S)A7" )+#)3" )+#)3$" SB4S: D )A:.......................................................1-4 Sub Procedures:.....................................................................................................1-4 1. 2. 3. 4. *. -. .. 1. 2. 1. 2. Why Sub /rocedures are used?.......................................................................1-4 )an you use a sub /rocedure in a sub /rocedure?..........................................1-4 What are the s/ecifications used in a sub /rocedure?.....................................1-4 +ow ,any ways a sub /rocedure can /ass /ara,eters?................................1-4 +ow do you in'o9e a stored /rocedure?..........................................................1-* =s there any cycle code (enerated for the sub /rocedure?..............................1-* What are the =,/ortant freEuently used co,,ands in =&#$ % en'iron,ent? 1-* What are )OD#8400 8 <isual A(e??..................................................................1-What are !ain rocedure and a sub /rocedure?.............................................1-. #0/lain about sub files in AS8400?...................................................................1-1 !essa(e subfile record for,at 9eywords........................................................112 a(e 11 of 250

Sub 6iles.................................................................................................................1-1

As400 Stuff 3. 4. 1. 2. 3. 4. *. -. .. 1. 2. 10. 11. 12. 13. 14. 1*. 1-. 1.. +ow to create !essa(e subfile?......................................................................112 What is acti'e subfile?.....................................................................................11. )& co,,ands?................................................................................................11. Data ty/es in )&?.............................................................................................122 Strin( o/eration in )&?....................................................................................123 +ow to set the cursor /osition in /articular field in /articular /osition?..........124 +ow will retrie'e the data in data area?..........................................................124 4uilt in function in )&?.....................................................................................124 Define indicator in )&?.....................................................................................12* !essa(e subfile in )&......................................................................................12* )& /rocessin( co,,ands D /ro(ra, control co,,ands?..............................12* +ow to )& code has to chan(e to use a call /rocedure?...............................12* What are 'arious ste/s accessin( data area in )&?......................................12* What is the eEui'alent co,,and to setll *loval in )&?.................................12* <arious ty/es of ,essa(e a'ailable in )&.....................................................12What will !O7!S% co,,and in do?............................................................12. What are the state,ents" which is not used in )&&# that is used in )& ?....121 +ow to create user define co,,and?..........................................................121 =nfo...............................................................................................................122

)& ro(ra,,in(....................................................................................................11.

11. What;s the difference between )+A=7 and S#:&&? =s there a /erfor,ance ad'anta(e?............................................................................................................200 12. 20. 21. 22. 1. 2. +ow do = debu( a re,ote >i.e. NbatchN? job fro, an interacti'e job?............201 What is the new # o/eration e0tender used for?..........................................203 Why doesn;t the O)+A$ builtAin function wor9 with nu,eric 'alues?..........203 +ow does the )O7S: 9eyword wor9 with rocedure /ara,eters?...............204 $ % =< A 4uiltAin 6unctions...............................................................................20* 6i(urati'e constants in $ %&#.........................................................................213 a(e 12 of 250

4uiltAin 6unctions...................................................................................................204

As400 Stuff 3. 4. *. -. @ #0/lain ADDDB$" SB4DB$" #P:$): and :#S:?...............................................213 #0/lain )o,/ile ti,e array" loo9u/" sortAa" 0Afoot" and $un ti,e array?.........212 What is the different between $#AD# and )+A=7 O/codes?...........................223 #0/lain 4uild in function in =&#?.......................................................................223 e!erences:........................................................................................................22.

Q $eferencesH

a(e 13 of 250

As400 Stuff

Basic 1. efine li!rary" A &ibrary is a collection of objects. :y/e K&=4 that is used to (rou/ related object and to find objects by na,e. A library is a directory to a (rou/ of objects. :he nu,ber of objects contained in a library and the nu,ber of libraries on the syste, are li,ited only by the a,ount of stora(e a'ailable. All libraries are /laced in the syste, library CSGS. &ibraries /ro'ide a ,ethod for or(aniFin( objects. A library is an o/enAended directory. A library can ne'er beco,e R6B&&@ as if has no finite siFe. &ibraries the,sel'es are objects. A library contain the object na,e" ty/e" and the address #i!rary list Syste, libraryA 1* >CSGS&=4? CSGS C+& SGS CBS$SGS roduct library I2 )urrent library I1 Bser library A 2* >CBS$&=4? C% & C:#! !G&=4 When you lo(on the first library to be load is CSGS. :he syste, library is loaded at the first ti,e.

1.

efine o!$ect" #'erythin( that can be stored or retrie'ed on the syste, is 9nown as an SO45#):T. Objects e0it to ,a9e users inde/endent of the i,/le,entation used in the ,achine. :he create object instruction establish the object@s na,e and its ty/e.

a(e 14 of 250

As400 Stuff All objects are structured with a co,,on object header" and a ty/e de/endent functional /ortion. A user is not concerned with the s/ace his object occu/ies. :he syste, allocate s/ace auto,atically W$3O45 D! is used to dis/lay all object in such a library :he library the object na,e and its ty/e is BniEue. 1. %&at is t&e difference !et'een ()*, E)* and +),#E" O ! Ori(inal /ro(ra, ,odel is the old $ %8400 syste," which will not allow a /ro(ra, ty/e to call another /ro(ra, ty/e. &i9e )&" $ %" )O4O&" &8=" 4AS=) only su//orted. # ! #0tended /ro(ra, ,odel will su//ort )" AS)A&" 6O$:$A7 and other /ro(ra,,in( conce/ts. $ %&# =t su//orts ,i0ed /ro(ra, su//ort in which you can co,bine any /ro(ra, with another ty/e of /ro(ra,. =t su//orts ,odularity" co/y boo9" better call /erfor,ance. <ersion is <2$3

<ersion is <1$2

2. %&at are t&e disad-antages of using .# o-er +)," We can able to read only records but we cannot able to write or u/date or delete records. We can ha'e only one file to be used in a )& /ro(ra, We cannot able to use /rinter files in )& We cannot able to use subfile in a )& /ro(ra, 1. /o' you can read and 'rite single co00and in .#" 4y usin( S7D$)<6 co,,and. #0a,/le :y/eH )& S3A7DASA!O8)& ADD KKKKKKKKKKKKKKK 4e(innin( of data KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK 0000.01 8KADD=7% :WO 7B!4#$S K8 a(e 15 of 250

As400 Stuff 0001.00 0002.00 0003.00 0004.00 000*.00 000-.00 %! D)&6 S7D$)<6 )+%<A$ S7D$)<6 #7D %! 6=&# >S3A7DASA!O8)& S)$? $)D6!: >S#)& ? $)D6!: >S#)& ? <A$ >D$#S? <A&B# >D7B!1 U D7B!2? $)D6!: >S#)& ?

KKKKKKKKKKKKKKKKKK #nd of data KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK OB: B: 6=$S: 7B!4#$H 12 S#)O7D 7B!4#$H 12 AAAAAAAAAA $#SB&:L 0000024

AAAAAAAAAA 2. /o' to retrie-e a date in .#" 4y usin( $:<SGS<A& co,,and we can (et the syste, dates. 6or (ettin( date CDA:#. :he 'arious for,at of date are KD!G" K!DG" KG!D" KGG!D" K5O&" K5O4 3. /o' to co1y a record in e2isting o!$ect to anot&er o!$ect" 4y usin( ) G6 co,,and if you want to co/y a data one /osition to another /osition. We can (i'e the records co/yin( /osition startin( and endin( of the records. We want /articular records ,eans. We can (i'e the co,,and in sE /osition. ) G6 ta9e 64 6ile na,e >source file? H 601 &ibAna,e 7ew file na,e &ibAna,e HS3A7DASA!O H 602 HS3A7DASA!O

a(e 16 of 250

As400 Stuff HK6=$S: $e/lace HKADD HK7O HK)+A$ Start /osition #nd /osition SEl co,,and H2000 H 6=&#D #! 7O )O7D=:=O7 K%: <A&B# 40 $ecord for,at ,a//in(HK!A >add field? UD$O >delete field? 4. /o' you 'ill a-oid 0ulti1le users u1dating t&e sa0e records" :he dis/layin( the records in the screen we will be (ettin( the ti,esta,/ alon( with the actual data. Store this in out/ut data structure and while u/datin( chec9 whether the /re'ious ti,e sta,/ is the sa,e ti,esta,/ before u/datin(. =f the record is u/dated by another user than the ti,e sta,/ will be chan(ed and if it does not ,atches then throw the error ,essa(e R$ecord is already u/dated by another user@ else u/date the records with current ti,e sta,/. Program 1 Store the ti,e sta,/ and this ti,e sta,/ will co,e as an in/ut to the second /ro(ra, Program2 +ere wst,st1 contains the in/ut ti,e sta,/ and chec9 this ,atches with the database. =f ,atches u/date else send error ,essa(e. 5. E21lain %+3(45) * and 6)(45 " H1000

W$3O45 D! =f we want to list all the source 6 or files of /articular ty/e the W$3O45 D! with file ty/e as 6AS$) for source 6 =O$ Kfile for listin( all the files e0tra can be (i'en. a(e 17 of 250

As400 Stuff DS O45D =f we 9now library na,e and object na,e and we want to 9now the source 6 where it is residin( then DS O45D with o/tion as Kser'ices instead of basic will (i'e the source 6 na,e. 1. /o' to create +),, +),#E, .#, .##E, )7, #7, )+8, and dis1lay file" $ % $ %&# )& )&&# )&&# 6 &6 $7 DS 6 Aby usin( )$:$ % %! co,,and Aby usin( )$:47D$ % )o,,and >or? 14 Aby usin( )$:)& %! co,,and Aby usin( )$:47D)& Aby usin( )$:)&!OD8)$: %! co,,and Aby usin( )$: 6 co,,and Aby usin( )$:&6 co,,and A by usin( )$: $:6 co,,and Aby usin( )$:DS 6 co,,and

$ %&# Aby usin( )$:$ %!OD >or? 1* 8)$: %! co,,and

2. %&at are t&e ad-antages of using 96:400 syste0" AS8400 is desi(ned and builds as a total syste,. :his ,eans that facilities such as relational database and networ9in( ca/ability >and ,uch ,ore? are fully inte(rated into the o/eratin( syste, and ,achine. :he user co,,unication with all these functions throu(h a sin(le control lan(ua(e &ayered ,achine architecture Object orientation Sin(leAle'el stora(e +ierarchy of ,icro/rocessors Security le'els &ayered ,achine architecture :his insulates users fro, hardware characteristics. =t enables the, to ,o'e to new hardware technolo(y at any ti,e" without disru/tin( their a//lication /ro(ra,s. We can able to chan(e any layer without affectin( the other layer. =f any /roble, occurs in OS" then we can wor9 with a//lication /ro(ra, inde/endently and this is the ,ajor ad'anta(e of AS8400 syste,. Object orientation a(e 18 of 250

As400 Stuff #'ery that can be stored or retrie'ed on the syste, is 9nown as an SobjectsT. Objects e0ist to ,a9e users inde/endent of the internal structure of the ,achine. Sin(leA le'el stora(e =t /ro'ides conti(uous ,e,ory between ,ain stora(e and dis9 stora(e. =t /ro'ides authority to add any dis9 s/ace so that user can access it without any /roble,. :here is no need for the user to thin9 where to store the a//lication /ro(ra,. +ierarchy of ,icro/rocessors <arious ty/es of ,icro/rocessors are used in AS8400. #ach and e'ery ,icro/rocessor is allocated for s/ecific /ur/ose. =f one chi/ is for in/ut o/eration and other for out/ut then we can do both in/ut and out/ut o/eration since both the ,icro/rocessor can /erfor, inde/endently. Security le'els =t will list the 'arious security /ro'ided by the syste,. 7o security assword security $esource security OS security )ertifiable security

1. %&at are t&e -arious ty1es of 6ecurity in 96:400" AS8400 is desi(ned for business that reEuires le'els of security ran(in( fro, nothin( at all to full (o'ern,ent certifiable security. 4y settin( a syste, 'alue" we can confi(ure fi'e increasin( le'el of security. 7o security assword security $esource security OS security )ertifiable security When AS8400 is confi(ured" three syste, 'alues dealin( with security need to be s/ecified. :hese 'alues are CABD5$&" C!APS=%7 D CS#)B$=:G. ;6E.<+=>?@ :his syste, 'alue deter,ines the le'el of security enforce,ent. S831 and the ori(inal AS8400 only had three of syste, security. At <=$3 of OS8400 the fourth le'el of security was added" and the fifth le'el of security was added at <2$3. :he 'alid 'alues for CS#)B$=:G are 10"20"30"40"*0. a(e 19 of 250

As400 Stuff ;*9A6=,8@ :his syste, 'alue deter,ines the ,a0i,u, nu,ber of si(n on atte,/ts allowed. =f the nu,ber of unsuccessful atte,/ts to si(n on to the syste, e0ceeds this nu,ber" the ter,inal or de'ice that atte,/ted the si(n on is 'aried off. ;9< 5+#@ AS8400 su//orts an o/tional security auditin( function. =f this function is s/ecified" certain security e'ents are journal. :he s/ecific e'ents that are lo((ed in the security audit journal are deter,ined by the 'alue s/ecified in the CABD5$& syste, 'alue and the le'el of syste, security s/ecified. #e-el 10@ 8o security Syste, is shi//ed with ,ini,u,Asecurity le'el and doesn@t reEuire any /assword to si(n on. =f user /rofile doesn@t e0ists with the sa,e na,e as the Bser id the syste, creates the user /rofile with that na,e. #e-el 20@ )ass'ord security !ini,u, security is acti'e and /assword is reEuired to si(n on. :he user /rofile ,ust already e0ist for the user before we can si(n on the syste, #e-el 30@ +esource security assword security is acti'e and user ,ust s/ecify (i'en authority to resources. :his le'el is reco,,ended because the syste, doesn@t (i'e the user authority to access the entire object on the syste, after the user si(n on. #e-el 40@ (1erating syste0 security assword security" resource security and OS inte(rity are acti'e. Bser ,ust be es/ecially (i'en authority to resources this le'el /ro'idin( ,ore security than le'el 30. All atte,/ts to access object usin( interfaces that are not su//orted fail. ro(ra,s that contains restricted instructions will not co,/ile a(e 20 of 250

As400 Stuff Bsers sub,ittin( jobs usin( the job descri/tion containin( the user /rofile na,e ,ust ha'e KBS# authority to user /rofile. #e-el 50@ .2 le-el security All the le'el 40 security attributes are included at le'el *0" and in addition so,e of the interfaces are ,odified to ,eet the )2 standards. 1. E21lain user 1rofile and grou1 1rofile" Bser /rofiles are used to identify users to the syste,s and 'erify authorities on the syste, >DS BS$ $6" )+%BS$ $6" #D:O45AB:? Bser /rofiles tell the syste, who can si(n on and what functions the user can /erfor, on the syste, on the syste, resources after si(nin( on. :he security officer or security ad,inistrator can create it. :he user /rofile defines the followin( ca/abilities for a /articular user Bser class Object owned and authoriFed AuthoriFation of objects ri'ile(ed instructions assword )urrent library =nitial /ro(ra, and ,enu Deli,itedAca/ability user &i,it de'ice session !a0i,u, stora(e allowed riority li,it S/ecial en'iron,ent <ser class When identifyin( a user on the syste, you can s/ecify the user class in the user /rofile. AS8400 has fi'e user classes that deter,ine the le'el of syste,@s access a user is /er,itted. :he fi'e user classes" startin( the hi(hest le'el of access" are Security officer >KS#)O6$? Security ad,inistrator >KS#)AD!? ro(ra,,er >K %!$? Syste, o/erator >KSGSO $? Bser >KBS#$? 9ut&oriBation of o!$ects

a(e 21 of 250

As400 Stuff Object authority" or the ri(ht to user to use or control an object co,es in two cate(ories. Object ri(hts Data ri(hts (!$ect rig&ts Object ri(hts are concerned with the object itself. Object ri(hts assi(n a user the followin( authority O/erational ri(hts >KO #$? Object ,ana(e,ent ri(hts >KO45!%:? Object e0istence ri(hts >KO45#P:? (1erational rig&t C*()E+D :he authority to use an object" loo9s at its descri/tion" and restores it. A user ,ust ha'e o/erational ri(hts to a /ro(ra, to e0ecute it. (!$ect 0anage0ent rig&ts C*(45*,>D :he authority to (rant and re'o9e and user ri(hts ,o'e and rena,e object" and ,e,bers to database file. (!$ect e2istence rig&ts C*(45EA>D :he authority to delete" free stora(e" sa'e restore or transfer ownershi/ of an object. ata rig&ts Data ri(hts a//ly to the data contained within the object. :y/es of data ri(hts $ead >K$#AD? :he authority is to retrie'e the contents of an object entry. Add >KADD? :he authority is to add entries to an object. 6or e0a,/le addin( records to a database file reEuires ADD ri(ht for the library. B/date >KB D? :he authority to chan(e the entries in an object reEuires B D ri(ht for the file. Delete >KD&:? :he authority is to re,o'e object in an object. 6or e0a,/le deletin( a /ro(ra, fro, a library reEuires D&: ri(ht for the library.

a(e 22 of 250

As400 Stuff Deletin( records for a database that reEuires D&: ri(hts the database file. 1. %&at is #ocE" /o' you ac&ie-e in 96:400" :o (i'e the access /er,ission for database file. :he &oc9s are /ro'ided by AS8400 syste, itself. :y/e of loc9 Share loc9 :he share loc9s only readin( o/eration > 6 file?. #0clusi'e loc9 :he e0clusi'e loc9 to /erfor, insert" u/date" and delete o/erations. 1. /o' you 'ill release t&e locE" 4y usin( $)&$S) V$eclai, $esourceW co,,and we can release the resources only. B7&O)3 or )+A=7 >7? co,,and also hel/s to release the loc9. 4y usin( W$3O45&)3 co,,and and ta9e 64. 2. E21lain a!out +>8.6+#(." :y/e G >Ges? in the Select /ara,eters /ro,/ts to define /ara,eters for the $:7)S$&O) 9eyword on the Define $eturn )ursor &ocation dis/lay. 3. /o' you e2ecute .# co00and in +),#E" 4y usin( C)!D#P) co,,and we can e0ecute )& co,,and in $ %&#. :wo /ara,eters will be called use in the )& co,,and to be e0ecuted and second is the len(th of the co,,and. 4. %&atFs ne' in G4+4 and +), =G" :here are a few si(nificant enhance,ents in $ % =< in OS8400 <ersion 4" $elease 4. :he H./9+ builtAin function has been fi0ed. =t now functions li9e it was su//osed to in the first /lace. Gou can wra/ a nu,eric 'alue in O)+A$ and a nicely edited character for, of the nu,ber is returned. :he edited for, includes the deci,al" tri,,ed off leadin( blan9s" and a ne(ati'e si(n. :he 7(+ loo1 /ro'ide free for,at 'ersion of DO o/eration code. With the 6O$ o/eration" you can be(in a loo/ o/eration and continue iteratin( a(e 23 of 250

As400 Stuff throu(h the loo/ until a 'ariable eEuals a li,it 'alue. :he synta0 for the 6O$ o/eration is enhanced with the :O" 4G and DOW7:O 9eywords. :he :O o/eration indicators the u//er li,it for the loo/in(" while the 4G 9eyword identifies the incre,ent 'alue for the loo/ counter. Alternati'ely" you can s/ecify the DOW7:O 9eyword to loo/ bac9wards fro, a lar(e 'alue to a s,all 'alue. :he ()E8()> 9eyword is added to the +eader s/ecification. :his 9eyword can be used alon( with its one and only 9eyword K=7MO6& to cause o'erflow indicators to be set off when their corres/ondin( /rinter file is closed and then reAo/ened durin( the /ro(ra,. =n subroutines" the #E9GE6+ o/eration can now be used to e0it a subroutine i,,ediately. #ffecti'ely this is a N(lorified (otoN o/eration that branches to the #7DS$ state,ent of a subroutine. 5. .an you clear u1 t&e confusion in t&e different releases of +), =G and (6:400 and =#E" $ % =< is the ne0t (eneration of the $ % lan(ua(e. $ % === is the ori(inal 'ersion of AS8400 $ %8400. :he na,e NAS8400 $ %8400N is that (i'en to the =4! co,/iler /ac9a(e for distribution on the AS8400. :his co,/iler /ac9a(e co,/iles 'arious 'ersions of $ %" includin( $ %== and at least two releases of $ %===.As of OS8400 <ersion 3 release 1" =4! chan(ed the na,e of this co,/iler /ac9a(e to NAS8400 =&# $ %8400N. :he reason for this na,e chan(e was to identify that fact that the co,/ile now includes a 'ersion of $ % that tar(ets the =nte(rated &an(ua(e #n'iron,ent >=&#?" which is $ % =<.=&# was first shi//ed in OS8400 <ersion 2" $elease 3. +owe'er" only the ) lan(ua(e co,/iler /roduced code that tar(eted this en'iron,ent. 6irst" a word about =&#" =&# is the new" Nnati'eN runti,e en'iron,ent for ro(ra,s" on the AS8400. Bnder OS8400 <ersion 2 $elease 3" =4! introduced a new /ro(ra, ,odel. :his basically ,eans that new features and interfaces beca,e a'ailable. +owe'er" =4! did not just /ort so,e runti,e en'iron,ent to the OS8400 o/eratin( syste," it actually reAwrote code" and wrote new code that" essentially" chan(ed the way OS8400 wor9s. :his new code /ro'ides su//ort for a ,i0ed set of hi(hAle'el lan(ua(es. re'iously" $ % and )& had their own little runti,e en'iron,ent" )O4O& had its ownX ) had its own" and so on. Bnder =&#" all /ro(ra,,in( lan(ua(es run in =&#. :he sa,e Nen'iron,entN is used for )O4O&" )" $ % and )&. +owe'er" to ta9e ad'anta(e of =&#" new co,/ilers needed to be created. As for $ %" rather than con'ert the e0istin( $ %== and $ %=== co,/ilers" =4!" who was desi(nin( a new 'ersion of $ % anyway" decided to tar(et =&# with the new co,/iler. :his would si,ultaneously /ro'ide a new 'ersion of $ % and an =&# tar(eted co,/iler.

a(e 24 of 250

As400 Stuff Names Are Important A (ood friend of ,ine once said" N7a,es are i,/ortantN in the /ro(ra,,in( world. =f a field is called N$hinocerosN" does it re/resent its use or /ur/ose? O9ay" so /erha/s in traditional $ % N=(uanaN is a better choice for this e0a,/le. >Shorter na,e? Durin( the de'elo/,ent of $ % =<" two distinct issues arose. 6irst" the internal na,e for $ % =< was N=&# $ %N. :his was not a code na,e" but rather the na,e =4! used to refer to the new co,/iler. After all" it was tar(etin( =&#X why not refer to it as N=&# $ %N? Second" the reAarchitecture of $ % ca,e into Euestion. Bnfortunately" the internal na,e N=&# $ %N be(an to be lea9ed out to the /ublic. Se'eral ,a(aFine writers and =4!ers not in'ol'ed in the de'elo/,ent of $ % =< continued to use the ter, N=&# $ %N when referrin( to $ % =<. = su//ose these /eo/le still refer to the AS8400 as SilverLa"e or /erha/s e'en #l$mpic. :hen when =4! announced the co,/iler /ac9a(e or /roduct na,e as NAS8400 =&# $ %8400N it only added to the confusion. =4! dro//ed the ball when /ro,otin( the $ % =< na,e. :hey are" after all" set u/ to ,ar9et their /roducts with their /roduct na,es. :he na,e of one /ro(ra,,in( lan(ua(e included in a /roduct that contains nearly se'en full co,/ilers isn;t hi(h /riority. $ % =< is the 'ersion of $ % that tar(ets =&#. OS8400 <3$1 co,/atible $ % =< can also tar(et what is now called Nthe ori(inal /ro(ra, ,odelN or si,/ly O !. O ! is just a na,e that has been (i'en to the ori(inal runti,e en'iron,ent of $ % and )& under OS8400. :his is the en'iron,ent in which $ %=== and )& run. Bnder =&#" howe'er" the ori(inal nati'e en'iron,ent is e,ulated" that is" =&# isn;t an en'iron,ent at all" it is native OS8400" whereas" O ! is now an en'iron,ent under =&#. So,e 'ery cle'er /ro(ra,,in( and desi(n went into this" don;t you thin9? 7ot 'ery ,any other o/eratin( syste,s" if any" /ro'ide this 9ind of continuity. RPG IV -- Release w at! $ % =< was first shi//ed with OS8400 <ersion 3" $elease 1. :his is now referred to as $ % =< release 1. 4ut don;t worry about re,e,berin( releases of $ % =<. Bnder OS8400 <ersion 3" $elease -" =4! enhanced $ % with /rocedures" ,any ,ore builtAin functions" and se'eral new data ty/es. :his is referred to as $ % =< release 2. :hen" OS8400 <ersion 3" $elease 2 was announced. =t brou(ht the ori(inal release of $ % =< >on the )=S) bo0es? u/ to the sa,e le'el as $ % =< under <3$-. Are you confused yet? !e tooJ Bnder OS8400 <ersion 3" $elease ." =4! added a cou/le of enhance,ents" ,ost notably they increased the len(th of a field na,e to a nu,ber so lar(e not e'en ,a(aFine authors that don;t write realAworld code could co,/lain about it any,ore. :hey also added one or two new data ty/es" roundin( out $ % =< so that it su//orts all AS8400 data ty/es" e0ce/t 'ariable len(th fields. :his 'ersion of $ % =< is 9nown as $ % =< $elease 3. :he followin( table identifies the current releases of $ % =<. 7ote that $ % =< releases do not necessarily coincide with releases of the o/eratin( syste,.

a(e 25 of 250

As400 Stuff

$ % =< $elease 1 2 2 3 4 4

OS8400 <ersion8$elease

)=S) or $=S)

<3 $1 <3 $<3 $2 <3 $. <4 $2 <3 $* >s/eculation? See note 1 <4 $3 <4 $4 >6ebruary 1222? <4 $* >Su,,er 2000?

)=S) $=S) )=S) $=S) $=S) )=S)

* * -

$=S) $=S) $=S)

8(>E 1H =t is s/eculated that =4! ,ay shi/ a final Nclean u/N release of OS8400 for )=S) that would included a lar(e le'el of co,/atibility with OS8400 <4 $*. :he release le'els of $ % =< are only i,/ortant if you want to 9ee/ trac9 of that 9ind of thin(. One disa//ointin( issue is that unless you stay on the ,ost current release of OS8400" you don;t (et all the cool new features in $ % =<. #'en if you stay current" you can;t tar(et /rior releases if you use any of the new features. =n fact" e'en if you use a new feature that doesn;t de/end on an o/eratin( syste, enhance,ent" it can;t be used for bac9 releases. :his is because of the way the :%:$&S >tar(et release? feature has been i,/le,ented. 4asically" if you;re on <4 $2 and you do a :%:$&S><3$2!0? the co,/iler calls the actual co,/iler for <3 $2. =t doesn;t ha'e a builtAin synta0 chec9er that says N:his feature reEuires an OS8400 u/(rade so don;t allow it" or this one is o9ay so acce/t it.N =t is callin( the sa,e NbinaryN co,/iler code that is on any old <3 $2 syste,. :his ,eans" for e0a,/le" a(e 26 of 250

As400 Stuff that if you want to ta9e ad'anta(e of the new co,/iler directi'es" but you often ha'e to tar(et a /rior release" you can@t use those directi'es. 6or e0a,/le" 8=6 D#6=7#D does nothin( for the e0ecutable code that;s (enerated" but is not su//orted when :%:$&S><3$2!0? is s/ecified. X> 4u,,erJ? So now we 9now about $ % =< release le'els and how the ter, N=&# $ %N (ot into our 'ocabulary. So let;s clear u/ another ter," the na,e of the $ % lan(ua(e. :he bi( one is the ter, N$ %8400N. :here is not /ro(ra,,in( lan(ua(e called N$ %8400N. :he lan(ua(e ,ost often called N$ %8400N is $ %===. +owe'er" bac9 in the Syste,831 days" the Syste,831 $ % lan(ua(e was called $ %===. When the AS8400 was announced" /ro(ra,,ers wanted to (i'e the,sel'es an ad'anta(e on their rYsu,Y. So they be(an callin( AS8400 $ %===" N$ %8400N. :hen to ,a9e ,atter worse" when $ % =< was announced" /ro(ra,,ers thou(ht that the nu,ber N=<N in N$ % =<N was less than the N400N in N$ %8400N. So they decided to call $ % =<" N=&# $ %N. Well let;s set the record strai(ht. :he table below lists the $ % lan(ua(e na,es" their incorrect na,e" and the /ro/er na,e. .o00only used %rong 8a0e $ %83$ %831 7or0al 8a0e )ro1er CcorrectD 8a0e

Syste,83-Aco,/atible $ %== Syste,831Aco,/atible $ %=== $ %=== $ % =<

$ %== $ %===

$ %8400 =&# $ %

$ %=== $ % =<

I"# Concepts 1. =ntegrated #anguage En-iron0ent C=#ED =&# is an architectural chan(e to lan(ua(e co,/ilers and the runti,e characteristics of AS8400 /ro(ra,s. =t is an e0tension to the architecture which ,eans that your e0istin( /ro(ra,s continue to run without chan(in( and reco,/ilin(. =&# is a'ailable with <ersion 2 $elease 3 of OS8400. a(e 27 of 250

As400 Stuff =nte(rated &an(ua(e #n'iron,ent is ti(htly inte(rated into the O/eratin( Syste,8400. :he 9ey benefits for the new =&# en'iron,ent areH #anguage =ntegrationH A//lication /ro(ra,s are de'elo/ed usin( the lan(ua(e ,i0 best suited to /erfor, each reEuired function. +eusa!ilityH )ode fro, su//orted lan(ua(es is di'ided into s,aller" reusable" ,ore lo(ical ,odules that co,/ile faster and reEuire less ,aintenance o'er their life. )erfor0anceH )a/ability is /ro'ided to o/ti,iFe code in co,/uteAintensi'e a//lications and to reduce the ti,e to /erfor, interA/ro(ra, calls. =nte(rated &an(ua(e #n'iron,ent increases de'elo/er /roducti'ity by /ro'idin( the ca/ability to di'ide code into s,aller" ,ore lo(ical units that co,/ile faster. :he syste, binder co,bines the co,/iled ,odules to create the a//lication /ro(ra,. =n addition" the se/aration of co,/ilation and bind ste/s /ro'ides ,ore fle0ibility /ac9a(in( the a//lication. :he new source le'el debu( tool that su//orts the =&# lan(ua(es /ro'ides enhanced ca/ability o'er the syste, debu((er with the new feature to debu( at the source or listin( le'el of the /ro(ra,. Ste/" brea9/oint" and conditional brea9/oint functions ha'e been /ro'ided. #0/ressions are entered and e'aluated usin( the synta0 of the /ro(ra,,in( lan(ua(e bein( debu((ed. :he current syste, debu( facility re,ains unchan(ed for /ro(ra,s de'elo/ed outside =&#.

=&# offers nu,erous benefits not found on /re'ious releases of the AS8400 syste,. :hese benefits includeH 1. 2. 3. 4. *. -. .. 1. 2. 4etter call /erfor,ance !odularity !ulti/leAlan(ua(e inte(ration #nhance,ents to the =&# co,/ilers $eusable co,/onents )ontrol o'er a//lication runAti,e en'iron,ent )ode o/ti,iFation :ool a'ailability 6oundation for the future

=n addition" =&# offers co,,on runAti,e routines used by the =&#Aconfor,in( lan(ua(es. !any of the a//lication /ro(ra, interfaces >A =s? are also /ro'ided as bind able >ser'ice? /ro(ra,s. :his allows your a//lications to use A =s and to (et faster =&# call /erfor,ance. :hese offAtheAshelf co,/onents /ro'ide such ser'ices asH a(e 28 of 250

As400 Stuff Date ,ani/ulation !essa(e handlin( !ath routines Acti'ation %rou/s Ser'ice ro(ra,s 1. 4etter .all )erfor0ance An =&# co,/iler does not /roduce a /ro(ra, that can be run. =nstead" it /roduces a ,odule object >K!ODB&#? that can be co,bined" or bound" with other ,odules to for, a sin(le run able unit" or /ro(ra,. =&# /ro(ra,s are called just as you call /ro(ra,s in your current a//lications. A benefit of this bindin( /rocess is that it hel/s to reduce the o'erhead associated with callin( /ro(ra,s by reducin( the nu,ber of e0ternal calls. 4efore =&#" only dyna,ic >or e0ternal? /ro(ra, calls were a'ailable to the a//lication /ro(ra,,er. With =&#" two 9inds of calls are a'ailableH Dyna,ic >or e0ternal /ro(ra,? calls V#.(.H ro(ra, )allsW Static >or bound? calls V#.(.H Ser'ice ro(ra, )allsW :he /erfor,ance of dyna,ic calls in =&# /ro(ra,s is fairly close to e0istin( call /erfor,ance. +owe'er" bound calls offer better /erfor,ance than dyna,ic calls. :hus" the bindin( ca/ability and the i,/ro'ed call /erfor,ance that results ,ay encoura(e you to de'elo/ your a//lications with a ,ore ,odular desi(n. 2. *odularity A ,ore ,odular a//roach to /ro(ra,,in( /ro'ides nu,erous benefits to you" includin(H 6aster co,/ilation because the units of code to co,/ile are s,aller >#s/ecially reco,/ilin( durin( de'elo/,ent?. 4etter /ro(ra,,er wor9 load distribution. O//ortunities to both /urchase and sell indi'idual ,odules of code. =ncreased reusabilityH !odules written for a s/ecific function can be bound into se'eral /ro(ra, objects. Si,/lified ,aintenanceH !aintenance ,ay be reEuired in only a sin(le ,odule.

3. *ulti1leI#anguage =ntegration a(e 29 of 250

As400 Stuff With your current a//lication" you can ,i0 different lan(ua(e /ro(ra,s" such as $ %" )O4O&" and ). +owe'er" to access code written in another lan(ua(e" your current a//lication ,ust /erfor, a dyna,ic call to a se/arate /ro(ra,. :he /erfor,ance cost of the dyna,ic call to a /ro(ra, and the inconsistencies between lan(ua(e beha'iors so,eti,es co,/licate the ,i0in( of lan(ua(es. With =&#" ,odules written in any =&# lan(ua(e can be bound to ,odules written in the sa,e or any other =&# lan(ua(e. 6or e0a,/le" a ,odule of code written in =&# )8400 >/erha/s a floatin(A/oint calculation? can be bound with ,odules written in =&# $ %8400" =&# )O4O&8400" =&# )8400" or =&# )&. :his /roduces a better /erfor,in(" and ,ore easily ,ana(ed a//lication. =n addition" you can acEuire ,odules written in a 'ariety of lan(ua(es" without needin( to /roduce the code yourself. :he A =s that =4! /ro'ides for =&# are just the be(innin(. <endors ha'e ,ore freedo, to sell >and a//lication /ro(ra,,ers to buy? libraries of routines for any co,,only used function" such as ta0 calculations. :hey can be written in any lan(ua(e and can be bound for better /erfor,ance. 4. En&ance0ents to t&e =#E .o01ilers :he =&# co,/ilers ha'e so,e si(nificant new function included as /art of the lan(ua(e. :his is /articularly true for =&# $ %8400" which is based on the $ % =< lan(ua(e definition. !any lon(Astandin( reEuests fro, $ % /ro(ra,,ers ha'e been addressed in the =&# $ %8400 co,/iler" includin( the followin(H 10Acharacter field na,es 6reeAfor, lo(ical and ,ath e0/ressions Date and ti,e data ty/es and o/erations #0ternal data ite,s >data e0/ort? B//ercase and lowercase source 6ileAle'el field /refi0 su//ort ointers

6or ,any /ro(ra,,ers" the /ri,ary ,oti'ation for ,o'in( to =&# is to (et access to the function that =&# lan(ua(e su//ort /ro'ides. 5. +eusa!le co01onents =&# allows you to select /ac9a(es of routines that can be blended into your own /ro(ra,s. $outines written in any =&# lan(ua(e can be used by all AS8400 =&# co,/iler users. :he fact that /ro(ra,,ers can write in the lan(ua(e of their choice ensures you the widest /ossible selection of routines.

a(e 30 of 250

As400 Stuff :he sa,e ,echanis,s that =4! and other 'endors use to deli'er these /ac9a(es to you are a'ailable for you to use in your own a//lications. Gour installation can de'elo/ its own set of standard routines" and do so in any lan(ua(e it chooses. 7ot only can you use offAtheAshelf routines in your own a//lications. Gou can also de'elo/ routines in the =&# lan(ua(e of your choice and ,ar9et the, to users of any =&# lan(ua(e.

6. .ontrol o-er 911lication +unI>i0e En-iron0ent =&# allows you to use better control o'er your a//lication and the resources it uses. Gou can s/ecify that a (i'en =&# /ro(ra, run in a /articular area within a job. :his area within a job is called an acti'ation (rou/. Gou can assi(n a na,e to the acti'ation (rou/ within the job. :hen" =&# /ro(ra,s and ser'ice /ro(ra,s can be created to use the na,ed acti'ation (rou/. :hus" you can use acti'ation (rou/s to set u/ lo(ical boundaries within the job to se/arate the a//lications. Within these boundaries" an acti'ation (rou/ has e0clusi'e use of the resource" such as o/en data /aths for the files used in the a//lication. Bsin( acti'ation (rou/s to isolate a//lications can also ,a9e it easier to end an a//lication in a job. =t aids in cleanin( u/ its resources >such as o/en files and acti'e /ro(ra,s? without disturbin( resources associated with other a//lications acti'e in the job. $ % /ro(ra,,ers ,i(ht thin9 of this techniEue as a 9ind of a//licationAle'el &$ indicator. 6or e0a,/le" it is a way to end an entire a//lication rather than endin( one /ro(ra, at a ti,e. 7. .ode (1ti0iBation :he new =&# co,/ilers and the associated OS8400 translator ha'e ,ore ad'anced o/ti,iFation techniEues built into the,. =n so,e cases" these new le'els of o/ti,iFation ,ay lead to i,/ro'ed /erfor,ance of e0istin( code. At co,/ilation ti,e" the /ro(ra,,er can select the desired le'el of o/ti,iFation for each /iece of code. 8. >ool 9-aila!ility :he ,ajority of tools for de'elo/ers in the co,/uter industry today are written in the ) lan(ua(e. With =&# bindin( ca/ability and i,/ro'ed o/ti,iFation" these ) lan(ua(e a//lications run faster. =n addition" they /erfor, better than they did with the /re'ious )8400 co,/iler. :herefore" we antici/ate that ,any tool 'endors will be(in to add their tools to the AS8400 to attract a new ,ar9et/lace for their /roducts. a(e 31 of 250

As400 Stuff !a9in( use of the ) lan(ua(e offers you a (reater choice ofH )AS# tools" 6ourthA(eneration lan(ua(es >4%&s?" #ditors" Debu((ers.

9. 7oundation for t&e 7uture =n addition to the increased o//ortunity to o/ti,iFe your a//lications with the current =&# co,/ilers" you can loo9 forward to e'en ,ore si(nificant enhance,ents. :he ,o'e toward objectAoriented /ro(ra,,in( lan(ua(es and 'isual /ro(ra,,in( tools increases the need for the ca/abilities /ro'ided by =&#. A//lications constructed of lar(e nu,bers of s,all" ,odulariFed" reusable co,/onents that efficiently transfer control a,on( the,sel'es offer you ,a0i,u, fle0ibility. Gou can use the, ,ulti/le ways in ,ulti/le a//lications. 1. A 1rocedure is a set of selfAcontained hi(hAle'el lan(ua(e state,ents that /erfor,s a /articular tas9 and then returns to the caller. 6or e0a,/le" an =&# )8400 function is an =&# /rocedure. 2. A su! 1rocedure is a /rocedure s/ecified after the ,ain source section. =t can only be called usin( a bound call. Sub /rocedures differ fro, ,ain /rocedures in se'eral res/ects" the ,ain difference bein( that sub /rocedures do not >and cannot? use the $ % cycle while runnin(. 3. A 0odule o!$ect is a non runable object that is the out/ut of an =&# co,/iler. A ,odule object is re/resented to the syste, by the sy,bol K!ODB&#. A ,odule object is the basic buildin( bloc9 for creatin( run able =&# objects. 4. All =&# /ro(ra,s and ser'ice /ro(ra,s are acti'ated within a substructure of a job called an acti-ation grou1. :his substructure contains the resources necessary to run the /ro(ra,s. 5. A ser-ice 1rogra0 is a collection of runable /rocedures and a'ailable data ite,s easily and directly accessible by other =&# /ro(ra,s or ser'ice /ro(ra,s. =n ,any res/ects" a ser'ice /ro(ra, is si,ilar to a subroutine library or /rocedure library. Ser'ice /ro(ra,s /ro'ide co,,on ser'ices that other =&# objects ,ay needX hence the na,e ser'ice /ro(ra,. An e0a,/le of set of ser'ice /ro(ra,s /roA'ided by OS8400 is the runAti,e /rocedures for a lan(ua(e. :hese runAti,e /rocedures often include such ite,s as ,athe,atical /rocedures and co,,on in/ut8out/ut /rocedures. 6. A !inding directory contains the na,es of ,odules and ser'ice /ro(ra,s that you ,ay need when creatin( an =&# /ro(ra, or ser'ice /ro(ra,. !odules or ser'ice /ro(ra,s listed in a bindin( directory are used only if they /ro'ide an a(e 32 of 250

As400 Stuff e0/ort that can satisfy any currently unresol'ed i,/ort reEuests. A bindin( directory is a syste, object that is identified to the syste, by the sy,bol K47DD=$. 1. %&at is a *odule" !odules are objects of K!ODB&# ty/e that are created by the co,/iler when the create $ % !odule >)$:$ %!OD? co,,and is /erfor,ed. A ,odule can be co,/osed of a ,ain /rocedure >also referred to as ,ain /ro(ra,? and8or one or ,ore sub /rocedures. :he ter, S/rocedureT often desi(nates a sub /rocedure or a ,ain /rocedure. A ,odule is so,eti,es called Sco,/ilation unitT as it co,es fro, co,/ilation of one source ,e,ber. !odules are not e0ecutableX they only ser'e as buildin( bloc9s for /ro(ra, creation. :he /rocess of /ro(ra, creation is called bindin(. 4ound /ro(ra,s are e0ecutable objects of K %! ty/e. :o bind ,odules into a /ro(ra," the )reate ro(ra, >)$: %!? co,,and is used. =f an $ % =< /ro(ra, does not call sub /rocedures" or e0ternal ,odules" the )reate 4ound $ % ro(ra, >)$:47D$ %? co,,and will do for both co,/ilation and bindin(. :his is the case" for e0a,/le" of an $ % =< /ro(ra, resultin( fro, con'ertin( an $ % === /ro(ra, by the )<:$ %S$) co,,and. A ,odule is a nonAe0ecutable /ro(ra, and it contains one or ,ore /rocedures. =f you ha'e ,odules without /rocedure then it ,eans that it is ha'in( only one default /rocedure and in case we can use )A&&4. We are creatin( a $ %&# ,odule by )$:$ %!OD and a )& ,odule by )$:)&!OD co,,ands. 2. %&at is a 6er-ice )rogra0" =f you ha'e /rocedures that are called by ,ore than one /ro(ra," you could bind the, indi'idually to each of the /ro(ra,s. =n such a case" they would occu/y s/ace in each /ro(ra, and would be difficult to ,aintain. =f you (rou/ the /rocedures in a ser'ice /ro(ra, instead" the /rocedures occur only once and can be easily ,aintained. Ser'ice /ro(ra,s are objects of KS$< %! ty/e which are created by the )reate Ser'ice ro(ra, >)$:S$< %!? co,,and. A ser'ice /ro(ra, is si,/ly a collection of ,odules es/ecially those containin( sub /rocedures. Ser'ice /ro(ra,s cannot be directly calledX howe'er" the /rocedures contained in it ,ay be called by =&# /ro(ra,s. Ser'ice /ro(ra,s are built by bindin(" ,uch li9e /ro(ra,s" but they need to be further bound to a /ro(ra, before they are used. :his is done by the )$: %! co,,and. Ser'ice /ro(ra,s can also be bound to other ser'ice /ro(ra,s. :he to/ ser'ice /ro(ra, in such a (rou/ is e'entually bound to a /ro(ra, usin( the )$: %! co,,and. a(e 33 of 250

As400 Stuff 3. %&at is a !inding irectory"

4indin( directories are objects of K47DD=$ ty/e. 4indin( directories can be used as an additional source of e0/orts. A bindin( directory contains a list of ,odules and ser'ice /ro(ra,s that are candidates for auto,atic bindin(. 7ot all ite,s of the list in the bindin( directory are necessarily bound. Only those reEuired by i,/orts that cannot otherwise be resol'ed are bound. !odules and ser'ice /ro(ra,s listed in a bindin( directory often contain standard /rocedures" for e0a,/le ,athe,atical functions or other syste, /rocedures. We can create our own bindin( directories usin( s/ecial )& co,,and )$:47DD=$. 4. %&y =01ort and E21ort" A ser'ice /ro(ra, ,a9es its own ,odules and /rocedures a'ailable to e0ternal users throu(h a ,echanis, called e0/ort. :he e0ternal users are ,odules and sub /rocedures in e0ternal /ro(ra,s and other ser'ice /ro(ra,s that use >call? the ,odules and sub /rocedures of the ser'ice /ro(ra, to call the,. :he e0ternal users are also called S/ublicT or SclientsT. !ain /rocedures of ,odules co,/risin( the ser'ice /ro(ra, are e0/orted auto,atically >i,/licitly?" the /ro(ra,,er do not need to use any s/ecial s/ecifications to ,a9e a ,ain /rocedure a'ailable to e0ternal users. A ser'ice /ro(ra, e0/orts its own sub /rocedures by s/ecifyin( the #P O$: 9eyword in the sub /rocedure definition. +owe'er" in order to brin( this s/ecification in effect" the bindin( co,,and >)$:S$< %!? s/ecifies which of the e0/orted /rocedures are actually ,ade a'ailable to e0ternal users. 4esides ,odules and sub /rocedures" 'ariables ,ay be e0/orted >by s/ecifyin( the #P O$: 9eyword?. #0/orted ,odules" sub /rocedures and 'ariables are collecti'ely called e0/orts. #0/orts are used in other /rocedures where they are referred to. :he references are also called i,/orts as o//osed to the e0/orts that are so,eti,es called definitions.

5. %&at is 9cti-ation ,rou1" Acti'ation (rou/s are te,/orary stora(e structures /laced inside jobs >which the,sel'es are also te,/orary structures?. :here are three ty/es of acti'ation (rou/sH Z Default Z na,ed Z 7ew

a(e 34 of 250

As400 Stuff Default acti'ation (rou/s e0ist auto,atically and are ne'er deleted. :here are two default acti'ation (rou/s. !any syste, /ro(ra,s run in the default acti'ation (rou/ 1. $ % =< /ro(ra,s created with the /ara,eter D6:A):%$ >KG#S? of the )$:47D$ % co,,and run in the default acti'ation (rou/. :he other ty/es of acti'ation (rou/s are s/ecified by the /ara,eter A):%$ in /ro(ra, and ser'ice /ro(ra, creation co,,ands A )$: %! and )$:S$< %!. :hus" the ty/e of an acti'ation (rou/ is deter,ined by the /ro(ra, or ser'ice /ro(ra, at creation ti,e. An acti'ation (rou/ is created when the /ro(ra, is started. An acti'ation (rou/ ,ay includeH 6tatic and auto0atic -aria!les :he 'ariables ty/es of /ro(ra,s runnin( in the acti'ation (rou/H Static 'ariables are those defined in a ,ain /rocedure. :hey co,e fro, e0ternal sources such as DDS or SC& s/ecifications" or they are defined as $ % 'ariables >fields" indicators?. One ,ore /lace you will find static 'ariables is as local 'ariables in sub /rocedures declared with the S:A:=) 9eyword. Auto,atic 'ariables are local 'ariables defined in sub /rocedures. (1en data 1at&s C( )D OD are te,/orary objects re/resentin( o/en files to /ro(ra,s. Data buffer and /ointer to a record are /art of the OD . yna0ically allocated storage :e,/orary object created by the A&&O) o/eration in the $ % =< /ro(ra,. Error &andling routines Syste, or user /ro(ra,s >,odules? handlin( error ,essa(es. ro(ra,,ers can write their own ,odules to handle error ,essa(es co,in( fro, any /rocedure in the call stac9" no ,atter in which /ro(ra,,in( lan(ua(e the /rocedure is written. 7otice that the S/ro(ra, stac9T has been rena,ed to Scall stac9T. 6. 8a0e 6o0e =#E 9)=Js" 9nd tell so0et&ing a!out t&e0"

:he &ist !odule =nfor,ation >;48#*( =? A = lists infor,ation about ,odules. :he infor,ation is /laced in a user s/ace s/ecified by you. :his A = is si,ilar to the Dis/lay !odule >DS !OD? co,,and. Gou can use the C47&!OD= A = toH Z &ist the sy,bols defined that can be e0/orted to other ,odules Z &ist the sy,bols that are defined e0ternal to the ,odule a(e 35 of 250

As400 Stuff Z &ist /rocedure na,es and their ty/e Z &ist objects that are referenced when the ,odule is bound into an =&# /ro(ra, or ser'ice /ro(ra, Z &ist co/yri(ht infor,ation 2. :he &ist Ser'ice ro(ra, =nfor,ation >;48#6),*? A = (i'es infor,ation about ser'ice /ro(ra,s" si,ilar to the Dis/lay Ser'ice ro(ra, >DS S$< %!? co,,and. :he infor,ation is /laced in a user s/ace s/ecified by you. Gou can use the C47&S %! A = toH Z &ist ,odules bound into a ser'ice /ro(ra, Z &ist ser'ice /ro(ra,s bound to a ser'ice /ro(ra, Z &ist data ite,s e0/orted to the acti'ation (rou/ Z &ist data ite, i,/orts that are resol'ed by wea9 e0/orts that were e0/orted to the acti'ation (rou/ Z &ist co/yri(hts of a ser'ice /ro(ra, Z &ist /rocedure e0/ort infor,ation of a ser'ice /ro(ra, Z &ist data e0/ort infor,ation of a ser'ice /ro(ra, Z &ist si(natures of a ser'ice /ro(ra, 3. :he &ist =&# ro(ra, =nfor,ation >;48#),*=? A = (i'es infor,ation about =&# /ro(ra,s" si,ilar to the Dis/lay ro(ra, >DS %!? co,,and. :he infor,ation is /laced in a user s/ace s/ecified by you. Gou can use the C47& %!= A = toH Z &ist ,odules bound into an =&# /ro(ra, Z &ist ser'ice /ro(ra,s bound to an =&# /ro(ra, Z &ist data ite,s e0/orted to the acti'ation (rou/ Z &ist data ite, i,/orts that are resol'ed by wea9 e0/orts that were e0/orted to the acti'ation (rou/ Z &ist co/yri(hts of an =&# /ro(ra, Gou can" for e0a,/le" list si(natures of ser'ice /ro(ra,s bound in a /ro(ra, usin( the ;48#6),* A = to (et the NoldN si(natures. Gou can also list all NnewN si(natures of these ser'ice /ro(ra,s usin( the C47& %!= A = and co,/are the two lists if they ,atch. =f there is so,e ,is,atch" you can tri((er a new bindin( of the a(e 36 of 250

As400 Stuff /ro(ra, >by /erfor,in( the )$: %! co,,and?. 4e /re/ared to ins/ect lists of lists in so,e cases because the infor,ation retrie'ed by these A =s is or(aniFed hierarchically. 7. %&at are acti-ation grou1s" Acti'ation (rou/ is the en'iron,ent where the =&# jobs are e0ecuted. Gou can s/ecify the acti'ation (rou/ in )$: %! or )$:S$< %! co,,and. Gou cannot create the acti'ation (rou/ by co,,and )$:A):%$ . K#7:!ODH :he /ro(ra, entry /rocedure ,odule >#7:!OD /ara,eter? is chec9ed. =f the ,odule attribute is $ %&#" )4&&#" or )&&#" then A):%$ is C=&# or C=&#:S.C=&# is used when S:%!D& >KS7%&<&? is s/ecified" and C=&#:S is used when S:%!D& >K:#$AS A)#? is s/ecified. K7#W H When the /ro(ra, (ets called" a new acti'ation (rou/ is created. K)A&&#$H When the /ro(ra, (ets called" the /ro(ra, is acti'ated into the caller;s acti'ation (rou/. 7a,e H S/ecify the na,e of the acti'ation (rou/ to be used when this /ro(ra, is called.

8. /o' do = create and use a ser-ice 1rogra0 htt/H88faE.,idran(e.co,8data8cache8-14.ht,l A s,all sa,/le ser'ice /ro(ra," with source" and instructions for how to create and use it is (i'en here. a. )reate the - source ,e,bers below" chan(in( !G&=4 to your library na,e in the entire source. b. Bse )$:$ %!OD to create the two sr'/(, ,odules S$<SA! 1 and S$<SA! 2. c. Bse )$:)& %! to create the )& /ro(ra, S$<SA! )$:. d. )all S$<SA! )$: to create the sr'/(, !G&=48S$<SA! . e. )reate a bindin( directory LLL[ )$:47DD=$ !G&=48S$<SA! 47D f. Add your ser'ice /ro(ra, to the bindin( directory LLL[ ADD47DD=$# !G&=48S$<SA! 47D O45>>!G&=48S$<SA! KS$< %!?? (. )reate your test /ro(ra,. Since it has the 47DD=$ 9eyword in the + s/ec" it will auto,atically find your ser'ice /ro(ra,. LLL[ )$:47D$ % !G&=48S$<SA! :S: S$)6=&#>!G&=48C$ %&#S$)? h. :ry callin( your test /ro(ra,. #nter a 'alue li9e 0-.03.31 or 0-0331 i. :ry addin( a new /rocedure to ,odule S$<SA! 1. a(e 37 of 250

As400 Stuff say a /rocedure to (et a nu,eric 'alue si,ilar to (et Answer add the /rototy/e to S$<SA! $ code the /rocedure in S$<SA! 1 add an #P O$: line to CS$<S$) S$<SA! 47D call your )& to create the sr'/(, a(ain reclai, the acti'ation (rou/ that your test /ro(ra, runs in >Bse DS %! to see what acti'ation (rou/ it is? A call your test /ro(ra, a(ain to ,a9e sure it still runs o9 with the new 'ersion of the ser'ice /ro(ra, j. Add so,e code to your test /ro(ra, to call the new /rocedure" and reco,/ile and test. Source filesH 1. 4inder source !G&=48CS$<S$) S$<SA! 47D ty/e 47DH 8KAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAK8 8K $ulesH K8 8K 1. 7e'er chan(e the order of e0/orts K8 8K 2. Add new e0/orts at the end K8 8KAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAK8 str/(,e0/ si(nature>;S$<SA! ;? e0/ort sy,bol>;(etAnswer;? 8K 1 K8 e0/ort sy,bol>;ch9Date;? 8K 2 K8 end/(,e0/ 2. )& to create ser'ice /ro(ra, !G&=48C)&S$) S$<SA! )$: ty/e )& H crtsr'/(, ,ylib8sr'sa,/ U ,odule>,ylib8sr'sa,/1 U ,ylib8sr'sa,/2? U srcfile>,ylib8Esr'src? src,br>sr'sa,/bnd? 3. $ % /rototy/e source !G&=48C$ %&#S$) S$<SA! 8if defined>S$<SA! $\)O =#D? 8eof 8endif 8define S$<SA! $\)O =#D D (etAnswer /r 2*a 'aryin( D e0t/roc>;(etAnswer;? D Euestion 2*a const 'aryin( D ch9Date D D in/ut D out/ut /r n e0t/roc>;ch9Date;? 10a const 'aryin( d a(e 38 of 250 $ ty/e $ %&#H A A A A A A

As400 Stuff D for,at ar, D 10a const 'aryin( o/tions>Kno/ass?

4. $ % test /ro(ra, source !G&=48C$ %&#S$) S$<SA! :S: ty/e $ %&#H + dftact(r/>Kno? bnddir>;!G&=48S$<SA! 47D;? 8co/y sr'sa,//r D ans s 10a 'aryin( D date s d D o9 s n 8free ans L (etAnswer >;%i'e a date in y,d for,at;?X o9 L ch9Date >ans H date H ;KG!D;?X if o9X ds/ly >;:hat was o9" date was ; U Ochar>date??X elseX ds/ly ;Oo/s" was not 'alid;X endifX Kinlr L ;1;X *. $ % sr'/(, ,odule 1 !G&=48C$ %&#S$) S$<SA! 1 ty/e $ %&#H + no,ain 8co/y sr'sa,//r (etAnswer b e0/ort D (etAnswer /i 2*a 'aryin( D Euestion 2*a const 'aryin( D answer s 2*a 'aryin( 8free ds/ly Euestion ; ; answerX return answerX 8endAfree (etAnswer e -. $ % sr'/(, ,odule 2 !G&=48C$ %&#S$) S$<SA! 2 ty/e $ %&#H + no,ain 8co/y sr'sa,//r D D D D D ch9Date b ch9Date /i in/ut out/ut for,at ar, e0/ort n 10a const 'aryin( d 10a const 'aryin( o/tions>Kno/ass? a(e 39 of 250

As400 Stuff

D for,at s 10a 'aryin( inF>;K=SO;? D se/ s 1a D se/ os s 10i 0 D ha'eSe/ s n D standardSe/ s 10a 'aryin( 8free 88 chec9 for o/tional /ara,eter if O/ar,s [ 2X for,at L for,at ar,X endifX 88 chec9 for se/arators se/ os L Ochec9>;01234*-.12; H in/ut?X if se/ os [ 0X se/ L Osubst>in/ut H se/ os H 1?X ha'eSe/ L KonX endifX if for,at L ;K=SO;X if ha'eSe/X standardSe/ L O0late>se/H;A;Hin/ut?X out/ut L Odate>standardSe/ H Kiso?X elseX out/ut L Odate>in/ut H Kiso0?X endifX elseif for,at L ;KG!D;X if ha'eSe/X standardSe/ L O0late>se/H;8;Hin/ut?X out/ut L Odate>standardSe/ H Ky,d8?X elseX out/ut L Odate>in/ut H Ky,d0?X endifX endifX return KonX 88 it was o9 be(sr K/ssrX return KoffX 88 so,e error occurred endsrX 8endAfree ch9Date e

a(e 40 of 250

As400 Stuff 9. *odules I /o' to 'rite and reuse t&e0 +ere we e0/lore the conce/t of ,odules which hel/s us to reuse the /rocedures without a//lyin( the ser'ice /ro(ra, conce/t. 7a,e of the /ro(ra, that binds all the ,odules is :S:!OD. :here won@t be any source for :S:!OD before )$: %!. After /ro(ra, creation if you debu( this /ro(ra, and see it will ha'e the source of the entry ,odule >here %!#7:!OD? :here are three ,odules %!!OD1" %!!OD2 and %!#7:!OD where %!#7:!OD is the entry ,odule >it contains the code to call the e0/ortable /rocedures /resent in %!!OD1 and %!!OD2?. 1. 6irst create all the ,odules usin( o/tion 1* li9e this. )$:$ %!OD !ODB&# >S+A=&#S+8 %!!OD1? S$)6=&# >S+A=&#S+8:#S: %!S? )$:$ %!OD !ODB&# >S+A=&#S+8 %!!OD2? S$)6=&# >S+A=&#S+8:#S: %!S? )$:$ %!OD !ODB&# >S+A=&#S+8 %!#7:!OD? S$)6=&# >S+A=&#S+8:#S: %!S? 2. :hen create the /ro(ra, >)$: %!? by bindin( all the ,odules li9e this. ro(ra, . . . . . . . . . . . . [ :S:!OD &ibrary . . . . . . . . . . . [ S+A=&#S+ !odule . . . . . . . . . . . . . [ %!!OD1 &ibrary . . . . . . . . . . . [ S+A=&#S+ [ %!!OD2 [ S+A=&#S+ U for ,ore 'alues [ %!#7:!OD [ S+A=&#S+ :e0t ;descri/tion; . . . . . . . K#7:!OD:P: Additional ara,eters ro(ra, entry /rocedure ,odule [ %!#7:!OD &ibrary . . . . . . . . . . . [ S+A=&#S+ 3. 7ow call the created /ro(ra, in debu( ,ode li9e this. S:$D4% %!>S+A=&#S+8:S:!OD? B D $OD>KG#S? O !S$)>KG#S? )A&& %!>S+A=&#S+8:S:!OD? 6ource code@ ),**( 1@ D ADD D <A$1 D <A$2 $ *S 0 <A&B# *S 0 <A&B# a(e 41 of 250

As400 Stuff D SB! ) D D D D ) ADD ),**( 2@ D D D D ) D D D D ) SB4 SB4 SB4 <A$1 <A$2 D=66 SB4 <A$1 <A$2 D=66 $ *S 0 <A&B# *S 0 <A&B# *S 0 #<A& 4 = *S 0 <A&B# *S 0 <A&B# *S 0 #<A& # D=66 L <A$1 A <A$2 K=7&$ L KO7 #P O$: ADD ADD <A$1 <A$2 SB! #<A& 4 = *S 0 <A&B# *S 0 <A&B# -S 0 #<A& # SB! L <A$1 U <A$2 -S 0 K=7&$ L KO7 #P O$:

),*E8>*( @ D D D D D D D D <A&1 <A&2 :O:A& 4A&A7)# ADD <A&1 <A&2 :O:A& S S S S $ *S 0 <A&B# *S 0 <A&B# -S 0 $ a(e 42 of 250 *S 0 =7M>22222? *S 0 =7M>22222? -S 0 =7M *S 0 =7M

D SB4

As400 Stuff D <A&1 D <A&2 D 4A&A7)# ) ) ) ) ) ) ) :O:A& *S 0 <A&B# *S 0 <A&B# *S 0

DS &G )A&& ADD><A&1H <A&2H :O:A&? :O:A& DS &G 4A&A7)# DS &G )A&& SB4><A&1H <A&2H 4A&A7)#? 4A&A7)# DS &G #<A& K=7&$ L KO7

1. %&at are t&e =#E +), coding 1rogra00ing considerations" .oding .onsiderations :his section /resents so,e considerations that you should be aware of before you be(in desi(nin( a//lications with ,ulti/leA/rocedure ,odules. :he ite,s are (rou/ed into the followin( cate(oriesH K %eneral K ro(ra, )reation K !ain rocedures K Sub /rocedures 1. ,eneral .onsiderations K When codin( a ,odule with ,ulti/le /rocedures" you will want to ,a9e use of 8)O G files" /ri,arily to contain any /rototy/es that your a//lication ,ay reEuire. =f you are creatin( a ser'ice /ro(ra," you will need to /ro'ide both the ser'ice /ro(ra, and the /rototy/es" if any. K !aintenance of the a//lication ,eans ensurin( that each co,/onent is at the ,ost current le'el and that any chan(es do not affect the different /ieces. Gou ,ay want to consider usin( a tool such as A//lication De'elo/,ent !ana(er to ,aintain your a//lications. 6or e0a,/le" su//ose that another /ro(ra,,er ,a9es a chan(e to the 8)O G file that contains the /rototy/es. When you reEuest a rebuild of your a//lication" any ,odule or /ro(ra, that ,a9es use of the 8)O G file will be reco,/iled auto,atically. Gou will find out Euic9ly if the chan(es to the 8)O G file affect the calls or /rocedure interfaces in your a//lication. =f there a(e 43 of 250

As400 Stuff are co,/ilation errors" you can then decide whether to acce/t the chan(e to /rototy/es to a'oid these errors" or whether to chan(e the call interface. 2. )rogra0 .reation K =f you s/ecify that a ,odule does not ha'e a ,ain /rocedure then you cannot use the )$:47D$ % co,,and to create the /ro(ra,. >A ,odule does not ha'e a ,ain /rocedure if the 7O!A=7 9eyword is s/ecified on a control s/ecification.? :his is because the )$:47D$ % co,,and reEuires that the ,odule contain a /ro(ra, entry /rocedure and only a ,ain /rocedure can be a /ro(ra, entry /rocedure. K Si,ilarly" when usin( )$: %! to create the /ro(ra," 9ee/ in ,ind that a 7O!A=7 ,odule cannot be an entry ,odule since it does not ha'e a /ro(ra, entry /rocedure. K A /ro(ra, that is created to run in the default O ! acti'ation (rou/ >by s/ecifyin( D6:A):%$ >KG#S? on the )$:47D$ % co,,and? cannot contain bound /rocedure calls. 3. *ain )rocedure .onsiderations K 4ecause the ,ain /rocedure is the only /rocedure with a co,/lete set of s/ecifications a'ailable >e0ce/t s/ecification?" it should be used to set u/ the en'iron,ent of all /rocedures in the ,odule. K A ,ain /rocedure is always e0/orted" which ,eans that other /rocedures in the /ro(ra, can call the ,ain /rocedure by usin( bound calls. K :he call interface of a ,ain /rocedure can be defined in one of two waysH 1. Bsin( a /rototy/e and /rocedure interface 2. Bsin( an K#7:$G &=S: without a /rototy/e K :he functionality of an K#7:$G &=S: is si,ilar to a /rototy/ed call interface. +owe'er" a /rototy/ed call interface is ,uch ,ore robust since it /ro'ides /ara,eter chec9in( at co,/ile ti,e. =f you /rototy/e the ,ain /rocedure" then you s/ecify how it is to be called by s/ecifyin( either the #P: $O) or #P: %! 9eyword on the /rototy/e definition. =f #P: %! is s/ecified" then an a(e 44 of 250

As400 Stuff e0ternal /ro(ra, call is usedX if #P: $O) is s/ecified or if neither 9eyword is s/ecified" it will be called by usin( a /rocedure call. K Gou cannot define return 'alues for a ,ain /rocedure" nor can you s/ecify that its /ara,eters be /assed by 'alue. 4. 6u! 1rocedure .onsiderations K Any of the calculation o/erations ,ay be coded in a sub /rocedure. +owe'er" all files ,ust be defined (lobally" so all in/ut and out/ut s/ecifications ,ust be defined in the ,ain source section. Si,ilarly" all data areas ,ust be defined in the ,ain /rocedure" althou(h they can be used in a sub /rocedure. K :he control s/ecification can only be coded in the ,ain source section since it controls the entire ,odule. K A sub /rocedure can be called recursi'ely. #ach recursi'e call causes a new in'ocation of the /rocedure to be /laced on the call stac9. :he new in'ocation has new stora(e for all data ite,s in auto,atic stora(e" and that stora(e is una'ailable to other in'ocations because it is local. >A data ite, that is defined in a sub /rocedure uses auto,atic stora(e unless the S:A:=) 9eyword is s/ecified for the definition.? 2. %&at (1codes are added in =#E" ADDDB$" SB4DB$" #<A& 3. %&at are t&e !e&a-ioral differences !:' ()* +),:400 and =#E" )o,/ared to O !" =&# /ro'ides $ % users with i,/ro'e,ents or enhance,ents in the followin( areas of a//lication de'elo/,entH K ro(ra, creation K ro(ra, ,ana(e,ent K ro(ra, call K Source debu((in( K 4indable a//lication /ro(ra, interfaces >A =s? #ach of the abo'e areas is e0/lained briefly in the followin( /ara(ra/hs and discussed further in the followin( cha/ters. 4. =#E ad-antages o-er +)," 4etter call /erfor,ance !odularity a(e 45 of 250

As400 Stuff 1. !ulti/leAlan(ua(e inte(ration #nhance,ents to the =&# co,/ilers $eusable co,/onents )ontrol o'er a//lication runAti,e en'iron,ent )ode o/ti,iFation :ool a'ailability 6oundation for the future

efine !inder 1rogra0" :he binder /ro(ra, ,eans bindin( the /rocedure it is called binder /ro(ra,.

2. /o' to t&e create 0odule" A ,odule is created as a se/arate object ty/e >K!ODB&#?. Bsin( the )$:$ %!OD co,,and creates an $ %&# ,odule. A ,odule object cannot be run directly. Gou ,ust use the )$: %! co,,and to bind ,odule object into a /ro(ra, object. Do o/tion 1* or )$:$ %!OD co,,and to create a ,odule. :he )$: %! co,,and is used to create a /ro(ra, fro, one or ,ore ,odule. S3A7DASA!O8$ %=&# !A=7 KKKKKKKKKKKKKKK 4e(innin( of data KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK 0001.00 ) 0002.00 ) 0003.00 ) 0004.00 ) )A&&4 )A&&4 )A&&4 S#:O7 ;ADD; ;SB4; ;!B&; &$

KKKKKKKKKKKKKKKKKK #nd of data KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK S3A7DASA!O8$ %=&# ADD KKKKKKKKKKKKKKK 4e(innin( of data KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK 0002.00 ) 0002.01 ) 0004.00 ) 000*.00 ) A ) MAADD MAADD ADD DS &G a(e 46 of 250 4 * 4 A 4 ) 40 40 40

As400 Stuff 000-.00 ) S#:O7 &$

KKKKKKKKKKKKKKKKKK #nd of data KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK S3A7DASA!O8$ %=&# SB4 KKKKKKKKKKKKKKK 4e(innin( of data KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK 002.00 ) 002.01 ) 004.00 ) 00*.00 ) 00-.00 ) A ) MAADD MAADD SB4 DS &G S#:O7 &$ 10 * 4 A 4 ) 40 40 40

KKKKKKKKKKKKKKKKKK #nd of data KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK S3A7DASA!O8$ %=&# !B& KKKKKKKKKKKKKKK 4e(innin( of data KKKKKKKKKKKKKKKKKKKKKKKKKKKKKK 0002.00 ) 0002.01 ) 0004.00 ) 000*.00 ) 000-.00 ) A ) MAADD MAADD !B&: DS &G S#:O7 &$ 10 * 4 A 4 ) 40 40 40

KKKKKKKKKKKKKKKKKK #nd of data KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK )$: %! :a9e 64 ro(ra, . . . . . . . . . . . . [ !A=7 7a,e

&ibrary . . . . . . . . . . . [ S3A7DASA!O 7a,e" K)B$&=4 !odule . . . . . . . . . . . . . [ !A=7 7a,e" (enericK" K %!" KA&& > # ?

&ibrary . . . . . . . . . . . [ S3A7DASA!O 7a,e" K&=4&" K)B$&=4... a(e 47 of 250

As400 Stuff [ ADD [ S3A7DASA!O [ SB4 [ S3A7DASA!O U for ,ore 'alues [ !B& [ S3A7DASA!O :e0t ;descri/tion; . . . . . . . K#7:!OD:P: OB: B: DS &G DS &G DS &G 2 * *0

3. %&at are t&e differences in .9##, .9##4 and .9##)" .9## is a dyna,ic call where the control will be transferred when the /ro(ra, is e0ecuted. >)ontrol will be transfer the another /ro(ra, >run ti,e? so it is dyna,ic call?. Where as )A&&4 and )A&& are static calls. A ,odule is a nonAe0ecutable /ro(ra, and it contains one or ,ore /rocedures. =f you ha'e ,odules without /rocedure then it ,eans that it is ha'in( only one default /rocedure and in case we can use .9##4. A ,odule is ha'in( ,ore than one /rocedure then we can (i'e e0/licitly the /rocedure na,e to be called in case of .9##) out of these three )A&& is the ,ost efficient one. >Bsin( the )A&&4" )A&& a /ro(ra, or ,odule is bind in the /ro(ra, so it is static?. 4. %&at is t&e difference !et'een 4ind !y -alue and 4ind !y reference" 4ind by 'alue 4ind by $eference

+ere the entire ,odules to be =n this case we are bindin( the bounded are /hysically co/ied into /ro(ra,s by usin( ser'ice the ,ain /ro(ra, object. /ro(ra,s" which contain a reference to the ,odule that has been called" and the ,odules are a(e 48 of 250

As400 Stuff not /hysically co/ied /ro(ra, object. into the

:he /ro(ra, will be e0ecuted e'en :he /ro(ra, will not e0ecute when when you delete the entire ,odule the bind ,odules are deleted. that has been called. 4ind by 'alue is faster than bind by =t is not as faster as bind by 'alue. reference. >All the ,odules to be >All the ,odules can@t bind the bind in the ,ain /ro(ra," so it is ,ain /ro(ra, it is refer the /ointer? fast?

5.

efine 1ass !y -alue and 1ass !y reference"

)ass !y reference@ ass by reference we are /assin( the address of the /ara,eters and not the actual 'alue and so the chan(es in the called /rocedure will affect the 'alue in the callin( /ro(ra,s. =n O ! /ro(ra,s we are usin( only call by reference. )ass !y -alue@ ass by 'alue we are /assin( the 'alue of the /ara,eter" chan(es ,ade to the for,al ar(u,ents in the called function ha'e no effect on the 'alues of the actual ar(u,ents in the callin( function it is used in c /ro(ra,. =n $ %&# we ha'e the o/tion to /ass the /ara,eter by 'alue by (i'in( the 9eyword G9#<E.

1. %&at are )rogra0 Entry )rocedure C)E)D and <ser Entry )rocedure C<E)D" =f we are bindin( ,any ,odules to(ether to for, a /ro(ra, then we ha'e to s/ecify which ,odule has to ta9e control first when it has been called and that ,odule is called as )E) for that /ro(ra,. Bser entry /rocedure C<E)D is the first state,ent that ta9es the control when a /ro(ra, has been called. 6or e0a,/le in ) /ro(ra,s ,ain >? will be e0ecuted first when it has been called and li9ewise in $ % the state,ent coded in ) S/ec will ta9e the control first.

a(e 49 of 250

As400 Stuff efine .o1y!ooE in +),#E" =t will co/y a Subroutine >or? any (rou/ of codes /hysically into the /ro(ra," which is co/yin( it. S3A7DASA!O8$ %=&# )O KKKKKKKKKKKKKKK 4e(innin( of data KKKKKKKKKKKKKKKKKKKKKKKKKKKKKK 0002.00 ) 0002.01 ) 0004.00 ) DS &G #PS$ S#:O7 ADD &$ A *0 2.

000*.00 )8)O G $ %=&#" )O G KKKKKKKKKKKKKKKKKK #nd of data KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK S3A7DASA!O8$ %=&# )O G KKKKKKKKKKKKKKK 4e(innin( of data KKKKKKKKKKKKKKKKKKKKKKKKKKKKKK 0000.01 0001.00 ) 0002.00 ) 0003.00 ) 0004.00 ) A ADD 4#%S$ ADD DS &G #7DS$ * A

KKKKKKKKKKKKKKKKKK #nd of data KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK OB: B: 13 DS &G 11

3. /o' to create a ser-ice 1rogra0 and '&at are t&e ste1s in-ol-ed in t&is"

a(e 50 of 250

As400 Stuff :he ser'ice /ro(ra, ,eans ,ost co,,only used ,odules are (rou/ed >bindin(? to(ether to for, it is called ser'ice /ro(ra,. A ser'ice /ro(ra, is not bound to its caller until acti'ation ti,e While creatin( ser'ice /ro(ra, we can create a binder /ro(ra, where we can refer the ,odules >or? /rocedures >or? e'en data ty/es to be used by the /ro(ra, which is usin( ser'ice /ro(ra,.

A$%antages of ser%ice programs :hey do not ta9e u/ au0iliary stora(e s/ace. :here is only one co/y for all users. :here is only a sin(le co/y of the readAonly code in ,ain stora(e for all users in this ser'ice /ro(ra,s is the sa,e as a /ro(ra, that you call dyna,ically. #ach user of the ser'ice /ro(ra, has an inde/endent wor9 area. Gou can /ass /ara,eters to a ser'ice /ro(ra,s by usin( the traditional /ara,eter list >or? by i,/ortin( and e0/ortin( 'ariables. Ser'ice /ro(ra,s can be ,aintained inde/endently of the /ro(ra,s that use the functions. =n ,ost cases" chan(in( a ser'ice /ro(ra,s does not cause a /ro(ra, usin( the function to be chan(ed or reAcreated. &isa$%antages of ser%ice programs Ser'ice /ro(ra,s are less desirable for a function you ,ay or ,ay not need. :he reason is that it is slower to call a ,ain /ro(ra, that refer to a ser'ice /ro(ra,
1. E21lain 1rocedure used in +),#E" A /rocedure is a nonAe0ecutable /ro(ra,. =f a ,odule is ha'in( ,ore than one /rocedure then we can (i'e e0/licitly the /rocedure na,e to be called in case of )A&& . Definin( the /rototy/eH rototy/e will s/ecify the followin( thin(s ara,eter ty/e SeEuence of the /ara,eter $eturn 'ariable and its ty/e =t tells the na,e of the /rocedure and also the ty/e of the call. =t will a'oid all the run ti,e /roble,s li9e /ara,eter ,is,atch by s/ecifyin( the /rototy/e. rototy/e interface =t is li9e Kentry /ara,eter where we will s/ecify the /ara,eters that are recei'ed in this /ro(ra,. =,/ort and e0/ort =f you want to s/ecify the /rocedures to be the e0ternal /ro(ra,s then we can s/ecify #P O$: in your /rocedure. a(e 51 of 250

As400 Stuff %lobal and local 'ariables =f you declare a 'ariable in ,ain /rocedure then it will be accessible in all sub /rocedure and this is (lobal declaration and if you s/ecify the declaration in the sub /rocedures then it will not be accessed in other /rocedures or in the ,ain /rocedure. $eturn =f we s/ecify return in the sub /rocedure then it ,eans that we are returnin( so,ethin( to the callin( /ro(ra,. We can return a ,a0i,u, of only one 'ariable to the callin( /ro(ra,. $ecursion A /rocedure callin( to itself is 9nown as recursion. ass by 'alue8/ass by reference =n case of /ass by reference we are /assin( the address of the /ara,eters and not the actual 'alue and so the chan(es in the called /rocedure will affect the 'alue in the callin( /ro(ra,. =n O ! /ro(ra, we are usin( only call by reference and in $ %&# we ha'e the o/tion to /ass the /ara,eter by (i'in( the 9eyword <A&B#. )A&& 8#0/ression We can call the /rocedure by usin( )A&& co,,and if it is not ha'in( any return ty/e and by an e0/ression if it returns any 'alue. ata!ase efine source 1&ysical file" Source /hysical file is also a file" which has one" or ,ore files included in it. =t is just li9e a directory and it contains ,any ,e,bers. :he ,e,bers are li9e a 'arious /ro(ra,s residin( in the directory .+>6+.)7 is used to create source /hysical file. 2. )&ysical 7iles and #ogical 7ile hysical files hold the actual data of a database file. :he data is written in arri'al seEuence. hysical files are not reEuired to ha'e 9eyed fields. =f a /hysical file has 9ey fields" this is the order that an $ % /ro(ra, will read the data if the 6ile S/ec in the /ro(ra, indicates to read the data in 9eyed seEuence. Also" with a 9eyed field" an $ % /ro(ra, can )+A=7" S#:&&" $#AD# and $#AD . A si,/le lo(ical file is a different 'iew of the /hysical file. =t is actually a list of /ointers to the /hysical file. !ost of the ti,e" a lo(ical file is nothin( ,ore than a way of accessin( the /hysical file with different 9ey fields. &o(ical file does not occu/ies any ,e,ory s/ace and lo(ical file be deri'ed fro, /hysical file. One or ,ore lo(ical file can be deri'ed fro, a sin(le /hysical file. A lo(ical file can contain u/ to 32 record for,ats. =t selects records dyna,ically. =t cannot e0ist without a /hysical file. We can filter the data with criteria by usin( a(e 52 of 250 1.

As400 Stuff select and o0it co,,and. .+>#7 co,,and is used to create a &6. =t accesses the data by creatin( access /ath. A lo(ical file does not contain any data but /ro'ides the R<=#WS@ of the data to satisfy endAuser@s needs. :here are two ty/es" 1. 7on A join lo(ical file" 2. 5oin lo(ical file With the standard AS8400 su//lied tools" it is hard to see the lo(ical file. One way is to use the co/y file ) G6 to co/y the lo(ical file to a new /hysical file. :hen" loo9 at the /hysical file... it will be in the sa,e order as the lo(ical file. :he AS8400 Database is full featured. &o(ical files can join ,ulti/le files and select and create new fields. !a0i,u, nu,ber of fields included in a 6 is 1000. !a0i,u, no of 9ey fields included is 120. :here are two ty/es of lo(ical files" 7on join lo(ical file 5oin lo(ical file 1. #ist t&e differences !et'een 1&ysical file and logical file. hysical file 1. Occu/ies the /ortion of ,e,ory. =t@s containin( data. &o(ical file Does not occu/y any ,e,ory s/ace. Does not contain any data.

2. A /hysical file contains one record A lo(ical file can contain u/ to 32 for,at and can contain ,any record for,ats but only one ,e,ber. ,e,bers 3.)an be e0ist e'en without &6 4. :he 6 cannot be deleted without deletin( the associated &6s. *..+>)7 co,,and is used to create such object -.:he object ty/e is 6 )annot e0ist without 6 =f the &6 is deleted then the 6 need not be deleted. .+>#7 co,,and is used to create such ty/e object :he object ty/e is &6

2. %&at are t&e four le-els of entries in 1&ysical file"

a(e 53 of 250

As400 Stuff C=D. 7ile le-el entries Co1tionalDH 6ile le'el entries (i'e the syste, infor,ation of the entire file. >B7=CB#" &=6O" 6=6O" 6)6O" $#6? B7=CB#H A record cannot be entered or co/ied into a file if its 9ey 'alue is sa,e as the 9ey 'alue of a record already e0istin( in the file. &=6OH &ast in first out 6=6OH 6irst in first out 6)6OH 6irst chan(e first out. $#6H :his 9eyword is used to s/ecify the na,e of the file fro, which the field descri/tions are retrie'ed. E2H you can s/ecify whether the 9ey is uniEue. CiiD. +ecord for0at le-el entriesH $ecord for,at le'el entries (i'e the syste, infor,ation about s/ecific record for,at in the file. 6or a )7 the record for,at na,e is s/ecified alon( with an o/tional te0t descri/tion. >6O$!A:" :#P:? CiD 7(+*9>H :his recordAle'el 9eyword s/ecifies that the record for,at bein( define is to share the field s/ecifications of a /re'iously defined record for,at. :he na,e of the record for,at bein( defined ,ust be the na,e of the /re'iously defined record for,at. >&e for0at of t&is Eey'ord is@ 6O$!A: >&=4A7A!# 8 6=&#A7A!#? CiiD >EA>@ :his record le'el 9eyword is used to su//ly a te0t descri/tion of the record for,at and it is used for docu,entation /ur/oses only. >&e for0at of t&is Eey'ord is@ :#P: >Rdescri/tion@? CiiiD 7ield le-el entries@ :he field na,es and field len(ths are s/ecified alon( with and o/tional te0t descri/tion for each field. >A&=AS" A&W7B&&" ))S=D" )+#)3" )+3!S%=D" )! " )O&+D%" )O! " DA:6!:" DA:S# " D6:" #D:)D#" #D:W$D" $#66&D" $#6S+=6:" :#P:" :=!#6!:" :=!#S# " <A&B#S" <A$&#7?

a(e 54 of 250

As400 Stuff >i'? 3ey field le-el entriesH :he field na,es used as 9ey fields are s/ecified. >D#S)#7D" S=%7#D" A4S<A&" B7S=%7#D" MO7#" 7OA&:S#C" D=%=:?

1. %&at are t&e si2 le-els of entries in logical file" >i? >ii? 7ile le-el entries Co1tional?H 6ile le'el entries (i'e the syste, infor,ation of the entire file. Gou can s/ecify whether the 9ey is sa,e as /hysical file. +ecord for0at le-el entriesH $ecord for,at le'el entries (i'e the syste, infor,ation about s/ecific record for,at in the file. 6or e0a,/les" for a lo(ical file when a record for,at is described we can s/ecify the /hysical file it is based on. #0a,/leH 5file" 6ile. 5(=8 #e-el entries@ 5oin le'el entries (i'e the syste, infor,ation about )7 used in a 5O=7 &O%=)A& 6=&#. >=t is not a//licable to 7O7 5O=7 &O%=)A& 6=&#S?. 5oin, 57# , 7ield le-el entries >o1tionalD@ :he field le'el entries (i'e the syste, infor,ation about indi'idual fields in the record for,at. #0a,/leH 5$ef 3ey field le-el entries@ :he 9ey field le'el entries (i'e the syste, infor,ation about the 9ey fields of a file. :he field na,es used as 9ey fields are s/ecified. 6elect : (0it le-el entries@ :hese entire (i'e the syste, infor,ation about which records are to be returned to the /ro(ra, when /rocessin( the file. :hese s/ecifications a//ly to lo(ical file only. E2a01les@ +angeCfieldD, -aluesCrecordfor0atD

>iii?

>i'? >'? >'i?

1. E21lain 5 <)6E; and 5 7>G9#. 5 <)6E;@ :his join Ile'el 9eyword is used to s/ecify the order in which records with du/licate join fields are /resented when the 5&6 is read. >&e for0at for t&is Eey'ord is@ 5DB S#C >SeEuencin( fieldAna,e VKD#S)#7DW?

a(e 55 of 250

As400 Stuff :his 9eyword has no effect on the orderin( of records with uniEue 9eys. =f KD#S)#7D is not s/ecified then the default is seEuencin( in ascendin( order. 5 7>G9#@ When this fileAle'el 9eyword is used the syste, /ro'ides default 'alues for all for fields when a join to a secondary file does not /roduce any records. =f this 9eyword is not s/ecified a record in the /ri,ary file for which there is no corres/ondin( record in the secondary file is s9i//ed. 1. %&at are t&e different !et'een nonI$oin logical files and $oin logical files. 7on join lo(ical file 5oin lo(ical file

We can able to insert or delete or =nsertion" u/datin( or deletion of u/date records usin( nonAlo(ical file. records is not /ossible in join lo(ical files. D6B can be used to dis/lay nonAjoin lo(ical file. 1A32 record for,at is s/ecified )o,,it,ent control is used D6B is not a'ailable Only one s/ecified record for,at can be

)o,,it,ent control cannot be used.

2. /o' 0any record for0ats can &a-e 1&ysical K logical file. =n /hysical file only one record for,at can be s/ecified. =n lo(ical file 1A32 record for,ats are s/ecified 1. %&at is t&e ad-antage o1en Luery file" Dyna,ic selection of records =t will sort the records based on the field 'alues. We can retrie'e records based on <irtual fields. )an create join lo(ical files a(e 56 of 250

As400 Stuff

1. E21lain nonI$oin logical file" 7onAjoin lo(ical files can either be a si,/le lo(ical file" which contains only one record for,at or a ,ulti/le record for,at lo(ical file" which contains ,ore than one record for,at. &o(ical files can be deri'ed fro, 1 to 32 /hysical files and so a lo(ical file can ha'e a ,a0i,u, of 32 record for,ats. 6ingle record for0at logical file@ =f a lo(ical file is deri'ed fro, sin(le /hysical file it is called si,/le lo(ical file. *ulti1le record for0at logical file@ !ulti/le record nonAjoin lo(ical files will select records fro, 2 or ,ore /hysical files by referrin( to only one lo(ical file. #ach record for,at is always associated with one or ,ore /hysical file. :he sa,e 6 can be used in ,ore than one record for,at. 61ecify t&e entries in single or 0ulti1le for0at logical files@ %& 'ile(level entries )optional*H >$#6A)) :+" DG7S&:? $#6A)) :+H :he access /ath infor,ation for this lo(ical file is to be co/ied fro, another 6 or &6. 7or0at of t&e Eey'ord is@ $#6A)) :+ >&=4 na,e 8 DA:A4AS# na,e? DG7S&:H :his 9eyword is selection and o,ission tests in the file. :his 9eyword s/ecifies dyna,ic select8o,it. +& ecord , level entries H> 6=&#?

6=&#H :he /hysical files containin( the data to be accessed throu(h the $ecord for,ats bein( defined. 7or0at of t&e Eey'ord is@ 6=&# >&=4 na,e 8 6 na,e? -& 'ield(level entries )optional* .. /e$ !ield ,level entries )optional* 0& Select and #mit ,!ield level entries )optional* a(e 57 of 250

As400 Stuff $#6A)) :+]it is a//licable for nonAjoin lo(ical file only and ,eanin( is referrin( the access /ath fro, the 6 or &6 in the file I le'el entries. 6=&#AAA it is a//licable only for nonAjoin lo(ical file in record le'el entries.

1. =t is 1ossi!le to insert record to 5(=8 #7" 7O" insertion" u/datin( or deletin( of records is not /ossible in 5O=7 &6.

2. E21lain $oin logical file" A joinAlo(ical file is a lo(ical file that co,bines two or ,ore 6. =n the record for,at not all the fields need to e0ist in all the 6. A 6 cannot be chan(ed throu(h a 5&6. D6B cannot be used to dis/lay a 5&6. Only one record for,at can be s/ecified in a 5&6. )o,,it,ent control cannot be used with a 5&6. 3ey fields ,ust be fields defined in the join record for,at and ,ust be fields fro, the $=!A$G 6=&#. 61ecify t&e entries in $oin logical file@ 1. 6ileAle'el entries >o/tional?H >5D6:<A&? 2. $ecordAle'el entriesH >56=&#? 3. joinAle'el entries H> 5O=7" 56&D" 5DB S#C? 4. 6ield Ile'el entries >o/tional?H >5$#6" A&&" )O7)A:" DG7S&:" $#7A!#" SS:" :$7:4&? *. 3ey field Ile'el entries >o/tional? -. Select and O,it field le'el entries. >O/tional?

56=&#AAAA=t is si,ilar to indicate that this is a join lo(ical field and it ,ust ha'e ,ore than 2 /hysical files. 5O=7H =t is si,ilar that this file le'el entries to be re/resent the /osition of the files .:here ,ust one /ri,ary file and can ha'e ,ore than = secondary files.. 56&DH Which feels we are (oin( to join. a(e 58 of 250

As400 Stuff 5$#6H re/resents the /ri,ary file reference field 5D6:<A&H re/resents that it as a left outer join. 6E#E.> (*=> )olu,ns . . . 1 .1 S#BLL[ S#&O!=: 6!: 6. KKKKKKKKKKKKKKK 4e(innin( of data KKKKKKKKKKKKKKKKKKK 0001.00 0002.00 0003.00 0004.00 $ $#)S#& #! 7O #! 7A!# 3 #! 7O * 0 20A #dit 3S#7:+=&S8#PA! &#

KKKKKKKKKKKKKKKKKK #nd of data KKKKKKKKKKKKKKKKKKKKKKKK E*)8( E*)89*E

000001 10"001 S+GA! 000002 10"002 SA73A 000003 10"003 S+GA! 000004 10"004 S#7:+ 00000* 10"00* SA73A 00000- 10"00- S+GA! 00000. 10"00. SA73A 000001 10"001 S#7:+ 000002 10"002 S+GA! 000010 10"010 S#7:+ KKKKKK KKKKKKKK #nd of re/ort KKKKKKKK )olu,ns . . . 1 .1 #dit 3S#7:+=&S8#PA! &# a(e 59 of 250

As400 Stuff S#BLL[ S#&O!=&6 6!: &6... KKKKKKKKKKKKKKK 4e(innin( of data KKKKKKKKKKKKKKKKKKKKK 0001.00 0002.00 0003.00 0004.00 $ $#)S#& 3 #! 7O S #! 7O O #! 7A!# )! >%: 10003? )! >#C ;S+GA!;? 6=&# >S#&O!=:?

KKKKKKKKKKKKKKKKKK #nd of data KKKKKKKKKKKKKKKKKKKKKKKKKK Dis/lay $e/ort #! 7O #! 7A!# 000001 10"002 SA73A 000002 10"004 S#7:+ 000003 10"00* SA73A 000004 10"00- S+GA! 00000* 10"00. SA73A 00000- 10"001 S#7:+ 00000. 10"002 S+GA! 000001 10"010 S#7:+ KKKKKK KKKKKKKK #nd of re/ort KKKKKKKK )olu,ns . . . 1 .1 S#BLL[ S#&O!=&6 6!: &6 KKKKKKKKKKKKKKK 4e(innin( of data KKKKKKKKKKKKKKKKKKKKKKKK 0001.00 0002.00 $ $#)S#& 3 #! 7O a(e 60 of 250 6=&# >S#&O!=:? #dit 3S#7:+=&S8#PA! &#

As400 Stuff 0003.00 0004.00 O #! 7A!# S #! 7O )! >#C ;S+GA!;? )! >%: 10001?

KKKKKKKKKKKKKKKKKK #nd of data KKKKKKKKKKKKKKKKKKKKKKKK #! 7O #! 7A!# 000001 10"002 SA73A 000002 10"004 S#7:+ 000003 10"00* SA73A 000004 10"00. SA73A 00000* 10"001 S#7:+ 00000- 10"010 S#7:+ KKKKKK KKKKKKKK #nd of re/ort KKKKKKKK )olu,ns . . . 1 .1 S#BLL[ S#&O!=: 6!: 6. KKKKKKKKKKKKKKK 4e(innin( of data KKKKKKKKKKKKKKKKKKK 0001.00 0002.00 0003.00 0004.00 $ $#)S#& #! 7O #! 7A!# 3 #! 7O * 0 20A #dit 3S#7:+=&S8#PA! &#

KKKKKKKKKKKKKKKKKK #nd of data KKKKKKKKKKKKKKKKKKKKKKKK #! 7O #! 7A!# 000001 000002 000003 000004 20 S+GA! 30 $A! 40 :O! *0 $A!#S+ a(e 61 of 250

As400 Stuff 00000* 0000000000. 000001 000002 -0 S+GA! .0 S+GA! 10 :O! 20 :O! 100 <ASB

KKKKKK KKKKKKKK #nd of re/ort KKKKKKKK )olu,ns . . . 1 .1 S#BLL[ S#&O!=&61 6!: &6 KKKKKKKKKKKKKKK 4e(innin( of data KKKKKKKKKKKKKKKKKKKKKKKK 0001.00 0002.00 0003.00 0004.00 $ $#)S#& 3 #! 7O S #! 7O S #! 7A!# )! >%: *0? <A&B#S >;S+GA!;? 6=&# >S#&O!=:1? #dit 3S#7:+=&S8#PA! &#

KKKKKKKKKKKKKKKKKK #nd of data KKKKKKKKKKKKKKKKKKKKKKKKKK #! 7O #! 7A!# 000001 000002 000003 000004 00000* 0000020 S+GA! -0 S+GA! .0 S+GA! 10 :O! 20 :O! 100 <ASB

KKKKKK KKKKKKKK #nd of re/ort KKKKKKKK )olu,ns . . . 1 .1 S#BLL[ S#&O!=&61 a(e 62 of 250 #dit 3S#7:+=&S8#PA! &#

As400 Stuff 6!: &6. KKKKKKKKKKKKKKK 4e(innin( of data KKKKKKKKKKKKKKKKKKKKKKKK 0001.00 0002.00 0003.00 0004.00 $ $#)S#& 3 #! 7O S #! 7O O #! 7O )! >%: *0? $A7%# >20 40? 6=&# >S#&O!=:1?

KKKKKKKKKKKKKKKKKK #nd of data KKKKKKKKKKKKKKKKKKKKKKKKKKK #! 7O #! 7A!# 000001 000002 000003 000004 00000* 00000*0 $A!#S+ -0 S+GA! .0 S+GA! 10 :O! 20 :O! 100 <ASB

KKKKKK KKKKKKKK #nd of re/ort KKKKKKKK )olu,ns . . . 1 .1 S#BLL[ S#&O!=&61 6!: &6 KKKKKKKKKKKKKKK 4e(innin( of data KKKKKKKKKKKKKKKK 0001.00 0002.00 0003.00 0004.00 000*.00 $ $#)S#& 3 #! 7O S #! 7O S #! 7A!# O #! 7O )! >%: *0? <A&B#S >;S+GA!;? $A7%# >.0 20? 6=&# >S#&O!=:1? #dit 3S#7:+=&S8#PA! &#

KKKKKKKKKKKKKKKKKK #nd of data KKKKKKKKKKKKKKKKKKKK a(e 63 of 250

As400 Stuff #! 7O #! 7A!# 000001 000002 000003 000004 00000* 0000000000. 000001 000002 20 S+GA! 30 $A! 40 :O! *0 $A!#S+ -0 S+GA! .0 S+GA! 10 :O! 20 :O! 100 <ASB

KKKKKK KKKKKKKK #nd of re/ort KKKKKKKK )olu,ns . . . 1 .1 S#BLL[ S#&O!=&61 6!: &6 KKKKKKKKKKKKKKK 4e(innin( of data KKKKKKKKKKKKKKKKK 0001.00 0002.00 0003.00 000*.00 $ $#)S#& 3 #! 7O S #! 7O O #! 7O )! >%: *0? $A7%# >.0 20? 6=&# >S#&O!=:1? #dit 3S#7:+=&S8#PA! &#

KKKKKKKKKKKKKKKKKK #nd of data KKKKKKKKKKKKKKKKKKKKKKKK #! 7O #! 7A!# 000001 000002 000003 000004 20 S+GA! 30 $A! 40 :O! *0 $A!#S+ a(e 64 of 250

As400 Stuff 00000* 0000000000. 000001 000002 -0 S+GA! .0 S+GA! 10 :O! 20 :O! 100 <ASB

KKKKKK KKKKKKKK #nd of re/ort KKKKKKKK 1. E21lain self $oin" 5oinin( a file to itAself is 9nown as selfAjoin. >Or? A /hysical file can be joined to itself to read records that are for,ed by co,binin( two or ,ore records fro, the 6 itself.

)olu,ns . . . 1 .1 S#BLL[ S#5O=7 6!: 6

#dit

3S#7:+=&S8#PA! &#

KKKKKKKKKKKKKKK 4e(innin( of data KKKKKKKKKKKKKKKKKKKK 0001.00 0002.00 0003.00 0004.00 000*.00 $ #! #! =D #! 7A!# !%$=D 3 #! =D * 0 20A * 0

KKKKKKKKKKKKKKKKKK #nd of data KKKKKKKKKKKKKKKKKKKKKKKKKKK

E*)=

E*)89*E

*,+= *0"001

000001 10"001 S#4= 5OS# + ).

a(e 65 of 250

As400 Stuff 000002 10"002 B$BS+O::A! *0"002 *0"003 *0"004 *0"00* 20"001 20"002 20"003 20"004 20"00*

000003 10"003 SA!##$ D=%+# 000004 10"004 S+A$A:A 00000* 10"00* AB&

00000- *0"001 S+=<A$A! 00000. *0"002 %AB$A< 000001 *0"003 3=7% 000002 *0"004 SA! 000010 *0"00* A7=& KKKKKK KKKKKKKK #nd of re/ort KKKKKKKK )olu,ns . . . 1 .1 S#BLL[ S#&5O=7 6!: &6 #dit

3S#7:+=&S8#PA! &#

KKKKKKKKKKKKKKK 4e(innin( of data KKKKKKKKKKKKKKKKKKKKKKKKKK 0001.00 0002.00 0003.00 0004.00 000*.00 000-.00 000..00 #! =D #! 7A!# !A7A%#$ $ #! 5 57=#E C6E5(=8 6E5(=8D 5O=7 >1 2? 56&D >!%$=D #! =D? 5$#6 >1? 5$#6 >1? $#7A!# >#! 7A!#? 5$#6 >2? )O&+D% >;!A7A%#$;?

KKKKKKKKKKKKKKKKKK #nd of data KKKKKKKKKKKKKKKKKKKKKKKKKKKKK E*)= E*)89*E *989,E+ S+=<A$A! %AB$A<

000001 10"001 S#4= 5OS# + ). 000002 10"002 B$BS+O::A!

a(e 66 of 250

As400 Stuff 000003 10"003 SA!##$ D=%+# 000004 10"004 S+A$A:A 00000* 10"00* AB& 3=7% SA! A7=&

KKKKKK KKKKKKKK #nd of re/ort KKKKKKKK )olu,ns . . . 1 .1 S#BLL[ S#&5O=71 6!: &6 $ #! 0002.00 0003.00 0004.00 000*.00 000-.00 000..00 !%$=D #! =D #! 7A!# KKKKKKKKKKKKKKK 4e(innin( of dataKKKKKKKKKKKKKKKKKKKKKKKK0001.00 56=&# >S#5O=7 S#5O=7? 5 5O=7 >1 2? 56&D >!%$=D #! =D? 5$#6 >1? $#7A!# >#! 7A!#? 5$#6 >1? 5$#6 >2? #dit 3S#7:+=&S8#PA! &#

KKKKKKKKKKKKKKKKKK #nd of data KKKKKKKKKKKKKKKKKKKKKKKKK #! =D #! 7A!# !%$=D 20"001 20"002 20"003 20"004 20"00*

000001 10"001 S#4= 5OS# + ). 000002 10"002 B$BS+O::A!

000003 10"003 SA!##$ D=%+# 000004 10"004 S+A$A:A 00000* 10"00* AB&

KKKKKK KKKKKKKK #nd of re/ort KKKKKKKK )olu,ns . . . 1 .1 S#BLL[ S#&5O=71 6!: &6 a(e 67 of 250 #dit 3S#7:+=&S8#PA! &#

As400 Stuff KKKKKKKKKKKKKKK 4e(innin( of dataKKKKKKKKKKKKKKKKKKKKKKKK 0001.00 0002.00 0003.00 0004.00 000*.00 000-.00 000..00 !%$=D #! =D !A7A%#$ $ #! 5 56=&# >S#5O=7 S#5O=7? 5O=7 >1 2? 56&D >!%$=D #! =D? 5$#6 >1? $#7A!# >#! 7A!#? 5$#6 >2? )O&+D% >;!A7A%#$;? 5$#6 >2?

KKKKKKKKKKKKKKKKKK #nd of data KKKKKKKKKKKKKKKKKKKKKKKKKKKK #! =D !A7A%#$ 000001 10"001 S+=<A$A! 000002 10"002 %AB$A< 000003 10"003 3=7% 000004 10"004 SA! 00000* 10"00* A7=& KKKKKK KKKKKKKK #nd of re/ort KKKKKKKK 2. E21lain nor0aliBation" =t is the /rocess of se(re(atin( and deco,/osin( infor,ation held within a syste, into lo(ically (rou/ed" related. BniEuely identifiable entities 3. E21lain t&e co00and 9 )7.6>" !%$=D 20"001 20"002 20"003 20"004 20"00*

ADD 6)S: is a co,,and that is used to define the )onstraint on your /hysical file. :he constraint has se'eral ty/es. :hese are $#6)S:" B7C)S: and $=3#G. 4y the by" this co,,and is hel/s to define B/date rules and Delete rules.

a(e 68 of 250

As400 Stuff 4. /o' to send t&e 0essage to t&e screen 68 ),**6," 4G /assin( uniEue ,essa(e =D ,essa(e data and ,essa(e file. S7D %!!S% synta0 S7D %! !S% !S%=D >!S%0001? !S%6 >!S%SB4? 5. /o' you can list all t&e #7 of a )7" 4y usin( DS D4$ co,,and it is to list all the files" which are related to a 6. =t dis/lays all the &6 that is referrin( the 6 and also lists the child table if it is ha'in( a relation throu(h ADD 6)S:. 6. %&at is use of 6)77 and 6)7 " DS 6D >dis/lay file descri/tion? =t is used to dis/lay the details about the file when it is created. DS 66D >dis/lay file field descri/tion? =t is used for listin( details about indi'idual fields. 1. E21lain inner $oin or natural $oin and left outer $oin" =nner join =nner $oin 0eans t&e 0atc&ing records in !et'een t&e $oining file 'ill !e selected. )olu,ns . . . 1 .1 S#BLL[ 5 601 6!: 6 KKKKKKKKKKKKKKK 4e(innin( of data KKKKKKKKKKKKKKKKKKKKKKKKKKKK 0001.00 0002.00 0003.00 0004.00 $ 5 1$#) #! 7O #! 7A!# 3 #! 7O *S 0 20A #dit 3S#7:+=&S8#PA! &#

KKKKKKKKKKKKKKKKKK #nd of data KKKKKKKKKKKKKKKKKKKKKKKKKKKKK )olu,ns . . . 1 .1 S#BLL[ 5 602 6!: 6. #dit 3S#7:+=&S8#PA! &#

a(e 69 of 250

As400 Stuff KKKKKKKKKKKKKKK 4e(innin( of data KKKKKKKKKKKKKKKKKKKKKKKKKKK 0001.00 0002.00 0003.00 0004.00 $ 5 2$#) #! 7O #! SA& 3 #! 7O *S 0 10 2

KKKKKKKKKKKKKKKKKK #nd of data KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK Dis/lay $e/ort #! 7O #! 7A!# 000001 1"001 S+GA!4A4B 000002 1"002 S#7:+=&3B!A$ 000003 1"003 $A!#S+ KKKKKK KKKKKKKK #nd of re/ort KKKKKKKK #! 7O #! SA& 100.00 20.00 300.00

000001 1"001 000002 1"002 000003 1"004

KKKKKK KKKKKKKK #nd of re/ort KKKKKKKK )olu,ns . . . 1 .1 S#BLL[ 5O6=&# 6!: &6. KKKKKKKKKKKKKKK 4e(innin( of data KKKKKKKKKKKKKKKKKKKKKKKK 0001.00 0002.00 0003.00 0004.00 000*.00 #! 7O #! 7A!# a(e 70 of 250 $ 5$#)1 5 56=&# >5 601 5 602? 5O=7 >1 2? 56&D >#! 7O #! 7O? 5$#6 >5 601? #dit 3S#7:+=&S8#PA! &#

As400 Stuff 000-.00 000..00 #! SA& 3 #! 7O

KKKKKKKKKKKKKKKKKK #nd of dataKKKKKKKKKKKKKKKKKKKKK #! 7O #! 7A!# 000001 1"001 S+GA!4A4B 000002 1"002 S#7:+=&3B!A$ KKKKKK KKKKKKKK #nd of re/ort KKKKKKKK &eft outer join #eft outer $oin all t&e records fro0 1ri0ary file and 0atc&ing records fro0 t&e secondary file 'ill !e selected. )olu,ns . . . 1 .1 S#BLL[ 5OOB: 6!: &6. KKKKKKKKKKKKKKK 4e(innin( of dataKKKKKKKKKKKKKKKKKKKKK 0001.00 0002.00 0003.00 0004.00 000*.00 000-.00 000..00 0001.00 #! 7O #! 7A!# #! SA& 3 #! 7O $ 5$#)1 5 5 7>G9# 56=&# >5 601 5 602? 5O=7 >1 2? 56&D >#! 7O #! 7O? 5$#6 >5 601? #dit 3S#7:+=&S8#PA! &# #! SA& 100.00 20.00

KKKKKKKKKKKKKKKKKK #nd of dataKKKKKKKKKKKKKKKKKKKK #! 7O #! 7A!# 000001 1"001 S+GA!4A4B 000002 1"002 S#7:+=&3B!A$ a(e 71 of 250 #! SA& 100.00 20.00

As400 Stuff 000003 1"003 $A!#S+ .00

KKKKKK KKKKKKKK #nd of re/ort KKKKKKKK S#CB#7)=7% DB &=)A:# $#)O$DS )olu,ns . . . 1 .1 S#BLL[ S#C1 6!: 6. KKKKKKKKKKKKKKK 4e(innin( of data KKKKKKKKKKKKKKKKKKKKKKK 0001.00 0002.00 0003.00 0004.00 000*.00 $ S#C$#)1 #! 7O #! 7A!#1 ADD$#SS 3 #! 7O * 0 20A 20A #dit 3S#7:+=&S8#PA! &#

KKKKKKKKKKKKKKKKKK #nd of data KKKKKKKKKKKKKKKKKKKKKKKKKK )olu,ns . . . 1 .1 S#BLL[ S#C2 6!: 6 KKKKKKKKKKKKKKK 4e(innin( of dataKKKKKKKKKKKKKKKK 0001.00 0002.00 0003.00 0004.00 $ S#C$#)2 #! 7O #! 7A!# :#& * 0 20A 10 0 #dit 3S#7:+=&S8#PA! &#

KKKKKKKKKKKKKKKKKK #nd of data KKKKKKKKKKKKKKKKKK

#! 7O #! 7A!#1 000001 10"001 4O4

ADD$#SS 23"O&D !AD=WA&A

a(e 72 of 250

As400 Stuff 000002 10"002 DA77G 000003 10"003 $=7) *0"&O7% =S&A7D 20"A::B$

KKKKKK KKKKKKKK #nd of re/ort KKKKKKKK E*)8( E*)89*E >E# 12*"... 12*"222 12*"111 4"222"-00

000001 10"001 4O4 000002 10"001 4O4 000003 10"001 4O4 000004 10"002 DA77G

KKKKKK KKKKKKKK #nd of re/ort KKKKKKKK )olu,ns . . . 1 .1 S#BLL[ 5D6:S#C 6!: &6 KKKKKKKKKKKKKKK 4e(innin( of data KKKKKKKKKKKKKKKKKK 0001.00 0002.00 0003.00 0004.00 000*.00 000-.00 000..00 0001.00 #! 7O #! 7A!#1 ADD$#SS :#& $ $#)S#C 5 56=&# >S#C1 S#C2? 5O=7 >1 2? 56&D >#! 7A!#1 #! 7A!#? 5DB S#C >:#&? 5$#6 >2? #dit 3S#7:+=&S8#PA! &#

KKKKKKKKKKKKKKKKKK #nd of dataKKKKKKKKKKKKKKKKKKKKKKKK E*)8( E*)89*E1 9 +E66 >E# 12*"... 12*"111

000001 10"001 4O4 000002 10"001 4O4

23"O&D !AD=WA&A 23"O&D !AD=WA&A a(e 73 of 250

As400 Stuff 000003 10"001 4O4 000004 10"002 DA77G 23"O&D !AD=WA&A *0"&O7% =S&A7D 12*"222 4"222"-00

KKKKKK KKKKKKKK #nd of re/ort KKKKKKKK 5O=7 D#S)#7D )olu,ns . . . 1 .1 S#BLL[ 5D6:S#C 6!: &6 KKKKKKKKKKKKKKK 4e(innin( of data KKKKKKKKKKKKKKKKKKKKKKK 0001.00 0002.00 0003.00 0004.00 000*.00 000-.00 000..00 0001.00 #! 7O #! 7A!#1 ADD$#SS :#& $ $#)S#C 5 56=&# >S#C1 S#C2? 5O=7 >1 2? 56&D >#! 7A!#1 #! 7A!#? 5DB S#C >:#& KD#S)#7D? 5$#6 >2? #dit 3S#7:+=&S8#PA! &#

KKKKKKKKKKKKKKKKKK #nd of data KKKKKKKKKKKKKKKKKKKKKKKKK E*)8( E*)89*E1 000001 10"001 4O4 000002 10"001 4O4 000003 10"001 4O4 000004 10"002 DA77G 9 +E66 23"O&D !AD=WA&A 23"O&D !AD=WA&A 23"O&D !AD=WA&A *0"&O7% =S&A7D >E# 12*"222 12*"111 12*"... 4"222"-00

KKKKKK KKKKKKKK #nd of re/ort KKKKKKKK 1. /o' to create a trigger in 96:400" :he tri((er is an e'ent to be /erfor,in( before or after any chan(e to a database. When a tri((er is added to a /hysical file" three attributes need to be defined. a(e 74 of 250

As400 Stuff :he first is the e'ent that will cause the tri((er to fire. A tri((er e'ent can be an insert" an u/date" or a delete a record fro, the file. :he second attribute to define is when to fire the tri((erAbefore or after the e'ent. :he third attribute to define is the identification of the tri((er /ro(ra, to by run. We can infer that u/ to si0 tri((ers can be defined for each 6. 6or each u/date" insert" and delete :wo tri((ers can be defined One that runs before the e'ent One that runs after the e'ent :hese tri((er are added usin( the ADD 6:$% )an be re,o'ed with the re,o'e 6 tri((er co,,and >$!< 6:$%? :he co,,and ADD 6:$% ta9es 64 6 &=4 :$=%%#$ :=!# :$=%%#$ #<#<: $O%$A! &=4 $# &A)# :$=%%#$ K7O A&&OW $# #A:#D K7O 6001 S3A7DASA!O KA6:#$ KB DA:# %!001 S3A7DASA!O K7O KG#S K7O KG#S K4#6O$# KA6:#$ KB DA:# K=7S#$: KD#&#:# 7A!#

1. /o' 'ill !e esta!lis&ing +E7E+E8>=9# =8>E,+=>? in as:400 syste0s" 4y usin( ADD 6)S: co,,and establish in as8400 syste,. $eferential inte(rity conce/ts $eferential constraint arent and de/endent files BniEue 9ey and /ri,ary 9eys arent and forei(n 9eys Delete rule ro/a(ate delete fro, /arent file to de/endent file $estrict delete on /arent file B/date rule $estrict inconsistent u/dates a(e 75 of 250

As400 Stuff =nsert o/erations on de/endent file are chec9ed $eferential constraint A referential constraint is a relation between two files" the /arent file and the de/endent file. :his relationshi/ establishes that e'ery record in the de/endent file has to ha'e a ,atchin( record in the /arent file. :he 9ey 'alue of any record in the de/endent file ,ust ,atch a 9ey 'alue in the /arent file. We call /arent 9ey the 9ey of the /arent file and forei(n 9ey the 9ey in the de/endent file. :he /arent 9ey has to be uniEue and cannot contain null 'alues. :he forei(n 9ey 'alue has to ,atch one >any only one? 'alue of the /arent 9ey. Otherwise the forei(n 9ey can contain a null 'alue. A record in the /arent file ,ay be related to ,ulti/le records in the de/endent filesX each record in the de/endent file has to ha'e just oneT /arentT or ha'e a null forei(n 9ey. ri,ary 9ey we ,eans a uniEue and ascendin( 9ey" which is the /ri,ary" access /ath for a 6 and cannot contain null 'alues. ri,ary access /ath for a database file on the AS8400 in the access /ath used to access the file by usin( O 7D46 co,,and. Delete rule We can delete a record fro, /arent file or de/endent file first chec9 for delete rule. )AS)AD#H =f we want to delete a record fro, the /arent file and its /arent 9ey is ,atchin( records in a de/endent file" the D4!S will delete all the ,atchin( records of the de/endent file. S#:7B&&H =f we delete a record fro, the /arent file and /arent 9ey is ,atchin( so,e records in a de/endent file" the D4!S will set to null the ,atchin( 9eys in the de/endent file. S#:D#6AB&:H :his is li9e /re'ious case" but ,atchin( occurrences in the forei(n 9ey are set to their default 'alues. :he default 'alue for the forei(n 9ey has to ,atch a record in the /arent file. $#S:$=):H :he D4!S will /re'ent any atte,/t to delete records in the /arent file if its 9ey is ,atchin( so,e records in the de/endent file. 7O A):=O7H :his has the sa,e ,eanin( as restrict" but different ti,in(. When we use K7OA):=O7 and an in'alid delete o/eration is about to ta9e /lace" D42 8400 will delay any error ,essa(e until the end of the o/eration itself" allowin( for instance the acti'ation of a before tri((er attached to the 6. =f Krestrict is in use" the e0ce/tion ,essa(e is sent i,,ediately. Deletin( records in a de/endent file is always /er,itted. B/date rule a(e 76 of 250

As400 Stuff $#S:$=):H We cannot chan(e the 'alue in a /arent 9ey if the old 'alues are ,atchin( so,e records in the de/endent file. :he re,ainin( /ortion of the record can always be u/dated. We cannot u/date a forei(n 9ey in a de/endent file if the new 'alue for the 9ey is not null and does not ,atch any 'alue of the /arent 9ey. 7O A):=O7H :his is sa,e as K restrict but with different ti,in( considerations. $efer abo'eX where we describe no action delete o/erations. =nserts :here is no insert rule to be chosen" but referential inte(rity /re'ents any insert in the de/endent file if the new record has no ,atch in the /arent file and its forei(n 9ey is not null. 1. %&at +<86;#6>* 'ill do" =f we want to e0ecute set of SC& state,ent then we can write all the SC& state,ent to be includin( with the source. :y/e as SC& Only insert" u/date and delete and no select is allowed. :hen use S:$SC&S:! to e0ecute the /ro(ra, $B7SC&S:! S$)6=&# >&=48:#S:? S$)!4$ >SC&01? )O!!=: >K7O7#? 1. %&at is a field reference file" :his is 6" which does not ha'e any data and contains only the field descri/tions and these fields are referred in other 6 by usin( $#6 and $#66&D 2. %&at are t&e -arious 'ays creating access 1at&" Access /ath ,eans the records are to be retrie'ed fro, a file. :he records can be retrie'ed fro, a 6 or a &6 either A$$=<A& S#CB#7)# or by 3#G#D S#CB#7)#. 6or &6 you can also select records usin( select or o,it 9eywords 9rri-al seLuence access 1at& SeEuentially" where each record is ta9en fro, the ne0t seEuential /hysical /osition in the file. Directly by relati'e records nu,ber" where the record nu,ber is identified by its /osition fro, the start of the file. 3eyed seLuence access 1at& =t is based on the contents of the 9ey fields as defined in DDS. :his ty/e of access /ath is u/dated in the contents of a 9ey field is chan(ed. :here are three ways of boundin( the access /ath a(e 77 of 250

As400 Stuff =00ediate Access /ath is always ,aintained for e'ery o/enin( in a file. +e!uild Access /ath is ,aintained when the file is o/en and 'arious u/dates are recorded and the access /ath is rebuilt e'ery ti,e when the access /ath is closed. elayed Access /ath is ,aintained when the file is o/ened and u/dates recorded. When the file is closed all the u/dates to the records are closed to(ether but it is not rebuild. When the recorded u/date /ercenta(e e0ceeds 2*O then rebuild of records ta9e /lace. 1. /o' 0any record for0ats )7, #7, 6A 1" &6A 32" DS 6A1024 S6&A*12 2. 6)7 and 67#"

efine 3#=6>" 3&=S: o/eration is a declarati'e o/eration that (i'es a na,e to list of 36&D. :his 3&=S: can be used as a search ar(u,ent to retrie'e records fro, files that ha'e a co,/osite 9ey. efine )#=6>" :he declarati'e &=S: o/eration defines sy,bolic na,e for a /ara,eter list to be s/ecified in a )A&& o/eration. 4. efine co01osite Eey" =t is a 9ey for a file" which is co,/osed of ,ore than one field. 3.

5. =s it 1ossi!le to create a logical file '&ose )&ysical file is not in sa0e li!rary" Ges...for that u ha'e to s/ecify the actual data /ath in 9eyword 6=&# &i9e A $ A1 6=&# >A!=:8A2? A 3 )OD# :hen this will create the &6 A1 for A2 6... Ges" just /ut the user library in which you want to create on to/ and followed by other library in which /hysical file is located. ro'ided the first library should not ha'e /hysical file. :hen try to create the lo(ical. 6. .an you delete t&e record s1ace 1er0anently in )7 t&roug& .#" BS=7% :+# )O!!A7D ;$%M 6!; :he $eor(aniFe hysical 6ile !e,ber >$%M 6!? co,,and co,/resses >re,o'es deleted records fro,? one ,e,ber of a /hysical file in the database" and it o/tionally reor(aniFes that ,e,ber. 7. %&at is t&e difference !et'een adding Eeys K constraints into a 1&ysical file" a(e 78 of 250

As400 Stuff Durin( the ti,e of co,/ilation of a file" constrains are bein( re,o'ed" fro, the file .but at the ti,e of co,/ilation 9eys are not re,o'ed in case fro, /f. )onstraints has no affects on ,e,bers of a /f but 9eys has affect on ,e,bers of /f A 9ey field defines the order in which the records of a 6 ,e,ber will be sorted >ascendin( or descendin(?. On the other hand" a constraint" such as B7=CB#" defines which 9ey field 'alues or records are 'alid 8allo'a!le to be written into a file. B7=CB# /re'ents a record with du/licate 9ey field 'alues to be written into a 6. 8. /o' to insert 0ore t&an one record to a 1f at a ti0e" C4ulE insert to a 1fD 4ul9 insert can be done in ways 1. Bsin( SC& we can run a Euery =nsert into table1 'alues >;a;" ;b;" ;c;?" >;0;" ;y;" ;F;? 2. Bsin( S:$D6B we insert records into 6 3. Bsin( D4B >Database utility? also we can insert records 9. /o' to see nu0!er of logical files de1ending on a 1f" .an 'e declare 0ore t&an 20 logical files fro0 a single 1f" =s it 1ossi!le" 1. We can see the nu,ber of lo(ical files in the followin( ways a. DS D4$ >filena,e? co,,and b. Bsin( D4B >6ilena,e? and Shift U 62 :here is one ,ore way to see the lo(ical BS=7% D4B is just ty/e ;D4$; and /ress enter. 2. Ges we can declare ,ore than 20 files on a /hysical file 10.= 'ant to c&ange t&e attri!ute of field or 'ant to add ne' field in e2isting )7 !ut condition is for0at le-el identifier s&ould not c&ange, is it 1ossi!le" Whene'er a file is chan(ed >by addin( or deletin( a field?" 6or,at le'el identifier is also chan(ed" e'en if u are usin( )+% 6. All the /ro(ra,s that are this file needs to be co,/iled a(ain. Gou can a'oid reco,/ilin( /ro(ra,s by settin( 6or,at &e'el )hec9 /ara,eter to K7O in co,,and )$: 6. 4ut this is not a (ood ,ethod" since it ,ay affect the /ro(ra,. 11.*a2i0u0 &o' 0any fields 'e can create under a record for0at of )7" We can (i'e ,a0 of 1000 fields in rec for,at of a 6. 4ut it also de/ends on the no. of bytes occu/ied by the record for,at. 4ecause rec. for,at of 6 ,ay occu/y at ,a0 32.-- bytes.ie if there is only one field which occu/y 32.-- bytes then we a(e 79 of 250

As400 Stuff can;t define a new field in record for,at. So it de/ends on the no. of bytes occu/ied by the field defined in the record for,at. #0. )har field A ,a0 'alue >32.-- bytes? <ariable len(th field A ,a0 'alue >32.40 bytes? Allow null field A ,a0 'alue >32.-*? <ariable D allow null field A ,a0 'alue >32.32? 12./o' can 'e 'rite #7 using flat file" 4&D=7D#P !&$?WS?"21"1"!&.$#:B$""DB 3#G 4&D=7D#P !&.+=S?WS?"2"-"!&.=7<+S""DB 3#G""1."* :G # 4&D=7D#P in syste, 3- en'iron,ent D 64 4&D=7D#P $O)#DB$# =(noredAO )reates an alternate inde0 for a /hysical file 7a,e of file to be )$#A:#D . . Start /osit for 1st field of 9ey 1A402&en(th of first field . . . . . 1A120 * 1 7=$OS+ O/tionalAK

Start /osit for 2nd field of 9ey 1A402&en(th of 2nd field . 1A120 *

Start /osit for 3rd field of 9ey 1A402&en(th of 3$D field 7a,e of +GS=)A& 6=&# )reation date of /hysical file Allow du/licate 9eys DB 3#G"7ODB 3#G refer dis9 locn A1"A2"A3"A4"bloc9 nu,ber 13.%&y 'e create t&e )&ysical 7ile *e0!er" !#!4#$ =S BS# :O S:O$# :+# DA:A" #A)+ 6=&# !BS: +A<# !#!4#$. a(e 80 of 250 DB 3#G 1A120 ... !&.)$D$

As400 Stuff 14../,)7 to co01ile t&e )7 'it&out using t&e data@ Gou ha'e added so,e fields to a /hysical file that has lots of records. Gou don@t want to lose the data" but you ha'e to co,/ile that to include those fields. =n that case" ,a9e use of )+% 6. )+% 6 6=&# >S+A=&#S+8S6&001 6? S$)6=&# >S+A=&#S+8:#S: %!S? =t (i'es you the result si,ilar co,/ilation >includin( the added fields? without losin( the data. +ere S6&001 6 is the 6 and :#S: %!S is the source /hysical file. 8ote@ )+% 6 cannot be used to achie'e the result si,ilar to co,/ilation in case of deletion of so,e fields. Gou ha'e to co,/ile the 6 to e0clude the deleted fields. =n SC& there is a co,,and called A&:#$ which /erfor,s si,ilar functions >li9e ADD constraint" D$O constraint" ADD field" A&:#$ field and D$O field? as )+% 6. 4ut here also we (et error ,essa(e when we try to alter or delete the fields just li9e the )+% 6 scenario. 15.*ulti for0at #ogical file E2a01le@ +ere is an e0a,/le of a ,ultiAfor,at lo(ical fileH A A A A A A A A $ 6O$!A:1 6=#&D1 6=#&D2 3 6=#&D1 $ 6O$!A:2 6=#&D1 6=#&D2 3 6=#&D1 6=&# >6=&#2? 6=&# >6=&#1?

=n the /ro(ra," you can chain with the file na,e and you;ll (et records fro, both /hysical files" or the for,at na,e and you;ll (et records only fro, the s/ecific 6=&#. =f you want to u/date or write a record with this lo(ical file" you ,ust use the for,at na,e. &i,itationH #'en thou(h lo(ical files allow ,ulti/le record for,ats" we cannot ha'e different record for,ats for the sa,e /hysical file >as the record for,at of the &6 has to be the sa,e as 6?. $ecord for,ats of ,any /hysical files can be /resent in

a(e 81 of 250

As400 Stuff one &6 ,a9in( it ,ulti for,at &6. We can ha'e u/ to 32 record for,ats in the sa,e &6. =f you want to access the sa,e 6 with different set of 9eys you ha'e to (o for ,ulti/le si,/le lo(ical files li9e the one shown below. &61H A A A A &62H A A A A $ 6O$!A:1 6=#&D2 6=#&D3 3 6=#&D2 6=&# >6=&#1? $ 6O$!A:1 6=#&D1 6=#&D2 3 6=#&D1 6=&# >6=&#1?

+ere we want to access the 6" 6ile1 with 2 sets of 9eys. 6ield1 D 6ield 2 is one set and 6ield 2 D 6ield 3 is the other set. 4ut we cannot ,ention 2 record for,ats with these 9eys in the sa,e lo(ical file. We ha'e to write 2 se/arate lo(ical files &61 and &62 in order to ha'e 2 different record for,ats for that 6" 6ile1. 16.9ccess )at& )7 and #7 =n a /ro(ra," a record is deleted fro, a /hysical file. =n the sa,e /ro(ra," the file is read a(ain >the file is not closed and the delete o/eration is not co,,itted as well?. =n that case" we will be accessin( the deleted record also" since the refresh has not ta9en /lace on that 6. Only after )o,,it >in case the file is not user o/en only co,,it or endin( the /ro(ra, can refresh the file? or e0/licit close" data refresh ha//ens. =t will not free u/ the s/ace thou(h. :he record will be e,/ty but will occu/y s/ace. Only $%M 6! can free u/ the s/ace occu/ied by the deleted record. 4ut in the case of &6" refresh ha//ens i,,ediately if we associate the, with the 9eywords that can rebuild8refresh the access /ath. Say for e0a,/le" we ha'e K=!!#D for rebuild" as soon as the o/eration ha//ens the file will (et refreshed. =t will not wait for the co,,it or close or /ro(ra, endin( to ha//en.

a(e 82 of 250

As400 Stuff 7oteH After deletin( record 2" and not issuin( $%M 6!" if we are tryin( to access the 6 with $$7 as 9ey startin( fro, the first record" the deleted record 2 will not be /rocessed e'en thou(h the s/ace is still occu/ied >i.e." it is not treated as a data record?. :he co,/iler treats it as e,/ty s/ace and s9i/s the record. 17.>ell 0e t&e differences !et'een e0!edded 6;#" 42 .#= Ccall #e-el =nterfaceD and

An a//lication that uses an e,bedded SC& interface reEuires a /reAco,/iler to con'ert the SC& state,ents into code" which is then co,/iled" bound to the database" and e0ecuted. =n contrast" a D42 )&= a//lication does not reEuire /reA co,/ilation or bindin(" but instead uses a standard set of functions to e0ecute SC& state,ents and related ser'ices at runti,e. :his difference is i,/ortant because" traditionally" /reAco,/ilers ha'e been s/ecific to a database /roduct" which effecti'ely ties your a//lications to that /roduct. D42 )&= enables you to write /ortable a//lications that are inde/endent of any /articular database /roduct. :his inde/endence ,eans a D42 )&= a//lication does not ha'e to be reco,/iled or rebound to access different database /roducts" but rather selects the a//ro/riate one at runti,e. D42 )&= can e0ecute any SC& state,ent that can be /re/ared dyna,ically in e,bedded SC&. :his is (uaranteed because D42 )&= doesn;t actually e0ecute the SC& state,ent itself" but /asses it to the D4!S for dyna,ic e0ecution. 18.,eneral 1oints in 42:400

1. D428400 is an inte(rated $D4!S. 2. :he ,ajor /arts of a file are $ecord for,at and Access /ath. 3. $ecord for,at in a file describes the way the data is actually stored. 4. Access /ath describes the order in which the records are to be retrie'ed. *. We ha'e two ty/es of access /atch 3eyes seEuence access /ath and Arri'al seEuence access /ath. -. Access ath ,aintenance s/ecifies how access /aths are ,aintained for closed files. While file is o/en the syste, ,aintains the access /ath chan(es. .. =n (eneral we ha'e three ty/es of access /ath ,aintenance" K=!!#D " KD&G and K$#4&D 1. K=!!#D ,ust be s/ecified for files that reEuire B7=CB# 9eys. >=,,ediate access /ath ,aintenance ,ainly for files used as interacti'ely? 2. K$#4&D the access /ath is co,/letely rebuilt each ti,e a file ,e,ber is o/ened. :his cannot be s/ecified for file if its access /ath is bein( journal.

a(e 83 of 250

As400 Stuff 10.KD&G the ,aintenance of the access /ath is delayed until the 6 ,e,ber is o/ened for use. B/dates to the access /ath are collected fro, the ti,e the ,e,ber is closed until it is o/ened a(ain. When it is o/ened" only the collected chan(es are ,er(ed into the access /ath. 11.=n )+% 6 co,,and we ha'e the 9eyword K&<&)+3 >&e'el )hec9?. :his s/ecifies whether the le'els of record for,at identifiers are chec9ed to 'erify that the current record for,at identifier is the sa,e as that s/ecified in the /ro(ra, that o/ens the /hysical file. :he le'el identifiers of the record for,ats are chec9ed when the file is o/ened. =f the le'el identifiers do not ,atch" an error ,essa(e is sent to the /ro(ra, reEuestin( the o/en" and the file is not o/ened. 12.6or /hysical file and for lo(ical the file ty/e should be S6=&#T. Attribute for /hysical file should co,e as S 6ADA:AT" lo(ical file co,e as S&6T and for source /hysical file attribute should co,e as S 6AS$)T 13.&et@s say one scenario" your source /hysical file na,e is SCDDSS$)T and inside this source /hysical file when you try to create a /hysical file with na,e sa,e as that of source /hysical file SCDDSS$)T what will ha//en? :he source /hysical file will (et deleted. 14.B7=CB# 9eyword is used in &6 and 6 to /re'ent du/licate 9ey 'alues. 1*.D#S)#7D 9eyword is used to arran(e records fro, the hi(hest to the lowest 9ey field 'alues. 1-.$A7%# 9eyword is used to /ro'ide a ran(e of 'alid 'alues. 1..$#6 9eyword s/ecifies the na,e of file contains the referenced fields. 11.$#66&D 9eyword co/ies the field descri/tion fro, the referenced file. 12.6O$!A: 9eyword shares the field descri/tion with the e0istin( record for,at. 20.D6: 9eywords /ro'ide the default 'alue for the fields. 21.)! 9eyword /ro'ides a co,/arison 'alue. #0a,/le )! >%# 0? 22.)+#)3 9eyword /ro'ides 'alidity chec9in(. 23.)O&+D% 9eyword /ro'ides colu,n headin(. 24.#D:)D# and #D:W$D 9eyword edit code and edit word. 2*.:#P: 9eyword /ro'ides the descri/tion of record or field. 2-.<A&B#S 9eyword /ro'ides a list of 'alid 'alues. a(e 84 of 250

As400 Stuff 2..A /hysical file can ha'e only one record for,at. 21.A /hysical file cannot share the for,at of lo(ical file. 22.6or /hysical file the default ,a0i,u, nu,ber of ,a0i,u, ,e,bers we can attain is K7O!AP ,e,ber is one" the

30.6or /hysical file the default 'alue of initial nu,ber of records which we can add to database is 10000 and ,a0i,u, incre,ents in a /hysical file are three. 31.!a0i,u, nu,ber of 9ey fields allowed in a 6 is 120. !a0 nu,ber of fields in a 6 is 1000. 32.!e,bers in /hysical file" the si(nificance of ,e,ber is it hel/s to classify data easier. 33.#0a,/le for ,e,ber conce/t is" = want to 9ee/ data for a year in one file" and = freEuently want to /rocess data for one ,onth at a ti,e. 6or this = can create one /hysical file with twel'e different ,e,bers for each ,onth. 34.We can co/y data of a ,e,ber to other ,e,ber of sa,e /hysical file. >We can@t co,/ile any new ,e,bers? 3*.S/ecific co,,ands for /hysical file ,e,bers" ADD 6!" )+% 6!" $!<!" =7M 6! >KD6: or KD&:?" $%M 6!" DS 6!. 3-.#'en if you delete the records in a 6 throu(h /ro(ra," still the s/ace used by the deleted records not used by other /ur/ose. +ence usin( $%M 6! co,,and we can co,/ress the deleted record s/ace. 3..+ow we can add a new field to a file which has thousands of data in it? )+% 6 co,,and will hel/ you to add new field without losin( your current data. 31.We can add ,e,ber to lo(ical file with co,,and ADD&6!. 32.DS 6D >Dis/lay file descri/tion? with :G # K!4$&=S: will dis/lay all ,e,bers associated with the s/ecified file. K:$% will (i'e you the tri((er /ro(ra, list. 40.An OD >O/en Data ath? is the /ath throu(h which all in/ut8out/ut o/erations for the files are /erfor,ed. =t connects the /ro(ra, to a file. =f we do not s/ecify the S+A$# >KG#S? then a new data /ath is created e'ery ti,e a file is o/ened. 41.&o(ical file is used to arran(e data fro, one or ,ore 6s into different for,ats and seEuences. &o(ical files contain no data. :hree different ty/es of a(e 85 of 250

As400 Stuff lo(ical file we ha'e" Si,/le lo(ical file" !ultifor, at lo(ical file and 5oin lo(ical file. A ,ulti for,at lo(ical file is also 9nown as Bnion file. 42.:he record for,at na,e of lo(ical file should8should not be sa,e as that of /hysical file which ,entioned in 6=&# 9eyword. 6=&# 9eyword tells the /hysical file that the lo(ical file based on. 43.:here are so,e 9eywords s/ecific for &6s" )O7)A:" DG7S&:" 56=&#" 56&D" 5O=7" 5$#6" 6=&#" $#7A!#" and SS:. 44.)olu,n 1. 'alues" $ I $ecord for,at na,e" 3A 3ey field na,e" 5 I 5oin s/ecification" S I Select field na,e" O I O,it field na,e. 4*.=n &6 the access /ath we can s/ecify in three ways" 9eyed seEuence access /ath" Arri'al seEuence access /ath and $#6A)) :+. 4-.=n 9eyed seEuence access /ath" $ )BS$)D 6=&#> 67A!#? 3 3#G1 3 3#G2 4..=n arri'al seEuence access /ath" $ )BS$)D 41.=n $#6A)) :+">$eference access /ath? $#6A)) :+>&=4$7A!#8 67A!#? $ )BS$)D 6=&#> 67A!#? 42.S#&#):8O!=: s/ecification a//ly to lo(ical file only. *0.=n ,ulti for,at lo(ical file the ,a0i,u, nu,ber of record for,at we can declare is 32. *1.#0a,/le of S#&#):8O!=: S 6=#&D1 <A&B#S>123 34* *-. *--? S 6=#&D2 $A7%#>30122 30300? S 6=#&D3 )! >%# 300? *2.We ha'e two ty/es of S#&#):8O!=:" Access /ath S#&#):8O!=: and Dyna,ic S#&#):8O!=:. Access /ath S#&#):8O!=: is ,aintained by syste, when records are added or chan(ed. Dyna,ic S#&#):8O!=: /rocessin( is done when records are read by the /ro(ra,. *3.6or a ,ulti for,at lo(ical file if you want to access a /articular ,e,ber of a /hysical file. :hen e0ecute the O<$D46 co,,and with the s/ecific ,e,ber na,e before readin( the lo(ical file. 6=&#> 67A!#?

a(e 86 of 250

As400 Stuff *4.Dyna,ic S#&#):8O!=:" when a /ro(ra, reads a records fro, the file" the syste, only returns those records that ,eet the select8o,it 'alues. :hat is the actual S#&#):8O!=: /rocessin( is done when records are done by the /ro(ra," rather than records are added or chan(ed. **.DG7S&: is the 9eyword for dyna,ic select. *-.Another ,ethod of selectin( records is usin( C$GS&: /ara,eter on the o/en Euery file >O 7C$G6? co,,and. *..5oin lo(ical file is a lo(ical file that co,bines fields fro, two or ,ore /hysical file. )annot chan(e /hysical file usin( join lo(ical file. )an s/ecify only one record for,at in join lo(ical file. :he record for,at in join lo(ical file cannot be shared. )o,,it,ent control cannot be used with join lo(ical file. *1.We can join a /hysical file to itself. *2.5oin lo(ical files are $ead only files. -0.=n 5oin lo(ical file ,a0i,u, of 31 secondary files can join. >:otal 32 files.? !a0 of two files can be joined at a ti,e. -1.#0a,/le of join lo(ical file" $ 5 5O=7$#) 56=&#> 61 62? 5O=7> 61 62? 56&D>74$ 74$? 74$ 5$#6> 61? 7A!# SA&A$G 3 74$

-2.At least two /hysical files ,ust be s/ecified on 56=&# 9eyword. :he first file s/ecified on the 56=&# is the /ri,ary file the other files are secondary files. -3.5O=7 9eyword identifies which two files are joined by the 5O=7 s/ecification. =f only two /hysical files are joined by the join lo(ical file" then 5O=7 9eyword is o/tional. -4.56&D 9eyword identifies the join fields that join records fro, /hysical files s/ecified in 5O=7. 56&D ,ust be s/ecified at least once for each 5O=7 s/ecification. 5oin fields e0ce/t character ty/e fields ,ust ha'e the sa,e attribute. -*. 5$#6 9eyword s/ecifies which /hysical file to use.

a(e 87 of 250

As400 Stuff --.#0a,/le of join lo(ical file" =n this case the 74$ filed co,es fro, 62" because relati'e file nu,ber is s/ecified. $ 5O=7$#) 56=&#> 61 62? 5 5O=7> 61 62? 56&D>74$ 74$? 74$ S 5$#6>2? 7A!# SA&A$G -..$eference file does not contain any data. :his is a /hysical file. =t is used as a reference for the field descri/tions for other files. -1.O 7C$G6 is li9e a te,/orary lo(ical file. =t will (et auto,atically deleted when we close this Euery file. O 7C$G6 co,,and o/ens a file that contains a set of database records that satisfies a database Euery reEuest. O 7C$G6 ne'er shares an e0istin( shared OD in the job or acti'ation (rou/. -2.O<$4D6 co,,and ,ust be e0ecuted before e0ecutin( O 7C$G6 co,,and. .0.We can co/y data fro, data /ath o/ened by O 7C$G6 by ) G6$!C$G6. .1. ara,eters in O 7C$G6 co,,ands" 7=#E I na,e of file that (et /rocessed by O 7C$G6 co,,and. ()>=(8 I o/en o/tion used for Euery file e0a,/le K=7 " KOB:" KB D" KD&:" KA&&. ;+?6#> I Euery select s/ecifies the selection 'alue. 3E?7# A KAS)#7D" KD#S)#7D. <8=;<E3E? I S/ecifies whether the Euery is restricted to records with uniEue 9ey 'alues. .2.#0a,/le for O 7C$G6 )o,,and" O 7C$G6 6=&#>O$D6=&#? O :=O7>KA&&? C$GS&:>RO$DDA:#LO$A7%#>S220101T S220131T? O$ O$DA!: [ 100@? 3#G6&D>O$DA!: KD#S)#7D? .3.Difference between 6 and &6 )&ysical 7ile One $ecord 6or,at $ecord will loss" while co,/ile )ontain actual data We can u/date data #ogical 7ile !ore than one record for,at 7o record loss while co,/ile Doesn@t contain data but it /ro'ides 'iew fro, 6 We cannot u/date data a(e 88 of 250

As400 Stuff

We can use $#6 9eyword We can@t use S#&#):8O!=: .4.Difference between 5&6 and &6 5oin #ogical file One record for,at $ecord for,at na,e should be different :hrou(h 5&6 we cannot chan(e 6 .*.Database ,ana(e,ent DS %!$#6.

We use $#6A)) :+" DG7S&: We can use e0ce/t in join lo(ical file.

#ogical 7ile One or ,ore record for,at $ecord for,at na,e should be sa,e as of hysical file :hrou(h &6 we can chan(e 6. DS 66D" DS 6D" DS D4$" and

co,,ands"

.-.A tri((er is a set of actions that are run auto,atically when a s/ecified chan(e o/eration is /erfor,ed on a s/ecified /hysical database file. :he chan(e o/eration can be an insert" u/date" or delete hi(h le'el lan(ua(e state,ent in an a//lication /ro(ra,. ...On the AS8400 syste," a set of tri((er actions can be defined in any su//orted hi(h le'el lan(ua(e. >)" )obol. $ %" &=" SC&? .1.ADD 6:$% co,,and adds a tri((er to call a na,ed tri((er /ro(ra, to a s/ecified /hysical file. :he tri((er /ro(ra, can be s/ecified to be called before or after a chan(e o/eration occurs. :he chan(e o/eration can be insert" u/date or delete. A ,a0i,u, of si0 tri((ers can be added to a /hysical file. Once a tri((er is added to a /hysical file" all ,e,bers of that s/ecified file are affected by tri((er. e0a,/le" ADD 6:$% 6=&# >#! ? :$%:=!#>KA6:#$? :$%#<#7:>K=7S#$:? %!>&=428=7S:$%? .2.:he $e,o'e hysical 6ile :ri((er >$!< 6:$%? co,,and re,o'es the association of files and tri((er /ro(ra,.

a(e 89 of 250

As400 Stuff 10.A tri((er /ro(ra, cannot include the followin( co,,ands" )O!!=:" $O&&4A)3" and #7D)!:):&. 11.A tri((er /ro(ra, can call other /ro(ra,s or can be nested >that is" a state,ent in a tri((er /ro(ra, causes the callin( of another tri((er /ro(ra,.? :he ,a0i,u, tri((er nested le'el for insert and u/date is 200. 12.A doubleAbyte character set >D4)S? is a character set that re/resents each character with 2 bytes. :he D4)S su//orts national lan(ua(es that contain a lar(e nu,ber of uniEue characters or sy,bols >the ,a0i,u, nu,ber of characters that can be re/resented with 1 byte is 2*- characters?. #0a,/les of such lan(ua(es include 5a/anese" 3orean" and )hinese. :here are two (eneral 9inds of D4)S dataH brac9etedAD4)S data and (ra/hic >nonA brac9eted? D4)S data. 4racEetedI 4.6 data is /receded by a D4)S shiftA out character and followed by a D4)S shiftAin character. ,ra1&icI 4.6 data is not surrounded by shiftAout and shiftAin characters. 13.:he D428400 database su//orts the followin( /hysical file constraints" $eferential constraints" ri,ary 9ey constraints and BniEue constraints. 14.:he Add hysical 6ile )onstraint >ADD 6)S:? co,,and adds all ty/es of /hysical file constraints. :o add uniEue and /ri,ary 9ey constraints" s/ecify KB7C)S: for the :y/e /ara,eter for a uniEue constraint and K $=3#G for a /ri,ary 9ey constraint. When addin( a /ri,ary 9ey constraint" the s/ecified 9ey beco,es the file;s /ri,ary access /ath. 1*.:he $e,o'e hysical 6ile )onstraint >$!< 6)S:? co,,and re,o'es a constraint. 1-. hysical 6ile )onstraint )onsiderations and &i,itations" A file ,ust be a /hysical file. A file can ha'e a ,a0i,u, of one ,e,ber" !AP!4$>1?. A constraint can be defined when the file has Fero ,e,bers. A constraint cannot be established until the file has one" and only one" ,e,ber. :here is a ,a0i,u, of 300 constraint relations /er file. )onstraints cannot be added to files in the C:#! library. 1. :he )$:S$) 6 co,,and creates a /hysical file" but with attributes a//ro/riate for source /hysical files. 6or e0a,/le" the default record len(th for a source file is 22 >10 for the source data field" - for the source seEuence nu,ber field" and - for the source date field?. 2. D428400 Database Data $eco'ery" we ha'e the followin( ,ethods. 5ournal ,ana(e,ent" for recordin( data chan(es to files )o,,it,ent control" for synchroniFin( transaction reco'ery 6orceAwritin( data chan(es to au0iliary stora(e Abnor,al syste, end reco'ery 3. SC&8400 will not su//ort ,ulti for,at lo(ical file. a(e 90 of 250

As400 Stuff 4. =n BD48400 >Bni'ersal Data 4ase? an SC& table is an sin(le ,e,ber /hysical file. *. =n BD48400 an SC& 'iew is a sin(le ,e,ber lo(ical file. -. =n BD48400 an SC& inde0 is a sin(le ,e,ber lo(ical file with 9eyed access. .. SC&8400 refreshes records as rows and fields as colu,ns. 1. :he SC& related /ro(ra, 'ariables" 3nown as the SC& co,,unication area >SC&)A?" you should code in the wor9in( stora(e section to ha'e the SC& co,/iler (enerate SC&)A (rou/ and ele,entary ite,s. #P#) SC& =7)&BD# SC&)A #7DA#P#). SC&)A wor9s as an error handler. 2. SC&)OD# 'alue less than Fero ,eans error" <alue S100T ,eans no rows found. 1. 7ile 1ointer after a failed c&ain o1eration When the )+A=7 o/eration is not co,/leted successfully >for e0a,/le" an error occurs or no record is found?" the file s/ecified in factor 2 ,ust be re/ositioned >for e0a,/le" by a )+A=7 or S#:&& o/eration? before a subseEuent read o/eration can be done on that file. 2. %&at are >riggers" :ri((ers is a self contained set of transact e0ecutable state,ents which can be in'o9ed durin( the o/erations such as insert" u/date" delete can be /erfor,ed in a database file. We can able to add tri((er in a /hysical fileH ADD 6:$% :o re,o'e a tri((erH $!< 6:$% =n the case of SC&8400 we can create tri((er by.... [[S:$SC& [[)$#A:# :$=%%#$ :$%\7a,e after =7S#$:8D#&#:#8B DA:# On 61 =nsert =nto 62 <alues >;$#)O$DS D#&#:#D =7 61;? [[Delete 6$O! 61 Where $ecordno L 10 [[S#lect K 6$O! 62. =n the abo'e code" the records in the 61 is deleted " at once the tri((er tr(\na,e is fired and the (i'en insert state,ent is acti'ated in /f2. 3. %&at is t&e 1ur1ose of <6+()8 Eey'ord" :he BS$O 7 9eyword causes the file not to be o/ened at /ro(ra, initialiFation. :his (i'es the /ro(ra,,er control of the file;s first o/en. :he file ,ust be e0/licitly o/ened usin( the O #7 o/eration. 6or e0a,/le" if a file is o/ened and later closed by the )&OS# o/eration" the /ro(ra,,er can reo/en the file >usin( the O #7 o/eration? without ha'in( s/ecified the BS$O 7 9eyword on the file descri/tion s/ecification. 4. %&at is #EGE# ./E.3" Whene'er 6 is co,/iled" the syste, (enerates uniEue code for identifyin( the file for future reference. a(e 91 of 250

As400 Stuff When we co,/ile the ro(ra, that uses the 6" it will use that uniEue code of the 6. =f we call the /ro(ra," it runs successfully. 4ut if we chan(e the 6 and reco,/ile the 6" the syste, (enerates a new uniEue code for that 6. So" our /ro(ra, doesn@t ha'e this uniEue code and hence ter,inates abnor,ally with a &e'el )hec9 error. :he solution of &e'el )hec9 error is whene'er it ha//ens we ha'e to either co,/ile the 6 with &e'el )hec9 /ara,eter 'alue K7O or we ha'e to co,/ile the /ro(ra, a(ain.

(G+ 47 1. %&at e2actly t&e (G+ 47 does"


=t can do a lot below are so,e basic e0a,/les 1? Say you ha'e an internally defined file in your /ro(ra,. O<$D46 6=&# >)$311+? :O6=&# >)4.)$1+? )A&& )$1+ D&:O<$ 6=&# >)$311+? 2? Say you want to use a different file >with the sa,e record le'el? in a /ro(ra,. O<$D46 6=&# > AG$O&&? :O6=&# >!G AG$O&&? )A&& %=<#$A=S# D&:O<$ 6=&# >!G AG$O&&? 3? Say you want to use O/nCry6 > u( hate old school?. O<$D46 6=&#>O)#A7+D$? :O6=&#>O)#A7+D$? S+A$#>KG#S? O 7C$G6 6=&#>>O)#A7+D$?? U C$GS&:>;+S:A:BS ^L N)N D +)BS: L 011..;? U 3#G6&D>>+)BS:$#6?? C$GS&:>;+)BS: L 011..;? U )A&& %!>A4010$? )&O6 O 7=D>O)#A7+D$? D&:O<$ 6=&#>KA&&? 4? Say you ha'e a s/ecific ,e,ber that you want to use O'rDbf 6ile >:a$/t0103/? :o6ile>:a$/t0103/? U O'rSco/e>K)all&'l? !br>D o!e,ber? )A&& :a$/t0103 DltO'r 6=&#>KA&&? &<&>K? :o be theoretical" :he O<$D46 is used to a(e 92 of 250

As400 Stuff

1? :o te,/orarily chan(e the attributes of a file li9e ,e,ber" /osition of rrn "sharin( the O/en Data ath etc.... 2? :o $edirect the references ,ade for one file to other file. Actually O<$D46 is used for ,ulti,e,ber conce/t. A /f ha'in( ,ulti/le ,e,ber and u need to access one of the ,e,bers fro, that" O<$D46 is used. Also" in )& u can access only 1 file at a ti,e. 6or ,ore than 1 file also O<$D46 is used ()8;+?7 5. %&at is t&e o1en Luery file" =t is a dyna,ic record selection. :he O 7C$G6 co,,and acts as a filter between the /rocessin( /ro(ra, and the database records. :he database file can be a 6 or &6. =t will create o/en data /athway to access >retrie'e? data file. =f you want to s/ecify any SC& o/eration within a )& we ha'e to use O 7C$G6 6unctions su//lied by O 7C$G6 areH Dyna,ic record selection. Dyna,ic 9eyed seEuence access /ath Dyna,ic 9eyed seEuence access /ath o'er a join Dyna,ic join +andlin( ,issin( records in secondary join files BniEueA9ey /rocessin( !a//ed field definitions %rou/ /rocessin( 6inal totalAonly /rocessin( =,/ro'in( /erfor,ance O/en Euery identifier >=D? 1. %&at is t&e different !et'een ()8;+?7 and 6;#+)," ()8;+?7 6;#+),

O 7C$G6 will co,e alon( with We need to ha'e SC&$ % installed OS8400 syste, and no need to ha'e in as8400 syste, which in'ol'es any additional /ac9a(e needed to additional cost to the /ro(ra,,ers e0ecute it O 7C$G6 is faster as co,/ared to =t is slower SC&$ %

a(e 93 of 250

As400 Stuff O 7C$G6 is nothin( but a dyna,ic SC&$ % is i,beddin( lo(ical files will be created and the state,ents directly within records state,ent 2. %&at are t&e -arious ste1s in creating ()8;+?7" :otally fi'e ste/s in'ol'ed in creatin( O 7C$G6 O<$D46 6=&# >file 6? :O6=&# >&=48 6? S+A$# >KGes? =f a 6 is ha'in( 100 records and if we want to o'erride the 6 so that it continues only the s/ecific nu,ber of records we are usin( O<$D46 O 7C$G6 6=&# >&=4 8 6? C$GS&: >R#! 7O K#C R K4)A: DA? =f you want to /erfor, any SC& o/eration we ha'e to declare in O 7C$G6 co,,and only. =n case of O 7C$G6 we can /erfor, e0/ression only based on characters but not on nu,eric. K4)A: =f you want to /erfor, any charter e0/ression are usin( K4)A: e0/ression which will /ro'ide a blan9s in between the 2 'ariables. OW&D)$D =t is si,ilar to O&=3# in SC& C$GS&: >R#! 7A!# K#C OW&D)$D >SSK S?@? =t will fetch all the records whose e,/na,e starts fro, S. K): =t will fetch all the records" which conditions the /articular charter. C$GS&: >R#! 7A!# K): SST R? O$A7%# =t will fetch the records within the s/ecific ran(e C$GS&: >R#! 7O K#E O$A7%# >100 110?@? )A&& %! >&=487A!#? A$! >? D&:O<$ As we see early the ,ain file lo(ically o'erridden and after /erfor,in( the necessary o/eration" we ha'e to delete the lo(ical file so that the ,ain file contains the actual records for this D&:O<$ will be used. D&:O<$ 6=&# >O 7 6? )&O6 We ha'e to close the file" which has been o/ened a(e 94 of 250 SC& SC&

As400 Stuff )&O6 O 7=D >O 7 6? Gou will co/y o'erridden file records usin( ) G6$!C$G6 ) G6$!C$G6 Since O<$D46 is lo(ical we cannot able to list the 'ariables" which satisfy the Euery condition. :o see the records bein( selected we ha'e to co/y fro, the source file to a te,/orary file for this ) G6$!C$G6 will be used ) G6$!C$G6 6$O!O 7=D >O 7 6? :O6=&# >&=487A!#? !4$ >K$# &A)#? )$:6=&# >KG#S? 6!:O : >K7O)+3? $B7C$G We ha'e co/ied the contents satisfy the Euery into a te,/orary file usin( ) G6$!C$G6. =f we run the destination file we (ot the actual records" which satisfy the Euery. $B7C$G C$G6=&# >&=787A!#? E2a01le@ Database 6 S3A7DASA!O8)& O #76 KKKKKKKKKKKKKKK 4e(innin( of data KKKKKKKKKKKKKKKKKKKKKKKKKKKK 0000.01 ) 0001.00 ) 0002.00 ) 0003.00 ) 0004.00 ) 000*.00 ) 000-.00 ) $ O 7C6=&# O#! 7O O#! 7A!# OADD$#SS ODO4 3 O#! 7O *S 0 20A 20A 1S 0 B7=CB#

KKKKKKKKKKKKKKKKKK #nd of data KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK Data file is1lay +e1ort O#! 7O O#! 7A!# 000001 1"001 S#7:+=& OADD$#SS SA&#!1 a(e 95 of 250 ODO4 1"232"002

As400 Stuff 000002 1"002 3B!A$ 000003 1"003 S+GA! 000004 1"004 $A!#S+ 00000* 1"00* 4A&B 00000- 1"00. 3B!A$ :$=)+G SA&#! SA&#! SA&#! 55 12"123"000 12"34*"000 1"010"100 222 32"231

KKKKKK KKKKKKKK #nd of re/ort KKKKKKKK )& /ro(ra, S3A7DASA!O8)& O 7C6=&#* KKKKKKKKKKKKKKK 4e(innin( of data KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK 0001.00 %! 0002.00 0003.00 0004.00 000*.00 000-.00 D)& D)&6 S7D$)<6 )+%<A$ O<$D46 <A$>DA? :G #>K)+A$? &#7>*? 6=&#>S3A7DASA!O8O 7C6=&#3? $)D6!:>O 763? $)D6!:>O 763? <A$>DA? <A&B#>DO#! 7O? 6=&#>O #76? S+A$#>KG#S? O 7C$G6 K4)A: DA? ) G6$!C$G6 6$O!O 7=D>O #76? 6=&#>>S3A7DASA!O8O #76??

000-.01 C$GS&:>;O#! 7O K#C; U 000-.02

000-.03 :O6=&#>S3A7DASA!O8:#! ? U 000-.04 0002.00 0010.00 0010.01 0011.00 D&:O<$ )&O6 $B7C$G #7D %!

!4$O :>K$# &A)#? )$:6=&#>KG#S? 6=&#>O #76? O 7=D>O #76? C$G6=&#>>S3A7DASA!O8:#! ??

a(e 96 of 250

As400 Stuff KKKKKKKKKKKKKKKKKK #nd of dataKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK OB: B: #! &OG## 7B!4#$H 1001 O#! 7O O#! 7A!# 000001 1"001 S#7:+=& OADD$#SS SA&#!1 ODO4 1"232"002

KKKKKK KKKKKKKK #nd of re/ort KKKKKKKK 1. /o' t&e records are accessed for using ()8;+?7" 4y creatin( o/en data /athway to access >retrie'e? data file. 2. %&at is t&e difference !et'een 7*> >9 and ()8;+?7" 7*> >9 ()8;+?

=t will sort the records seEuentially =t will sort the records based on the based on the /osition of the record field 'alues. =f any chan(e in the attribute siFe of a =f there is any chan(e in the attribute 6 then we ha'e to chan(e the siFe it will not affect the /ro(ra, /ro(ra, s/ecification also. s/ecification also.

6!:D:A is bit faster in /rocess than O 7C$G6 is slower as co,/are to O 7C$G6. 6!:D:A if we are /rocessin( ,illions of records. 3. #ist out t&e ifferences !et'een a #7 and co00and ()8;+?7"

&6 creates a new object in the syste, while that is not the case for O 7C$G6.&6 creates a /er,anent data access /ath to the /hysical file that will be u/dated as and when and add" u/date and delete o/eration is /erfor,ed on file Whereas O 7C$G6 creates a te,/orary access data /ath that is shared by hi(h le'el /(, for further /rocessin( of recs in file. = a(ree with <ai'20. 5ust want to add that O 7C$G6 is used with 9eyword Share >KGes? and that;s what ,a9es the OD a'ailable to hi(h le'el /(,s. Also the usa(e of O 7C$G6 is for adhoc jobs that are e0ecuted once in a while whereas &6 is used in case where the OD is (oin( to be used /retty re(ularly. So &6 object would be /referred when the usa(e is (oin( to be re(ular. O 7C$G6 would be (ood where the job is (oin( to be once in a while. a(e 97 of 250

As400 Stuff &6 would ,a9e the job faster co,/ared to O 7C$G6 thou(h it de/ends on what 9ind of ,aintenance o/tion you use for &6. :he ,ain difference isH &o(ical file creates /er,anent object on the syste,. O 7C$G6 creates te,/orary access /ath. 4. ()8;+?7 I 6&ort e21lanation 'it& sa01les in .#) )&A $O%$A! 6B7):=O7.....H $#:$=#<#8S#&#): DA:A W=:+ :+# )&A)O!!A7D O 7C$G6. =&&BS:$A:#D =7 SA! &#S 1 A 3. :AS3.........H $#:$=#<# BS#$=76O O7 6=#&DS 6$O! :+# BS$ $6A6=&#. BS# :+# )&A)O!!A7D DS BS$ $6 KA&& OB: B:>KOB:6=&#? 6=&#>&=48C$GS&: 6?. &=4 =S GOB$ OW7 :#S:A&=4$A$G. :+# $O%$A! O7&G BS#S 2 6=#&DS :O A<O=D )O76BS=O7. =7 :+=S $O%$A! :+# :#S:A&=4$A$G =S 5 +&=4.

=7 B:........H D4A6=&#H C$GS&: 6 6=#&DSH B B $6 10 A

B B=D

10 0

D=S)&A=!#$...H :+# DA:A $#:$=#<#D A7D :+# )O!4=7A:=O7 O6 6=#&DS =S )O! &#:#&G 7O7S#7S# A7D =7:#7D#D O7&G :O =&&BA S:$A:# :+# BS# O6 :+=S )O!!A7D. )$#A:# 4#::#$ #PA A! &#S O7 GOB$ OW7 JJ )$#A:# A 6=&# =7 GOB$ :#S:&=4$A$G )A&&#D 4$B%. :+=S =S :+# 6=&# :+A: $#)=#<#S OB: B:ADA:A 6$O! :+# O 7C$G6. OB: B:.......H D4A6=&#H 4$B% 6=#&DSH B B $6 10 A

a(e 98 of 250

As400 Stuff B B=D 10 0

O #7=D =7 :+# O 7C$G6AS:A:#!#7: =S GOB$ $#6#$#7)# :O :+# =7:#$7A& O 7C$G6AOB: B:. BS# :+=S 7A!# AS 6$O!A6=&# =7 :+# 6=7A& ) G6$!C$G6 W+#$# GOB $#:$=#<# :+# S#&#):#D DA:A :O A +GS=)A& 6=&#. := ..........H 4# A4SO&B:#&G SB$# :O BS# :+# $=%+: 7B!4#$ O6 CBO:#S > ; ? W+#7 GOB D#6=7# :+# S#&#):AS:A:#!#7:. A&& )+A$A<A$=A4&#S =7 :+# O 7C$G6 S#&#):A&=7# !BS: 4# #!4#DD#D =7 :$= &#ACBO:#S A7D K)A:H ;;; K)A: D)+A$<A$ K)A: ;;; N; K)A: D)+A$<A$ K)A: ;N ),* D)& D)& D)& D)& D)& D)&6 <A$>DBS#$? :G #>K)+A$? &#7>10? <A$>D7$? :G #>KD#)? &#7>10 0? <A$>D#P? :G #>KD#)? &#7>1 0? <A$>D7$A&6? :G #>K)+A$? &#7>10? <A$>DP? :G #>K)+A$? &#7>1? U <A&B#>; ;? 6=&#>C$GS&:D6? $)D6!:>KA&&? O$

8K :+# <A$ P +#& S :O &#A<# :+# &=4$A$GA&=S: B7)+A7%#D K8 8K W+#7 :+# $O%$A! +AS 6=7=S+#D $O)#SS=7%. ADD&=4&# &=4>5 +&=4? !O7!S% !S%=D>) 62103? #P#)>)+%<A$ <A$>DP? <A&B#>;P;?? K8 K8

8K $O! : 6O$ 7A!# O% =D A7D :G # O6 #PA! &# )+O=S#H S7D$)<6 $)D6!:>60?

8K C$GS&: O7&G O #$A:#S W=:+ A&6AA<A$=A4&#S. :+# 7B!#A K8 a(e 99 of 250

As400 Stuff 8K $=) <A$. D7$ =S )O7<#$:#D :O )+A$. D7$A&6 8K BS#D =7 SA! &# 3. )+%<A$ K8 K8

<A$>D7$A&6? <A&B#>D7$? K8

8K 63 WAS $#SS#D O7 :+# S)$##7 =6 =6 =6 =6

)O7D>D=703 L ;1;? :+#7>%O:O )!D&4&>#7D?? )O7D>D#P L 1? :+#7>%O:O )!D&4&>O7#?? )O7D>D#P L 2? :+#7>%O:O )!D&4&>:WO?? )O7D>D#P L 3? :+#7>%O:O )!D&4&>:+$##??

8KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK8 8K SA! &# O7#H )+A$ )O7S:A7: A7D 7B! )O7S:A7: 8KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK8 O7#H O 7C$G6 C$GS&:>; U >B B $6 K#C ;;5 +;;? U KA7D U >B B=D K#C 331? U ;? U O 7=D>4$B%? %O:O )!D&4&>OB:? 6=&#>>5 +&=48C$GS&: 6?? U K8

8KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK8 8K SA! &# :WOH )+A$ <A$=A4&# A7D 7B! )O7S:A7: 8KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK8 :WOH O 7C$G6 6=&#>>5 +&=48C$GS&: 6?? U a(e 100 of 250 K8

As400 Stuff C$GS&:>; U >B B $6 K#C ;;; K)A: DBS#$ K)A: ;;;? U KA7D U >B B=D K#C 331? U ;? U O 7=D>4$B%? %O:O )!D&4&>OB:?

8KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK8 8K SA! &# :+$##H )+A$ <A$=A4&# O% 7B! <A$=A4&#. 8K 8K D=%=:S =S A O 7C$G6 3#GWO$D :+A: )O7<#$:S A 6=#&D 6$O! 7B!#$=) :O A&6A >)+A$.? K8 K8 K8

8KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK8 :+$##H O 7C$G6 6=&#>>5 +&=48C$GS&: 6?? U

C$GS&:>; U >B B $6 K#C ;;; K)A: DBS#$ K)A: ;;;? U KA7D U >OD=%=:S>B B=D? K#C ;;; K)A: D7$A&6 K)A: ;;;? U ;? U O 7=D>4$B%? %O:O )!D&4&>OB:?

8KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK8 8K !A3# A )O G O6 :+# O 7C$G OB: B:6=&# :O :+# 6 4$B% 8KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK8 OB:H ) G6$!C$G6 6$O!O 7=D>4$B%? :O6=&#>5 +&=484$B%? U a(e 101 of 250 K8

As400 Stuff !4$O :>KADD? )&O6 D&:O<$ %O:O O 7=D>4$B%? 6=&#>KA&&? )!D&4&>)+O=S#? K8

8K &=4$A$GA&=S: =S $#S:O$#D #7DH =6 $)&$S) $#:B$7 #7D %! D=S &AGA6=&#H A A A A A A A A A A A A A A A $O! : $ 60 )603>03 ;Afslut;? 1 -2:=!# 1 -3;:i,eH;

)O7D>DP L ; ;? :+#7>$!<&=4&# &=4>5 +&=4??

DS S=M>24 10 KDS3?

1 30;$etrie'e user and id; DS A:$>+=? 2 -2DA:# #D:)D#>G? 2 -3;DateH; 4 12;Bser na,e . . . . . H; DS A:$>+=? 1A = 24 4DS A:$>7D? 24 -;#nterL$un )O&O$>4&B? a(e 102 of 250 63L#0it;

As400 Stuff A A A A A A A A A A A +GS=)A& 6=&# 4$B%H KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK K +GS=)A& 6=&# 4$B% :O +O&D S#&#):#D $#)O$DS =7 O 7C$G6 #P 7$ BS#$ 10A = 4 3* - 12;Bser id . . . . . . H; DS A:$>+=? 10S 0= - 3*)+#)3>6#? )+#)3>$M? 1 12;Sa,/le . . . . . . H; DS A:$>+=? 10 1;1 L )+A$ )O7S:A7: o( 7B! )O7S:A7:; 11 1;2 L )+A$ <A$=A4&# o( 7B! )O7S:A7:; 1S 0= 1 3*$A7%#>1 3? 12 1;3 L )+A$ <A$=A4&# o( 7B! <A$=A4&#;

KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK K\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ A $ S#&#):

K\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ A A A A B B=D B B $6 10 :#P:>;BS#$;? )O&+D%>;BS#$;? 10 0 :#P:>;=D;?

)O&+D%>;=D;?

K\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ = ho/e this will hel/ you understandin( so,e of the basics in O 7C$G6. +owe'er there is a s,all thin( usually wra//ed in /lastic or hidden on a )D called a ,anual. :his could be a (reat hel/ but so,eti,es 'ery hard to understand and with a(e 103 of 250

As400 Stuff so,e stu/id e0a,/les that don;t wor9. !y sa,/les can be ty/ed in on your AS8400 and it wor9s. Don;t hesitate to send a ,ail if you want ,ore hel/ or want to discuss so,e of the abo'e ,entioned to/ics. 4$ 5 + and %&. +ere are so,e reference sitesH Database /ro(ra,,ers (uide htt/H88/ublib.boulder.ib,.co,8iseries8'*r28ic22248info8db/8rbafo,st02.ht, htt/H88/ublib.boulder.ib,.co,8iseries8'*r28ic22248info8db/8rbafo,st122.ht,_+D$O 7C6 htt/H88www.(eocities.co,8Silicon<alley8+ills8--328o/nEryf.ht,l 5. ()8;+? E2a01le &tt1@::1u!li!.!oulder.i!0.co0:&t0l:as400:-4r5:ic2979:info:d!2:r!afo0st1 40.&t0M/eaderN199 >E6>)7 data@ #! 7O 1 2 #! 7A!# A(nie A,udha #! +O7#

1"234"*-. 3"4*-".12

>E6>)71 data@ #! 7B! 1 3 #! 7A! A(nie <arun #! ADD$ )oi,batore 4an(alore

7or0at of ()8;+?+E6 7ote that it contains the fields of :#S: 6 as well as :#S: 61 #! 7B! #! 7A! #! +O7# #! ADD$

a(e 104 of 250

As400 Stuff 6/9=#E6/:>E6>),*6:>6>()8;+?7 ro(ra, to test O 7C$G6 co,,and %! 8K :o select the records /resent in :#S: 6 D :#S: 61 and co/y that to a new file >which contains all the fields of :#S: 6 and :#S: 61 K8 O 7C$G6 6=&#>>S+A=&#S+8:#S: 6? >S+A=&#S+8:#S: 61?? U

6O$!A:>S+A=&#S+8O 7C$G$#S? U 56&D>>:#S: 68#! 7O :#S: 618#! 7B! K#C?? U 5D6:<A&>K7O? ) G6$!C$G6 6$O!O 7=D>:#S: 6? :O6=&#>S+A=&#S+8O 7C$G$#S? U !4$O :>K$# &A)#? )$:6=&#>KG#S? 6!:O :>K7O)+3? )&O6 O 7=D>:#S: 6?

8K :o select the records /resent in :#S: 6 D not /resent in :#S: 61 K8 O 7C$G6 6=&#>>S+A=&#S+8:#S: 6? >S+A=&#S+8:#S: 61?? U

6O$!A:>S+A=&#S+8:#S: 6? U 56&D>>:#S: 68#! 7O :#S: 618#! 7B!?? U 5D6:<A&>KO7&GD6:? ) G6$!C$G6 6$O!O 7=D>:#S: 6? :O6=&#>C:#! 8$#SB&:? U !4$O :>K$# &A)#? )$:6=&#>KG#S? 6!:O :>K7O)+3? )&O6 O 7=D>:#S: 6?

8K :o select the records /resent in :#S: 61 D not /resent in :#S: 6 K8 O 7C$G6 6=&#>>S+A=&#S+8:#S: 61? >S+A=&#S+8:#S: 6?? U

6O$!A:>S+A=&#S+8:#S: 61? U 56&D>>:#S: 618#! 7B! :#S: 68#! 7O?? U 5D6:<A&>KO7&GD6:? ) G6$!C$G6 6$O!O 7=D>:#S: 61? :O6=&#>C:#! 8$#SB&:1? U !4$O :>K$# &A)#? )$:6=&#>KG#S? 6!:O :>K7O)+3? a(e 105 of 250

As400 Stuff )&O6 #7D %! 6;#+),#E 6. 6;#+),#E E2a01le D %!#! 7A!# D #! =D S S S 2*A *S 0 =7M>00003? &=3#> %!#! 7A!#? O 7=D>:#S: 61?

D :S:#! 7A!# )8#P#) SC&

)U =7S#$: =7:O S+A=&#S+8:#S: 6 <A&B#S>00003" ;<arun;? )8#7DA#P#) )8#P#) SC& )U S#&#): #! 7A!# =7:O H %!#! 7A!# 6$O! S+A=&#S+8:#S: 6 )U W+#$# #! 7O L H#! =D )8#7DA#P#) )8#P#) SC& )U B DA:# S+A=&#S+8:#S: 6 S#: #! 7A!# L ;A%7=#; )U W+#$# #! 7A!# L ;A%7=; )8#P#) SC& )U D#&#:# 6$O! S+A=&#S+8:#S: 6 W+#$# #! 7O L 00003 )8#7DA#P#) ) ) #<A& #<A& 7. 6;# .ursor@ We ha'e $ % /ro(ra,s that use SC& cursors to seEuentially retrie'e data. =f a /ro(ra, cancels and = call it a(ain" the /ro(ra, resu,es /rocessin( a cursor where a(e 106 of 250 :S:#! 7A!# L %!#! 7A!# K=7&$ L KO7

As400 Stuff it left off. = ha'e to si(n off and bac9 on in order to restart fro, the to/. Why doesn;t the /ro(ra, start o'er fro, the be(innin( of the returned data set? :he beha'ior you;re witnessin( co,es fro, three contributin( factors. 6irst" your /ro(ra, was co,/iled to close the cursor when the acti'ation (rou/ is destroyed. Second" your /ro(ra, is runnin( in the default acti'ation (rou/. :hird" you are not chec9in( the o/en of the cursor to deter,ine whether it succeeds or fails. 6ortunately" this is an easy /roble, to fi0. &et;s loo9 at a /ro(ra, li9e the ones &ynne is tal9in( about. 6Esys/rt o f 132 /rinter 6 D F=n/ut ds inF D F)ust7u,ber -/ 0 D F&ast7a,e 1a D F=nitials 3a D F4alanceDue ./ 2 D F)reditDue ./ 2 D $atio s 3/ 0

8free e0ec sEl declare c1 cursor for S#&#): cusnu," lstna," init" baldue" cdtdue 6$O! Eiws8Ecustcdt O$D#$ 4G 1X e0ec sEl o/en c1X dow ;1;X e0ec sEl fetch c1 into HF=n/utX if sElstt [L ;02000;X lea'eX endifX e'al>h? $atio L F)reditDue 8 F4alanceDue K 100X e0ce/t /lineX enddoX Kinlr L KonX 8endAfree OEsys/rt e /line 1 a(e 107 of 250

As400 Stuff O F)ust7u,ber O F&ast7a,e U 1 O F=nitials U 1 O F)reditDue j U 1 O F4alanceDue j U 1 O $atio j U 1 7otice the e'al within the doAwhile loo/. =;'e included this line of code in order to ,a9e the /ro(ra, cancel. +ere;s the result set fro, runnin( the Euery. :his is the data that the /ro(ra, reads as in/ut. )BS7B! &S:7A! =7=: 4A&DB# )D:DB# 12213. &ee 6& 412.*0 .*0 312*.2 Ste'ens 3 & *1..* 1.*0 3221*2 <ine SS 432.00 .00 32.2-. :yron W# .00 .00 4.*231 Doe 5W 2*0.00 100.00 *13220 Abraha, ! : *00.00 .00 *23022 Willia,s # D 2*.00 .00 -23122 :ho,as A 7 .00 .00 132213 5ones 4D 100.00 .00 14-213 Alison 5 S 10.00 .00 2314.2 +ennin( % 3 3..00 .00 23141* 5ohnson 5 A 3"21..*0 33.*0 :he first ti,e = call the /ro(ra," = (et the followin( out/ut" followed by esca/e ,essa(e !)+1211" which tells ,e that the /ro(ra, atte,/ted to di'ide by Fero. 12213. &ee 6& .*0 412.*0 0 312*.2 Ste'ens 3 & 1.*0 *1..* 3 3221*2 <ine SS .00 432.00 0 :he second ti,e = call the /ro(ra," = (et the followin( out/ut before = (et another !)+1211. 4.*231 Doe 5 W 100.00 2*0.00 40 *13220 Abraha, ! : .00 *00.00 0 *23022 Willia,s # D .00 2*.00 0 7otice that the second run of the /ro(ra, did not be(in with the first record of the result set. :he /ro(ra, was co,/iled to close the cursor when the acti'ation (rou/ is destroyed. :he syste, destroys na,ed acti'ation (rou/s when the last /ro(ra, in the acti'ation (rou/ ends. +owe'er" the default acti'ation (rou/" which is intended for use only with O ! /ro(ra,s" is destroyed only when the job ends. :herefore" the cursor re,ained o/en between in'ocations. =f = had chec9ed the SC& status 'ariable" SC&S::" after the o/en durin( the first call" = would ha'e found that SC&S:: contained a 'alue of fi'e Feros" ,eanin( that the o/en succeeded. 4ut SC&S:: would ha'e had a 'alue of 24*02 after the o/en in the second call" ,eanin( that the cursor was already o/en in the acti'ation (rou/. a(e 108 of 250

As400 Stuff So" how do = fi0 the /roble,? :he si,/lest fi0 is to chan(e the /ro(ra, so that it closes the cursor when the ,odule ends. = do that by addin( the followin( code to the to/ of the calcs in the $ % /ro(ra,. e0ec sEl set o/tion closElcsrLKend,odX Gou should also consider runnin( the /ro(ra, in a na,ed acti'ation (rou/. Gou can easily do this by addin( an + s/ec to the /ro(ra,. + dftact(r/>Kno? act(r/>??????? =;ll lea'e it to you to thin9 about what acti'ation (rou/ na,e you should re/lace the Euestions ,ar9s with. =f an $ % /ro(ra, is a standalone a//lication" you can use K7#W. Also" = encoura(e you to chec9 the status of the o/en and to end the /ro(ra, (racefully if it has a 'alue (reater than or eEual to 02000. e0ec sEl o/en c1X if sElstt [L ;02000;X 88 do so,ethin( to handle the failed o/en 8. 6a01le i0!edded 6;#+),#E 1rogra0 Sa,/le i,bedded" or e,bedded" SC&$ %&# /ro(ra,H + Act%r/>K)A&&#$? + DftAct%r/>K7O? D O/en)ursor D 6etch)ursor D )lose)ursor D !y&ib D !y6ile 8free KinlrLKonX if not O/en)ursor>?X 88 /erfor, error routine to alert the troo/s 88 ... s s $ $ $ 10a 10a n n n

a(e 109 of 250

As400 Stuff #lseX Dow 6etch)ursor>?X 88 /uttin( the fetchcursor on the do loo/ allows the user of 88 iter" and thus iter will not /erfor, an infinite loo/ 88 nor,al /rocessin( here... #ndDoX )lose)ursor>?X #nd=fX returnX 8endAfree O/en)ursor D O/en)ursor D $eturn<ar )8#P#) SC& )U Set O/tion )U )U )U )U )U )U 7a,in( )o,,it Bsr rf L KSys" L K7one" L KBser" s 4 = n li9e>$eturn<ar?

DynBsr rf L KBser" Datf,t L Kiso"

)loSEl)sr L K#nd!od

)8#7DA#P#) )8#P#) SC& )U Declare )1 cursor for )U Select Syste,\:able\Sche,a as library" a(e 110 of 250

As400 Stuff )U Syste,\:able\7a,e as file

)U fro, Esys28systables )8#7DA#P#) )8#P#) SC& )U O/en )1 )8#7DA#P#) 8free SelectX When SElSttL;00000;X return KonX OtherX return KoffX #ndSlX 8endAfree O/en)ursor 8eject 6etch)ursor D 6etch)ursor D $eturn<ar )8#P#) SC& )U 6etch )1 into H!y&ib" H!y6ile )8#7DA#P#) 8free SelectX When sElsttL;00000;X a(e 111 of 250 s 4 = n li9e>$eturn<ar? #

As400 Stuff 88 row was recei'ed" nor,al $eturn<arLKonX When sElsttL;02000;X 88 sa,e as Oeof" sooner or later this is nor,al $eturn<arLKoffX OtherX 88 alert the troo/sJ $eturn<arLKoffX #ndSlX return $eturn<arX 8endAfree 6etch)ursor 8eject )lose)ursor D )lose)ursor D $eturn<ar )8#P#) SC& )U )lose )1 )8#7DA#P#) 8free SelectX When sElsttL;00000;X 88 cursor was closed" nor,al $eturn<arLKonX OtherX a(e 112 of 250 s 4 = n li9e>$eturn<ar? #

As400 Stuff 88 alert the troo/sJ $eturn<arLKoffX #ndSlX return $eturn<arX 8endAfree )lose)ursor 9. E0!edded 6;#@ =nte(ration of sEl in traditional sEl r/( a//lication. 6tatic@ SC& state,ent defined when /ro(ra, is co,/iled. 6iles and fields are established before /ro(ra, e0ecutes. SC& reAco,/ilation ta9es /lace. yna0ic@ SC& state,ent defined durin( /ro(ra, e0ecution. 6iles and fields are not established before /ro(ra, e0ecutes. 7o SC& reAco,/ilation ta9es /lace. 5ournal 1. %&at is t&e $ournal" Any chan(es in 6 will be recorded. A journal is an object of ty/e K5$7 which detects and records that cause a 6 to chan(e. :he infor,ation recorded by the journal is stored in an object K5$7$)< called journal recei'er. 2. %&at are t&e -arious ste1s creating $ournal" :he ste/s to start journalin( )reate a journal recei'er A )$:5$7$)< )reate a journal A )$:5$7 Start journalin( of a 6 A S:$5$7 6 4ac9u/ the 6 A SA<O45 :he ste/s to end journalin( #nd journalin( a 6 A#7D5$7 6 Delete a journal AD&:5$7 Delete the last journal recei'er AD&:5$7$)< Sa'e journal recei'ers ASA<O45 :he co,,ands used for house9ee/in( /ur/oses a(e 113 of 250

As400 Stuff )han(e journal A)+%5$7 Sa'e object ASA<O45 Delete a journal recei'er AD&:5$7$)< :he co,,ands used in case of a failure are Dis/lay journal entries ADS 5$7 A//ly journal chan(es AA G5$7)+% $e,o'e journal chan(es A$!<5$7)+% $estore a sa'ed object A$S:O45 1. E21lain .o00it0ent .ontrol" :he AS8400 syste, has an inte(rated transaction reco'ery function called co,,it,ent control. )o,,it,ent control is an e0tension of the journal function on the syste,. :he records used durin( a co,/le0 transaction are loc9ed fro, other user and at the end of the transactionX the /ro(ra, issues the co00it o1eration, u/datin( the records. =f the syste, fails before the co,,it o/eration is /erfor,ed" all database chan(es are rolled !acE to the /re'ious co,,it o/eration and all the affected records are unloc9ed. .(**=>I:he transactions are u/dated in the data file. )o,,it occurs on .(**=> co,,and +(##49.3A :he transactions are 7O: u/dated in the data file. $ollbac9 occurs if there are unco,,itted transactions and on +(##49.3 co,,and. 2. .an any!ody tell '&y 5ournaling is co01ulsory !efore .o00it0ent .ontrol" )o,,it,ent ctrl is use to sa'e 8rollbac9 the (rou/ of chan(es and 5ournalin( is use to sa'e the chan(ed records in 5ournal recei'er. 3. .o00it0ent control =01le0entation and controlling co00it0ent control fro0 e2ternal 1rogra0. 1. )$:5$7$)< 2. )$:5$7 3. S:$5$7 4. S:$)!:):& >in )& /ro(ra,? *. Declare file with 9eyword )O!!=: and in /ro(ra, use )o,,it and $ollbac9 based on /rocessin( lo(ic >i.e. after successful e0ecution use )o,,it and when in'o9ed e0ce/tion handlin( then use rollbac9?. -. #7D)!:):& ata 9reas, ;ueues, 9rrays K 6tructures@ a(e 114 of 250

As400 Stuff 1. %&at is t&e data area" A data area is an object used to store data for access by any job runnin( on the syste,. =t is /er,anent stora(e. A data area can be used whene'er you need to store infor,ation of li,ited siFe" inde/endent of the e0istence of the /ro(ra,s or files. :y/ical uses of data areas areH :o /ro'ide an area to /ass infor,ation within job. :o /ro'ide a field that is easily and freEuently chan(ed to control references within a job such as su//lyin( the ne0t chec9 nu,ber. :o /ro'ide a constant field for use in se'eral jobs" such as ta0 rate :o /ro'ide li,ited access to a lar(e /rocess that reEuires the data area. A data area can be loc9ed to a sin(le user" thus /re'entin( other users fro, /rocessin( at the sa,e ti,e. :o create a (eneral data area use the co,,and >)$:D:AA$A? :o retrie'e 'alues fro, data area use >$:<D:AA$A? :o chan(e this 'alue" use >)+%D:AA$A? :o dis/lay the current 'alue" use >DS D:AA$A? :o delete a data area use >D&:D:AA$A? :y/e of data area created by the syste, &ocal data area %rou/ data area ro(ra, initialiFation /ara,eter > = ? data area S3A7DASA!O8$ %=&# DA$#A KKKKKKKKKKKKKKK 4e(innin( of data KKKKKKKKKKKKKKKKKKKKKKKKKKKKKK 0001.00 DS 0002.00 D% 0003.00 ) 0004.00 ) 000*.00 ) 000-.00 ) 000..00 ) 0001.00 ) S S S KD:AA$A K&O)3 10A 10A =7M >;= +A:# GOB;? D#6=7# =7 #<A& OB: DS &G S#:O7 a(e 115 of 250 &$ S SL% S DA:A1 S

As400 Stuff KKKKKKKKKKKKKKKKKK #nd of data KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK OB: B: DS &G = +A:# GOB AB:O 7B!4#$ %#7#$A:=O7 S3A7DASA!S8:#S: :#S:#P12 KKKKKKKKKKKKKKK 4e(innin( of data KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK 0001.00 DA 0002.00 ) 0003.00 ) 0004.00 ) 000*.00 ) 000-.00 ) 000..00 ) A S KD:AA$A K&O)3 4S 0 D#6=7# =7 #<A& OB: DS &G S#:O7 &$ A ALAU1 A DA:A2 A

KKKKKKKKKKKKKKKKKK #nd of data KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK OB: B: DS &G DS &G 2. * efine # 9, , 9, and )=)" &O)A& DA:A A$#A >&DA? A local data area is created for each job in the syste, auto,atically" when you sub,it a job. Only one &DA can be created by sub,ittin( a job. :he syste, create a local data area" which is initially filled with blan9s" with a len(th of 1024 and ty/e *./9+. When you sub,it a job usin( S4!5O4 co,,and" the 'alue of the sub,ittin( job@s local data area is co/ied into the sub,itted job@s local data area. Gou can refer to your job@s local data area by s/ecifyin( K&DA for the D:AA$A 9eyword on the )+%D:AA$A" $:<D:AA$A" and a(e 116 of 250

As400 Stuff DS D:AA$A co,,ands or K&DA for the sub strin( builtAin function >OSS:? :he followin( is true of a local data areaH :he local data area cannot be referred to fro, any other job. Gou cannot create" delete or allocate a local data area. We can to chan(e the contents of &DA by the by usin( )+%D:AA$A co,,and. 7o library is associated with the local data area. A))#SS=7% &DAH )+%<A$ <A$ >OSS: >K&DA 3 *?? <A&B#>123? O$ )+%D:AA$A D:AA$A >K&DA >3 *?? <A&B#>123? )+%<A$ <A$ >D$O&7O? <A&B# >OSS: >K&DA 3 *?? O$ $:<D:AA$A D:AA$A >K&DA >3 *?? $:7<A$ >D$O&7O? %$OB DA:A A$#A >%DA? :he syste, creates a (rou/ data area when an interacti'e job beco,es a (rou/ job. Only one (rou/ data area can e0ist for a (rou/. :he (rou/ data area is deleted when the last job in the (rou/ is ended" or when the job is no lon(er /art of the (rou/ job. A (rou/ data area" which is initially filled with blan9s" has a len(th of *12 and ty/e K)+A$. :he followin( is true for a (rou/ data area Gou cannot use the (rou/ data area as a substitute for a character 'ariable on the sub strin( builtAin function. A (rou/ data area cannot be referred by jobs outside the (rou/. Gou cannot create" delete" or allocate a (rou/ data area 7o library is associated with a (rou/ data area. #0a,/le )+%D:AA$A D:AA$A >K%DA? <A&B# >RD#)#!4#$ 122-@? $:<D:AA$A D:AA$A >K%DA? $:7<A$ >D%$ A$A? $O%$A! =7=:=A&=MA:=O7 A$A!#:#$ C)=)? DA:A A$#A A = data area is created for each /reAstarted job when the job is started. :he object subAty/e of the DA is different than a re(ular data area. :he = can only be referred to by the s/ecial 'alue na,e K DA. a(e 117 of 250

As400 Stuff :he siFe of the DA is 2000 bytes but the nu,ber of /ara,eter contained in it is not restricted. 2. %&at is t&e data Lueue" =t is a te,/orary stora(e. We can able to store and retrie'e the data" but once data is retrie'ed the data is lost. 6irst create the data Eueue by usin( )$:D:AA$A co,,and Sendin( a ,essa(e to a data Eueue >CS7DD:AC" C$)<D:AC" And )&$D:AC? Data Euery is nothin( but a Eueue in which are /ro(ra, can send a data and other /ro(ra, or the sa,e /ro(ra, can recei'e the /ro(ra,. CS7DD:AC is stored in CSGS. 2. E21lain ;68 >9; and ;+.G >9;" CS7DD:AC 4y usin( this co,,and sent data sa,e 8 another /ro(ra,. CS7DD:AC A$! >CB#B# 7A!# &=4 D&#7 DDA:? C$)<D:AC 4y usin( this co,,and recei'e data sa,e 8another /ro(ra, C$)<D:AC A$! >CB#B# 7A!# &=4 D&#7 DDA: DWA=:? 2. %&at are t&e 0andatory 1ara0eters for declaring a CB#B# 7A!# &=4 7A!# &#7%:+ DA:A WA=: 2. %&at is t&e co00and to create 0enu" )$:!7B I )reate !enu 3. %&at is t&e difference !et'een .9## and >ransfer .ontrol C>7+.>#D" )A&& :6$):& 1.)all will transfer the control accordin( with the )A&& S:A)3 2. :he )A&& is used to different ty/es of /ro(ra,s. #0H $ %=&#8400" )&8400" )8400" )O4O&8400. :ransfer )ontrol >:6$):&? will re,o'e the )A&& S:A)3 and transfer the control to the callin( /ro(ra,. :6$):& is only used in )& /ro(ra,s. ata Lueue"

a(e 118 of 250

As400 Stuff 4. E21lain *ulti i0ensional 9rray" :he ,ulti di,ension data structure array will be i,/le,ented in occur class. :he si,ilar ele,ents of sa,e data ty/e and sa,e attributes siFe re/eatin( ,any ti,es this ti,e usin( Occur o/code. )an only be used with a ,ulti/le occurrence data structure" allow you to s/ecify which occurrence of data structure is used for subseEuent o/eration within the /ro(ra,s. 2. efine data structure and ty1es of data structure" :he different ty/es of fields and sub fields are stored in a sin(le area. :his area in stora(e is called data structure. Data structure ,eans /ro(ra, allows you to define an area in stora(e and the layout of the fields" called sub fields" with the area. :his area in stora(e is called a data structure. ata structure can !e used for %rou/ nonAconti(uous data into conti(uous internal stora(e locations Define the sa,e internal area ,ulti/le ti,es usin( different data for,ats. O/erate on a field and chan(e its contents Di'ide a field into sub fields without usin( the !O<# or !O<#& Define a data structure and its sub fields in the sa,e way a record is defined. Define ,ulti/le occurrences of a set of data :here are four different ty/es of data structure co,,only used. %eneral data structure Data area data structure 6ile infor,ation data structure ro(ra, status data structure Data structure can be s/ecified in D s/ec :y/e = DS ata structure na0e = ,lobally initialiFed data structure 6II)ro(ra, status data structure <II ata area data structure 4lanEs],eneral >or? 7ile status data structure ata area data structure A data area data structure" identified by a < in /osition 11 of the data structure state,ent" indicates to the $ %&# /ro(ra, that if should read in and loc9 the data area of the sa,e na,e at /ro(ra, at /ro(ra, initialiFation and should write out and unloc9 the sa,e data area at end of the /ro(ra,.

a(e 119 of 250

As400 Stuff :he data area and data area structure ,ust ha'e the sa,e na,e unless you rena,e the data within the /ro(ra, by usin( the K7A!<A$ D#6=7# state,ent. 7ile infor0ation data structure A file infor,ation data structure /ro'ides you with status infor,ation on file e0ce/tion 8error occurs. :his data structure na,e ,ust be uniEue for each file. =t consists of /re defined sub fields that /ro'ide infor,ation on the file e0ce/tion8error that occurred. )rogra0 status data structure :his data structure is identified by as S in /osition 11 of the data structure state,ent" /ro'ides /ro(ra, e0ce/tion8error infor,ation to the /ro(ra,. :he K$OB:=7#" KS:A:BS" K A$! 9eywords ,ostly /referred to deter,ine the S DS. #0a,/le S3A7DASA!O8DA:AS:$ DB! KKKKKKKKKKKKKKK 4e(innin( of data KKKKKKKKKKKKKKKKKKKKKKKKK 0001.00 +D#4B% >KG#S? 0002.00 D SS$ 0004.00 DS:A:BS 000*.00 D$OB:=7# 000*.01 D A$!S 000*.02 D$#S 000..00 ) 000..01 ) 0010.00 ) 0011.00 ) 0012.00 ) 0013.00 ) 0014.00 ) 001*.00 ) K SS$ S MAADD MAADD #<A& ;7O:)O!; A ;)O!=7%; :A% DS &G &$ 1 0 SDS Kstatus Kroutine K/ar,s 2S 0 7B!1 7B!2 20 20

$#SL7B!187B!2

DS &G

S#:O7 4#%S$ a(e 120 of 250

As400 Stuff 001-.00 ) 001..00 ) 0011.00 ) 0012.00 ) 0020.00 ) 0021.00 ) S:A:BS $OB:=7# A$!S DS &G DS &G DS &G DB! %O:O #7DS$ A

KKKKKKKKKKKKKKKKKK #nd of data KKKKKKKKKKKKKKKKKKKKKKKKKKKKKK Out/ut DS &G 102

DS &G KD#:) DS &G 0

DS &G )O!=7% 2. /o' do = declare an array 'it& a dyna0ic nu0!er of ele0ents" =n $ % =<" the new ><3 $.? A&&O)" $#A&&O) and D#A&&O) o/eration codes can be used to allocate ,e,ory. :his ,eans that at run ti,e" you can (o out to the syste, and as9 it to assi(n stora(e to the /ro(ra, that was not allocated to the /ro(ra, when it was e'o9ed. :hese o/eration codes can be used to allocate ,e,ory u/ to 1-!4. :he allocation can be assi(ned to a /ointer 'ariable. =n $ % =<" /ointers ha'e the dataAty/e of asteris9 >K?. All that is needed is to allocate ,e,ory to a /ointer that is used with the 4AS#D 9eyword of the desired dyna,ic array. :he e0a,/le that follows illustrates this techniEueH .....D7a,eUUUUUUUUUUU#BDS.......&en(thU:Dc.6unctionsUUUUUUUUUUUUU UUUUU D DynoArr S . 0 Di,>10000? based> /DynoArr? D nSiFe S 10i 0 .....)S$n01..............O/)ode>e0?#0tendedAfactor2UUUUUUUUUUUUUUUUUU ) #'al nsiFe L OsiFe>DinoArr? K -4 .....)S$n016actor1UUUUUUUO/)ode>e0?6actor2UUUUUUU$esultUUUUUUU U&enUUDc+i&o#E ) Alloc nSiFe /DynoArr KK We now ha'e enou(h stora(e allocated for -4 ele,ents. a(e 121 of 250

As400 Stuff ) #'al nsiFe L OsiFe>DinoArr? K .0 ) $eAlloc nSiFe /DynoArr KK We ha'e chan(ed the allocation to enou(h stora(e for .0 ele,ents )K ... code to use the array (oes here... ) Dealloc>7? /DynoArr KK We ha'e just returned the stora(e to the syste,. :o increase or decrease the nu,ber of ele,ents in the dyna,ic array" use the $#A&&O) o/eration code. Si,/ly chan(e the nu,ber of bytes that need to be allocated" and call $#A&&O) with the new siFe in 6actor 2 and the ori(inal /ointer 'ariable in the $esult field. $#A&&O) allocates new stora(e of the siFe s/ecified" and co/ies the ori(inal data to that new location. :hen it frees >NdeallocatesN? the ori(inal stora(e. =! O$:A7:H Always re,e,ber to D#A&&O) anythin( you A&&O). :hat is always free u/ ,e,ory that you ha'e allocated otherwise ,e,ory lea9s will be created. =f you are not on <3 $." you can still use dyna,ic ,e,ory by callin( one of the syste, A =s or lin9in( into the C)2&# bindin( directory and callin( the ) runti,e !A&&O) and D#A&&O) functions.

3. ata structure array !asics =t;s all /retty strai(htforward. =f 1$DS is a data structure array of 10 ele,ents" then 1$DS)0* will access the fifth ele,ent of that data structure array. 4ut how do you access the subfields? :hat reEuires a bit ,ore discussion. When you define a data structure array" you not only use the i0 9eyword" but you ,ust also s/ecify the Lualified 9eyword. :he ;ualified 9eyword was introduced in <*$1" and it allows you to s/ecify the na,e of a data structure subfield Eualified by the na,e of the data structure. 6or e0a,/le" if data structure 1$DS is defined with the Lualified 9eyword and it contains a subfield na,ed Sub!ield%" then you would use the followin( notation to access the subfieldH !yDS.Subfield1 =f data structure 1$DS is also defined with the i0 9eyword" then so,ethin( li9e the followin( notation is used to access subfields in a s/ecific ele,entH !yDS>*?.Subfield1 =n this e0a,/le" you would be accessin( the subfield na,ed Sub!ield% in the fifth ele,ent in the data structure array 1$DS. 8) .lear u1 t&e confusion o-er 0ulti1leIoccurrence data structures o'er the /ast few ,onths = ha'e detected a hint of confusion about
a(e 122 of 250

As400 Stuff

,ulti/leAoccurrence data structures with re(ard to data structure arrays. While the two ha'e so,e dissi,ilarities" data structure arrays are essentially and technically the sa,e as ,ulti/leAoccurrence data structures. !ore /recisely" ,ulti/leAoccurrence data structures are" and 2ave al3a$s been" data structure arraysX they were just i,/le,ented /oorly and (i'en a (oofy =4! na,e. Of course" this was the result of the si0Acharacter li,it on field na,es and on the esult 'ield colu,n. Bnder the co'ers" data structure arrays and ,ulti/leAoccurrence data structures are i,/le,ented al,ost identically. Gou see" a data structure is a hi(hAle'el lan(ua(e >+&&? constructX there is no such thin( as a data structure down at the ,achine interface >!=? le'el. :hat ,eans all data structures ,ust be i,/le,ented in a si,ulated fashion" re(ardless if they are si,/le data structures" ,ulti/leA occurrence data structures or data structure arrays. =nterestin(ly" the != lan(ua(e does contain arrays AA and fairly so/histicated ones at that. So" once a data structure is defined at the != le'el" ,a9in( it into an array is fairly strai(htforward. :han9fully" we >i.e." the $ % lan(ua(e? ha'e e'ol'ed to where we can actually call data structure arrays NarraysN instead of N,ulti/leAoccurrences.N Bnfortunately" ,ost" if not all" of the docu,entation has not. = ha'e yet to find one definiti'e state,ent that e0/lains" for e0a,/le" that ,ulti/leA occurrence data structures are often interchan(eable with data structure arrays" such as when /assed as /ara,eters. Arrays >this includes ,ulti/leAoccurrence data structures because re,e,ber" they are arrays? are stored in one chun9 of conti(uous stora(e. :here are no e0tra s/aces in between the indi'idual ele,ents of the array unless you s/ecify ali(n,entX that is" the co,/iler will not add any e0tra s/ace that you don;t as9 for. :herefore" in stora(e" a ,ulti/leAoccurrence data structure loo9s e0actly li9e a data structure array. Another (ood e0a,/le of the docu,entation bein( out of date is the S4L e!erence. =n the N=&# $ %"N it discusses usin( ,ulti/leAoccurrence data structures for ,ulti/leArecord fetches. +owe'er" it ,a9es no ,ention of usin( data structure arrays as an alternati'e" ne'er ,ind that usin( data structure arrays is actually a better alternati'e. 9l'ays use data structure arrays if you are in char(e of settin( /ro(ra,,in( /ractices and standards in your sho/" you should insist that data structure arrays are used instead of ,ulti/leAoccurrence data structures whene'er /ossible. :hey are ,uch si,/ler to code" and they are ,uch less /rone to bu(s. N)&#A$N ad'anta(e o'er resettin( wor9 fields
a(e 123 of 250

As400 Stuff

Bse the N)&#A$N o/eration code to clear the fields in a sin(leAoccurrence data structure or ,ulti/leAoccurrence data structures. ass lar(er a,ounts of data between /ro(ra,s when usin( se/arate /ro(ra,s to retrie'e and dis/lay data" use arrays or ,ulti/leAoccurrence data structures to /ass bac9 lar(er a,ounts of data strin(s. 5. ata area, ata ;ueue and *essage ;ueue@ Data area siFe is defined while creation and if the data of the sa,e siFe is /ut on the data area the /re'ious data would (et o'erwritten. 6or e0a,/le we ha'e a data area of siFe *12. 6irst ti,e you ha'e ,o'ed the 'alue of siFe *12. =f you try to ,o'e so,e other data of the sa,e siFe >*12? the second ti,e" then the first data would be lost since it (ets o'erwritten by the latest one. 4ut data will be /resent in the data area e'en after se'eral retrie'als. On the other hand" we define the siFe of the data the data Eueue can hold at the ti,e of creation. :he data Eueue will (row as and when new data co,es in. :he nu,ber of data in the data Eueue is not fi0ed while creation and the nu,ber of data it can hold de/end u/on the syste, s/ace. =t is just li9e the nor,al Eueue" it (rows when new data co,es in. We just set the siFe of one data and not the siFe of the data Eueue. 6or e0a,/le you ha'e created a data Eueue of siFe 100. =f you ,o'e data for the first ti,e it will be stored in the first /osition. :hen if you ,o'e the second data it will be stored in the second /osition and so on. De/endin( u/on the ,ethod >6=6O" &=6O or 9eyed? s/ecified at the ti,e of creation" for retrie'in( data the data will be fetched. After the data is retrie'ed once >'ia recei'e data Eueue co,,and? it will be lost. =t will be /resent in the data till the first retrie'al. =n the ,essa(e Eueue the ,essa(e will be /resent e'en after se'eral retrie'als. 6. ,rou1 5o!s and ,rou1 data area@ %rou/ data area is created by the syste, when an interacti'e job beco,es a (rou/ job. %rou/ job is nothin( but another job with the sa,e job na,e but with a different job nu,ber. Gou will ha'e 2 sessions in the sa,e session itself. #0a,/leH
a(e 124 of 250

As400 Stuff

Assu,e that you ha'e a session with the 5obH C AD#<0001 and the 7u,berH 24-*.1 >Do a ShiftU63 to (et this infor,ation after lo((in( in?. After creatin( ,ulti/le jobs the job na,e will be the sa,e but we will ha'e different job nu,bers for each session. :ry to dis/lay the contents of K&DA and K%DA. DS D:AA$A K&DA Will dis/lay the contents of local data area 4ut DS D:AA$A K%DA will (i'e an error ,essa(e >D:AA$A>K%DA? not 'alid because job not (rou/ job? since this job is not an interacti'e job. )han(e the interacti'e job to (rou/ job >:S:%$ 5O4? li9e this. )+%%$ A %$ 5O4>:S:%$ 5O4? !S%C>K7O7#? 7ow try DS D:AA$A K%DA. =t will wor9" because the interacti'e job is now chan(ed to a (rou/ job. 7ow we ha'e one (rou/ job :S:%$ 5O4. We are creatin( another (rou/ job li9e this to e0/lore the (rou/ job conce/t. %i'e the co,,and :6$%$ 5O4 %$ 5O4>KS#&#):? and /ress #nter. :hen ress 6- to Start a new (rou/ job. %i'e the followin( details and ress #nter. %rou/ job . . . . . . . . . . . %$ :#S:2 =nitial (rou/ /ro(ra, . . . . . C)!D 7oteH =nstead of C)!D you can (i'e a /ro(ra, na,e as well. After the /ro(ra, ends the job will end and control will co,e bac9 to the /re'ious job fro, where the :6$%$ 5O4 is issued. =f you Si(noff fro, any (rou/ job session then all the jobs will be ended since si(nin( off fro, that job closes the K%DA which internally ends all the jobs /resent in that (rou/. 8ote@ =f you do it with Shift U #sc U 1 we can ha'e 2 sessions only with the sa,e job na,e. Shift U #sc U 1 will ta9e you to si(n on screen. Gou can lo(in to (o to the second session >,eanin( second job with the sa,e job na,e and a new job nu,ber?" you will be in the sa,e session e'en now. =f you si(n off fro, that session you will (o the first session >/lace where you (a'e Shift U #sc U 1? and not to the Si(n on screen I 4ut it is not a (rou/ job" we are just accessin( 2 sessions fro, the sa,e session itself and there is no /ro'ision of switchin( between the sessions. After co,/letin( the wor9 in the second session you ha'e to si(noff to co,e to the first session. =t is just an o/tion to ha'e one ,ore session inside the sa,e session rather than o/enin( a new session. :hat@s all.

a(e 125 of 250

As400 Stuff

4ut with (rou/ job conce/t we can ha'e u/ to 32 sessions in the sa,e session. With transfer (rou/ job co,,and we can (o to different sessions. 7. ata 6tructure 9rray and E2a01le@ DS *A *S 0 #'al #'al #'al 8. Ds\Array>1?.Ds\6ld1 L ;:#S:; Ds\Array>1?.Ds\6ld2 L 1234* K=nlr L KOn ata area and data Lueue@ Di,>2*? Cualified

D Ds\Array D Ds\6ld1 D Ds\6ld2 ) ) )

ifference !et'een

ata area@ Data will not be lost after it is accessed. ata Lueue@ Data will be lost after C$)<D:AC is e0ecuted" ,eanin( data will be lost fro, the data Eueue after it is recei'ed. 9. ifference !et'een dataIstructure array and 0ulti occurrence data structure

ataIstructure array@ Subfield na,es can contain ,ore than si0 characters. *( 6@ Subfield na,es cannot contain ,ore than si0 characters. 10.+), data structure arrays i01ro-e0ent o-er 0ulti1leI occurrence data structures =n case you ha'en;t yet heard the news" the =&# $ % co,/iler now su//orts AA as of <*$2 data structure arrays. :hat is" you can now s/ecify the Di, 9eyword on the definition of a data structure to di,ension that data structure. 5ust as you can di,ension a standAalone field to create an array of that ty/e of field" you can now di,ension a data structure to create an array of that 9ind of data structure. 11..o01ile ti0e array, 1re run ti0e array run ti0e array

a(e 126 of 250

As400 Stuff

)o,/ile ti,e array is the array which is declared with all the actual 'alues in the /ro(ra, usin( ):DA:A re run ti,e arrayH =t is loaded fro, a colu,n of /hysical file $un ti,e arrayH 'alues are loaded in the array durin( e0ecution ti,e Gou define array on NDN S/ecification you can load data into an array at co,/ile" with 'alue entered at end of the /ro(ra, is called L )o,/ile ti,e array. Gou define array on NDN S/ecification you can load data into a array at co,/ile" with 'alue obtained fro, a 6ile is called L reA$unti,e Array Arrays can be loaded with 'alues durin( the /ro(ra, e0ecution this is called L $unti,e Array S,all correction about /re run ti,e arrayH :he file used as in/ut ,ust be a seEuential /ro(ra, described file. DB$=7% =7=:=A&=MA:=O7" 4B: 4#6O$# A7G =7 B:" )A&)B&A:=O7" O$ OB: B: O #$A:=O7S A$# $O)#SS#D the array is loaded with initial 'alues fro, the file. 4y ,odifyin( this file" you can alter the array@s initial 'alues on the ne0t call to the /ro(ra," W=:+OB: $#)O! =&=7% the /ro(ra,. 12.+877701 data structure not allo'ed =;, usin( a data structure for ,e $#AD8W$=:#8$#AD o/erations but = 9ee/ (ettin( $76..01 A Data structure not allowed. +ere;s the codeH 6W!#$&% dC d d ne0t\eid d `err 8free
a(e 127 of 250

if a e e DS /r s

9 dis9 #P:7A!#>W!#$&% HW!#$&%HK=7 B:? CBA&=6=#D 11s 0 n

As400 Stuff

set(t Khi'al w,erl(/X 88 read into a ds so as not to disturb the 88 (lobal file fields read/ w,erl( CX 88 $76..01 hereJ :he answer is that the co,/iler wants you to use &=3#$#) instead of #P:7A!#. :ry dC Ds &i9e$ec>W!#$&% H K=n/ut ? &#B'G 1. /o' to e!ug a 4atc& =#E +),"

1. )o,/ile your =&# source usin( D4%<=#W >KSOB$)#? O :=O7 >KS$)S:!:HK7OD#4B%=O? 2. +old the job Eueue where the /ro(ra, will be sub,itted 3. Sub,it the job 4. +old the sub,itted job *. $elease the jobE" and if reEuired chan(e the jobE. -. Start ser'icin( the sub,itted job usin( S:$S$<5O4 5O4 >nu,ber8user8na,e? >Start Ser'ice job?" where Nnu,berN" Nuser; and Nna,eN are attributes retrie'ed fro, the sub,itted job. .. Start the debu((er usin( S:$D4% %! >library8/ro(ra,? B D $OD >KG#S? >Start Debu(? 1. Gou are now in the dis/lay ,odule source. Don;t try to debu( or add brea9/oints. =t;s too early. :he job ,ust be acti'e before. &ea'e this screen usin( 612. 2. $elease the held job. 10. When the job is acti'ated" the start ser'ice job window co,es. Bse
a(e 128 of 250

As400 Stuff

610 to enter debu( co,,and. 11. Bse DS !ODS$) >Dis/lay ,odule source? co,,and to (o bac9 to the source and add brea9/oint where'er you want" usin( 612. Bse 612 to resu,e the job" and 612 once a(ain to (o bac9 to the start ser'ice job window. 13. Bse #nter to launch the job. 14. :he /rocess brea9s at the first brea9/oint installed and (i'es you the control. 1*. Debu(....,y friend 1-. When the job is finished" you recei'e a ;5ob bein( ser'iced ended; ,essa(e. 1.. Bse #7DD4% co,,and to end debu(. 11. Bse #7DS$<5O4 to end ser'icin( 2. e!ug -alue of 1ointer"

When debu((in( =&# $ % code" to see what a /ointer is /ointin( to" you can use H0 or Hc when usin( the #<A& debu((er co,,and on the /ointer itself. :his ,eans you can debu( a /ointer;s 'alue without ha'in( an $ % 4AS#D 'ariable. :his shows the first 10 bytes that N/trN is /ointin( to" as character dataH LLL[ #<A& /trHc 10 :his shows the first 10 bytes that N/trN is /ointin( to" in he0H LLL[ #<A& /trH0 10 :his is useful when the /ointer is /ointin( to data that is not readable as character data] 3. /o' do = de!ug =#E 1rogra0s" 6>+=6 4 doesnFt 'orEO 4e sure you co,/ile your /ro(ra, with an o/tion that allows the debu((er to NseeN the sourceH D4%<=#W>K&=S:? will reEuire access to the source at runA ti,e" while D4%<=#W>K&=S:? inserts a co/y of the co,/ile listin( ri(ht into the object code" so no access to the source is needed at runAti,e.
a(e 129 of 250

As400 Stuff

After that" the basic seEuence of e'ents is to S:$D4%" set the brea9/oints" hit 63 bac9 to the co,,and line and call your /ro(ra,. Detailed ste/sH 1. S:$D4% A you ,ay need to s/ecify B D $OD>KG#S?" but /lease be 'ery careful debu((in( in a /roduction en'iron,entJ 2. Set brea9/oints. osition the cursor on a line where you want a brea9/oint. ress 6-. :he debu((er will sto/ before this line is e0ecuted. Set as ,any as you need. 3. =f you are debu((in( a ser'ice /ro(ra," /ress 614 to see a screen where you can add the ser'ice /ro(ra, >KS$< %!? to the list of ,odules under debu( control. Bse o/tion * on the ,odule line to enter the source and set brea9/oints. ress 614 to (et bac9 to the ori(inal source. 4. #0it the S:$D4% session and (et bac9 to the co,,and line. *. )all your /ro(ra, the way you nor,ally wouldX fro, a ,enu or co,,and line. Gou don;t necessarily need to call the /ro(ra, under debu(X if it;s the third one in a series" you can call the first one and let the /ro(ra,s /ro(ress as nor,al. :here are a few differences between S:$=SD4 and S:$D4%H S:$=SD4 WA:)+ has no eEui'alent. WA:)+ under S:$D4% will brea9 when a watched 'ariable chan(es. Gou don;t dis/lay 'ariables with the NDN co,,andX it;s #<A& under S:$D4%. :o see a 'ariable in he0" do an e'al 'arna,eH0. Gou don;t set a 'alue with NcN" you use #<A&X e'al 'arna,e L ;O #7;. &oo9 at the hel/ for co,,ands on the co,,and line for a Euic9 reference of the a'ailable co,,ands. )hec9 the lan(ua(e reference ,anual for details of how to use the debu((er with your tar(et lan(ua(e. 1. /o' can = de!ug an =#E 1rogra0 in !atc&" 4rad Stone has a 6AC entry that addresses thisH htt/H88b'stools.co,8faE.ht,l_$ % <sing t&e green screen de!ugger@ 1. Sub,it your /ro(ra, to batch. :he job !BS: be held. Gou can either hold the job Eueue >+&D5O4C? or hold the indi'idual job >+&D5O4? or s/ecify +O&D>KG#S? on the S4!5O4 co,,and.
2. W$3S4!5O48W$3BS$5O48W$3A):5O4 and find your sub,itted job.

7ote that the S4!5O4 co,,and (i'es you an infor,ational ,essa(e


a(e 130 of 250

As400 Stuff

with the job na,e8nu,ber. What you need is the job na,e" user =D and job nu,ber A the fully Eualified job na,e. #0a,/leH 1234*-84B)38!O7:+#7D 3. S:$S$<5O4 on the held batch job. 4. S:$D4% on your /ro(ra,. S/ecify B D $OD>KG#S? if needed. Gou;ll see the source listin( if you co,/iled with D4%<=#W>K&=S:? or KSOB$)#. *. ress 612 to e0it A you cannot set a brea9/oint yet. -. $elease the job so that it beco,es S:A:BS>KA):=<#?. .. Gou;ll see a dis/lay as9in( if you want to debu( or continue. ress 610 to debu(. 1. DS !ODS$) to see the source listin( a(ain. Alternately" /ress 610 to ste/ into the first instruction. 2. 7ow you can add your brea9/oints. 10. ress 63 until you;re bac9 to the Ndebu( or continueN dis/lay. ress #nter to run the /ro(ra, with your brea9/oints set. 11.When you;re done" do an #7DD4% and #7DS$<5O4. <sing t&e =4* istri!uted e!ugger@ 1. S4!5O4 )!D>)A&& %!>yourlib8your/(,?? 5O4C>yourlib8yourjobE? +O&D>KG#S? 2. Start your )ode debu((er fro, StartA[ ro(ra,sA[WebS/here De'elo/,ent... A[=4! Distributed Debu((erA[=4! Distributed Debu((er 3. Select the debu((er Start u/ window and 9ey into the job na,e entry field K8__________8K where __________ is your user id. 4. Gou ,ay ha'e to lo( in and s/ecify the AS8400 syste, na,e. *. Select the job that is bein( held in yourjobE. -. )lic9 the o9 /ush button. .. #nter the library and /ro(ra, na,e into the ro(ra, entry field 1. )lic9 the &oad /ush button on the debu((er Startu/ infor,ation window. A debu((er ,essa(e will a//ear tellin( you to start the /ro(ra,. 2. )lic9 O9 on the ,essa(e /ush button" e'en thou(h it tells you to start your /ro(ra, first.
a(e 131 of 250

As400 Stuff

10.Switch to a *2*0 e,ulation window. 11.W$35O4C 5O4C>yourlib8yourjobE? $elease your job. 1. /o' can = de!ug an ()* 1rogra0 in !atc&" Gou can follow the ste/s in +ow can = debu( an =&# /ro(ra, in batch? And use the old >no source? debu((er S:$D4%. !i9e 4arton su((ests co,/ilin( the /ro(ra, with O :=O7 >KS$)D#4B%? and then usin( S:$D4% O !S$)>KG#S?" which should wor9 with the ste/s (i'en abo'e. S:$=SD4 won;t wor9 unless the job is runnin(" so you can;t /ut it on hold and enter your brea9 /oints. !artin $owe contributed the followin( ideaH =nsert a si,/le )& /ro(ra, into your $ % that waits for you to answer a ,essa(e. :his way" the job is runnin(" but not /rocessin( yet. >$ %400A& 24 !ay 2001? +ere is an ada/tation of his ideaH +ere;s the $ % /ro(ra, you;re tryin( to debu(H + 1 ) )A&& ;D4%WA=:; ) MAADD1 P *0 ) S#:O7 &$ =;'e inserted N)A&& ;D4%WA=:;N and reAco,/iled. +ere;s the source for D4%WA=:H /(, dcl Dre/ly Kchar 1 sndusr,s( ,s(id>) 62121? U ,s(f>C) 6!S%? U ,s(dta>; aused for debu(;? U ,s(r/y>Dre/ly? end/(, S:$=SD4 %! >4A:)+O !? B D $OD >K7O? =7< %! >K7O? S$<5O4 >KS#&#):? you@ll see a list of all acti'e jobs on your syste,. Select the one you;re tryin( to debu(. Gou;ll (et a ,essa(e sayin( that the /ro(ra, is in debu( ,ode. Answer the N/aused for debu(N ,essa(e" and the source will /o/ u/ after the call to D4%WA=:.
a(e 132 of 250

As400 Stuff

2. /o' can = tell if 0y 1rogra0 is running in !atc& or interacti-e" +ere;s a /ro(ra, that uses the CBS$5O4= A =. After callin( the A =" the 5ob :y/e field >CBS5:04? will contain a 4 for batch or = for interacti'e. =f you don;t /ass the internal job na,e >don;t /ass anythin(? it will retrie'e infor,ation about the current job. DCBS=020000 DK D CBS4$01 DK D CBS4A01 DK D CBS5703 DK D CBSB703 DK D CBS574$03 DK D CBS=5=D01 DK D CBS5S0* DK D CBS5:04 DK D CBS5S0DK D CBSS7 DK D CBS$ 01 DK D CBSS =D00 DK D CBS) BB00 DK D CBSA=O$ DK D CBS=: DK D CBS$: DS Cwc 5O4=0200 44 0 4ytes $eturn * 14 0 4ytes A'ail 2 11 5ob 7a,e 12 21 Bser 7a,e 22 34 5ob 7u,ber 3* *0 =nt 5ob =D *1 -0 5ob Status -1 -1 5ob :y/e -2 -2 5ob Subty/e -3 .2 Subsys 7a,e .3 .-4 0 $un riority .. 104 0 Syste, ool =D 11 144 0 ) B Bsed 1* 114 0 Au0 =O $eEuest 12 224 0 =nteract :rans 23 2-4 0 1
a(e 133 of 250

As400 Stuff

DK $es/onse :i,e D CBS6: 2. 2. DK 6unction :y/e D CBS671* 21 10. DK 6unction 7a,e D CBSA5S 101 111 DK Acti'e 5ob Stat D CBS7D4&W 112 11*4 0 DK 7u, D4ase &oc9 Wts D CBS7=!&W 11- 1124 0 DK 7u, =nternal !ch &c9 Wts D CBS7D4&W00 120 1234 0 DK 7u, 7on D4ase &oc9 Wts D CBS:D4&W 124 12.4 0 DK Wait :i,e D4ase &oc9 Wts D CBS:=!&W 121 1314 0 DK Wait :i,e =nternal !ch & D CBS7D4&W01 132 13*4 0 DK Wait :i,e 7on D4ase &oc9 D CBS#$<#D4* 13- 13DK $eser'ed D CBS)S =D 13. 1404 0 DK )urrent Syste, ool =D D CBS:)01 141 1444 0 DK :hread )ount DCBS#) DS 11- inF D CBS4 $< 1 44 0 inF>11-? D CBS4A<& * 14 0 inF>0? D CBS#= 2 1* D CBS#$<#D 11D CBS#D01 1. 11D D D D D D c c 6or,at7a,e S =n5ob7a,e S =nt5ob7a,e S 5ob7a,e S Outcount S $ecei'e&en S Kentry list ar, 1 =nF>;5O4=0200;? 212- =nF>;K;? * 0 10i 0 =nF>11.? =n5ob7a,e
a(e 134 of 250

As400 Stuff

c c c

=f O/ar,s [ 0 #'al 5ob7a,e L =n5ob7a,e #ndif

K )all the a/i to (et the infor,ation you want ) )all ;CBS$5O4=; ) ar, Cus=020000 ) ar, $ecei'e&en ) ar, 6or,at7a,e ) ar, 5ob7a,e ) ar, =nt5ob7a,e ) ar, Cus#c c #'al Kinlr L Ko
3. /o' to de!ug $o!s in *6,% 'it&out ending it"

Gou ha'e to /rocess in three ste/sH 1? %et the 7a,e8Bser87u,ber of the job in !essa(e Waitin( status. Gou can find this by the W$3A):5O4 co,,and" and then /ress * in front of the job. On the to/ of the screen" you (et those infor,ation@s. 2? Ser'ice the job with the co,,andH S:$S$<5O4 5O4>5O47A!#8BS#$87B!4#$? 3? Bse the usual co,,and S:$D4%. =,/ortant noteH Do not for(et to /ut the o/tion D4%<=#W>KA&&? when creatin( the /ro(ra, and8or the ,odule" if you want to be able to see the error inside the source code while debu((in(.
4. /o' do you do de!ugs for =#E 1rogra0s and /andle

E2ce1tions" )reate the /ro(ra, #! $ : so that you can debu( it usin( the source debu((er. :he D4%<=#W /ara,eter on either )$:47D$ % or )$:$ %!OD deter,ines what ty/e of debu( data is created durin( co,/ilation. :he /ara,eter /ro'ides si0 o/tions which allow you to select which 'iew>s? you wantH K KS:!: ] allows you to dis/lay 'ariables and set brea9/oints at state,ent locations usin( a co,/iler listin(. 7o source is dis/layed with this 'iew. K KSOB$)# ] creates a 'iew identical to your in/ut source.

a(e 135 of 250

As400 Stuff

K K)O G ] creates a source 'iew and a 'iew containin( the source of any 8)O G ,e,bers. K K&=S: ] creates a 'iew si,ilar to the co,/iler listin(. K KA&& ] creates all of the abo'e 'iews. K K7O7# ] no debu( data is created. :he source for #! $ : is shown in 6i(ure 21 on /a(e *4. 1. :o create the object ty/eH )$:47D$ % %! >!G&=48#! $ :? D4%<=#W >KSOB$)#? D6:A):%$ >K7O? :he /ro(ra, will be created in the library !G&=4 with the sa,e na,e as the source ,e,ber on which it is based" na,ely" #! $ :. 7ote that by default" it will run in the default na,ed acti'ation (rou/" C=&#. :his /ro(ra, object can be debu((ed usin( a source 'iew. 2. :o debu( the /ro(ra, ty/eH S:$D4% #! $ : Programming Concepts 1. ,eneral +), =G )rogra0 .ycle 6i(ure shows the s/ecific ste/s in the (eneral flow of the $ % =< /ro(ra, cycle. A /ro(ra, cycle be(ins with ste/ 1 and continues throu(h ste/ ." then be(ins a(ain with ste/ 1. :he first and last ti,e a /ro(ra, (oes throu(h the $ % =< cycle differ so,ewhat fro, the nor,al cycle. 4efore the first record is read the first ti,e throu(h the cycle" the /ro(ra, resol'es any /ara,eters /assed to it" writes the records conditioned by the 1 >first /a(e? indicator" does file and data initialiFation" and /rocesses any headin( or detail out/ut o/erations ha'in( no conditionin( indicators or all ne(ati'e conditionin( indicators. 6or e0a,/le" headin( lines /rinted before the first record is read ,i(ht consist of constant or /a(e headin( infor,ation or fields for reser'ed words" such as A%# and KDA:#. =n addition" the /ro(ra, by/asses total calculations and total out/ut ste/s on the first cycle.

a(e 136 of 250

As400 Stuff

Durin( the last ti,e a /ro(ra, (oes throu(h the cycle" when no ,ore records are a'ailable" the &$ >last record? indicator and &1 throu(h &2 >control le'el? indicators are set on" and file and data area cleanu/ is done. 'igure 0& PG I5 Program Logic C$cle

1 9ll headin( and detail lines >+ or D in /osition 1. of the out/ut s/ecifications? are /rocessed. 2 >&e ne0t in/ut record is read and the record identifyin( and control le'el indicators are set on. 3 >otal calculations are /rocessed. :hey are conditioned by an &1 throu(h &2 or &$ indicator" or an &0 entry. 4 9ll total out/ut lines are /rocessed >=dentified by : at /osition 1. of out/ut s/ecifications?. 5 =t is deter,ined if the &$ indicator is on. =f it is on" the /ro(ra, is ended. 6 >&e fields of the selected in/ut records are ,o'ed fro, the record to a /rocessin( area. 6ield indicators are set on. 7 9ll detail calculations are /rocessed >those not conditioned by control le'el indicators in /ositions . and 1 of the calculation s/ecifications? on the data fro, the record read at the be(innin( of the cycle.

a(e 137 of 250

As400 Stuff

2. %&at are 6tatic !ind and Dyna,ic 4indH

yna0ic !inds"

Su//ose /(, A is callin( /(, 4. =n current scenario" /(, A will (et co,/iled irres/ecti'e of /(, 4 object >K/(,?" is there or not. =t will (i'e an error at runti,e" but not at co,/ile ti,e since this is a dyna,ic bind. Static bindH Su//ose /(, A is callin( /(, 4. =n current scenario" /(, A will not (et co,/iled if /(, 4 object >K/(,? not there. =t will (i'e an error at co,/ile ti,e since this is a static bind. 3. .+>48 +), K .+>+),),* )$:47D$ %H +ere the ,odule is been created internally >a te,/orary one? and the K %! is been created. )$:$ % %!H +ere the ,odule a /er,anent one is created and the K %! is been created.
4. /idden 7ields@

=n the hidden fields" the fields that are been hidden ha'e the /re'iously entered 'alues below and on 6* the 'alues /re'iously entered will be a'ailable on the field. 5. #ast state0ent of any +), 1g0 is #+" 7ot necessary. We can write the codes after S#:O7 &$ also and it will e0ecute that too. :he ,ain difference is that the /ro(ra, will end after the last line of codin( you did and will clear all the access /ath and 'ariables to blan9s or Feros. 4ut when you (i'e $#:B$7 then the /ro(ra, will not e0ecute the below codin( /art and will end as soon as the $#:B$7 is encountered" but here it will not clear the access /ath and the 'ariables. =f you run the /ro(ra, a(ain you will find the last 'alue in the 'ariable. While writin( a /ro(ra, &ast state,ent of $ % /ro(ra, need not be &$. =t is the last e0ecutable state,ent. =.e. after all /rocessin( is done &$ >&ast $ecord indicator? will be set on. 7O:#H =n a /ro(ra, that does not contain a /ri,ary fileX you can set the &$ indicator on as one ,ethod to end the /ro(ra,.
a(e 138 of 250

As400 Stuff

&ast state,ent is $#:B$7. !eans #0it fro, /ro(ra, &$ is second last state,ent. !eans ,o'e /ointer to end of file. #0H )&OS 4#%S$ !O<# ;1; $#:B$7 #7DS$ K=7&$

&$ is (enerally set on after all /rocessin( is done i.e. at the end of the /ro(ra, but there is no hard and fast rule for that. 6. =s .onstant can !e define as a Eey field" 7o" 4ut you can (i'e a constant <alue in /hysical file field and you can s/ecify that field as a 9ey field. =n 6 A PPPPP 20 yyyyy -0 300000 <alue >N!G7A!#N?

7. %&ic& Eey'ord is used !ot& in su!file and su!file control record for0at of a 6)7" S#:O66 S#:O66 8. 03 12 ;#0it; ;)ancel;

efine interacti-e $o!s and !atc& $o!s"

=n =nteracti'e jobs user interaction to called job. 4ut in batch jobs user interaction not reEuired >actions ta9en by Syste,?. =nteracti'e job usin( N)A&&N co,,and >)A&& $O%$A!7A!#? to run /ro(ra, and you can;t use your /c until /ro(ra, ends. 4atch job usin( NS4:5O4N co,,and >S4!5O4N)A&&8 $O%$A!7A!#N? to run /ro(ra, and you can use your /c and the /ro(ra, will run in the batch >C4A:)+? you can see this use W$3A):5O4 co,,and. 9. %/9> =6 >/E =77E+E8.E 4E>%EE8 F.(#/ ,F 98 F9#=96F" 4oth >)O&+D% D A&=AS? are used to identify fields. )O&+D% D A&=AS is the Descri/tion of fields. :he difference is that in A&=AS we can access data based on that A&=AS na,e" while )O&+D% is not allowed. Su//ose in 6 field na,e as D#S.1" (i'e A&=AS as Descri/tion.1" then user can access data fro, usin( Descri/tion.1.
a(e 139 of 250

As400 Stuff

10.%&atFs t&e difference !et'een .(86> and G9#<E" =f you /ass a /ara,eter by 'alue" you are free to chan(e the 'ariable defined by the /rocedure interface >you ,i(ht want to chan(e blan9s to Feroes" double Euotes" stri/ leadin( Feroes?. 6or a )O7S: /ara,eter you would ha'e to co/y to a local 'ariable first. :he /oint is that in both cases the caller is assured that his 'ariable won;t be chan(ed by the called /rocedure" but the called /rocedure can use <A&B# /ara,eters as wor9 'ariables" whereas )O7S: /ara,eters are not allowed to be used in any way e0ce/t NreadAonly.N A technical difference is that a )O7S: /ara,eter is /assed by reference" while a <A&B# /ara,eter is /assed by 'alue. When a /ara,eter is /assed by reference" the called /rocedure recei'es a /ointer to the /ara,eter. When a /ara,eter is /assed by 'alue" the called /rocedure recei'es the actual 'alue. Since a call to a /ro(ra, always /asses /ara,eters by reference >on the =series at least?" <A&B# is not allowed on /ro(ra, /rototy/es >#P: %! 9eyword?" but )O7S: is allowed. 11..# E(7@ When the end of file is reached" ,essa(e ) 601-4 is sent to the /rocedure or O ! /ro(ra,. :he )& 'ariables declared for the record for,at are not chan(ed by the /rocessin( of the $)<6 co,,and when this ,essa(e is sent. Gou should ,onitor for this ,essa(e and /erfor, the a//ro/riate action for end of file. =f you atte,/t to run additional $)<6 co,,ands after end of file has been reached" ,essa(e ) 601-4 is sent a(ain. 12.#e-el .&ecE Error@ All the files will ha'e a 'alue for &e'el )hec9 after co,/ilation if the /ara,eter &e'el chec9 >Kyes? is (i'en. =f the file is ,odified and co,/iled a(ain" it will (et a new 'alue for le'el chec9. =f the /ara,eter &e'el )hec9>Kyes? is (i'en for the file and the /ro(ra, usin( that file is not co,/iled after the file is ,odified and co,/iled" then the /ro(ra, will encounter le'el chec9 error at the ti,e of e0ecution. 13.6ignificance of +eturn and *=8#+ P *(8. =f K=7&$ L KO7 is s/ecified in a /ro(ra," it instructs the co,/iler that all the o/erations should be ter,inated >i.e." if file is o/ened i,/licitly it should be closed" data ,o'e,ent to8fro, data area should ha//en etc? before e0itin(

a(e 140 of 250

As400 Stuff

the /ro(ra,. #'en if there are any e0ecutable state,ents followin( that they will be e0ecuted once. 7ow" K=7&$ L KO7" followed by $#:B$7 will ter,inate the o/erations and return to the caller. Any e0ecutable state,ents that follow these 2 state,ents will not be e0ecuted. =f $#:B$7 is (i'en se/arately" the /ro(ra, will (et returned" but the o/erations will not be ter,inated >i.e." if file is o/ened i,/licitly it will not be closed" data ,o'e,ent to8fro, data area will not ha//en etc?. Any state,ents that follow $#:B$7 will ne'er (et e0ecuted.
14. *Entry significance of factor 1, factor 2 and result fields.

htt/H88/ublib.boulder.ib,.co,8infocenter8iadthel/8'.r08inde0.js/? to/icL8co,.ib,.etools.iseries.lan(ref.doc8e'ferlsh320.ht,
15. E >. E K E >%+ , (GE+#9?, +6> 6), .o00and 9ttention

Eey and .o00and 7unction 3ey and Galidity c&ecE@ #D:)D# D #D:W$D #D:)D# D #D:W$D are 9ey words used for for,attin( /ur/ose. #D:)D# cannot be a//lied to )haracter filed. And #D:)D# has so,e )odes /reAdefined for e0a,/le" #D:)D#>Q? I for su//ressin( the leadin( Fero G I for date field. #D:W$D can be used to define user defined for,attin( for fields. O<#$&AG =t allows a record for,at to be dis/layed on screen retainin( the /re'ious dis/layed record for,ats. What 9ey word is used when screen is reAdis/layed? $S:DS is a /ara,eter to be s/ecified at co,/ile ti,e for dis/lay file. )o,,and Attention 9ey and )o,,and 6unction 3ey? With the hel/ of )o,,and attention 9ey we can /ass only the indicator status to /ro(ra, not the data fro, screen. While co,,and function 9ey /asses indicator status as well as a data fro, screen to /ro(ra,. +ow to 'alidate in/ut 'alues in Dis/lay file? With the hel/ of <alidity chec9 9ey words <A&B#" $A7%#" )O!
a(e 141 of 250

As400 Stuff

1. %&at is t&e difference !et'een .9 and .7 Eeys" )6 transfers the chan(ed data and )A transfers only the indicator 'alue.

1. %&at is )6 6" :he ro(ra, Status Data Structure is the way the $ % co,/iler infor,s the /ro(ra, what is ha//enin( at runti,e. :his is e0/lained in the $ % reference under 6ile and ro(ra, #0ce/tion8#rrors. 6or <*$1 #n(lish" here is the lin9H htt/H88/ublib.boulder.ib,.co,8iseries8'*r18ic22248boo9s8c022*01310.ht,_+ D$ $O%P # +ere is an e0a,/le of $ % D s/ecs to describe the SDS /ro'ided by Si,on )oulterH D SDS D $O)\7A!# K $O) na,e D %!\S:A:BS KS:A:BS D $<\S:A:BS 120S 0 status D &=7#\7B! 21 21 D $OB:=7# K$OB:=7# D A$!S K A$!S /ar,s D #P) \:G # 40 42 D #P) \7B! 43 4nu,ber D %!\&=4 11 20 D #P) \DA:A 21 1.0 D #P) \=D 1.1 1.4 D DA:# 121 121 D G#A$ 122 200S 0 f,t? D &AS:\6=&# 201 201 D 6=&#\=76O 202 243 D 5O4\7A!# 244 2*3 D BS#$ 2*4 2-3 D 5O4\7B! 2-4 2-2S 0
a(e 142 of 250

K rocedure K Status code K re'ious K Src list line nu K $outine na,e K 7u, /assed K #0ce/tion ty/e K #0ce/tion K ro(ra, library K #0ce/tion data K #0ce/tion =d K Date >KDA:# f,t? K Gear >KG#A$ K &ast file used K 6ile error info K 5ob na,e K Bser na,e K 5ob nu,ber

As400 Stuff

D 5O4\DA:# f,t? D $B7\DA:# >BDA:#? D $B7\:=!# >BDA:#? D )$:\DA:# D )$:\:=!# D ) &\&#<#& D S$)\6=&# D S$)\&=4 D S$)\!4$ D $O)\ %! D $O)\!OD D )B$$\BS#$

2.0 2.212

2.*S 0 211S 0 21.S 0

K Date >BDA:# K $un date K $un ti,e K )reate date K )reate ti,e K )o,/iler le'el K Source file K Source file lib K Source file ,br K (, roc is in K !od roc is in K !od roc is in

211 223 224 222 300 303 304 313 314 323 324 333 334 343 344 3*3 3*1 3-.

K Status codes K 7or,al )odes K )ode )ondition K 00000 7o e0ce/tion8error occurred K 00001 )alled /ro(ra, returned with the &$ indicator on. K #0ce/tion8#rror )odes K )ode )ondition K 00100 <alue out of ran(e for strin( o/eration K 00101 7e(ati'e sEuare root K 00102 Di'ide by Fero K 00103 an inter,ediate result is not lar(e enou(h to contain the result. K 00104 6loat underflow. An inter,ediate 'alue is too s,all to be contained in the K =nter,ediate result field K 00112 =n'alid Date" :i,e or :i,esta,/ 'alue. K 00113 Date o'erflow or underflow. >6or e0a,/le" when the result of a Date calculation K results in a nu,ber (reater than K+=<A& or less than K&O<A&.? K 00114 Date ,a//in( errors" where a Date is ,a//ed fro, a 4 character year to a 2 K )haracter year and the date ran(e are not 1240A2032. K 00120 :able or array out of seEuence. K 00121 Array inde0 not 'alid K 00122 O))B$ outside of ran(e
a(e 143 of 250

As400 Stuff

K 00123 $eset atte,/ted durin( initialiFation ste/ of /ro(ra, K 00202 )alled /ro(ra, or /rocedure failedX halt indicator >+1 throu(h +2? not on K 00211 #rror callin( /ro(ra, or /rocedure K 00222 ointer or /ara,eter error K 00231 )alled /ro(ra, or /rocedure returned with halt indicator on K 00232 +alt indicator on in this /ro(ra, K 00233 +alt indicator on when $#:B$7 o/eration run K 00222 $ % =< for,atted du,/ failed K 00333 #rror on DS &G o/eration K 00401 Data area s/ecified on =78OB: not found K 00402 K DA not 'alid for nonA/restart job K 00411 Data area ty/e or len(th does not ,atch K 00412 Data area not loc9ed for out/ut K 00413 #rror on =78OB: o/eration K 00414 Bser not authoriFed to use data area K 0041* Bser not authoriFed to chan(e data area K 00421 #rror on B7&O)3 o/eration K 0042* &en(th reEuested for stora(e allocation is out of ran(e K 0042#rror encountered durin( stora(e ,ana(e,ent o/eration K 00431 Data area /re'iously loc9ed by another /ro(ra, K 00432 Data area loc9ed by /ro(ra, in the sa,e /rocess K 004*0 )haracter field not entirely enclosed by shiftAout and shiftAin characters K 00*01 6ailure to retrie'e sort seEuence. K 00*02 6ailure to con'ert sort seEuence. K 00102 )o,,it,ent control not acti'e. K 00103 $ollbac9 o/eration failed. K 00104 #rror occurred on )O!!=: o/eration K 0010* #rror occurred on $O&43 o/eration K 0020. Deci,al data error >di(it or si(n not 'alid? K 002.0 the le'el nu,ber of the co,/iler used to (enerate the /ro(ra, does not a(ree K With the le'el nu,ber of the $ % =< runAti,e subroutines K 02221 internal failure in =&# $ %8400 co,/iler or in runAti,e subroutines K 02222 ro(ra, e0ce/tion in syste, routine. 2. %&at is t&e file infor0ation data structure"
a(e 144 of 250

As400 Stuff

:he 6ile infor,ation data structure is the way the $ % runti,e en'iron,ent infor,s the /ro(ra, about the status of a file" seen fro, the o/eratin( syste, /ers/ecti'e. So,eti,es called a feedbac9 data structure" it is u/dated after e'ery =8O o/eration >$ % =<? or after a bloc9 of records is transferred >$ %8400?. =nfor,ation can be found in the $ % reference under 6ile and ro(ra, #0ce/tion8#rrors. 6or <*$1 #n(lish" here is the lin9H htt/H88/ublib.boulder.ib,.co,8iseries8'*r18ic22248boo9s8c022*013...ht,_+ D$6=&#P # Do note that there are e0a,/le D s/ecs at the abo'e lin9. Si,on )oulter /osted one e0a,/le of D s/ecs to the $ %400A& listH K Standard $ % feedbac9 area 1A10 D=76DS ds D 6ile K6=&# D O/en=nd 2 2 D #O6=nd 10 10 D 6ileStatus KS:A:BS D O/)ode KO )OD# D $outinr K$OB:=7# D &ist7u, 30 3. D S/clStat 31 42S 0 D $ecord6,t K$#)O$D D !s(=D 4*2 DK the ne0t 4 fields are a'ailable after OS: D Screen\ KS=M# D 7&S=n\ K=7 D 7&SOut\ KOB: D 7&S!ode\ K!OD#

K 6ile na,e K 6ile o/en? K 6ile at eof? K Status code K &ast o/code K $ % $outine K &istin( line K S #)=A& status K $ecord na,e K #rror !S%=D K Screen siFe K 7&S =n/ut? K 7&S Out/ut? K 7&S !ode?

K O/en feedbac9 area 11A240 K 7O:# that (ettin( data beyond colu,n 10 is e0/ensi'e K =n ter,s of /ro(ra, o/ens... D OD \:G # 11 12 K OD :y/e D 6=&#\7A!# 13 22 K 6ile na,e D &=4$A$G 23 102 K &ibrary na,e D S OO&\6=&# 103 112 K S/ool file na,e D S OO&\&=4 113 122 K S/ool file lib
a(e 145 of 250

As400 Stuff

D S OO&\7B! nu, D $)D\&#7 D 3#G\&#7 D !#!4#$ D :G # D $OWS rows D )O&B!7S cols D 7B!\$)DS records D A))\:G # D DB \3#G D S$)\6=&# D <O&\O66 D 4&3\$)DS D O<#$6&OW D 4&3\=7)$ D 6&A%S1 D $#CB#S:#$ na,e D O #7\)OB7: D 4AS#D\!4$S ,brs D 6&A%S2 D O #7\=D D $)D6!:\&#7 le D ))S=D D 6&A%S3 D 7B!\D#<S defin

123

124= 0

K S/ool file K !a0 record len K !a0 9ey len K !e,ber na,e K 6ile ty/e K 7u, $:8DS K 7u, $:8DS K 7u, of K Access ty/e K Du/licate 9ey? K Source file? K <ol label offs K !a0 rcds in bl K O'erflow line K 4l9 incre,ent K !isc fla(s K $eEuester K O/en count K 7u, based K !isc fla(s K O/en identifie K !a0 rcd f,t K Database ))S=D K !isc fla(s K 7u, de's

12* 12-= 0 12. 121= 0 122 131 14. 141= 0 1*2 1*3= 0 1*4 1*1**= 0 1*2= 0

1-0 1-1 1-2 1-2 1-3 1-3 114 11*= 0 11- 11.= 0 111 112= 0 120 121= 0 12- 1212. 2020. 211 201= 0 212= 0

213 213 214 21* 21- 21.= 0 211 212= 0 220 220 22. 221= 0

DK =8O feedbac9 area 241A3-DK 7O:# that this area is shared with the OS: feedbac9 area belowJ D K 241A242 not used D W$=:#\)7: 243 24-= 0 K Write count D $#AD\)7: 24. 2*0= 0 K $ead count D W$:$D\)7: 2*1 2*4= 0 K Write8read count
a(e 146 of 250

As400 Stuff

D O:+#$\)7: count D O #$A:=O7 o/eratio D =O\$)D\6!: na,e D D#<\)&ASS D =O\ %!\D#< na,e D =O\$)D\&#7

2** 2-0 2-1

2*1= 0 2-0 2.0

K Other =8O K )uurent K $cd for,at K De'ice class K (, de'ice K $cd len of =8O

2.1 2.2 2.3 212 213 21-= 0

DK OS: area 241Annn DK Dis/lay D %!\D#<\ 241 2*0 de'ice D D#<\DS)\ 2*1 2-0 descri/tion D BS#$\=D\ 2-1 2.0 D D#<\)&ASS\ 2.1 2.1 D D#<\:G #\ 2.2 2.. D $#C\D#<\ 2.1 2.1 D A)C\S:A:\ 2.2 2.2 status D =7<\S:A:\ 210 210 D DA:A\A<A=&\ 211 211 a'ailable D 7B!\$OWS\ 212 213= 0 rows D 7B!\)O&S\ 214 21*= 0 cols D 4&=73\ 21- 21D &=7#\S:A:\ 21. 21. D DS \&O)\ 211 211 location D DS \:G #\ 212 212 D 34D\:G #\ 220 220 ty/e D ):&\=76O\ 342 342 D )O&O$\DS \ 343 343 ca/able? D %$=D\DS \ 344 344
a(e 147 of 250

K ro(ra, K De' K Bser =D K De'ice class K De'ice ty/e K $eEuester? K AcEuire K =n'ite status K Data K 7u,ber of K 7u,ber of K Allow blin9? K Online8offline? K Dis/lay K Dis/lay ty/e K 3eyboard K )ontroller info K )olor K %rid line ds/?

As400 Stuff

K :he followin( fields a//ly to =SD7. D =SD7\&#7\ 31* 31-= 0 len D =SD7\:G #\ ty/e D =SD7\ &A7\ /lan D =SD7\7B!\ D =SD7\S&#7\ address D =SD7\S:G #\ address D =SD7\S7B!\ address D =SD7\)O7\ D =SD7\$&#7\ len D =SD7\$7B!\ D =SD7\#&#7\ D =SD7\#:G #\ ty/e D =SD7\#7B!\ nu, D =SD7\P:G #\ ty/e DK =)6 D %!\D#<\ de'ice D D#<\DS)\ descri/tion D BS#$\=D\ D D#<\)&ASS\ D D#<\:G #\ D $#C\D#<\ D A)C\S:A:\ status D =7<\S:A:\ D DA:A\A<A=&\ a'ailable D S#S\S:A:\ D SG7)\&<&\ 31. 312 321 43* 43. 432 410 411 311 320 430 43-= 0 431 4.1 410 412= 0

K $,t nu,ber K $,t nu,ber K $,t nu,ber K $,t nu,ber K $,t subA K $,t subA K $,t subA K )onnection K $,t address K $,t address K #0tension len K #0tension K #0tension K P.2* call K ro(ra, K De' K Bser =D K De'ice class K De'ice ty/e K $eEuester? K AcEuire K =n'ite status K Data K Session status K Synch le'el

413 *14 *12 *20 *21 *21 *22 *-241 2*1 *-1 *-2*0 2-0

2-1 2.0 2.1 2.1 2.2 2.2 2.1 2.1 2.2 2.2 210 210 211 211 221 222 221 222
a(e 148 of 250

As400 Stuff

D )O7<\:G #\ ty/ D $!:\&O)\ location D &)&\&B\ D &)&\7#:=D\ D $!:\&B\ D $!:\7#:=D\ =D D A )\!OD#\ D &B-\S:A:#\ state D &B-\)O$\

223 224

223 301

K )on'ersation K $e,ote K &ocal &B na,e K &ocal net =D K $e,ote &B K $e,ote net K A ) !ode K &B- con' K K &B- con' correlator K $,t nu,ber K $,t nu,ber K $,t nu,ber K $,t nu,ber K subAaddr len K subAaddr ty/e K $,t subA K )onnection K $,t address K $,t address K #0tension len K #0tension K #0tension K P.2* call ty/e

302 302 310 31. 311 32* 32- 333 334 341 34* 34* 343*3

K :he followin( fields a//ly to =SD7. D =SD7\&#7 31* 31-= 0 len D =SD7\:G # ty/e D =SD7\ &A7 /lan D =SD7\7B! D =SD7\S&#7 D =SD7\S:G # D =SD7\S7B! address D =SD7\)O7 D =SD7\$&#7 len D =SD7\$7B! D =SD7\#&#7 D =SD7\#:G # ty/e D =SD7\#7B! nu, D =SD7\P:G # 31. 312 311 320

321 430 43* 43-= 0 43. 431 432 4.1 410 411 410 412= 0

413 *14 *12 *20 *21 *21 *22 *-*-1 *--

K :he followin( infor,ation is a'ailable only when /ro(ra, was started K as result of a recei'ed /ro(ra, start reEuest. > \ stands for /rotected? D :$A7\ %! *-. -30 K :rans /(, na,e
a(e 149 of 250

As400 Stuff

D \&BW=D&7 D \&B7A!#&7 D \&B7A!# D \&BW=D=7 instance D \&BW=DS#C nu,

-31 -31 -32 -32 -33 -42 -*0 -** -*-*.= 0

K &BW=D fld len K &BA7A!# len K &BA7A!# K &BW=D K &BW=D seE

K :he followin( infor,ation is a'ailable only when a /rotected con'ersation K is started on a re,ote syste,. >B\ stands for un/rotected? D B\&BW=D&7 -*1 -*1 K &BW=D fld len D B\&B7A!#&7 -*2 -*2 K &BA7A!# len D B\&B7A!# --0 -.K &BA7A!# D B\&BW=D=7 -.. -12 K &BW=D instance D B\&BW=DS#C -13 -14= 0 K &BW=D seE nu, DK De'ice inde/endent area 3-.Annn DK 7O:# that this area is shared with the OS: feedbac9 area abo'eJ DK rinter D )B$\&=7# 3-. 3-1= 0 K )urrent line nu, D )B$\ A%# 3-2 3.2= 0 K )urrent /a(e cnt D $:\!A5O$ 401 402 K !ajor ret code D $:\!=7O$ 403 404 K !inor ret code DK Dis9 D 6D43\S=M# fdb9 D 5O=7\4=:S D &O)3\$)DS rcds D OS\4=:S D D&:\4=:S bits D 7B!\3#GS >bin? D 3#G\&#7 3-. 3.0= 0 K SiFe of D4 K 56=&# bits K 7br loc9ed K 6ile /os bits K $cd deleted K 7u, 9eys K 3ey len(th

3.1 3.4= 0 3.. 3.1= 0 31* 314 31. 323 31* 314 311= 0 324= 0
a(e 150 of 250

As400 Stuff

D !4$\7B! nu,ber D D4\$$7 nu, D 3#G DK DK =)6 D =)6\A=D D =)6\&#7 D =)6\!A5O$ D =)6\!=7O$ D S7A\S#7S# D SA6#\=7D D $CSW$: D $!:\6!: f,t D =)6\!OD# DK Dis/lay D DS \6&A%1 D DS \A=D D )B$SO$ D DA:A\&#7 len D S6\$$7 D !=7\$$7 D 7B!\$)DS rcds D A):\)B$S DK D DS \!A5O$ D DS \!=7O$ code K K K K K K

32* 32.

32-= 0 400= 0

K !e,ber K $elati'eArcdA K 3ey 'alue >,a0 K siFe 2000? K A=D byte K Actual data len K !ajor ret code K !inor ret code K S7A sense rc K Safe indicator K $eEuest write K $e,ote rcd K !ode na,e K Dis/lay fla(s K A=D byte K )ursor location K Actual data K Subfile rrn K Subfile ,in rrn K Subfile nu, K Acti'e window K cursor location K !ajor ret code K !inor ret

401 2400

3-2 3-2 3.2 3.*= 0 401 402 403 404 40* 412 413 413 41* 41* 41- 42* 430 43.

3-. 3-1 3-2 3-2 3.0 3.1 3.2 3.*= 0 3.- 3..= 0 3.1 3.2= 0 310 311= 0 312 401 403 313 402 404

Status codes 7or,al )odes )ode a De'ice a $) a )ondition 00000 a a a 7o e0ce/tion8error. 00002 aW a n8a a 6unction 9ey used to end dis/lay. 00011 a W"D"SC a 1100 a #nd of file on a read >in/ut?.
a(e 151 of 250

As400 Stuff

K 00012 a W"D"SC a n8a a 7oArecordAfound condition on a )+A=7" S#:&&" and S#:%: K 00013 aW a n8a a Subfile is full on W$=:# o/eration. K #0ce/tion8#rror )odes K )ode a De'ice a $) a )ondition K 01011 a W"D"SC a n8a a Bndefined record ty/e >in/ut record does not ,atch rec K a a a indicator?. K 01021 a W"D"SC a n8a a :ried to write a record that already e0ists >file bein K a a a 9ey is du/licate" or atte,/ted to write du/licate rela K a a a subfile?. K 01022 aD a n8a a $eferential constraint error detected on file ,e,ber. K 01023 a D"SC a n8a a #rror in tri((er /ro(ra, before file o/eration /erfor, K 01024 a D"SC a n8a a #rror in tri((er /ro(ra, after file o/eration /erfor,s K 01031 a W"D"SC a n8a a !atch field out of seEuence. K 01041 a n8a a n8a a Array8table load seEuence error. K 01042 a n8a a n8a a Array8table load seEuence error. Alternate collatin( s K 010*1 a n8a a n8a a #0cess entries in array8table file. K 010.1 a W"D"SC a n8a a 7u,eric seEuence error. K 01121>4? a W a n8a a 7o indicator on the DDS 9eyword for rint 9ey. K 01122>4? a W a n8a a 7o indicator on the DDS 9eyword for $oll B/ 9ey. K 01123>4? a W a n8a a 7o indicator on the DDS 9eyword for $oll Down 9ey. K 01124>4? a W a n8a a 7o indicator on the DDS 9eyword for )lear 9ey. K 0112*>4? a W a n8a a 7o indicator on the DDS 9eyword for +el/ 9ey. K 0112->4? a W a n8a a 7o indicator on the DDS 9eyword for +o,e 9ey. K 01201 aW a 3400 a $ecord ,is,atch detected on in/ut. K 01211 a all a n8a a =8O o/eration to a closed file. K 0121* a all a n8a a O #7 issued to a file already o/ened.
a(e 152 of 250

As400 Stuff

K 0121->3? a all a yes a #rror on an i,/licit O #78)&OS# o/eration. K 0121.>3? a all a yes a #rror on an e0/licit O #78)&OS# o/eration. K 01211 a D"SC a n8a a $ecord already loc9ed. K 01221 a D"SC a n8a a B/date o/eration atte,/ted without a /rior read. K 01222 a D"SC a n8a a $ecord cannot be allocated due to referential constraint K 01231 aS a n8a a #rror on S #)=A& file. K 0123* a a n8a a #rror in $:):& s/ace or s9i/ entries. K 01241 a D"SC a n8a a $ecord nu,ber not found. >$ecord nu,ber s/ecified in K a a a /resent in file bein( /rocessed.? K 012*1 aW a 1000 1100 a er,anent =8O error occurred. K 012** aW a 1200 1300 a Session or de'ice error occurred. $eco'ery ,ay be /os K 012-1 aW a n8a a Atte,/t to e0ceed ,a0i,u, nu,ber of acEuired de'ices. K 012.1 aW a n8a a Atte,/t to acEuire una'ailable de'ice K 01211 aW a n8a a O/eration to un acEuired de'ice. K 01212 aW a 0302 a 5ob endin( with controlled o/tion. K 01214 aW a n8a a Bnable to acEuire second de'ice for sin(le de'ice file K 0121* aW a 0100 a Atte,/t to acEuire a de'ice already acEuired. K 0121aW a n8a a Atte,/t to o/en shared file with SA<DS or =7D o/tions. K 0121. aW a n8a a $es/onse indicators o'erla/ =7D indicators. K 01222 a W"D"SC a yes a Other =8O error detected. K 01331 aW a 0310 a Wait ti,e e0ceeded for $#AD fro, WO$3S:7 file. K AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA K 7otesH K >3? Any errors that occur durin( an o/en or close o/eration K will result in a KS:A:BS 'alue of 121- or 121. K re(ardless of the ,ajor8,inor return code 'alue. K >4? See 6i(ure 2 in to/ic 1.3.2.4 for s/ecial handlin(. K A=D byte ,a/ D 3ey61 s 1 inF>0;31;?
a(e 153 of 250

As400 Stuff

D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D

3ey62 s 3ey63 s 3ey64 s 3ey6* s 3ey6s 3ey6. s 3ey61 s 3ey62 s 3ey610 s 3ey611 s 3ey612 s 3ey613 s 3ey614 s 3ey61* s 3ey61s 3ey61. s 3ey611 s 3ey612 s 3ey620 s 3ey621 s 3ey622 s 3ey623 s 3ey624 s 3ey6)lr s 3ey6#nt s 3ey6+l/ s 3ey6$Dn s 3ey6$B/ s 3ey6 rt s 3ey649s/ s 3ey6Auto#nter s

1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

inF>0;32;? inF>0;33;? inF>0;34;? inF>0;3*;? inF>0;3-;? inF>0;3.;? inF>0;31;? inF>0;32;? inF>0;3A;? inF>0;34;? inF>0;3);? inF>0;41;? inF>0;42;? inF>0;43;? inF>0;44;? inF>0;4*;? inF>0;4-;? inF>0;4.;? inF>0;41;? inF>0;42;? inF>0;4A;? inF>0;44;? inF>0;4);? inF>0;4D;? inF>0;61;? inF>0;63;? inF>0;64;? inF>0;6*;? inF>0;6-;? inF>0;61;? 1 inF>0;36;?

3. .# )ara0eter 4asics When a 'ariable is declared within a )& /ro(ra," the syste, assi(ns stora(e for that 'ariable within the /ro(ra, auto,atic stora(e area > ASA?. =f you subseEuently use the 'ariable as a /ara,eter within a )A&& co,,and" the syste, does not /ass the 'alue of that 'ariable to the called /ro(ra," but rather a /ointer to the ASA of the callin( /ro(ra,. :his is 9nown as /ara,eter /assin( by reference.
a(e 154 of 250

As400 Stuff

6or this reason" it is 'ery i,/ortant that both /ro(ra,s declare the /ara,eter to be of the sa,e ty/e and siFe. :o illustrate" let;s loo9 at the followin( e0a,/leH )g09@ (, D)& D<ar1 K)+A$ 2 =nF> ;A4; ? D)& D<ar2 K)+A$ 2 =nF> ;GM; ? )all (,4 ar,> D<ar1 D<ar2? #nd (, )g04@ (, ar,> Di\<ar1 Di\<ar2 ? D)& Di\<ar1 K)+A$ 4 D)& Di\<ar2 K)+A$ 2 #nd (, +o/efully" you;'e noticed that the first /ara,eter is declared to be lar(er in (,4 than it was in (,A. Althou(h you ,i(ht e0/ect Di\<ar1 to contain ;A4 ; after the call" the followin( is what the in/ut /ara,eters in (,4 actually containH Di\<ar1 L ;A4GM; Di\<ar2 L ;GM; Di\<ar1 shows the contents of the first /ara,eter" and the second" because the second /ara,eter is i,,ediately adjacent to the first within the stora(e area. =f the second /ara,eter was not conti(uous to the first" then the last two bytes of Di\<ar1 would show whate'er ha//ened to be in the stora(e area at that ti,e. Gou can thin9 of Di\<ar1 as a 4Abyte NwindowN into the stora(e area of the callin( /ro(ra,. =t;s /assed a /ointer that tells it where the 'iew be(ins" and it accesses anythin( in stora(e fro, that /oint u/ to the /ara,eter;s declared len(th. #ooEing at #iterals :here are se'eral ways that a /ro(ra, can be called" other than fro, another /ro(ra,. #0a,/les include the co,,and line" S4!5O4" job
a(e 155 of 250

As400 Stuff

scheduler etc. =n the case of an interacti'e call fro, the co,,and line" you s/ecify the /ara,eters as literals" ieH )all (,4 ar,>;A4; ;GM;? )onsider that when we do this" there is no ASA. We;ll loo9 at the i,/lications of that in a ,inute" but for nowX just ,a9e a note of it. Sub,ittin( a job fro, the co,,and line isn;t any different. =f you;re sub,ittin( a )A&&" then you;ll be s/ecifyin( any associated /ara,eters as literals. +owe'er" thin(s can (et a bit decei'in( when you sub,it a job fro, 3it2in a /ro(ra," as the followin( e0a,/le illustratesH )g0.@ (, D)& D<ar1 K)+A$ 2 =nF> ;A4; ? D)& D<ar2 K)+A$ 2 =nF> ;GM; ? Sb,5ob ),d>)all (,4 ar,> D<ar1D<ar2?? #nd (, )learly" we;re not /assin( literals here. Or are we? &et;s thin9 about how thin(s would wor9 if we /assed 'ariablesH (,) sub,its a call to (,4" /assin( two 'ariables as /ara,eters. (,) i,,ediately ends as a result of the #nd (, state,ent. (,4 be(ins runnin( in batch and recei'es /ointers to (,);s ASA. (,4 crashes when it atte,/ts to use the /ointers.

We ha'e in'alid /ointers because (,) is no lon(er runnin(. =f you;'e e'er tried this /ersonally" you 9now that it doesn;t ha//en in /ractice. :he reason for that is that the syste, is con'ertin( those 'ariables to literals before issuin( the )A&& co,,and. =t@s 'ery snea9y" but effecti'e. 7ow that we;'e seen so,e e0a,/les of where literals are used" and why" it;s ti,e to tal9 about the ASA a(ain. When we discussed the basics of )& /ara,eter /assin(" we learned that the called /ro(ra, e0/ects to recei'e a /ointer to a stora(e area within the ASA for each in/ut /ara,eter. :his reEuire,ent hasn;t chan(ed. So now we ha'e a situation where the )A&& co,,and is /assin( literals" but the called /ro(ra, is still e0/ectin( /ointers. Ob'iously" it;s ti,e for the syste, to /erfor, so,e ,ore ,a(ic behind the scenes. =n order to acco,,odate the reEuire,ents of the called /ro(ra,"
a(e 156 of 250

As400 Stuff

the syste, creates a s/ace in te,/orary stora(e for each literal bein( /assed" and ,o'es the 'alue of the literal into that stora(e s/ace. 7ow it can /ass /ointers to the called /ro(ra," and e'eryone is ha//y. #0ce/t you that is" because none of this chan(es the fact that you;re (ettin( N(arba(eN in the in/ut 'ariables of your called /ro(ra,J 6air enou(h. =;, (ettin( to that now" but you needed the bac9(round in order to understand the ne0t /art. 6iBing =t 9ll <1 7ow that you 9now the syste, is creatin( 'ariables behind the scene" you ,i(ht wonder how it 9nows what siFe those 'ariables need to be. :he answer is that it doesn;t. =nstead" the desi(ners ha'e i,/osed so,e s/ecific rules about how literals are transfor,ed to 'ariables" and thereby /assed as /ara,eters. )& su//orts only three basic data ty/esH c2aracter" decimal" and logical. 6or the /ur/oses of this discussion" you can consider the lo(ical data ty/e eEui'alent to the character ty/e" because it;s treated in the sa,e ,anner. :he si,/lest rule is the one that handles deci,al literals. All deci,al literals will be con'erted to /ac9ed deci,al for,at with a len(th of >1* *?" where the 'alue is 1* di(its lon(" of which * di(its are deci,al /laces. :herefore" any /ro(ra, that you e0/ect to call fro, the co,,and line" or S4!5O4 etc." needs to declare its nu,eric in/ut /ara,eters as KD#)>1* *?. )haracter literals are a little bit ,ore co,/licated" but still fairly strai(htforward. :here are two rules to re,e,ber. :he first is that any character literal u/ to 32 characters in len(th will be con'erted to a 32 byte 'ariable. :he 'alue is left justified" and /added on the ri(ht with blan9s. So if you were to /ass the followin( literalH )all (,4 ;A4; the associated stora(e s/ace for that literal would containH ;A4000000000000000000000000000000; )32ere 676 represents a blan" space* :he second rule is that character literals lon(er than 32 bytes are con'erted to a 'ariable of the sa,e len(th as the literal 'alue itself" as in the followin( e0a,/leH )all (,4 ;:his is a lon( character literal that will e0ceed 32 bytes.; the associated stora(e s/ace for that literal would containH ;:his is a lon( character literal that will e0ceed 32 bytes.; 6inally" since the lo(ical data ty/e follows the sa,e rules as the character ty/e" and the only /ossible 'alues for a lo(ical data ty/e are ;0; or ;1;" we
a(e 157 of 250

As400 Stuff

9now that a lo(ical literal will always be created as a 32 byte" left justified" /added character 'ariable. )ara0eter )ro!le0s =n the be(innin( of this e0/lanation" you learned that it was i,/ortant for the /ara,eter declarations to ,atch between a called /ro(ra, and its caller. :hen you disco'ered that the syste, so,eti,es has to ta9e it u/on itself to declare the /ara,eters of the caller on your behalf. =f the two declarations don;t ,atch" we ha'e the /otential for trouble. =n the case of a deci,al 'alue" the result is i,,ediate and ob'iousX you (et a data deci,al error. )haracter 'ariables are ,ore difficult to debu( because they don;t (enerate any i,,ediate errors. What actually ha//ens de/ends u/on the len(th of the /ara,eter in the called /ro(ra,. =f the len(th of the /ara,eter in the called /ro(ra, is less t&an the len(th of the /ara,eter bein( /assed" the e0tra characters are effecti'ely truncated" as followsH )all So,e (, >;A4)D#6%;? 8* s$stem creates -+ b$te *C9: *8 So,e (,H (, ar,> Di\<ar1 ? D)& Di\<ar1 K)+A$ 4 #nd (, What ha//ens is that the syste, /asses ;A4)D#6%0000000000000000000000000; );7; is a blan"*" but because of the declared len(th of Di\<ar1" So,e (, only see;s ;A4)D;. 6or ,ost of us" this is the beha'ior that we would e0/ect. :hin(s (et nasty when the declared len(th of the 'ariable is longer t&an what is bein( /assed in. Bsin( the sa,e e0a,/le as we;'e just seen abo'eH So,e (,H (, ar,> Di\<ar1 ? D)& Di\<ar1 K)+A$ 34 #nd (, =n this case" the syste, will still allocate 32 bytes of stora(e and assi(n ;A4)D#6%0000000000000000000000000; to it" but because Di\<ar1 is now
a(e 158 of 250

As400 Stuff

declared to be 34 bytes lon(" So,e (, will see ,ore stora(e than it was intended to. =t will see the 32 bytes that were allocated for it" 1lus two additional bytes. =t;s those two additional bytes that can cause the infa,ous Nun/redictable resultsN which =4!;s docu,entation often refers to. =f the e0tra bytes contain blan9s" chances are that you won;t notice a /roble," but if they contain so,ethin( else" your in/ut /ara,eter will contain N(arba(eN. As you can see" 32en dealing 3it2 literals" the ,a(ic nu,ber for character /ara,eters is 32. =f the called /ro(ra, declares the /ara,eter to be less than or eEual to 32" you;ll ne'er see N(arba(eN in the /ara,eter. Once you cross that 32 byte threshhold" you need to ta9e e0tra care to ensure that the siFe of the literal bein( /assed is eEual to the declared siFe of the in/ut /ara,eter. >&ings to +e0e0!er

Always ,atch the ty/e8siFe of /ara,eters on your /(, to /(, calls. $e,e,ber that the syste, con'erts literals to 'ariables in the bac9(round. $e,e,ber that deci,al literals are always con'erted to KD#)>1* *? and that char literals less than or eEual to 32 bytes are con'erted to K)+A$>32? and that char literals (reater than 32 bytes are con'erted to 'ariables of eEui'alent siFe.

And last" but not leastH the called /ro(ra, NseesN as ,uch stora(e as it declares for an in/ut /ara,eter" re(ardless of whether or not the caller actually allocated that ,uch stora(e for it. +ere is an e0a,/le of usin( a co,,and with nu,eric /ara,etersH htt/H88faE.,idran(e.co,8data8cache812..ht,l +ow to easily create a )!D object to start your )& /ro(ra, and a'oid these errorsH htt/H88faE.,idran(e.co,8data8cache8*.-.ht,l 1. .alling 1rogra0 >6>.9## code@ D $esult D 6actor1 D 6actor2 S S S *A =nF>;A;? *A =nF>;4;? *A =nF>;);?
a(e 159 of 250

As400 Stuff

D <ar1 ) ) ) ) ) 6actor1 $esult

S )all ar, #'al Ds/ly #'al

*A =nF>;P;? ;:S:#7:$G; 6actor2 $esult

$esult L ;:#S:; K=nlr L Kon

.alled 1rogra0 C>6>E8>+?D code@ D $es S *A D 6act1 S *A D 6act2 S *A ) ) ) K#ntry 6act1 list ar, #'al 6act2 $es K=nlr L Kon

escri1tion of t&e -alues in 7actor 1, 7actor 2 and +esult@ While callin( :S:#7:$G 6actor1 L 4 6actor2 L ) $esult L A Soon after enterin( :S:#7:$G A 6actor 2 (ets ,o'ed to $esult. 6actor 1 and 6actor 2 (ets cleared 6actor1 L ; ; 6actor2 L ; ; $esult L ) 4efore lea'in( :S:#7:$G A $esult is ,o'ed to 6actor 1. 7ow $esult is not cleared after 'alue is ,o'ed. 6actor1 L ) 6actor2 L ; ; $esult L ) After e0ecutin( K=nlr L Kon of the called /ro(ra, :S:#7:$G 6actor1 L ) 6actor2 L ; ; $esult L ; ;
a(e 160 of 250

As400 Stuff

After returnin( to the callin( /ro(ra, :S:)A&& A 6actor 1 (ets ,o'ed to 6actor 2. 6actor 1 (ets cleared. 6actor1 L ; ; 6actor2 L ) $esult L ; ; 2. is1lay )rogra0 +eferences C 6)),*+E7D :he Dis/lay ro(ra, $eferences >DS %!$#6? co,,and /ro'ides a list of the syste, objects referred to by the s/ecified /ro(ra,s. :he followin( list shows the syste, objects /ro'ided for the res/ecti'e /ro(ra, ty/esH .# K6=&#" K %!" and KD:AA$A .#E KS$< %! .##E K6=&#" K %!" KD:AA$A" and KS$< %! +), K6=&#" KD:AA$A" and K %! +),#E K6=&#" K %!" KD:AA$A" and KS$< %! :his infor,ation can be dis/layed" /rinted" or /laced in a database out/ut file. =f the infor,ation is shown or /rinted" a list >by library? of the s/ecified userA authoriFed /ro(ra,s" alon( with the objects referenced by each /ro(ra," is created. 6or files" infor,ation about how each file is used >in/ut" out/ut" u/date" uns/ecified" or any co,bination of these four? is also shown or /rinted. =f the infor,ation is written to a database file" the database file will ha'e a record for,at na,ed CW+D$ $. :he fields in record for,at CW+D$ $ are the sa,e as the fields in the =4!Asu//lied for,at CW+D$ $ in file CADS %! in the library CSGS. :he followin( infor,ation is contained in the database fileH :he na,e of the /ro(ra, and its te0t descri/tion :he na,e of the library containin( the /ro(ra, :he nu,ber of objects referenced by the /ro(ra,
a(e 161 of 250

As400 Stuff

:he Eualified na,e of the syste, object :he infor,ation retrie'al dates :he object ty/e of the referenced object

6or files" the record contains the followin( additional fieldsH :he na,e of the file in the /ro(ra, >/ossibly different fro, the syste, object na,e if an o'erride was in effect when the /ro(ra, was created? :he /ro(ra, use of the file >1Lin/ut" 2Lout/ut" 4Lu/date" 1Luns/ecified" or a nu,ber re/resentin( a co,bination of any of these fourX for e0a,/le" a code of 11 is a co,bination of 1" 2" and 1" which is in/ut" out/ut" and uns/ecified? :he nu,ber of record for,ats referenced" if any :he na,e of the record for,at used by the file and its record for,at le'el identifier :he nu,ber of fields referenced for each for,at 8ote@ :his co,,and lists which objects are referenced when the object is created or u/dated usin( B D %! or B DS$< %!. :he referenced object na,es and libraries listed ,ay be different than the actual na,es of the objects" since this infor,ation is stored when the /ro(ra, is created. #ntries can be added as the =&# /ro(ra, or ser'ice /ro(ra, is u/dated usin( B D %! or B DS$< %!" but entries are ne'er re,o'ed. =f the object has been ,o'ed since the /ro(ra, was created" or an o'erride was in effect durin( creation" the na,es listed ,ay differ fro, the actual na,es. +estrictions@ 1. :he user ,ust ha'e object o/erational authority for the /ro(ra,. 2. Also" of the libraries s/ecified by the library Eualifier" only the libraries for which the user has read authority are searched for the /ro(ra,s. #0a,/lesH DS %!$#6 %!>&=4$A$G18KA&&? OB: B:>KOB:6=&#? OB:6=&#>&=4286=&#2? :his co,,and creates a list of all authoriFed /ro(ra,s found in &=4$A$G1" and of the files and other syste, objects that the /ro(ra,s reference. =t stores the list in a database file na,ed 6=&#2 in &=42. DS %!$#6 %!>&=4$A$G184=&&=7%? OB: B:>K $=7:? :his co,,and creates a list of syste, objects that are referenced by the 4=&&=7% /ro(ra, in &=4$A$G1. :he out/ut is s/ooled for /rintin(.
a(e 162 of 250

As400 Stuff 1.

ifference !et'een *(0it and *no 1ass@

O,ittin( ara,etersH When callin( a /ro(ra, or /rocedure" you ,ay so,eti,es want to lea'e out a /ara,eter. =t ,ay be that it is not rele'ant to the called /rocedure. =f you need to o,it a /ara,eter on a call" you ha'e two choicesH S/ecify O :=O7S>KO!=:? and /ass KO!=: S/ecify O :=O7S >K7O ASS? and do not /ass the /ara,eter. :he /ri,ary difference between the two ,ethods has to do with how you chec9 to see if a /ara,eter has been o,itted. =n either case" an o,itted /ara,eter cannot be referenced by the called /rocedureX if it is" un/redictable results will occur. So if the called /rocedure is desi(ned to handle different nu,bers of /ara,eters" you will ha'e to chec9 for the nu,ber of /ara,eters /assed. =f KO!=: is /assed" it will ;count; as a /ara,eter. )assing *(*=> Gou can /ass KO!=: for a /rototy/ed /ara,eter if the called /rocedure is aware that KO!=: ,i(ht be /assed. =n other words" you can /ass KO!=: if the 9eyword O :=O7S >KO!=:? is s/ecified on the corres/ondin( /ara,eter definition in the /rototy/e. When KO!=: is s/ecified" the co,/iler will (enerate the necessary code to indicate to the called /rocedure that the /ara,eter has been o,itted. 7oteH KO!=: can only be s/ecified for /ara,eters /assed by reference. :o deter,ine if KO!=: has been /assed to an =&# $ % /rocedure" use the OADD$ builtAin function to chec9 the address of the /ara,eter in Euestion. =f the address is K7B&&" then KO!=: has been /assed. Gou can also use the )##:S:A >)hec9 for O,itted Ar(u,ent? bind able A =. #0H KAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA K )##:S:A >:est for o,itted ar(u,ent? AA =&# )## A = K 1. resence fla( Out/ut 4inary>4? K 2. Ar(u,ent nu,ber =n/ut 4inary>4? KAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA .EE>6>9 )+ EA>)+(.CF.EE>6>9FD )resent 10= 0 9rg8u0 10= 0 .(86>
a(e 163 of 250

As400 Stuff

7eed!acE ... /a-e)ar0 ... . . K . 6

129 10= 0

()>=(86C*(*=>D

.9##) .EE>6>9C/a-e)ar0 @ 3 @ *(*=>D =7 /a-e)ar0 P 1 do so,ethin( with third /ara,eter E8 =7

#ea-ing (ut )ara0eters :he other way to o,it a /ara,eter is to si,/ly lea'e it out on the call. :his ,ust be e0/ected by the called /rocedure" which ,eans that it ,ust be indicated on the /rototy/e. :o indicate that a /rototy/ed /ara,eter does not ha'e to be /assed on a call" s/ecify the 9eyword O :=O7S >K7O ASS? on the corres/ondin( /ara,eter definition. 7ote that all /ara,eters followin( the first K7O ASS one ,ust also be s/ecified with O :=O7S >K7O ASS?. Gou can s/ecify both K7O ASS and KO!=: for the sa,e /ara,eter" in either order" that is" O :=O7S >K7O ASSHKO!=:? or O :=O7S >KO!=:HK7O ASS?. As an e0a,/le of O :=O7S >K7O ASS?" consider the syste, A = C)!D#P) >#0ecute )o,,and? which has an o/tional third /ara,eter. KAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA K :his /rototy/e for C)!D#P) defines three /ara,etersH K 1A a character field that ,ay be shorter in len(th K :han e0/ected K 2A Any nu,eric field K 3A An o/tional character field KAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA D Ec,de0c $ #P: %!>;C)!D#P);? D c,d 3000A O :=O7S>K<A$S=M#? )O7S: D c,dlen 1* * )O7S: D 3A )O7S: O :=O7S>K7O ASS?
1. %&at do 'e 0ean !y e2ternaliBing"

4y e0ternaliFin( we ,ean that all $#AD" )+A=7" and other database o/erations are located in se/arate routines and /ro(ra,s that reEuire =8O ,a9e reEuests to these routines to /erfor, the o/eration on their behalf.

a(e 164 of 250

As400 Stuff

2. %&at 'ill 7(+ o1code 'ill do"


S3A7DASA!O8DO&OO 6O$ KKKKKKKKKKKKKKK 4e(innin( of data KKKKKKKKKKKKKKKKKKKKKKKKKKKKK 0001.00 di 0002.00 dn 0003.00 c 0004.00 c 000*.00 c 000-.00 c 000..00 c 0001.00 c i i s s for ds/ly endfor for ds/ly endfor iLn downto 1 */ 0 inF>1? */ 0 inF>10? iL1 to n

0001.01Kfor>=L*X=b40XiLiU10? 0002.00 c 0010.00 c 0011.00 c 0012.00 c 0013.00 c 0014.00 c 001*.00 c i i for ds/ly endfor for ds/ly endfor seton lr iL* to 40 by n iL* by n to 40

KKKKKKKKKKKKKKKKKK #nd of data KKKKKKKKKKKKKKKKKKKKKKKKKKKKK OB: B: DS &G 1 DS &G 2 DS &G 3 DS &G 4 DS &G * DS &G DS &G DS &G DS &G DS &G 10 2 1 . -

a(e 165 of 250

As400 Stuff
DS &G DS &G . DS &G 1 DS &G 2 DS &G 10 DS &G * DS &G 1* DS &G 2* DS &G 3* DS &G DS &G DS &G DS &G DS &G DS &G DS &G DS &G DS &G * 4 3 2 1 * 1* 2* 3*

3. %&at are t&e -arious stages for a $o! after it is su!0itted"


5ob Eueue" Acti'e job" and OB:C are the three sta(es after the job has been sub,itted. Acti'ation (rou/ is the boundary set for si,ilar /ro(ra,s. Acti'ation (rou/ is also a stora(e s/ace in ,e,ory. )& has a O<$D46 co,,and and calls a $ %&# /ro(ra, $ %&# /ro(ra, /erfor,s a read o/eration and the /ointer is now in the second /ro(ra, and now call the /ro(ra, 3 $ %&# /ro(ra, that also do a read o/eration which will read the second record Since the /ointer is in the second /osition and then return to 2nd /ro(ra, in the abo'e situation when the control transfer fro, 3rd record since the 2 rd record is already read in /ro(ra, 3. 4ut we need to need the 2nd record accordin( to the lo(ic but this is not /ossible in any O ! /ro(ra,s. 4ut in $ %&# there is a solution for this /roble, by (i'in( a co,,on acti'ation (rou/ for 1st and 2nd /ro(ra, and ha'e a se/arate acti'ation (rou/ for the 3 rd /ro(ra, while creatin( the /ro(ra, itself and this will a'oid the entire /roble, we faced before. =n so,e situation we want to share between 2 /ro(ra, then we can (i'e the acti'ation (rou/ in K<ob le'el in which the chan(es in one /ro(ra, will be affected in another /ro(ra,. >y1es of acti-ation grou1 le-els@ *8e'@ =n this case e'ery ti,e you call the /ro(ra, an new acti'ation (rou/ will be created which this case will not be used ,ostly. *caller@ =f we don@t 9now the ty/e of the /ro(ra, that is callin( then we can s/ecify Kcaller where the acti'ation (rou/ will be the sa,e of the /ro(ra, that is callin(. 8a0ed acti-ation grou1@ We can (i'e our own na,ed for different acti'ation (rou/.

4. %&at is an acti-ation grou1"

a(e 166 of 250

As400 Stuff

1. %&at are t&e state0ents t&at are affected !y acti-ation grou1"


O<$D46 O 7D46 O 7C$G6 S:$)!:):& D&:O<$

1. /o' to see source of co1y!ooEs include in a 1rogra0 '&ile co01iling or de!ugging"


While co,/ilin( the /ro(ra, (i'e Klist instead of Ksource which will e0/and all the co/yboo9s.

2. E21lain Eey'ord in =#E"


O'erlay $ena,e refi0 O/tions )onst

1. /o' you can sc&edule a $o! to run 1eriodically"


We ha'e to create a job scheduler for runnin( a job /eriodically. +ere we can ,a9e a job to run once or /eriodically at a (i'en date and ti,e. We can create a job scheduler by usin( ADD5O4S)D# co,,and. We can list all the job scheduler runnin( by usin( the co,,and W$35O4S)D# co,,and and we can delete a job scheduler by usin( $!<5O4S)D# or we can reschedule the job by usin( )+%5O4S)D#.

2. /o' you can i01ort and e21ort a data ty1e !et'een 2 1rogra0s"
=f you are usin( an e0/ort state,ent when declarin( a 'ariable then the data ty/e can be i,/orted in any ,odules that is bind either by 'alue or by reference. So in this case we can /ass 'alues in between ,odules instead of usin( &=S: and K#7:$G.

3. 8a-igation !et'een t'o screens


S3A7DASA!S8:A4&#S #P21 KKKKKKKKKKKKKKK 4e(innin( of data KKKKKKKKKKKKKKKKKKKKKKKKKKKKK 0001.00 6#PDS 6 0002.00 ) 0003.00 ) K=703 )6 # MAADD 1 KO66 WO$3S:7 S)$1 20

DOW#C

a(e 167 of 250

As400 Stuff
0004.00 ) 000*.00 ) 000-.00 ) 03 000..00 ) 0001.00 ) 0002.00 ) 0010.00 ) 0011.00 ) 0012.00 ) 0013.00 ) 0014.00 ) 03 001*.00 ) 001-.00 ) 001..00 ) 0011.00 ) 0012.00 ) 0020.00 ) 03 0021.00 ) 0022.00 ) S)$1 S)$1 DOW#C #P6!: &#A<# =6 MAADD &#A<# #7D=6 #7DDO DOW#C #P6!: &#A<# =6 MAADD &#A<# #7D=6 #7DDO &#A<# #7DDO S#:O7 &$ K=70.LKO7 1 S)$1 2 K=701LKO7 2 S)$1 1

DS 61

DS 62

KKKKKKKKKKKKKKKKKK #nd of data KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK =t is a 1Abit fla( where 'alue will be either 0 or 1 AS8400 /ro'ider 22 indicators for the business user. 1A24 A[assi(ned functions 9eys 2*A22 A[our own /ur/ose

4.

efine indicator K *(GE9"

1.

efine =>E+ : #E9GE: (: o'"


=:#$A[ :ransfer the control before do loo/.

a(e 168 of 250

As400 Stuff
&#A<#A[ :ransfer the control after do loo/. DOB )hec9s after enterin( the loo/" it is /erfor,ed at least once. DOW )hec9s before enterin( into the loo/.

2. E21lain 9ssu0e and (-erlay"


9ssu0e :y/e G >Ges? to select the ASSB!# 9eyword. =t causes the AS8400 syste, to assu,e that this record a//ears on the dis/lay when the file is o/ened. Bse this 9eyword to recei'e data that a /re'ious /ro(ra, has left on the dis/lay. (-erlay :y/e G >Ges? to allows the o'erlayin( of fields on the record without erasin( the entire dis/lay. 7oteH =f you ty/e anythin( other than G or blan9" your entry will be i(nored. Gou ,ust s/ecify the O<#$&AG 9eyword to select the other 9eywords on this dis/lay" with the e0ce/tion of B:O<$.

3. %&y e2ternaliBe"

Why would you want to do this? erha/s we can best answer that Euestion by /osin( one of our own. Su//ose that durin( discussions with your users" it beco,es a//arent to you that the business needs ha'e chan(ed. After ha'in( studied the new reEuire,ents for a while" you realiFe that you need to redesi(n the database to acco,,odate these chan(es. Would youH Z !odify your database and then locate all rele'ant =8O o/erations and ,odify the, as reEuired. Z Decide that doin( the ri(ht thin( is just too ,uch wor9" and just Nhac9N the database one ,ore ti,e. #0ternaliFin( the =8O o/erations of databases /ro'ides one way of hel/in( to ensure that your a//lications can ada/t Euic9ly and >relati'ely? /ainlessly to chan(in( business needs. =nstead of codin( a $#AD" )+A=7" or whate'er at each /oint in the /ro(ra, where database access is reEuired" you in'o9e a routine to /erfor, the =8O for you.
4. %&at is t&e disad-antage of using Galidity .&ecE Eey'ord" /o' to o-erco0e t&ese disad-antages" =f in'alid 'alues are entered" a(e 169 of 250

As400 Stuff :he o/tion filed is dis/layed in re'erse i,a(e. Syste, defined ,essa(e is dis/layed which ,ay not be user friendly. 3eyboard is loc9ed" we ha'e to reset it. :o o'erco,e abo'e disad'anta(e 'alidations is done within /ro(ra, and user friendly8defined ,essa(e is dis/layed.

1. .&ain@
)hain is a co,bination of S#:&& and $#AD#
#$

%&ic& of t&e follo'ing o1erations does 8(> Bero t&e field 7# 9 defined as 4,0"
) ) ) ) ) ) ) ) !O<# KM#$OS 6&DA MAADD KM#$OS 6&DA MAADD 0 6&DA !O<# KA&&;0; 6&DA SB4 6&DA 6&DA !O<# ;0000; 6&DA )&#A$ 6&DA !O<# K4&A73S 6&DA

:he last instruction does 7O: Fero the field 6&DA. %$

/o' can you c&ecE for a records e2istence 'it&out causing and =:( C./9=8:+E9 D" %it& t&e &el1 of 7ile =nfor0ation ata 6tructure, 'e can c&ecE e2istence of records in a 1&ysical file. >&e code is descri!ed !elo'@
=n 6ile descri/tion continuation line >= 63? 3=76DS $)DS =$)DS DS = K$#)O$D _$)DS with the abo'e code we can chec9 the e0istence of records in a file without causin( =8O o/eration.

&$ %&at is t&e difference !et'een < 9>E and t&e syste0 date" BDA:# su//orts twoAdi(it year. :he for,at is K!DG >!!DDGG?. KDA:# >syste, date? su//orts four di(it year. :he for,at is K!DGG >!!DDGGGG?. '$ Describe the difference between the DOWxx and DOUxx operations? DOW00 H =f the condition beco,es true" then only the (rou/ of instructions allowed e0ecutin(. DOB00 H =rres/ecti'e of condition" it will e0ecute at least one ti,e.

a(e 170 of 250

As400 Stuff
($ Define the purpose of the ITER operation? =f you s/ecify the =:#$" the (rou/s of state,ents are allowed to e0ecute re/eatedly. )$ List the steps/commands necessary to accomp ish the fo owin!" a. )o/y data fro, the file O$D+D$ into file O$D+=S: b. :he file O$D+=S: ,ay or ,ay not e0ist c. =f the file O$D+D$ does e0ist" it ,ay or ,ay not contain data d. :he file O$D+=S: ,ay or ,ay not contain data" if the file does contain data the old data should be erased )o,,andsH a. ) G6 6=&#>O$D+D$? :O6=&#>O$D+=S:? b. ) G6 6=&# >O$D+D$? :O6=&# >O$D+=S:? )$:6=&# >KG#S? c. ) G6 6=&# >O$D+D$? :O6=&# >O$D+=S:? KADD d. ) G6 6=&# >O$D+D$? :O6=&# >O$D+=S:? K$# &A)#

8. %&at is t&e 1ur1ose of t&e follo'ing" 7(+ / +1 =7 E 3 =63 (+ / +7 3+E89*E(+ / +71


=n order to rena,e the record for,at of a data base file in a /ro(ra," we can use the abo'e ste/s. ur/ose of rena,in( isH =f the record for,at na,e is si,ilar in two files and if both are used in a sa,e /ro(ra," the /ro(ra, will not co,/ile. +ence we ha'e to rena,e either of the file.

9. %&at is t&e 1ur1ose of t&e follo'ing .:.()? ;+),6+.,(+ E++


Durin( the co,/ilation the source code of O$D#$$ co/y boo9 is co/ied into the e0istin( /ro(ra,. Whereas 8)O G is co,/iler directi'e state,ent.

10.%&at is t&e 1ur1ose of t&e follo'ing" 9 .6+#(. C71+(% 71.(#D


Bsin( this record le'el 9eyword" you can s/ecify cursor location on an out/ut o/eration to the record for,at you are definin(. :he /ro(ra, sends out/ut after settin( the cursor location.

**) What is the difference between SFLCLR and SFLINZ?


S6&)&$H =t clears the subfile. S6&=7MH 6irst it clears the subfile and initialiFin( the nu,eric 'ariables with Feros and al/hanu,eric 'ariables with characters.

*A) Define the purpose/use for SFLRNA?


Bsin( this" we can ,a9e s/ecified subfile record for,at inacti'e.

*B) How can ou detect and hand!e a record !oc" situation?


=f you try to read the loc9ed record" we can (et syste, defined ,essa(e i. e. " the

a(e 171 of 250

As400 Stuff
/ro(ra, will ended abnor,ally. With the hel/ of 6ile =nfor,ation Data Structure we can handle record loc9 situation. %enerally it will ha//en" when the sa,e file of ty/e N BN used in different /ro(ra,s.

*8) How can ou detect o#erf!ow for a print pro$ra% that prints %u!tip!e !ines per c c!e?
Gou s/ecify the indicators OA throu(h O% and O< in 33 A 34 colu,ns in a /rinter file. :his indicator auto,atically set on whene'er o'erflow occurs on a ty/e of /a(e.

*') How wou!d ou desi$n the process for a ni$ht! & hi$h #o!u%e chec" producin$ process that needs to se!ect on! records that are f!a$$ed to be processed?
With the hel/ of O 7C$G6 )l/ co,,and" we can select the records fro, the data base file. :he /rocess in'ol'es followin( ste/sH Ste/sH 1. O<$D46 with S+A$# >KG#S? 2. O 7C$G6 3. )A&& the /ro(ra, 4. D&:O<$ *. )&O6

16./o' 'ould you $oin 3 se1arate fields, a first na0e, 0iddle initial and last na0e toget&er as 1 field 'it& 1ro1er s1acing" ?ou can descri!e in eit&er +), and:or +), =#E C=ntegrated #anguage En-iron0entD
!O<# ;Dr. ; 67A!# 3 !O<# ;5O+7; !7A!# 4 !O<# ;WA:SO7; &7A!# 67A!# )A: !7A!#H 1 <A$1 1 <A$1 )A: &7A!#H1 <A$2 1* DS &G <A$2 !O<# KO7 K=7&$

17. %&en ),*9 calls ),*4 for t&e first ti0e ),*4 e2ecutes t&e *=8Q6+. ),*4 uses t&e +E>+8 o1eration to return to ),*9. %&en ),*9 call ),*4 t&e second ti0e is t&e *=8Q6+ e2ecuted"
=f you s/ecify $#:$7 in called /ro(ra," the K=7MS$ will not e0ecute a(ain.

18.6&o' 2 'ays to con-ert a date fro0 ??** o1eration not acce1ta!leD

to **

?? C*<#>

1? )<:DA: DA:#>? $:7<A$> ? 6$O!6!:> ? :O6!:> ? Source code is reEuired to con'ert fro, one date for,at to another date for,at. :he source code in )& is (i'en belowH

a(e 172 of 250

As400 Stuff
%! D)& <A$>D<A$1? &#7%:+>-? :G #>K)+A$? <A&B#>;GG!!DD;? D)& <A$>D$)<D? &#7%:+>-? :G #>K)+A$? D)& <A$>D<A$2? &#7%:+>4? :G #>K)+A$? D)& <A$>D<A$3? &#7%:+>2? :G #>K)+A$? )+%<A$ <A$>D<A$2? <A&B#>OSS:>D<A$1 3 4?? )+%<A$ <A$>D<A$3? <A&B#>OSS:>D<A$1 1 2?? )+%<A$ <A$>D$)<D? <A&B#>D<A$2 K)A: D<A$3? S7D!S% !S%>D$)<D? :OBS$>KBS$ $6? #7D %! 12. Deter,ine the 'alue of the result field a. )ost L `110. 00 b. :a0 L 20O c. !ar9B/L 0*O d. Sale L 10O ) #'al :otal)ost L >>)ost K !ar9B/? K :a0?? A Sale L 1. 0`

A9) Define the purpose of Factor ' the (peration Code and )IN'* in fo!!owin$ code HI L( +, C )-.D /est0D1 %%ddDate '*
=f the factor 1 'alue ,atches with factor2 'alue" the indicator s/ecified in #C co,es KO7.

21. escri!e t&e function of 6E>## o1eration in +), language"


:he S#:&& o/eration /ositions a file at the ne0t record with a 9ey or relati'e record nu,ber that is (reater than or eEual to 9ey or relati'e record nu,ber s/ecified in factor1.

22. escri!e t&e function of 6E>,> o1eration in +), language"


:he S#:%: o/eration /ositions a file at the ne0t record with a 9ey or relati'e record nu,ber that is (reater than 9ey or relati'e record nu,ber s/ecified in factor 1. 23. What is the /ur/ose of &e'el )hec9 /ara,eter in a hysical file? S/ecifies whether the le'el identifiers of the record for,ats in the /hysical file are chec9ed when the file is o/ened by the /ro(ra,.

A8) Define a 2ob ,ueue?


5ob Eueues are Eueues of batch jobs waitin( to be /rocessed.

a(e 173 of 250

As400 Stuff

A') Define an (utput ,ueue?


Out/ut Eueues are Eueues of jobs waitin( to be /rinted.

AC) What is the function of C3-S3LF co%%and?


=t co/ies the s/ooled file to the data base file.

A() What is the function of C3-F co%%and?


:o co/y the data fro, the one file to another.

AD) What is the function of CR/D43(52 co%%and?


:o create the re/lica fro, the ori(inal object.

AE) Define Subs ste%?


Subsyste, is nothin( but it /ro'ides s/ecialiFed en'iron,ent to co,/lete the e0ecution of jobs.

B9) What are different t pes of Subste%s?


C4A:)+" C=7:#$" CS &" C)!7" C):&" C4AS#.

B*) Define a 5atch 2ob?


K K K K K K A user reEuests the job. :he job is created >job na,e is assi(ned" job attributes are allocated? :he job is /laced on a job Eueue :he sub syste, C4A:)+ ta9es the job fro, job Eueue and starts it. Out/ut (enerated by the batch job is /laced on an out/ut Eueue. :he s/ool sub syste, /rints the out/ut on the out/ut Eueue.

BA) Describe about ,uer /677?


Cuery8400 is a licensed /ro(ra, that uses a Euery to analyFe and select the infor,ation contained in the data base files and create a Euery re/ort. A Euery re/ort can beH K dis/layed on a wor9station >screen? K /rinted K stored in another database file.

BB) What is the CL3 co%%and to access a ,uer /677?


W$3C$G

B8) 3urpose of (#errides?


:he basic /ur/ose of O'errides is to te,/orarily chan(e the attributes of a file. So you don;t ha'e to create /er,anent files for e'ery co,bination of attributes your a//lication ,i(ht need. O'errides (i'es you the fle0ibility to use e0istin( ,odel files and dyna,ically chan(e their attributes.

B') Define Data Structure?


Data structures are s/ecified in the =n/ut s/ecifications of an $ %8400 /ro(ra, to define an area in stora(e and layouts of related sub fields.

a(e 174 of 250

As400 Stuff

BC) What is the purpose of Data structure?


K K K K K Di'ide a field in to sub fields )han(e the for,at of a field %rou/ nonAconti(uous data in a conti(uous for,at Define an area of stora(e in ,ore than one for,at Define !ulti/le occurrences of data structures.

B() List and e8p!ain the different t pe of data structures?


K Data area data structure when the data area is defined in an $ %8400 /ro(ra, as a data area data structure" its data is i,/licitly retrie'ed for /rocessin( and written bac9 at the end of the /ro(ra,. =n the data area data structure" letter NBN ,ust be entered to define the data structure as a data area data structure. K 6ile infor,ation data structure a file infor,ation data structure /ro'ides e0ce/tion8error infor,ation that ,ay be occurred when /rocessin( a file durin( /ro(ra, e0ecution. :his ty/e of data structure contains /re defined sub fields that identify K :he na,e of the file for which the error occurred K :he record /rocessed when the error occurred K :he o/eration bein( /rocessed when the error occurred K :he status code nu,ber K :he $ %8400 routine in which the error occurred. #0ce/tion errors ,ay be controlled by testin( for an error code in the KS:A:BS field which is included in a file infor,ation data structure. S/ecifically" 9eywords includin( K6=&#" K$#)O$D" KO )OD#" KS:A:BS" K$OB:=7# /ro'ide the /re'iously na,ed infor,ation. ro(ra, status data structure ro(ra, status data structure howe'er identity e0ce/tion8errors that are (enerated in the /ro(ra, by $ %8400 o/erations and not by a file. 7ote that any code (reater than 00022 is fla((ed as an e0ce/tion8error. 6our 9eywords A KS:A:BS" K$OB:=7#" K $O%$A!" K A$!S are su//orted by a /ro(ra, status data structure.

BD) What is the purpose of D-NSL/ "e word?


:his is a file le'el 9eyword used in a lo(ical file. =f you s/ecify this in a file le'el" the syste, doesn;t /erfor, record selection until the /ro(ra, reads file. :hen on the Select8O,it criteria" it selects the records fro, the s/ecified file.

BE) What is the difference between access path and D na%ic se!ect?
Dyna,ic select occurs whene'er the /ro(ra, reads file. 4ut access /ath occurs before the file is read >but not necessarily?. 4ecause access /ath ,aintenance /erfor,ed on the file.

89) Wh wou!d ou prefer (3N,R-F than !o$ica! fi!e?


:he ,ain difference isH &o(ical file creates /er,anent object on the syste,. O 7C$G6 creates te,/orary access /ath.

a(e 175 of 250

As400 Stuff

8*) What is the difference between 3ac"ed deci%a! and Zoned deci%a!?
ac9ed deci,alH One di(it occu/ies 1 byte. Moned deci,alH One di(it occu/ies 2 bytes.

8A) What is defau!t data t pe 0if ou define deci%a!s 9791 in 3h sica! fi!e?
ac9ed deci,al

8B) What is defau!t data t pe for the fie!ds0sub fie!ds1 defined in data structures in R3:?
Moned deci,al

88) When do ou e8p!icit! open fi!es and c!ose fi!es in an R3: pro$ra%?
=f you s/ecify the letter ; B ; at colu,n .3A.4" you need to be o/en and close files e0/licitly in a $ % /ro(ra,.

8') What is Spoo! fi!e& wh is it re;uired?


A file that holds out/ut data to be /rocessed" such as infor,ation waitin( to be /rinted.

8C) What is 2ob& What are the attributes of a 2ob?


A 5ob is a basic unit of wor9 on AS8400. :he attributes areH 5ob 7u,ber BniEue syste, (enerated seEuential nu,ber 5ob 7a,e Any user defined na,e >!a0 10 char? Bser 7a,e Who initiated the job.

8() What is Sub<S ste%?


SubASyste,s are s/ecific user defined /artitions of the ) B where 'arious jobs ,ay be e0ecuted. One subsyste, can ha'e ,ore than one acti'e job at a ti,e.

8D) What is a De#ice fi!e?


A de'ice file contains the descri/tion of how data is to be /resented to a /ro(ra, fro, a de'ice or 'ice 'ersa. De'ice file can be rinter" Dis9" :a/e and $e,ote syste,.

8E) How can a data area be !oc"ed after bein$ updated?


Bsin( OB: K&O)3

'9) What are the t pes of ob=ect authorities?


KBS#" K)+A7%#" KADD" KD&:" K$#AD" KB D" KA&&" K#P)&BD#" KO45#P=S:" KO45!%:" KO45O $

'*) What is the use of (>R3R/F?


O'erride with rinter file >O<$ $:6? co,,and is used to o'erride certain /ara,eters of the /rinter files used in the /ro(ra, or to re/lace the /rinter file.

a(e 176 of 250

As400 Stuff

'A) What is Subfi!e?


Subfile is (rou/ of records of sa,e record for,at and can be read fro, or write to the dis/lay in a sin(le o/eration.

'B) What are a!! the contents of subfi!e?


Subfile $ecord 6or,at" Subfile )ontrol $ecord 6or,at" $elati'e $ecord 7u,ber" Subfile $ecord 7u,ber" Associated Subfile 3eywords.

'8) What is S6& A% and S6&S=M?


S6& A%H it is an attribute which s/ecifies the nu,ber of records that can be dis/layed in a screen. S6&S=MH it is an attribute which s/ecifies the nu,ber of records can be stored in subfile.

'') Can %ore than one subfi!e record be disp!a ed on one !ine?
Ges" by usin( S6&&=7 9eyword.

'C) How do ou specif the nu%ber of records to ro!! in a subfi!e?


Bse S6&$O&<A& 9eyword in DDS alon( with nu,ber" which s/ecifies the nu,ber of records to scroll at a ti,e.

'() How wi!! ou disp!a a particu!ar pa$e in subfi!e?


!o'e a 'alid relati'e record nu,ber >$$7? in the field s/ecified usin( S6&$)D74$ 9eyword in DDS.

'D) How to pic" up the chan$ed records e#er ti%e in a subfi!e after the first chan$e %ade?
Seton S6&7P:)+% 9eyword indicator and u/date the subfile record.

'E) What is the use of SFL+ND "e word?


4y s/ecifyin( this 9eyword" the 4otto,8!ore ,essa(e could be dis/layed at end of screen.

C9) How to to$$!e between sin$!e !ine and .u!ti < !ine disp!a of a particu!ar record in a subfi!e?
Bsin( S6&D$O 9eyword.

C*) +8p!ain the difference between definin$ Subfi!e and .essa$e<subfi!e?


Subfile record is defined by S6& 9eyword" where as !essa(e subfile is defined by S6&!S% 9eyword.

CA) What are the different t pes of #ariab!es a#ai!ab!e in CL?


D#)" )+A$" &%&

CB) How do ou pass para%eters in CL?


Bsin( A$! 9eyword.

a(e 177 of 250

As400 Stuff

C8) What is difference between CA/& /CA/& 5CA/?


)A: )oncatenate two 'ariables or constants into one continuous strin(. 4)A: :runcates all trailin( blan9s in the first character strin(" one blan9 is inserted" then the two character strin(s are concatenated. :)A: :runcates all trailin( blan9s in the first character strin(" the two character strin(s are concatenated.

C') What are the different t pes of %essa$es in CL?


=,,ediate ,essa(e" 4rea9 ,essa(e" ro(ra, ,essa(e" Bser ,essa(e

CC) How to trap errors in CL?


4y usin( !onitor !essa(e )o,,and >!O7!S%?

C() What is the %a8i%u% !en$th of a #ariab!e na%e in CL?


!a0i,u, 11 characters >includin( ;D;?

CD) What are the !i%itations of CL 0co%pare to R3:1 ?


Gou cannot use )& /ro(ra, to ADD or B DA:# records in database files. Bse rinter or =)6 files. Bse ro(ra, described files. Bse the conce/t of subfile >to dis/lay ,ore than one record?" but a sin(le out/ut ,essa(e subfile is a s/ecial ty/e of subfile that is su//orted well in )&. Bse subroutines. Gou cannot declare ,ore than one object >file? in a )& /ro(ra,.

CE) What is the use of Header Specification in R3:/677?


=t identifies by + in colu,n -" /ro'ides infor,ation about (eneratin( and runnin( /ro(ra,s.

(9) When wi!! D4.3 and D+54: opcodes be i$nored?


=f blan9 is s/ecified in /osition 1* of + s/ecs.

(*) Specif different indicators used in R3:?


O'erflow indicators $ecord =dentifyin( =ndicators 6ield =ndicators $esultin( =ndicators )ontrol &e'el =ndicators

(A) What are Contro! !e#e! indicators?


&1 to &2 used to identify certain fields on control fields and then used to condition which o/erations are to be /rocessed at detail or total calculation or out/ut ti,e.

a(e 178 of 250

As400 Stuff

(B) What is the use of + specification in R3:?


#0tension S/ecs describes all record address files" arrays and tables.

(8) What is the use of L specs in R3:?


&ine counter s/ecification can be used to describe /rinter file to indicate the len(th of the for, and nu,ber of lines /er /a(e.

(') In which specification the report !a out can be defined?


O S/ecification.

(C) How %an fi!es can be defined in F specs? *0 (() How %an printer fi!es can be defined in F specs? 1 (D) :i#e three %ain purposes of Fi!e specification?
:o define files" to describe the files" to assi(n the files to s/ecified de'ices.

(E) How do ou specif pa$e o#erf!ow indicator for printer fi!es in R3:?
S/ecify an indicator in /osition 33A34 of 6 s/ecification.

D9) What is a 3ri%ar Fi!e?


=t is used in $ % ro(ra, )ycle to auto,atically read records in a cycle.

D*) Can an inde8ed fi!e be accessed in arri#a! se;uence in R3: pro$ra%? Ges. DA) What is a 3ro$ra% Described fi!e in R3:?
:he field na,e and len(th of the fields are defined within the $ % /ro(ra,.

DB) What is e8terna!! described fi!e?


All infor,ation about the fields is s/ecified in DDS and the $ % /ro(ra, can use the, within the /ro(ra,.

D8) Can ou specif a disp!a fi!e to be used in the fo!!owin$ %odes Input& (utput& or Co%bined %odes? Ges. D') What is %atch fie!d indicator?
!atchin( record indicator is seton when all the ,atchin( fields in the record of a secondary file ,atches with all the ,atchin( fields of a record in a /ri,ary file.

DC) What are a!! the co%pi!er directi#e state%ents?


8:=:&#" 8S A)#" 8#5#):" 8)O G

D() Durin$ e8ecution& an R3:/677 pro$ra% auto%atica!! fo!!ows a se;uence of operations for each record that is processed? /he bui!t<in pro$ra% c c!e inc!udes the fo!!owin$ !o$ica! steps?
1. readin( in/ut >$#AD?

a(e 179 of 250

As400 Stuff
2. /rocessin( calculations > $O)#SS? 3. writin( out/ut >W$=:#?

DD) What are the different (pcodes a#ai!ab!e in R3: for Database access?
$#AD" )+A=7" W$=:#" B DA:" D#&#:" S#:&&" S#:%:" $#AD#" $#AD " $#D #" O #7" )&OS#" 6O$)#" 7#P:" B7&)3. 302. +ow can database records be read without loc9 ? ut ;7; in /osition *3 of ) s/ecs.

DE) %&at does ./E.3 o1code do "


:he chec9 o/eration 'erifies that each character in the base strin( >factor 2? is a,on( the character indicated in the co,/arator strin(>factor 1?.

E9) How do hand!e fi!e e8ception/error


K=76DS "K SS$ definin( it in 6 s/ec

E*) What is (3N,R-F& .(N.S: co%%ands


=t is Dyna,ically creation of access /ath" and it can ha'e resultant fields i.e. if the e0/ression is A L 4 U ) then 4 and ) are fro, the file while A is defined in O 7C$G6. We can di'ert the out/ut of co,,and to an OB:6=&#. )o,,and associated with O 7C$G6 is ) G6$!C$G6 to sa'e the out/ut /er,anently =t is a )& co,,and to ,onitor and error8e0ce/tion ,essa(e so that in case of an error a du,/ is a'oided and the control is in /ro(ra,. =t is also used to ,onitor user ,essa(e.

92.%&at are t&e uses of 79.>(+1, 79.>(+2 and +E6<#> field for t&e +),
o1eration code )9+*" =t is add 'alue of 6A):O$1 to 6A):O$2 or co,/are the 'alue of 6A):O$ 2 with 6A):O$1.

93./o' 'ill you find a string using ) *"


4y usin( 67DS:$ D!.

94./o' do you read c&anged records !acE'ard in su!file"


7O: OSS=4&#.

95.%&at is t&e difference !et'een nor0al <) using 7< 1rogra0" 133. %&at is t&e synta2 for )#=6>" K#7:$G &=S: A$! 134. %&ic& are t&e 6tring *ani1ulation (1codes"
>E6>8, 6.98, ./E.3, ./E.3+, 6<46> K .9>

>9 to )7 and u1dating

4oth are sa,e only difference is D6B allows you to add or chan(e selected fields

a(e 180 of 250

As400 Stuff

()b Proce$)res:
1. %&y 6u! 1rocedures are used"

Sub /rocedures can define their own local 'ariables. Sub /rocedures can acce/t /ara,eters. Sub /rocedures /ro'ide /ara,eter chec9in( Sub /rocedures can be used as a user defined function. Gou can call the sub /rocedure fro, outside the ,odule" if it is e0/orted. Sub /rocedures /ro'ide ,ulti/le entry /oints within the sa,e $ % ,odule.
1. .an you use a su! 1rocedure in a su! 1rocedure"

Ges
2. %&at are t&e s1ecifications used in a su! 1rocedure"

" D" ) only.


3. /o' 0any 'ays a su! 1rocedure can 1ass 1ara0eters"

Z 4y reference >default? Z 4y 'alue >9eyword <A&B# on the /ara,eter definition? Z 4y readAonly reference >9eyword )O7S: on the /ara,eter definition? 4. /o' do you in-oEe a stored 1rocedure" :o in'o9e a stored /rocedure we use the SC& )A&& state,ent. :his state,ent contains the na,e of the stored /rocedure and any ar(u,ents /assed to it. Ar(u,ents ,ay be constants" s/ecial re(isters" or host 'ariables. +ere is an e0a,/le how to call stored /rocedure and /ass two ar(u,entsH 8#0ec SEl )A&& ,ylib8/rocna,e >H A$:7B!" H A$:D#S? 8#ndA#0ec #asiest way to return a co,/letion status to the SC& /ro(ra, issuin( the )A&& state,ent is to code an e0tra =7OB: ty/e /ara,eter and set it /rior to
a(e 181 of 250

As400 Stuff

returnin( fro, the /rocedure. Another" ,ore co,/licated ,ethod of returnin( a co,/letion status is to send an esca/e ,essa(e to the callin( /ro(ra, >o/eratin( syste, /ro(ra, CSC)A&&? which in'o9es the /rocedure. 5. =s t&ere any cycle code generated for t&e su! 1rocedure" 7o. 7ot (enerated.
6. %&at are t&e =01ortant freLuently used co00ands in

=#E+), en-iron0ent" )o,,only Bsed )& )o,,ands 9ction .# co00and +esult

Bsin( Syste, !enus ,enu ,( =87( ,( .* +), ,( .* .+> ,( .* 222 )allin( /ro(ra, )o,/ilin( .9## .+>222*( .+>48 222 4indin( !odules .+>6+G),* <) ),* object Debu((in( 6>+ 4,
a(e 182 of 250

,( *9=8

Dis/lay ,ain

Dis/lay hel/ ,enu &ist co,,ands for $ % &ist co,,ands for creatin( &ist co,,ands for ;000; /ro(ra,Ana,e runs a )reates 000 !odule )reates 4ound 000 ro(ra, )reates a /ro(ra, fro, =&#

.+>),*

)reates a ser'ice /ro(ra, B/dates a bound /ro(ra, Starts =&# source debu((er

As400 Stuff

E8 )reatin( 6iles

4,

#nds =&# source debu((er )reates rint 6ile )reates hysical 6ile )reates Source hysical 6ile )reates &o(ical 6ile

.+>)+>7 .+>)7 .+>6+.)7 .+>#7

7. %&at are .( E:400 : Gisual 9ge""

AD:S )S >for Windows c? is a wor9station /roduct that includes two ser'er access /ro(ra,sH K )oo/erati'e De'elo/,ent #n'iron,ent8400 >)OD#8400? K <isual A(e for $ %c )OD#8400 contains features to hel/ edit" co,/ile" and debu(H $ %" =&# $ %" )O4O&" =&# )O4O&" )ontrol &an(ua(e >)&?" =&# )" and =&# )& host source /ro(ra,sX desi(n dis/lay" /rinter" and database host filesX and ,ana(e the co,/onents that ,a9e u/ your a//lication. :his enhances /ro(ra, de'elo/,ent and ,o'es the /ro(ra, de'elo/,ent wor9load off the host. :he a//lication" when built" runs on an AS8400. 6or $ % and =&# $ % a//lication de'elo/,ent and ,aintenance" )OD#8400 /ro'idesH K &an(ua(e sensiti'e editin(] includes to9en hi(hli(htin(" for,at lines" a full suite of /ro,/ts" and online hel/. K =ncre,ental synta0 chec9in(] /ro'ides i,,ediate error feedbac9 as each line of source is entered K ro(ra, 'erification] /erfor,s" at the wor9station" the full ran(e of synta0 and se,antic chec9in( that the co,/iler does" without (eneratin( object code K ro(ra, con'ersion] /erfor,s" at the wor9station" an O ! to =&# $ % con'ersion K A windowed en'iron,ent for sub,ittin( host co,/iles and binds K SourceAle'el debu((in(
a(e 183 of 250

As400 Stuff

K A DDS desi(n utility]allows you to easily chan(e screens" re/orts" and database files K Access to A//lication Dictionary Ser'ices. <isual A(e for $ % offers a 'isual de'elo/,ent en'iron,ent on the wor9station /latfor, for $ % a//lication de'elo/ers to de'elo/" ,aintain" and docu,ent client8ser'er a//lications. A//lications can be edited" co,/iled" and debu((ed on your wor9station. :he a//lications" when built" are started on a wor9station and can access AS8400 host data and other AS8400 objects. =ts inte(rated co,/onents allow a//lication de'elo/ers to /reser'e their current s9ills and easily de'elo/ AS8400 $ % a//lications with (ra/hical user interfaces.
8. %&at are *ain )rocedure and a su! 1rocedure"

An =&# $ % ,odule consists of a ,ain /rocedure and Fero or ,ore sub /rocedures. >=f there are sub /rocedures" the ,ain /rocedure is o/tional.? 9 0ain 1rocedure is a /rocedure that can be s/ecified as the /ro(ra, entry /rocedure >and so recei'e control when an =&# /ro(ra, is first called?. :he ,ain /rocedure is defined in the 0ain source section" which is the set of +" 6" D" =" )" and O s/ecifications that be(in a ,odule. =n <3$1" all =&# $ % ,odules had a ,ain /rocedure and no other /rocedures. A su! 1rocedure is a /rocedure that is s/ecified after the ,ain source section. A sub /rocedure differs fro, a ,ain /rocedure /ri,arily in thatH K 7a,es that are defined within sub /rocedure are not accessible outside the sub /rocedure. K 7o cycle code is (enerated for the sub /rocedure. K :he call interface ,ust be /rototy/ed. K )alls to sub /rocedures ,ust be bound /rocedure calls. K Only " D" and ) s/ecifications can be used. Sub /rocedures can /ro'ide inde/endence fro, other /rocedures because the data ite,s are local. &ocal data ite,s are nor,ally stored in auto,atic stora(e" which ,eans that the 'alue of a local 'ariable is not /reser'ed between calls to the /rocedure.

a(e 184 of 250

As400 Stuff

Sub /rocedures offer another feature. Gou can /ass /ara,eters to a sub /rocedure by 'alue" and you can call a sub /rocedure in an e0/ression to return a 'alue.

6u! 7iles 1. E21lain a!out su! files in 96:400" A subfile is a (rou/ of records $#AD fro, or W$=::#7 to a dis/lay de'ice file in one sin(le o/eration. =t is a dis/lay file facility =t is a (rou/ of records that can be stored in the ,ain ,e,ory. :he /ro(ra, can store a (rou/ of records in the subfile one by one in a seEuence. #( =8, 6<47=#E6@ &oad all >SiFe [ a(e? &oad on de,and >SiFe [ a(e? &oad on de,and >SiFe L a(e? #oad all C6iBe R)ageD All the records fro, the database file will be loaded in to the subfile in one shot. :he subfile siFe should be (reater than the /a(e siFe at least by one. >S6&S=M L*" S6& A%L4?. :he subfile siFe will dyna,ically (row when the subfile siFe ,entioned is less than the nu,ber of records in the database file. A%#B and A%#DOW7 are ta9en care of by the syste,. :he total subfile siFe 2222 records. #oad on de0and C6iBe R )ageD :he nu,ber of records as ,entioned in S6& A% will be loaded initially. :hen the re,ainin( records can be loaded by /ressin( )9,E (%8" which is ta9en care of by the /ro(ra,,er. Sa,e ti,e )9,E<) is ta9en care of by the syste,. :he subfile siFe should be (reater than the /a(e siFe at least by one. >S6&S=M L*" S6& A%L4?. :he subfile siFe will dyna,ically (row when the subfile siFe ,entioned is less than the nu,ber of records in the database file. All the records loaded will e0ist in the subfile. :he total subfile siFe 2222 records.

a(e 185 of 250

As400 Stuff #oad on de0and C6iBe P )ageD :he nu,ber of records that will be loaded into the subfile ,ust always be eEual to the 'alue ,entioned in for S6&S=M and S6& A%. #'ery ti,e the subfile should be cleared before /a(in( u/ or /a(in( down. )9,E<) and )9,E (%8 are ta9en care of the /ro(ra,,er. :he nu,ber of records that can be in the subfile at any instance will be eEual to S6&S=M and S6& A% 'alues. 6u!file 1oints@ $ecord for,atsH One dis/lay A1024 records for,ats One dis/lay files I*12 subfiles $ecord for,ats are 1. Subfile record for,at >S6&? 2. Subfile control record for,at >S6&):&? Subfile record for,at >S6&? :his record for,at will ha'e the ,ulti/le record definitions ADefinin( fields. ADefinin( database fields. Subfile )ontrol record for,at >S6&):&? :his record for,at will control the subfile record for,at. ADefinin( te0ts ADefinin( control fields. Subfile SiFe >S6&S=M? :his 9eyword can be used to s/ecify the ,a0i,u, nu,ber of records that can be in the subfile >buffer? Default A[2 !a0i,u, A[2222 Subfile a(e >S6& A%? :his 9eyword can be used to s/ecify the ,a0i,u, nu,ber of records that can be in one subfile /a(e. :hat is the ,a0i,u, nu,ber of records that the syste, will dis/lay in the screen at a ti,e. ADefault A[1 a(e 186 of 250

As400 Stuff A!a0i,u,A[ de/ends u/on the dis/lay record siFe. =f the subfile siFe is at least one (reater than the subfile /a(e then the subfile siFe will (row dyna,ically u/ to 2222. ,eneral Eey'ords S6&DS S6&)&$ S6&#7D Define %eneral 3eywords Subfile control record . . . . . . . . . H S#7W&:1 :y/e choices" /ress #nter. 3eyword S#7W7D1 7a,e 7a,e 7a,e =ndicators8U ? ? 25 26 A[ subfile dis/lay A[ subfile clear A[ subfile end S6&DS ):& A[ subfile dis/lay control

$elated subfile record . . . . . . . S6&):&

Subfile cursor relati'e record . . . S6&)S$$$7 Subfile ,ode . . . . . . . . . . . . S6&!OD# GLGes Dis/lay subfile records . . . . . . S6&DS Dis/lay control record . . . . . . . S6&DS ):& =nitialiFe subfile fields . . . . . S6&=7M Delete subfile area . . . . . . . . S6&D&: )lear subfile records . . . . . . . S6&)&$ =ndicate ,ore records . . . . . . . S6&#7D S6&#7D /ara,eter . . . . . . . . S6&#7D /ara,eter . . . . . . . . K!O$# KS)$4A$ ? 28 30

K!O$#...

$ecord not acti'e . . . . . . . . . S6&$7A !ore... 63L#0it 612L)ancel Subfile Dis/lay >S6&DS ? a(e 187 of 250

As400 Stuff :his 9eyword is used to insert the syste, that the subfile records for,at has to be dis/layed. :he subfile record for,at without any record in it cannot be dis/layed. Subfile Dis/lay control >S6&DS ):&? :his 9eyword is used to instruct the syste, that the subfile control record for,at has to be dis/layed. 0002.00 ) 730 Subfile )lear >S6&)&$? :his 9eyword is used to clear the records in the subfile records for,at. An indicator can control this 9eyword. 000*.00 ) 000-.00 ) 000..00 ) Subfile #nd >S6&#7D? :his 9eyword is used to (et the dis/lay of RU@ si(n or a te0t R,ore@ or Rbotto,@ in the botto, of the subfile. RU or R,ore@ indicates the e0istence of ,ore records in the subfile which can be dis/layed by /ressin( )9,E (%8 9ey. S4otto,@ indicates the end of the subfile. =nstead of #nter 3ey A +el/ :y/e a )6 or )A 9ey nu,ber to s/ecify that the o/erator is to use the #nter 9ey as a $oll B/ 9ey. :he s/ecified )6 or )A 9ey acts as the #nter 9ey. *andatory Eey'ords for su!file ++8 S6& S6&):& S6&S=M S6& A% S6&DS C+elati-e record nu0!erD Ccontrol record le'el 9eyword? S#:O7 W$=:# S#:O66 S#7W&:1 21 21 S#:O7 2*2-

$$7 is the nu,eric 'alue >1 to 2222? associated with each subfile record for accessin( #ach record should ha'e a uniEue $$7 'alue :his 'alue has to be (i'in( by the /ro(ra,. :his has to be associated with the subfile record for,at in the 6 s/ec continuation line. a(e 188 of 250

As400 Stuff :his has to be declared in the /ro(ra, as nu,eric 'ariable of ,a0i,u, len(th 4 and deci,al /osition 0. 6 s/ec for,at in continuation line with S6=&# o/tion 0002.00 6S#7D#S6=&#)6 # 0003.00 6 WO$3S:7 S6=&# >S6&01H$$71 ?

Where $$71 A[ $$7 'ariable na,e S6&01A[ subfile record for,at na,e.

$ %&# O/codes #P6!: =f S6&DS and S6&DS ):& indicators are on" this o/code will send the two subfile record for,ats to the dis/lay de'ice and waits for the user@s res/onse. W$=:# I >S6&? :his o/code is used to add a record to the subfile record for,at $$7 'alue should be set with a nonAe0istin( 'alue before addin( the record in the subfile record for,at. W$=:# >S6&):&? :his 9eyword is used for clearin( D dis/lay the subfile 67# +() Csu!file dro1D :his control record le'el 9eyword is used to assi(n a )A >co,,and attention? or )6 >co,,and function? 9ey. :he /ro(ra, first dis/lays the subfile in truncated for,X subfile records are truncated to fit on one dis/lay line. When the user /resses the s/ecified 9ey" the /ro(ra, dis/lays the records in the folded for,. Or Subfile =nitially :runcated A +el/ :y/e a co,,and function >)6? or co,,and attention >)A? 9ey nu,ber to assi(n a )6 or )A 9ey to s/ecify if a subfile control record reEuirin( ,ore than one dis/lay line should be truncated to one line" or should be folded to dis/lay on two lines. When this 9eyword is s/ecified" the subfile is first dis/layed in truncated for,. :he o/erator /resses the s/ecified )6 or )A 9ey to switch fro, truncated for, to folded for, or fro, folded for, to truncated for,. a(e 189 of 250

As400 Stuff

67#7(#

Csu!file foldD

:his control record le'el 9eyword is used to assi(n a )A >co,,and attention? or )6 >co,,and function? 9ey. :he /ro(ra, first dis/lays the subfile in folded for,. When the user /resses the s/ecified 9ey" the /ro(ra, dis/lays the records a(ain in the truncated for,. Or Subfile =nitially 6olded A +el/ :y/e a co,,and function >)6? or co,,and attention >)A? 9ey nu,ber to assi(n a )6 or )A 9ey to s/ecify if a subfile control record reEuirin( ,ore than one dis/lay line should be truncated to one line" or should be folded to dis/lay on two lines. When this 9eyword is s/ecified" the subfile is first dis/layed in folded for,. :he o/erator /resses the s/ecified )6 or )A 9ey to switch fro, folded for, to truncated for, or fro, truncated for, to folded for,.

67#=8Q Csu!file initialiBeD :his control record le'el 9eyword is used to s/ecify that the /ro(ra, is to initialiFe all records in the subfile on the out/ut o/eration >read D u/dates? to the subfile control record for,at. :he fields in each subfile record are initialiFed to )+A$A[4&A73S 7B!#A[M#$OS 6&OA:A[7B&&S 67#8A>./, Csu!file ne2t c&angeD :his record le'el 9eyword is used on the subfile control record for,at to force the user to correct /ro(ra,Adetected 9eyin( error in the subfile records that ha'e been read by the /ro(ra,. =t does this by causin( the record to be chan(ed so that a (etAne0tAchan(ed o/eration ,ust read the record. Or $eturn $ecord A +el/ :y/e G >Ges? to instruct the syste, to return this subfile record to your /ro(ra, on a subseEuent %etA7e0tA)han(ed in/ut o/eration to the subfile. :his record is returned whether or not the o/erator chan(es it. 7oteH Gou ,ust ty/e G. =f you do not" the entry will not be used. dGou can s/ecify condition indicators for the S6&7P:)+% 9eyword.

a(e 190 of 250

As400 Stuff 67#+(#G9# Csu!file roll -alueD :his fieldAle'el 9eyword is used to s/ecify that the user can 9ey a 'alue into this field to tell the /ro(ra, how ,any records to A%#B or A%#DOW7 when the a//ro/riate /a(in( 9ey is /ressed. 67#+. 84+ Csu!file record nu0!erD :his field le'el 9eyword on the subfile control record for,at is used to s/ecify that the /a(e of the subfile to be dis/layed is the /a(e containin( the record whose relati'e record is in this field. =f you do not s/ecify this 9eyword" the /ro(ra, dis/lays the first /a(e of the subfile by default #0a,/le for load all S3A7DASA!O8SB46=&# 7#W#! KKKKKKKKKKKKKKK 4e(innin( of data KKKKKKKKKKKKKKKKKKK 0001.00 0002.00 0003.00 0004.00 000*.00 000-.00 000..00 0001.00 0002.00 $ #! 7#W #! 7O! #! 7A S#P3 A%#3 ADD$#SS* )=:G* 3 #! 7O! - 0 1*A 1A 3 0 1*A 10A :#P:>;#! &OG## 7B!4#$;? :#P:>;#! &OG## 7A!#;? :#P:>;#! &OG## S#P;? :#P:>;#! &OG## A%#;? :#P:>;ADD$#SS;? :#P:>;)=:G;? B7=CB#

KKKKKKKKKKKKKKKKKK #nd of data KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK DA:A 6=&# is1lay +e1ort

#! 7O! #! 7A

S#P3 A%#3 ADD$#SS*

)=:G*

a(e 191 of 250

As400 Stuff 000001 000002 000003 000004 00000* 0000000000. 000001 000002 000010 000011 000012 000013 101 3.S#7:+=&3B!A$ 102 $.S+GA!SB7DA$ 103 4.!O+A7 104 3.3B!A$ 10* A.A$B& 10- 4A&B 10. S#7:+=& 101 $A5 102 +#!A 110 <#& 111 $A!#S+ 122 SBD+A 123 3A7DASA!G ! ! ! ! ! ! ! ! ! ! ! ! ! 2* A::B$ 2. :$=)+G SA&#! :$=)+G SA&#! SA&#! 7A!A33A& SA&#! :$=)+G SA&#! )+#77A= SA&#! SA&#! A::B$ A::B$

2. :)OD# 2* SA&#! 2* SA&#! 2* SA&#! 3* SA&#! 22 :)ODW# 33 SA&#! -. SA&#! *- A::B$ 21 SA&#! 34 SA&#!

KKKKKK KKKKKKKK #nd of re/ort KKKKKKKK S3A7DASA!O8SB46=&# SB404 KKKKKKKKKKKKKKK 4e(innin( of data KKKKKKKKKKKKKKKKKKKKKKKKKKKK 0002.00 6S#7D#S6=&#)6 # 001*.00 ) 001-.00 ) 001-.01 ) 001-.02 ) 001-.03 ) 001..00 ) 03 0011.00 ) K=703 DOW#C #P6!: =6 )A&& #7D=6 &#A<# #7DDO a(e 192 of 250 WO$3S:7 KO66

!A=71 K=704LKO7 A7D #! )B$L;#! 7O!; ;S#&OADA&&3;

As400 Stuff 0012.00 ) S#:O7 &$

KKKKKKKKKKKKKKKKKK #nd of data KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK S3A7DASA!O8SB46=&# S#&OADA&&3 KKKKKKKKKKKKKKK 4e(innin( of data KKKKKKKKKKKKKKKKKKKKKKKKKKKKK 0001.00 67#W#! =6 # D=S3 WO$3S:7 S6=&#>S#7W7D1H$$71? MAADD S#:O7 W$=:# S#:O66 $#AD S#:O7 DOW W$=:# ADD $#AD &#A<# #7DDO DOW &#A<# W$=:# W$=:# #P6!: +#A:#$ 6OO:#$1 S#7W&:1 K=703LKO66 K=730LKO66 S#7W7D1 1 #! 7#W $$71 30 #! 7#W S#7W&:1 21 30 2*21 $$71 40 21

0002.00 6S#7D#S6=&#)6 # 0003.00 6 0004.00 ) 000*.00 ) 000-.00 ) 000..00 ) 0001.00 ) 0002.00 ) 730 0010.00 ) 0011.00 ) 0012.00 ) 0013.00 ) 0014.00 ) 30 001*.00 ) 001-.00 ) 001-.01 ) 03 001-.02 )K 001-.03 )K 001-.04 )

a(e 193 of 250

As400 Stuff 0020.00 ) 0021.00 ) #7DDO S#:O7 &$

KKKKKKKKKKKKKKKKKK #nd of data KKKKKKKKKKKKKKKKKKKKKKKKKKKKK 'indo' 0ain1 ta9e 1 Select $ecord 3eywords $ecord . . . H !A=71 :y/e choices" /ress #nter. GLGes %eneral 9eywords . . . . . . . . ? =ndicator 9eywords . . . . . . . ? A//lication hel/ . . . . . . . .

Select %eneral 3eywords $ecord . . . H !A=71 :y/e choices" /ress #nter. =f this record is not on dis/lay" write it to the dis/lay before issuin( read . . . . . . . =7M$)D 3ee/ record on dis/lay . . . . . . . . . . . . . . 3## Assu,e record is on dis/lay . . . . . . . . . . . ASSB!# Allow rollin( of lines . . . . . . . . . . . . . . A&W$O& $etain )&#A$ +#& +O!# and $O&& 9eys . . . . . . . $#:3#G $etain co,,and function >)6nn and )Ann? 9eys . . . $#:)!D3#G )han(e in/ut defaults . . . . . . . . . . . . . . )+%=7 D6: Select /ara,eters . . . . . . . . . . . . . . . a(e 194 of 250 ? 3eyword GLGes

As400 Stuff !enuA4ar dis/lay . . . . . . . . . . . . . . . . . !7B4A$DS Select /ara,eters . . . . . . . . . . . . . . . #ntry field attribute . . . . . . . . . . . . . . #7:6&DA:$ Select /ara,eters . . . . . . . . . . . . . . . $eturn cursor location . . . . . . . . . . . . . . $:7)S$&O) Select /ara,eters . . . . . . . . . . . . . . . Define $eturn )ursor &ocation $ecord . . . H !A=71 3eyword nu,ber 1 of 1 G $oll U8A 64 for list :y/e /ara,eters" /ress #nter. 3eyword $eturn cursor location . . . . . . . . . . $:7)S$&O) ? :y/e indicator K$#)7A!# . . . . . . . . )ursor record . . . . . . . . . . . . . )ursor field . . . . . . . . . . . . . . )ursor /osition . . . . . . . . . . . . .703 .704 03 04 +E.6 E*).<+ ? GLGes GLGes 7a,e 7a,e 7a,e ?

>93E 12 98

74 %orE 'it& 7ields

$ecord . . . H !A=71 :y/e infor,ation" /ress #nter. a(e 195 of 250

As400 Stuff 7u,ber of fields to roll . . . . . . . . . . . . . . . . . . :y/e o/tions" chan(e 'alues" /ress #nter. 1LSelect 9eywords 4LDelete field O/tion Order 6ield .0 A%# 80 90 +E.6 E*).<+ ) ) S 4 ) 9 9 :y/e Bse &en(th $ow8)ol $ef )ondition O'erla/ 21 1* 014 / / 10 10 -

100 AAAAAAAAAA 110 63A[#P=: 120 #! 7O!

.- 21 003 3. 22 00* -"0 02 03- G !ore...

Add Add Add

+ !

+idden !essa(e ro(ra,AtoAsyste,

:A3# 12 6E8%#>1 6elect %indo' 3ey'ords Window record . . . . . . . . . . . . . H :y/e choices" /ress #nter. GLGes %eneral 9eywords . . . . . . . . ? Select record 9eywords . . . . . ? %eneral S6&):& 9eywords . . . . . ? Subfile dis/lay layout . . . . . ? a(e 196 of 250 S#7W&:1

As400 Stuff Subfile ,essa(es . . . . . . . . ? 6elect ,eneral 3ey'ords Window record . . . . . . . . . . . . . H S#7W&:1 :y/e choices" /ress #nter. 3eyword GLGes =ndicators8U G

Window /ara,eters . . . . . . . . . . . . W=7DOW Select /ara,eters . . . . . . . . . . . ?

Window borders . . . . . . . . . . . . . . WDW4O$D#$ Select /ara,eters . . . . . . . . . . . $e,o'e windows . . . . . . . . . . . . . . $!<WDW Bser $estore Dis/lay . . . . . . . . . . . BS$$S:DS efine %indo' )ara0eters $ecord . . . H 3eyword . . H S#7W&:1 W=7DOW 7a,e

$eferenced window . . . . . . . . . . . . AO$A Window definition Default start /ositionin( . . . . . . . AO$A Start line ro(ra,AtoAsyste, field . . . . . . . Actual line . . . . . . . . . . . . . Start /osition ro(ra,AtoAsyste, field . . . . . . . Actual /osition . . . . . . . . . . . 2 2 1A2*

GLGes

7a,e

7a,e 1A121

a(e 197 of 250

As400 Stuff Window lines . . . . . . . . . . . . . . Window /osition . . . . . . . . . . . . !essa(e line . . . . . . . . . . . . . . G G 20 40 1A2* 1A121 GLGes GLGes

$estrict cursor to window . . . . . . .

6elect +ecord 3ey'ords $ecord . . . H S#7W&:1 :y/e choices" /ress #nter. GLGes %eneral 9eywords . . . . . . . . ? =ndicator 9eywords . . . . . . . ? A//lication hel/ . . . . . . . . +el/ 9eywords . . . . . . . . . . Out/ut 9eywords . . . . . . . . .

.712 .703

12 03 Define %eneral 3eywords

Subfile control record . . . . . . . . . H S#7W&:1 :y/e choices" /ress #nter. 3eyword S#7W7D1 7a,e 7a,e 7a,e =ndicators8U ? ? 25 26

$elated subfile record . . . . . . . S6&):&

Subfile cursor relati'e record . . . S6&)S$$$7 Subfile ,ode . . . . . . . . . . . . S6&!OD# GLGes Dis/lay subfile records . . . . . . S6&DS Dis/lay control record . . . . . . . S6&DS ):&

a(e 198 of 250

As400 Stuff =nitialiFe subfile fields . . . . . S6&=7M Delete subfile area . . . . . . . . S6&D&: )lear subfile records . . . . . . . S6&)&$ =ndicate ,ore records . . . . . . . S6&#7D S6&#7D /ara,eter . . . . . . . . S6&#7D /ara,eter . . . . . . . . K!O$# KS)$4A$ ? K!O$# ... 28 30

$ecord not acti'e . . . . . . . . . S6&$7A !ore... 63L#0it 612L)ancel Define Dis/lay &ayout Subfile control record . . . . . . . . . H S#7W&:1 :y/e 'alues" /ress #nter. 3eyword 7u,ber $ecords in subfile . . . . . . . . . . S6&S=M ro(ra,AtoAsyste, field . . . . . . $ecords /er dis/lay . . . . . . . . . S6& A% S/aces between records . . . . . . . . S6&&=7 OB: B: #! &OG## D#:A=&S 1.S#&#): O : #! 7B!4#$ 000101 000102 000103 000104 7A!# 5 6

3.S#7:+=&3B!A$ $.S+GA!SB7DA$ 4.!O+A7 3.3B!A$ a(e 199 of 250

As400 Stuff 00010* A.A$B& !ore...

#! &OG## D#:A=&SH 1.S#&#):

O :

#! 7B!4#$

7A!#

0001000010. 000101 000102 000110

4A&B S#7:+=& $A5 +#!A <#& !ore...

#! &OG## D#:A=&S 1.S#&#): O : #! 7B!4#$ 000111 000122 123 7A!#

$A!#S+ SBD+A

3A7DASA!G

2. *essage su!file record for0at Eey'ords S6&!S%$)D >subfile ,essa(e record? :his 9eyword is used to (i'e the line nu,ber to (et the first ,essa(e in the dis/lay. S6&!S%3#G >subfile ,essa(e 9ey? a(e 200 of 250

As400 Stuff :his 9eyword is used to s/ecify that the /ro(ra, ,essa(e Eueue is built one at a ti,e. S6& %!C >subfile /ro(ra, Eueue? =t is a ,essa(e Eueue created for e'ery /ro(ra, acti'e in the call stac9. :his 9eyword is used to s/ecify the field that can ha'e the na,e of the /ro(ra, ,essa(e Eueue. 1. /o' to create *essage su!file" )reate ,essa(e subfile )$:!S%6 !3S6=&#8&=4 W$3!S%6 6=&#8A7!# O :=O7 12 Add !essa(e Descri/tion >ADD!S%D? :y/e choices" /ress #nter. !essa(e identifier . . . . . . . *360001 !essa(e file . . . . . . . . . . [ !3S6=&# 7a,e 7a,e

&ibrary . . . . . . . . . . . [ S3A7DASA!O 7a,e" K&=4&" K)B$&=4 6irstAle'el ,essa(e te0t . . . . #! &OG## 7B!4#$ K1 )A77O: 4# M#$OS A%# DOW7 !essa(e data fields for,atsH Data ty/e . . . . . . . . . . *./9+ K7O7#" KC:D)+A$" K)+A$... 7u,ber" K<A$G

&en(th . . . . . . . . . . . . 10

W$3!S%6 !3S0001 !3S0002 !3S0003 !3S0004 0 0 0 0 #! &OG## 7B!4#$ )A77O: 4# M#$OS #! &OG## D1 7B!4#$ A=$#ADG #P=S: #! &OG## 7A!# )A77O: 4# 4&A73S ADD$#SS>1? )A77O: 4# 4&A73S

a(e 201 of 250

As400 Stuff !3S000* !3S000!3S000. !3S0001 !3S0002 !3S0010 0 0 0 0 0 0 )=:G )A77O: 4# 4&A73S !A$=:A& S:A:BS W=&& 4# W=:+ >!8S? #! &OG## 7B!4#$ D1 ADD#D SB))#S6B&&G #! &OG## 7B!4#$ DO#S 7O: #P=S:S #! &OG## B DA:#D SB))#SS6B&&G #! &OG## 7B!4#$D#&#:# SB))#S6B&&G 0-82.802 !S%$#)1 0-82.802

.reate 0essage su!file 10 *6,+E.1 S6&!S% 20 *6,.>#1 S6&):&

BS=7% 1 S#&#:=O7 Select Subfile 3eywords Subfile record . . . . . . . H !S%$#)1 :y/e choices" /ress #nter GLGes %eneral 9eywords . . . . . . . . =ndicator 9eywords . . . . . . . !essa(e record . . . . . . . . . :#P: 9eyword . . . . . . . . . . efine *essage +ecord Subfile record . . . . . . . H !S%$#)1 :y/e choices" /ress #nter. 3eyword &ine nu,ber for first ,essa(e . . . . S6&!S%$)D 24 !essa(e =D field . . . . . . . . . . S6&!S%3#G >if /ro(ra, ,essa(e Eueue is built one ,essa(e at a ti,e? a(e 202 of 250 <**? 1A2. 7a,e ? ? ?

As400 Stuff ro(ra, ,essa(e Eueue field . . . . . S6& %!C %enerate a 2.- byte field . . . . . *E669,E 6<47=#E C67>.>#D Subfile control record . . . . . . . . . H !S%):&1 :y/e choices" /ress #nter. GLGes %eneral 9eywords . . . . . . . . ? Subfile dis/lay layout . . . . . ? Subfile ,essa(es . . . . . . . . ? Select record 9eywords . . . . . ? :#P: 9eyword . . . . . . . . . . efine ,eneral 3ey'ords Subfile control record . . . . . . . . . H !S%):&1 :y/e choices" /ress #nter. 3eyword *6,+E.1 7a,e 7a,e 7a,e ;<E<E GLGes =ndicators8U ? ? 7a,e ;<E<E GLGes 7a,e

$elated subfile record . . . . . . . S6&):&

Subfile cursor relati'e record . . . S6&)S$$$7 Subfile ,ode . . . . . . . . . . . . S6&!OD# ro(ra, ,essa(e Eueue field . . . . S6& %!C %enerate a 2.- byte field . . . . GLGes Dis/lay subfile records . . . . . . S6&DS Dis/lay control record . . . . . . . S6&DS ):& =nitialiFe subfile fields . . . . . S6&=7M Delete subfile area . . . . . . . . S6&D&: )lear subfile records . . . . . . . S6&)&$ a(e 203 of 250 ?

As400 Stuff =ndicate ,ore records . . . . . . . S6&#7D S6&#7D /ara,eter . . . . . . . . S6&#7D /ara,eter . . . . . . . . K!O$# KS)$4A$ K!O$# ...

$ecord not acti'e . . . . . . . . . S6&$7A !ore... 63L#0it 612L)ancel Select $ecord 3eywords $ecord . . . H !S%):&1 :y/e choices" /ress #nter. GLGes %eneral 9eywords . . . . . . . . ? =ndicator 9eywords . . . . . . . ? O'erlay 9eywords . . . . . . . . ?

Select O'erlay 3eywords $ecord . . . H !S%):&1 :y/e choices" /ress #nter. 3eyword GLGes =ndicators8U $oll ?

O'erlay without erasin( . . . . . . O<#$&AG

)reate )& /ro(ra, for S7D %!!S% S3A7DASA!O8#! )BS:O$ !S% KKKKKKKKKKKKKKK 4e(innin( of data KKKKKKKKKKKKKKKKKKKKKKKKKKKKK 0001.00 0002.00 0003.00 %! D)& D)& A$!>D!S%=D D!S%6= D!S%D:A? <A$>D!S%=D? :G #>K)+A$? &#7>.? <A$>D!S%6=? :G #>K)+A$? &#7>.? a(e 204 of 250

As400 Stuff 0004.00 D)& <A$>D!S%D:A? :G #>K)+A$? &#7>10? S7D %!!S% !S%=D>D!S%=D? !S%6>D!S%6=?

000*.00 !S%D:A>D!S%D:A? 000-.00 #7D %!

KKKKKKKKKKKKKKKKKK #nd of dataKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK .reate .# 1rogra0 for +*G*6, S3A7DASA!O8#! )BS:O$ $!O KKKKKKKKKKKKKKK 4e(innin( of data KKKKKKKKKKKKKKKKKKKKKKKKKKKKK 0001.00 $!<!S% %!C>K $<? )&#A$>KA&&?

KKKKKKKKKKKKKKKKKK #nd of data KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK Desi(n the screen %enerate $ % /ro(ra, 0000.01 6!#SS:A4 =6 A # 0001.00 6!3SS)$ 0001.01 ) 0002.02 ) 0003.00 ) 0004.00 ) 000*.00 ) 000-.00 ) 000..00 ) 0001.00 ) 0001.01 ) 0001.02 ) 0012.00 ) 0013.00 ) &01 )6 # !O<#& !O<#& !O<#& &=S: A$! A$! A$! DOW !O<#& !O<#& W$=:# #P6!: !S%=D !S%6= !S%D:A K=703LKO66 0 0 !S%):&1 !3SS#7 #$$O$ #$$O$#! 10 10 . 10 10

3 D=S3 WO$3S:7 !S:A:BS ;K; S 1

CB#B# !S%6=

;!3S6=&#;

a(e 205 of 250

As400 Stuff 0013.01 ) 0014.00 ) 0014.01 ) 0014.02 ) 001*.00 ) 001-.00 ) 001..00 ) 001..01 ) )A&& =6 ;$!O; #! 7B!4LKM#$OS 1 1 #$$O$ #$$O$#! !S%=D !S%D:A &01

!O<#& !O<#& !O<#& !O<#& )A&& #7D=6

;!3S0001; KM#$OS ;!S%;

1. %&at is acti-e su!file" Subfiles" which are in the ,ain ,e,ory" are called as acti'e sub files. A ,a0i,u, of 12 sub file can be acti'e at a ti,e. .# )rogra00ing 1. .# co00ands" 1. %+3*4+) * 2. .+>6+.)7 4y usin( this co,,and to create source /hysical file. Default 6 siFe is 22. 3. 6)7 =t is used to dis/lay the details about the file when it is created. 4. 6)77 =t is used for listin( details about =ndi'idual 6ields. 5. 6>+ 7< =t is used to add Data into the records. 6. 6>+6 9 =t is used to (o into screen Desi(nin( or !enu Desi(nin(. a(e 206 of 250

As400 Stuff 7. .+>*6,7 6or creatin( the !essa(e file 8. %+3*6,7 =f you want to create or chan(e or delete any ,essa(e we can use this co,,and. 9. .+> >99+9 6or creatin( :he Data Area 10. 6) >99+9 Dis/lay the contents of Data area. 11. ./, 9>9+9 .han(e the contents of a Data area. 12. 6)#=4# 6or listin( the contents of library 13. 9 #=4#E Adds a library into current library 14. +*G#=4#E $e,o'es a library in current library list 15. ./,.<+#=4 6or chan(in( the )urrent &ibrary to a new library 16. E >#=4# =t is used to the edit of the library file. >)han(e library file it is te,/orary delete the library file? 6or Addin( or re,o'in( library lists. 17. 68 4+3*6, Bsed for sendin( ,essa(e to all user. 18. .+>)7 a(e 207 of 250

As400 Stuff =t is used to create a 6. Bsin( this co,,and we can set the ,a0i,u, nu,ber of records" whether delete or u/date o/eration is allowed or not" ,a0i,u, stora(e allocation" waitin( ti,e etc can be deter,ined 19. .+>#7 )reates the lo(ical files 20. 6>++#< :o (o into the $&B we are usin( this co,,and. Default len(th of $&B is 132 if you (i'e it and creatin( it 'ery first ti,e else it set the /a(e width 'alue of last edited $&B. We can (i'e the /a(e width 'alue fro, 1 to 3.1 in /a(e width o/tion. 21. 6)646

=t is used to list the 'arious subsyste,s runnin( under AS8400 en'iron,ent. <arious subsyste,s runnin( are C=7:#$" CA):=<#" and C4A:)+ etc. 22. .+>+),),* =t is used to create an $ % /ro(ra,. We can deter,ine what sort of source file is (enerated. 6or e0a,/le when we need the entire source co,/ile as it is since source is default. =f we (i'e K7OSOB$)# only synta0 errors is (enerated 7OS#)&<& will not allows secondary ,essa(e where as other settin( is allowed it and so on 23. .+>.#),* :o create )& /ro(ra, 24. E >(459<> =t is used to (i'e authority to a /articular source 6. 6or (i'in( authority to other user we ,ust (i'e authority to library" user /rofile and the source 6. 25. 6)(45

=f we 9now library na,e and object na,e and we want to 9now the source 6 where it is residin( then DS O45D with o/tion as ser'ices instant of basic will (i'e the source 6 na,e. =t describes 'arious object descri/tions li9e created Date" )reated by" Source hysical file" which it is bein( created" and so on. a(e 208 of 250

As400 Stuff 26. 6>+6;# Starts SC&. 27. %+36)#7 :o wor9 with S/ool file 28. #>6)#7 :o delete the s/ool file 29. .+> <)(45 :his co,,and creates du/licate object. =f you want to co,/ile a 6 ha'in( 1000 of records and when we co,/ile it all the data will be lost else if you want to add or delete a attribute data for other fields will ha'e to co/ied. 6or that we a du/licate object. 30. .)?7 $ecords are bein( co/ied fro, 6 to te,/orary file and after co,/ilin( it we ha'e to a(ain co/y bac9 fro, te,/orary file to the ori(inal file. =f we Add a attribute we ha'e to (i'e K,a/ and if we want to delete a attribute we ha'e to (i'e Kdro/ in the ,a/ entry field. 31. #>7

After co/yin( into the ori(inal file we ha'e to delete the te,/orary file or if you want to delete any file we are usin( this co,,and. D&:6 will only re,o'e the object 32. +*G* =t is used to delete the ,e,ber as well as the object. 33. +<8;+? Dis/lays all the records in a 6 34. .+>.* =t is the /owerful co,,and used to create user define co,,ands. 35. .*))7* =t is used to co,/are two /ro(ra,s or files. =t can be coded by ta9in( o/tion *4 in Subfile screen. a(e 209 of 250

As400 Stuff 36. *+,6+. =t is used to ,er(e a file with another file. We ha'e to ,ention three files one is the root file" which is just a root and does not contain any code e'en. :he second file is tar(et file where we can ha'e the readyA,ade we can co/y the tar(et source.

37. +>G.#6+. =f you delete a )& Source then we can retain the source if you are ha'in( the object by usin( this co,,and. 38. 64*5(4 =f you want to sub,it the job in certain inter'al i.e. on a s/ecified date and ti,e we can use this co,,and. 39. 6)5(4 =t will dis/lay all the jobs. 40. 6)<6+)+7

=t will dis/lay all the entries re(ardin( the /articular user /rofile. =t dis/lays infor,ation li9e what is the user. rofile na,eX date /re'iously" user class" /rintin( and all. 41. .)?6+.7 =f we want to co/y all the ,e,bers in a source 6 to another source 6 this co,,and is used. 42. %+39.>5(4 :o dis/lay the acti'e jobs runnin( in AS8400 syste,s. 43. 6)5(4#(, 4y usin( this co,,and dis/lay the out/ut console. 44. 68 *6, :his co,,and is to send the ,essa(e to an user. 45. 6)*6, :his co,,and is dis/lay all the ,essa(e. a(e 210 of 250

As400 Stuff 46. ./,.<+#=4 )han(e the current library file. 47. 9 #=4#E =t is used to add the library. =t is fully ad,inistrator authority. 48. +*G#=4#E :his co,,and is to re,o'e a library fro, the list. 49. .+><6+)+7 =t is used to dis/lay the ri(hts (i'en to a user. :he syste, ad,inistrator can chan(e authority he can (i'e the authority as a syste, ad,inistrator. 50. 6) 4+ Cdata !ase relationD

:his is used to list all the files" which are related to a 6. =t dis/lays all the &6 that is referrin( the 6 and also lists the child table if it is ha'in( a relation throu(h ADD 6)S:. 51. 6)5(4

=t will dis/lay all the jobs sub,itted within the s/ecific inter'al and dis/lay the entire user who wor9ed on the syste, at that ti,e

52. %+3*6,; =t will list all the ,essa(es of different user in the job Eueue. 53. .)?6+.7 =f we want to co/y all the ,e,bers in a source 6 to another source 6 we can use this co,,and. 54. .)?>( 3> =f we want to co/y fro, source 6 to a dis9ette file

55. .)?>(>9) =f we want to co/y source 6 to a ta/e then we can use this co,,and. a(e 211 of 250

As400 Stuff 56. 6>+ 4, =f we want to debu( a =&# /ro(ra, then we can use this co,,and .We ha'e to create a =&# /ro(ra, by co,/ilin( with 1* which is )$:$ %!OD co,,and and ta9e 610 (i'e debu((in( 'alues as KSource. :his will create a ,odule. :hen we ha'e the create the /ro(ra, by (i'in( /ro(ra, na,e and ,odule na,e as the sa,e and if we are callin( any other ,odules also in that include that in the )$: %! co,,and #0H )$: %! %! >&=48 7A!#? !ODB&# >&=48 7A!#? >&=48S 7A!#? 7ow the /ro(ra, as well as the ,odule is created. :hen we ha'e to start the debu( by usin( the co,,and. S:$D4% %! >&=48 7A!#? B D $OD >KG#S? =t will show the source code of the /ro(ra, and we ha'e to /ress 6- set the brea9 /oint and /ress 610 9ey and call the /ro(ra, )A&& 7A!# 611A[ dis/lay the 'ariable :G # >? KD#) #E8 CD Default >1* *? !a0 >1* 2? K)+A$ K&%& Default >32? 1 Default >b? Default >R0@? G9#<E CD Default >0?

Shift U 611 A[ (o to ,odule 2. ata ty1es in .#" )har" &o(ical" 7u,erical

3. 6tring o1eration in .#" *.9> A[)oncatenate without editin(.

a(e 212 of 250

As400 Stuff *4.9>A[trailin( blan9s in the first character strin( is truncated. One blan9 is inserted" and then the two character strin(s are concatenated. Any leadin( blan9s of the second o/erand are not truncated K>.9>IRAll trailin( blan9s in the first character strin( is truncated" and then the two character strin(s are concatenated. Any leadin( blan9s of the second o/erand are not truncated. S3A7DASA!O8)& S:$=7% KKKKKKKKKKKKKKK 4e(innin( of data KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK 0000.01 8KS:$=7% K)A: K4)A: K:)A: 6B7):=O7 K8 0001.00 0001.02 0001.03 0001.04 0001.0* 0001.00001.0. 0001.01 0001.02 0001.10 0001.11 0001.12 %! D)& D)& D)& D)& D)& )+%<A$ )+%<A$ )+%<A$ S7D!S% S7D!S% S7D!S% A$!>DS:$ DS:$1 DS:$2 DS:$3 DS:$4? <A$>DS:$? :G #>K)+A$? &#7>1*? <A$>DS:$1? :G #>K)+A$? &#7>1*? <A$>DS:$2? :G #>K)+A$? &#7>1*? <A$>DS:$3? :G #>K)+A$? &#7>1*? <A$>DS:$4? :G #>K)+A$? &#7>40? <A$>DS:$2? <A&B#>DS:$ K)A: DS:$1? <A$>DS:$3? <A&B#>DS:$ K4)A: DS:$1? <A$>DS:$4? <A&B#>DS:$ K:)A: DS:$1? !S%>DS:$3? :OBS$>S3A7DASA!G? !S%>DS:$4? :OBS$>S3A7DASA!G? !S%>DS:$2? :OBS$>S3A7DASA!G?

000-.00 #7D %! KKKKKKKKKKKKKKKKKK #nd of data KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK +un call /ro(ra, na,e >stringD f4 ro(ra, . . . . . . . . . . . . [ S:$=7% 7a,e

a(e 213 of 250

As400 Stuff &ibrary . . . . . . . . . . . [ S3A7DASA!O 7a,e" K&=4&" K)B$&=4 ara,eters . . . . . . . . . . . [ S#7:+=& [ 9u,ar [ ;; [ ;; U for ,ore 'alues [ ;; DS !S% 4. /o' to set t&e cursor 1osition in 1articular field in 1articular 1osition" Bsin( the )ur/os 5. /o' 'ill retrie-e t&e data in data area" =n Iretrie'e a data area OutAwrite a data area 6. 4uilt in function in .#" OSB4S:$=7% or OSS: :he sub strin( builtAin function /roduces a character strin( that is a subset of an e0istin( character strin( and can only be used with a )& /ro(ra,. OSB4S:$=7% >)haracterA'ariableAna,e Startin(A/osition len(th? Or OSS: >)haracterA'ariableAna,e Startin(A/osition len(th? OSW=:)+ 2. efine indicator in .#"

We can set on or set off the indicator by the co,,and. )+%<A$ >D=730? <A&B# >R0@? A[setoff )+%<A$ >D=730? <A&B# >R1@?A[set on

a(e 214 of 250

As400 Stuff 3. *essage su!file in .# Subfile cannot be used in )& but we can use ,essa(e subfiles in )&. 4. .# 1rocessing co00ands K 1rogra0 control co00ands" $O)#SS=7% A[ )+%<A$" S7D %!!S%" O<$D46" A7D D&:6. $O%$A! )O7:$O& A[)A&&" $#:B$7" :6$):& 5. /o' to .# code &as to c&ange to use a call 1rocedure" 4y usin( )A&& $) co,,and. :his is the bound call in )& that calls a /rocedure within a ,odule. 6. %&at are -arious ste1s accessing data area in .#" :he first create a (eneral data area use the co,,and >)$:D:AA$A? :o retrie'e 'alues fro, data area use >$:<D:AA$A? :o chan(e this 'alue" use >)+%D:AA$A? :o dis/lay the current 'alue" use >DS D:AA$A? :o delete a data area use >D&:D:AA$A?

2. %&at is t&e eLui-alent co00and to setll *lo%al in .#" OSD46 with file /osition as Kstart will set the file to the be(innin( >or? usin( O<$D46 and s/ecify the 9ey field 'alue by $$7 'alue >or? by (i'in( Kstart. 3. Garious ty1es of 0essage a-aila!le in .#. !essa(e is the interface between o/eratin( syste, and the /ro(ra,s or user and /ro(ra,. We can classify the ,essa(e into two ty/es na,ely =,,ediate ,essa(e redefined ,essa(e =00ediate 0essage Which does the /ro(ra, or syste, user create when they are sent and are not /er,anently stored in the syste,? )ontrol lan(ua(e S7DBS$!S% S7D %!!S% S7D!S% S7D4$3!S% Dis/lay files #$$!S% S6&!S% a(e 215 of 250

As400 Stuff =7CB=$G and =76O$!A:=O7A& ,essa(eH Bsin( S7DBS$!S% co,,and to send ty/e of ,essa(e )redefined 0essage :hey are created before they are used. :hese ,essa(es are /laced in a ,essa(e file >Eueue? when they are created" and retrie'ed fro, the file when they are used. )ontrol lan(ua(e S7DBS$!S% S7D %!!S% $:<!S% Dis/lay files #$$!S%=D S6&!S%=D !S%)O7 !S%=D )O! &#:=O7 and D=A%7OS:=) ,essa(e Bsin( S7D %!!S% co,,and these of ,essa(e can be sent to any ,essa(e Eueue. D=A%7OS:=) ,essa(e tell the callin( /ro(ra, about errors detected by the /ro(ra,. )o,/letion ,essa(e tell the result of wor9 done by the /ro(ra,. S:A:BS ,essa(es Bsin( S7D %!!S% co,,and status ,essa(e can be sent to it@s caller@s /ro(ra, ,essa(e Eueue or to the e0ternal ,essa(e Eueue for the job. :hese ,essa(es tell the recei'in( /ro(ra, the status of the wor9 /erfor,ed by the sendin( /ro(ra,. #S)A # ,essa(e Bsin( S7D %!!S% co,,and esca/e ,essa(e fro, a )& /ro(ra, can be sent to its callin( /ro(ra,. An esca/e ,essa(e tells the callin( /ro(ra, ended abnor,ally and why. 7O::6G ,essa(e 7otify ,essa(e fro, a )& /ro(ra, can be sent to the ,essa(e Eueue of callin( /ro(ra, or to the e0ternal ,essa(e Eueue. A notify ,essa(e tells the callin( /ro(ra, about a condition under which /rocessin( can continue. redefined ,essa(e are stored in ,essa(e file :o create a ,essa(e file a(e 216 of 250

As400 Stuff )$:!S%6 !S%6 >!6=&#? S=M# >? AB: >? :#P: >? )reate and ,aintain ,essa(es ADD!S%D )+%!S%D O$ W$3!S%D DS !S%D $!<!S%D !essa(e file C) 6!S% in library CSGS contain the syste, ,essa(e 2. %&at 'ill *(8*6, co00and in do" :he ,onitor ,essa(e >!O7!S%? co,,and ,onitors the ,essa(e send to the /ro(ra, ,essa(e Eueue for the conditions s/ecified in the co,,and. =f condition e0ists" the )& co,,and s/ecified on the !O7!S% co,,and is run. :y/es of ,onitor ,essa(e #sca/e !essa(e Status or 7otify !essa(e #sca/e !essa(e #sca/e ,essa(e are send to tell your /ro(ra, of an error condition that forced the sender to end. 4y ,onitorin( for esca/e ,essa(e" you can ta9e correcti'e actions or clean u/ and end your /ro(ra,. Status or 7otify !essa(e Status and notify ,essa(e are send to tell your /ro(ra, of an abnor,al condition that is not serious enou(h for sender to end. 4y ,onitorin( for status or notify ,essa(e" your /ro(ra, can detect this condition and not allow the function to continue. :wo le'els of !O7!S% co,,and ro(ra, le'el S/ecific co,,and le'el ro(ra, le'el :he !O7!S% is s/ecified i,,ediately followin( the last declare co,,and in your )& /ro(ra,. Gou can use as ,any as 100 /ro(ra,Ale'el !O7!S% co,,ands in a /ro(ra,. S/ecific co,,and le'el +ere the !O7!S% co,,and i,,ediately follows a )& co,,and. Gou can use as ,any as 100 co,,andsAle'el !O7!S% co,,ands for a sin(le co,,and. !onitor ,essa(e co,,and synta0 a(e 217 of 250

As400 Stuff !O7!S% !S%=D >? )! D:A >? #P#) >?

!S%=DA$eEuired #0H !S%=D >!)+1211? )! D:A I>O/tional? #0H !O7!S% !S%=D >!)+1211? )! D:A >&=4? #P#) A A>O/tional? )& co,,and 2. %&at are t&e state0ents, '&ic& is not used in .##E t&at is used in .#)" $)&$S) which is re/laced by $)&A):%$ :6$):& 2. /o' to create user define co00and" 4y usin( the )$:)!D co,,and /rocess the co,,and definition state,ents to create the co,,and definition object. :he )$:)!D co,,and ,ay be run interacti'ely or in a batch job.

Ste/s for creatin( )$:)!D co,,ands 1. #nter the co,,and definition state,ents into the source file )o,,and ty/e )!D S3A7DASA!O8)& )!D1 KKKKKKKKKKKKKKK 4e(innin( of data KKKKKKKKKKKKKKKKKKKKKKKKKKKK 0001.00 )!D KKKKKKKKKKKKKKKKKK #nd of data KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK 2. #nter source /ro(ra, in any lan(ua(e S3A7DASA!O8)& D&=4 :G # H )&

KKKKKKKKKKKKKKK 4e(innin( of data KKKKKKKKKKKKKKKKKKKKKKKKKKKKKK a(e 218 of 250

As400 Stuff 0001.00 %! 0002.00 DS &=4& 0003.00 #7D %! KKKKKKKKKKKKKKKKKK #nd of data KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK 3. )reate the co,,and by usin( )$:)!D ta9e f4 )o,,and . . . . . . . . . . . . [ 36 7a,e

&ibrary . . . . . . . . . . . [ 6398 969*( 7a,e" K)B$&=4 ro(ra, to /rocess co,,and . . . [ #=4 7a,e" K$#PP

&ibrary . . . . . . . . . . . [ 6398 969*( 7a,e" K&=4&" K)B$&=4 Source file . . . . . . . . . . [ .#) 7a,e

&ibrary . . . . . . . . . . . [ 6398 969*( 7a,e" K&=4&" K)B$&=4 Source ,e,ber . . . . . . . . . [ .* 1 :hreadsafe . . . . . . . . . . . K7O 7a,e" K)!D KG#S" K7O" K)O7D KSGS<A&" K$B7" K!S%" K7O$B7

!ultithreaded job action . . . . KSGS<A& :e0t ;descri/tion; . . . . . . . KS$)!4$:P:

3. =nfo D#6AB&: )& !S%=D? ) 60000 Ds/f windows ty/e? W=7DOW What is the le'el chec9 error? :he le'el chec9 error ,eans $ %&# /ro(ra, is co,/iled and 6 or &6 are co,/ile su//ose the 6 or &6 co,/ile after the co,/ilin( the $ %&# /ro(ra, this ty/e of error is called le'el chec9 error. =f you want to co/y a 6 without ,a9in( any ,odification to it then 6O$!A: 9eyword is used. Default access /ath ,aintenance is K=!!#D !a0i,u, no of /rinter files included in a $ %&# /ro(ra, is 1 a(e 219 of 250

As400 Stuff !a0i,u, no of files declared in $ %&# is *0 and )& is l !a0i,u, no of 9ey fields included is 120 !a0i,u, no of fields included in a 6 is 1000 !a0i,u, no of arrays included is a $ % is 200 !a0i,u, no of /ara,eter /assed in a $ % is 2** and )& 40 :otal no of syste, library is 1* and user library is 2* While lo((in( on the first library to be included is CSGS C% + and C:#! are user library rinter file default len(th is 132. Default siFe of a ,e,ber is )$:S$) 6 co,,and for ordinary files is 22.

2. %&atFs t&e difference !et'een ./9=8 and 6E>##" =s t&ere a 1erfor0ance ad-antage" :here are two i,/ortant differences between )+A=7 and S#:&&. 1. :he )+A=7 o/eration a//lies a record loc9 to files that are o/en or u/date. :he S#:&& o/eration does not a//ly the loc9. 2. :he )+A=7 o/eration co/ies the record;s data to the in/ut buffer for the /ro(ra,. :he S#:&& o/eration does not. +ore &etails :he )+A=7 o/eration /erfor,s a rando, %#: o/eration to the database file. =f the o/eration is successful" the data in the record is co/ied to the in/ut buffer. =f the )+A=7 o/eration fails" a recordAnotAfound condition is si(naled" ty/ically 'ia $esultin( =ndicator 1. =f the database file has been o/ened for B DA:#" the )+A=7 o/eration /laces a record loc9 on the retrie'ed record. 7o other a//lication can access this record for u/date while this loc9 is a//lied. 6urther,ore" if another /ro(ra, has issued a loc9 to the recordin( bein( accessed" the )+A=7 o/eration will wait for the database ti,eAout /eriod. =f the record is released durin( that /eriod" the )+A=7 o/eration continues. =f the other /ro(ra, does not release the record" the )+A=7 o/eration fails with an e0ce/tion. ./9=8 'it& 8( #(.3 :he )+A=7 o/eration su//orts the 7O &O)3 o/eration e0tender >the old NhalfAadjustN colu,n?. =n $ % === you s/ecify an 7 in the o/eration e0tender colu,n" in $ % =<" you s/ecify )+A=7 >n? for the o/eration code. Bsin( 7O &O)3 allows you to access a record without a record loc9 bein( a//lied" re(ardless of the way in which the file is o/en. :he record;s data" howe'er" is still co/ied to the in/ut buffer when 7O &O)3 is s/ecified. :he S#:&& o/eration /erfor,s a Euasi $#AD &#SS :+A7 O$ #CBA& o/eration. =f the o/eration is successful" a $#AD $=O$ is /erfor,ed. :he database record;s data" howe'er" is not co/ied to the in/ut buffer" nor is there a record loc9 a//lied to a(e 220 of 250

As400 Stuff the accessed record. +ence" S#:&& is /robably the o/eration code to use for testin( the e0istence of a record. +owe'er" if the record needs to be retrie'ed" )+A=7 ,ore effecti'e. Performance =f your reEuire,ent is to chec9 for the e0istence of a record" traditionally the )+A=7 o/eration is used. +owe'er" since )+A=7 co/ies the record;s data to your /ro(ra,;s in/ut buffer" there is additional o'erhead reEuired for the )+A=7 o/eration. :he S#:&& can be used to effecti'ely acco,/lish the sa,e tas9 as the )+A=7 test. Bse S#:&& with resultin( indicator 3 >eEual?. =f this indicator is set on" a record e0ists whose 9ey ,atches they 'alue s/ecified in 6actor 1. =f your reEuire,ent is that the record e'entually be u/dated" subseEuent to the e0istents test" you should consider usin( of )+A=7. 2. /o' do = de!ug a re0ote Ci.e. T!atc&TD $o! fro0 an interacti-e $o!" :he ability to debu( another job has been a lon(Astandin( reEuire,ent for AS8400" now =series /ro(ra,,ers. =t isn;t as difficult as it ,ay see,. Whether you need to debu( a batch job" another interacti'e job" or an +:: ser'er job >browser8)%= /ro(ra,?" the followin( ste/s can (et you started. (tarting &eb)g for a Remote ,ob 1. Deter,ine the job na,e of nu,ber for the job you need to debu(. Bse W$3A):5O4 and note the 5ob na,e" nu,ber and user /rofile =D. =f debu((in( a )%= /ro(ra," loo9 in the job lo( of the job for ) 6 ,essa(e +: 2001. 1. $un the Start Ser'ice 5ob >S:$S$<5O4? co,,and s/ecifyin( the job to be debu((ed #.(." S:$S$<5O4 5O4 >01234*8usrid8jobna,e? 1. $un Start Debu( >S:$D4%? on the /ro(ra, to be debu((ed #.(." S:$D4% %! >libna,8/(,na,e? B D $OD>KG#S e K7O? 1. At this /oint the /ro(ra, in the re,ote job is under debu( control fro, your job Gou can now set brea9 /oints >if you;re debu((in( an $ % =< /ro(ra," the source will ha'e already been dis/layed?. ress 612 fro, within the debu((er to return to )!D entry after settin( your brea9 /oints.

1. #'o9e the /ro(ra, in the re,ote job. =f you you;re doin( a web browser session" hit the SB4!=: button. 2. Gou interacti'e job will Nbrea9N at the debu( brea9 /oints and you can debu( a//lication nor,ally. a(e 221 of 250

As400 Stuff #n$ing &eb)g for a Remote ,ob #ndin( the debu( session should be done in the followin( seEuence. 1. 6ro, your debu((in( session" run the #nd Debu( >#7DD4%? co,,and 2. :hen run the >#nd Ser'ice 5ob? #7DS$<5O4 co,,and Gour session is no lon(er controllin( the re,ote job. :he re,ote job continues nor,ally. (pecial Consi$erations w en &eb)gging a -eb Browser.CGI Program :o debu( a )%= /ro(ra, that is e'o9ed fro, a Web 4rowser session runnin( fro, the standard =4! +:: Web Ser'er" you need to do the followin( in addition to the abo'e. Before (tarting &eb)g for a -eb Browser.CGI (ession.Program #nd the +:: Ser'er usin( the followin( )& co,,andH #7D:) S<$ K+:: WA$7=7%JJJ AA Gou !BS: include K+:: as the /ara,eter for #7D:) S<$ otherwise all :) 8= ser'er jobs >includin( telnet" ft/" s,t/" etc.? will be ended. And this is a bad thin(. =4! suc9s for ,a9in( KA&& the default for #7D:) S<$. $estart the +:: Ser'er usin( the followin( )& co,,andH S:$:) S<$ K+:: +:: S<$>D#6AB&: ;A,inat 1 A,a0at 1;? :his restarts the +:: ser'er with once instance of each job ty/e >one for )%=" one for 5a'a" etc.? Bsin( W$3A):5O4 in the C+:: S<$ subsyste, location the jobs runnin(. :he job whose joblo( contains the ) 6 ,essa(e +: 2001 is the one to be debu((ed. After 6inishin( the Debu( Session #nd the +:: ser'er usin( the followin( )& co,,andH #7D:) S<$ K+:: $estart the +:: ser'er usin( the followin( )& co,,and" unless your sho/ has another /rocess for startin( the +:: ser'erH S:$:) S<$ K+:: Gour syste, should be bac9 to nor,al. 2. %&at is t&e ne' E o1eration e2tender used for" :he new >#? o/eration e0tender is used to cause the O#$$O$ and OS:A:BS builtAin functions to be initialiFed after an o/eration is /erfor,ed. :hat is" these builtAin a(e 222 of 250

As400 Stuff functions and the # o/eration e0tender are used in /lace of $esultin( =ndicator 2 on all o/eration codes that currently su//ort $esultin( =ndicator 2 as an error condition. 6or e0a,/le" to chec9 to see if a record is loc9ed" you would code the followin(H .....)S$n016actor1UUUUUUUO/)ode>e0?6actor2UUUUUUU$esultUUUUUUU U&enUUDc+i&o#E ) )ust7O .&ain>#? )ust!ast ) if O#$$O$ L KO7 ) Select ) When OS:A:BS L 1221 ) e0sr B/date7o$ead ) When OS:A:BS L 1211 ) e0sr $ecd&oc9ed ) endS& ) #&S# ) if O6OB7D> )ust!ast ? ) e0sr whate'er... ) endif ) endif :he conce/t is to first chec9 O#$$O$ for a (eneraliFed error condition" and then chec9 OS:A:BS for the s/ecific error. 7ote that no resultin( indicators are used in the /re'ious e0a,/le. :he nor,al not(!ound condition is chec9ed usin( the O6OB7D builtAin function rather than testin( $esultin( =ndicator 1. 3. %&y doesnFt t&e H./9+ !uiltIin function 'orE 'it& nu0eric -alues" Bnder the initial release of OS8400 <ersion 4" $elease 2" the O)+A$ builtAin function was introduced. +owe'er" the function" as desi(ned" only con'erted DA:# 'alues to character 'alues. :his /ro'ed to be too restricti'e a use for this function. =n the ne0t release of OS8400 ><4$4? =4! will add function to O)+A$ allowin( it to con'ert all for,s of nonAcharacter data to character. =n that release O)+A$ will function with nu,eric 'alues. D A,ount ) #'al .) 2 =nF>123.4*? te0t L ;:he a,ount isH ; U O)har > a,ount ?

:he :#P: field would contain the followin( after the #<A& o/eration is /erfor,edH ;:he a,ount isH 123.4*; Bnli9e O#D=:)" the O)+A$ builtAin function tri,s off leadin( blan9s. +owe'er" O#D=:) /ro'ides ,uch ,ore editin( /ower than O)+A$. Bse O)+A$ for basic nu,ber to character con'ersion. a(e 223 of 250

As400 Stuff 4. /o' does t&e .(86> Eey'ord 'orE 'it& )rocedure 1ara0eters" =f you are certain that the called /rocedure will 7O: ,odify a /ara,eter" the )O7S: 9eyword can /ro'ide se'eral benefits. 1. =t auto,atically con'erts a field of a si,ilar data ty/e" to the len(th and ty/e reEuired by the /ara,eter. What this ,eans" is say a /ara,eter is a 1* /osition /ac9 field" with * deci,als. 7or,ally" you;d ha'e to s/ecify a d9>1*"*? field for the /ara,eter. +owe'er" if the /ara,eter is readAonly" you can s/ecify )O7S: on the rototy/e and rocedure =nterface for the /ara,eter. When you do this" the co,/iler auto,atically con'erts the 'alue >say it;s a literal of 2.? to the siFe and ty/e reEuired by the /ara,eter. :his wor9s really cool with DA:# fields. A date for any for,at can be /assed as a /ara,eter 'alue when that /ara,eter 'alue is )O7S:. 2. erfor,ance is i,/ro'ed because the co,/iler can (enerate ,ore o/ti,iFed code for the )O7S: /ara,eter.

)O7S: can be used on calls to /rocedures or /ro(ra,s. We use it all the ti,e when callin( C)!D#P) fro, within $ % =<. All three /ara,eters of the C)!D#P) /ro(ra, are )O7S: 'alues. :he e0a,/le code below can be used as the $O:O:G # to call C)!D#P) fro, within $ % =<. :o call it usin( this /rototy/e" s/ecify so,ethin( li9eH .9##) runCFaddli!le 0y#i!F 14D in your calculation s/ecs. .....D7a,eUUUUUUUUUUU#BDS.......&en(thU:Dc.6unctionsUUUUUUUUUUUUU U D +un )+ E2t)g0>;C)!D#P);? D c,dstr 30009 .onst (1tions>K<arSiFe? D c,dlen 1*) * .onst D c,dDbcs 39 .onst (1tions>K7O ASS? 8ote@ if you;re usin( )odeStudio or =4!;s )ode8400 as your $ % =< editor under Windows" you could si,/ly hi(hli(ht the abo'e source code within your =nternet 4rowser" and co/y it to the Windows cli/board. :hen acti'ate )odeStudio >or )ode8400? and use the aste function to insert the code directly into the editor. retty cool" huh? b([

4uiltIin 7unctions

1. +), =G I 4uiltIin 7unctions :he ori(inal release of $ % =< included a set of builtAin functions. :hese builtAin functions wereH a(e 224 of 250

As400 Stuff OADD$" O ADD$" OS=M#" O#&#!" OSB4S:" O:$=!" O:$=!&" O:$=!$ =n addition" under OS8400 <3$2 and <3$. the O A$!S builtAin function was introduced. Since then" se'eral builtAin functions ha'e been added to $ % =<. :he followin( table /ro'ides the OS8400 <ersion and $elease that the s/ecific builtAin functions were introduced and8or enhanced. 7O:#H =4! See,s to s9i/Ashi/ the $ % =< co,/iler. So $ % =< in <4$1" <4$3 and <4$* has no new functionality. :he ne0t scheduled u/(rade is OS8400 <*$1 in s/rin( 2001.

<ersion $elease <3$.

4uiltAin 6unction OA4S

ara,eters

$eturn <alue Descri/tion

nu,eric e0/ression 'ariable na,e ,e,ory siFe

Absolute 'alue of e0/ression

OADD$ <*$1 OA&&O)

Address of 'ariable ointer to stora(e. the allocated

<4$2 <4$4

O)+A$

(ra/hic" date" ti,e" ti,esta,/" or nu,eric e0/ression co,/areA'alue H dataAtoAsearch f H startA/osition g

<alue in character data ty/e

<*$1

O)+#)3

6irst /osition in the searchedAdata that contains a character not in the list of the characters in the co,/are 'alue. &ast /osition in the searchedA data that contains a character not in the list of the characters in the co,/are 'alue. >Search

<*$1

O)+#)3$

co,/areA'alue H dataAtoAsearch f H startA/osition g

a(e 225 of 250

As400 Stuff

be(ins with the ri(htA,ost character and /roceeds to the left. <*$1 ODA:# f 'alue f H dateA for,atAcode g A date dataAty/e 'alue after con'ertin( the N'alueN to the s/ecified date for,at. =f no 'alue is s/ecified" the current syste, date is returned. A duration 'alue that can be used in an e0/ression to add a nu,ber of days to a date 'alue. <alue in /ac9ed nu,eric for,at. =f di(its and dec/os are s/ecified the result 'alue is for,atted to fit in a 'ariable of the nu,ber of di(its s/ecified. +alfAadjusted 'alue in /ac9ed nu,eric for,at. :he len(th and deci,al /ositions 7u,ber of deci,al di(its.

<*$1

ODAGS

days

<3$.

OD#)

nu,eric e0/ression fHdi(its H dec/osg

<3$.

OD#)+

nu,eric e0/ression H di(its H dec/os nu,eric e0/ression startAdate H endA date H durationA code

<3$.

OD#) OS

<*$1

OD=66

)alculates the difference between two date fields. :he ty/e of difference returned is s/ecified by the durationA code. erfor,s inte(er di'ision and returns the Euotient >result?

<4$4

OD=<

7u,erator Deno,inator

a(e 226 of 250

As400 Stuff

of that di'ision o/eration. <3$. O#D=:) nonAfloat nu,eric e0/ression H edit code fHK)B$SG! e KAS:6=&& e currency sy,bolg nu,eric e0/ression nonAfloat nu,eric e0/ression H edit word array" table" or ,ulti/le occurrence data structure na,e ffile na,eg Strin( 'alue. re/resentin( edited

<3$.

O#D=:6&:

)haracter e0ternal dis/lay re/resentation of float. Strin( 'alue re/resentin( edited

<3$.

O#D=:W

O#&#!

7u,ber of occurrences

ele,ents

or

<4$2

O#O6

;1; if the ,ost recent file in/ut o/eration or write to a subfile >for a /articular file" if s/ecified? e ended in an endA ofAfile or e be(innin(AofAfile condition ;0; otherwise. ;1; if the ,ost recent S#:&& >for a /articular file" if s/ecified? or &OO3B o/eration found an e0act ,atches ;0; otherwise. ;1; if the ,ost recent o/eration code with e0tender ;#; s/ecified resulted in an error ;0; otherwise.

<4$2

O#CBA&

ffile na,eg

<4$2

O#$$O$

a(e 227 of 250

As400 Stuff

<3$.

O6&OA:

nu,eric e0/ression ffile na,eg

<alue in float for,at.

<4$2

O6OB7D

;1; if the ,ost recent rele'ant o/eration >for a /articular file" if s/ecified? found a record >)+A=7" D#&#:#" S#:%:" S#:&&?" an ele,ent >&OO3B ?" or a ,atch >)+#)3" )+#)3$" S)A7? ;0; otherwise. )on'erts character data to doubleAbyte character set 'alue. A duration 'alue that can be used in an e0/ression to add a nu,ber of hours to a ti,e 'alue. <alue in inte(er for,at

<4$4

O%$A +=)

Any 'alue

character

<*$1

O+OB$S

hours

<3$.

O=7:

nu,eric e0/ression nu,eric e0/ression any e0/ression

<3$.

O=7:+

+alfAadjusted 'alue in inte(er for,at

<3$.

O&#7

1. $eturns the len(th of a 'ariable or literal 'alue" or the current len(th of a 'aryin( len(th field. 2. When used on the left side of the eEual si(n" sets the len(th of a 'aryin( len(th field.

a(e 228 of 250

As400 Stuff

<*$1

O&OO3B 00

searchAdata H array f H startA inde0 f H ele,ents to search gg searchAdata H searchedAtable f H alternateAtable g

An array inde0 of the ele,ent in the array where the searchAdata is located.

<*$1

O:&OO3B 00

KO7 if the search is successful" otherwise KO66. >7O:#H :he inde0es of the searchedAtable and alternateAtable are set to the inde0 of the searchAdata if KO7 is returned.? A duration 'alue that can be used in an e0/ression to add a nu,ber of ,inutes to a ti,e 'alue. A duration 'alue that can be used in an e0/ression to add a nu,ber of ,onths to a date 'alue. A duration 'alue that can be used in an e0/ression to add a nu,ber of ,illiseconds to a ti,e 'alue. <alue in indicator for,at re/resentin( the null indicator settin( for the nullA ca/able field. :he current occurrence of the data structure" or sets the current occurrence of the data structure

<*$1

O!=7B:#S

,inutes

<*$1

O!O7:+S

,onths

<*$1

O!S#)O7DS

,illiseconds

<3$.

O7B&&=7D

nullAca/able field na,e

<*$1

OO))B$

dataAstructure

a(e 229 of 250

As400 Stuff

<4$2

OO #7

file na,e

;1; if the s/ecified file ;0; if the s/ecified closed. )onsider this to be an ;=s this file o/eration. Address of /rocedure

is o/en file is builtAin o/en?N

O ADD$ <3$2 <3$<*$1 O A$!S

/rocedure na,e

7u,ber of /ara,eters /assed to /rocedure /ointer H newAsiFe ointer to stora(e. the allocated

O$#A&&O)

<4$4

O$#!

7u,erator Deno,inator

erfor,s inte(er di'ision and returns the re,ainder fro, the di'ision o/eration. Strin( /roduced by insertin( re/lace,ent strin( into source strin(" startin( at start /osition and re/lacin( the s/ecified nu,ber of characters. 6irst /osition of search ar(u,ent in strin( or Fero" if not found.

<4$2

O$# &A)#

re/lace,ent strin(H source strin( fHstart /osition fHsource len(th to re/lacegg search ar(u,ent H strin( to be searched fHstart /ositiong seconds

<3$.

OS)A7

<*$1

OS#)O7DS

A duration 'alue that can be used in an e0/ression to add a nu,ber of seconds to a ti,e 'alue. KO7 if the job is bein( shut down >e.(." when the

<*$1

OS+:D7

a(e 230 of 250

As400 Stuff

W$DW7SGS co,,and issued? otherwise KO66 returned. OS=M# 'ariable" data structure" array" or literal fH KA&&g

is is

7u,ber of bytes used by 'ariable or literal. KA&& returns the nu,ber of bytes used by all the ele,ents of the array" or all the occurrences of the data structure. :he sEuare root of e0/ression or 'alue. the

<*$1

OSC$:

e0/ression 'alue ffile na,eg

or

<4$2

OS:A:BS

0 if no /ro(ra, or file error occurred since the ,ost recent o/eration code with e0tender ;#; s/ecified ,ost recent 'alue set for any /ro(ra, or file status" if an error occurred if a file is s/ecified" the 'alue returned is the ,ost recent status for that file. )haracters addressed by /ointer ar(u,ent u/ to but not includin( the first 0;00;. :he e0tracted co,/onent of the date 'alue. >:he functional eEui'alent of the #P:$): o/eration code.? Substrin( 'alue. =f len(th is not s/ecified" the substrin( be(ins with start and

<3$.

OS:$

/ointerfH,a0i,u , len(thg

<*$1

OSB4D:

date H code

durationA

OSB4S:

strin(H startfHlen(thg

a(e 231 of 250

As400 Stuff

continues throu(h the end of the strin(. <*$1 O:+=S Bsed for 5a'a inte(ration. $eturns an Object reference. f 'alue f H ti,eA for,atAcode g A ti,e dataAty/e 'alue after con'ertin( the N'alueN to the s/ecified ti,e for,at. =f no 'alue is s/ecified" the current syste, ti,e is returned. A ti,esta,/ dataAty/e 'alue with or without se/arators. Strin( with left and ri(ht blan9s tri,,ed >re,o'ed? Strin( with tri,,ed Strin( with tri,,ed character $eturns 'alue. a left blan9s

<*$1

O:=!#

<*$1

O:=!#S:A!

f'alue f H K=SO e K=SO0 g strin(

O:$=!

O:$=!&

strin(

O:$=!$

strin(

ri(ht

blan9s

<4$4

OB)S2

Any 'alue

'aryin(

len(th

<4$2

OB7S

nu,eric e0/ression nu,eric e0/ression fro,Atable H toA table H strin(AtoA

<alue in unsi(ned for,at

<4$2

OB7S+

+alfAadjusted 'alue unsi(ned for,at :he con'erted strin(

in

<*$1

OP&A:#

is

a(e 232 of 250

As400 Stuff

con'ert startin(A /osition g <4$4 OP6OO: Array na,e

returned.

)ross foots >totals? all the ele,ents in an array.

1. 7igurati-e constants in +),#E K+=<A&" K&O<A&" KM#$O" KM#$OS" K4&A73S" S#:&&" S#:%:.

2. E21lain 9 9

<+, 6<4 <+, EA>+.> and >E6>" <+@

=t is a /owerful o/code" which is used to add any date related function to a /articular date" ti,e or ti,esta,/. E2a01le@ S3A7DASA!O8DA:# ADDDB$ KKKKKKKKKKKKKKK 4e(innin( of data KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK 0000.01 dKdate function usin( the adddur 0001.00 D:=!#S:# 0001.01 D:=!#* 0002.00 DDA:#1 0002.01 DDA:#2 0002.02 DDA:#3 S S S S S M M D D D

a(e 233 of 250

As400 Stuff

0002.03 DDA:#4 0003.00 D:=!#1 0003.01 D:=!#2 0003.02 D:=!#3 0003.03 D:=!#4 0004.00 ) 000*.00 ) 000-.00 ) 000..00 ) 000..01 ) 000..02 ) 0001.00 ) 0002.00 )K 0010.00 ) 0011.00 ) 0012.00 ) 0013.00 ) 0014.00 ) 0014.01 ) 0014.02 ) 0014.03 ) 0014.04 ) 0014.0* ) 001*.00 ) :=!#1 :=!#1 :=!#1 :=!#S:# DA:#2 DA:#3 DA:#4 :=!#1 :=!#2 :=!#3 :=!#4 :=!#* DA:#1 DA:#1 DA:#1

S S S S S !O<#&

D : : : : KDA:# 02HKG 0*HK! 01HKD :=!#1 :=!#S:# 10HK+ 10HK!& 10HKS 10HK!S :=!#2 :=!#3 :=!#4 :=!#* DA:#1 DA:#2 DA:#3 DA:#4

ADDDB$ ADDDB$ ADDDB$ :=!# :=!# ADDDB$ ADDDB$ ADDDB$ ADDDB$ DS &G DS &G DS &G DS &G DS &G DS &G DS &G DS &G S#:O7

&$

a(e 234 of 250

As400 Stuff

KKKKKKKKKKKKKKKKKK #nd of data KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK OB: B: DS &G 2004A0-A2. DS &G 2002A11A2. DS &G 2002A0-A21 DS &G 12.11.3DS &G 22.11.3DS &G 00.00.00 DS &G 12.11.4DS &G 2002A0-A2.A12.11.3-.2*3010

6<4 <+@ =t is used to find the difference between two date >or? ti,e >or? ti,e sta,/ #0a,/le S3A7DASA!O8DA:# SB4DB$ KKKKKKKKKKKKKKK 4e(innin( of data KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK 0000.01 dKdate function usin( the SB4DB$ 0001.00 D:=!#S:# 0001.01 D:=!#* 0002.00 DDA:#1 0002.01 DDA:#2 0002.02 DDA:#3 S S S S S M M D =7M >D;12..A0-A20;? D D

a(e 235 of 250

As400 Stuff

0002.03 DDA:#4 0003.00 D:=!#2 0003.01 D:=!#1 0003.02 D:=!#3 0003.03 D:=!#4 000*.00 ) 000-.00 ) 000..00 ) 000..01 ) 0001.00 ) 0010.00 ) 0012.00 ) 0013.00 ) 0014.00 ) 0014.01 ) 0014.02 ) 0014.03 ) 0014.04 ) 001*.00 ) :=!#2 :=!#2 DA:#2 DA:#3 DA:#4 :=!#1 :=!#2 :=!#3 :=!#4 DA:#1 DA:#1 DA:#1

S S S S S SB4DB$ SB4DB$ SB4DB$ :=!# SB4DB$ SB4DB$ DS &G DS &G DS &G DS &G DS &G DS &G DS &G S#:O7

D : =7M >:;12. *0.10@? : : : 02HKD 0*HK! 01HKG :=!#1 10HK+ 10HKS :=!#1 :=!#4 DA:#2 DA:#3 DA:#4

&$

KKKKKKKKKKKKKKKKKK #nd of data KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK OB: B: DS &G 12..A0-A11 DS &G 12..A01A20 DS &G 12.-A0-A20

a(e 236 of 250

As400 Stuff

DS &G 02.*0.10 DS &G 12.*0.10 DS &G 00.00.00 DS &G 12.*0.00 #P:$):H =t is used to e0tract year" ,onth" day" hours" ,inutes" seconds" and ,icroseconds of a ti,e sta,/ or date field. E2a01le@ S3A7DASA!O8DA:# #P$): KKKKKKKKKKKKKKK 4e(innin( of data KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK 0000.01 dK6=7: :+# #P$): DAG !O7:+ G#A$ 0001.00 D:=!#S:# 0002.00 DDA:#1 0002.01 DDA:#3 0002.02 DDA:#2 0002.04 DDA:#4 0002.0* DDA:#* 0002.0- DDA:#0002.0. DDA:#. 0002.01 DDA:#1 0003.00 D:=!#0 0003.01 D:=!#1 0003.02 D:=!#2 0003.03 D:=!#4 S S S S S S S S S S S S S M D =7M >D;12..A0-A20;? D * 0 * 0 * 0 * 0 * 0 * 0 : =7M >:;12. *0.10@? : * 0 * 0

a(e 237 of 250

As400 Stuff

0003.04 D:=!#* 0003.0* D:=!#0003.0- D:=!#3 0004.00 ) 0004.01 ) 0004.02 ) 000*.00 ) 000-.00 ) 000..00 ) 000..01 ) 000..02 ) 000..03 ) 000..04 ) 000..0* ) 000..0- ) 000..0. ) 0011.00 ) 0012.00 ) 0013.00 ) 0013.01 ) 0013.02 ) 0013.03 ) 0014.00 ) 0014.01 ) DA:#2 DA:#1 DA:#4 DA:#* DA:#DA:#. :=!#2

S S S !O<#& :=!# :=!# #P:$): #P:$): #P:$): #P:$): #P:$): #P:$): #P:$): #P:$): #P:$): #P:$): #P:$): DS &G DS &G DS &G DS &G DS &G DS &G DS &G

* 0 * 0 2- 0 KDA:# DA:#3 :=!#1 :=!#S:# DA:#1HK! DA:#3HK! DA:#1HKD DA:#3HKD DA:#1HKG DA:#3HKG :=!#1HK+ :=!#1HK+ :=!#0HK+ :=!#0HKS DA:#2 DA:#4 DA:#* DA:#DA:#. DA:#1 :=!#2 :=!#4 :=!#* :=!#-

:=!#S:#HK!S :=!#3

a(e 238 of 250

As400 Stuff

0014.02 ) 0014.03 ) 0014.04 ) 0014.0* ) 001*.00 )

:=!#4 :=!#* :=!#:=!#3

DS &G DS &G DS &G DS &G S#:O7 &$

OB: B: DS &G -

DS &G 2002 DS &G DS &G DS &G 20 2.

DS &G 12.. DS &G DS &G DS &G DS &G DS &G :#S:H :est is the ,ost /owerful o/code" which will chec9 a date is a 'alid" or not .:he low le'el indicator is set on if the date is not 'alid or set off if the date is a 'alid one. :est will be (i'en with e0tended factor li9e test >d?" test >t?" test >F? for date" ti,e and ti,e sta,/ and if test without e0tended factor default to date >F?. #0a,/le S3A7DASA!O8DA:# a(e 239 of 250 12 12 12 10 441000

As400 Stuff

:#S: KKKKKKKKKKKKKKK 4e(innin( of data KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK 0000.01 )K:#S: 6O$ <A&=D DA:# :+# DA:# <A&=D S#:O66 O$ S#:O7 >7O:<A&=D? 0001.00 ) 0002.00 ) 0003.00 ) 0003.01 ) 0003.02 ) 0003.03 ) 0003.04 ) 0003.0* ) 0004.00 ) ;<A&=D; K=730 =6 ;7O:<A=&D; #&S# DS &G #7D=6 S#:O7 &$ !O<#& :#S: >D? DS &G K=730LKO7 DS &G ;1380381222@ A A 10 30

KKKKKKKKKKKKKKKKKK #nd of data KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK OB: B: DS &G 1 DS &G 7O:<A=&D

3. E21lain .o01ile ti0e array, looEu1, sortIa, 2Ifoot, and +un ti0e array" .o01ile ti0e array :he co,/ile ti,e array ,eans the ele,ents of the array will be loaded before the e0ecution of the /ro(ra,s. :he 'alue will be static. We ,ust declare in 9eyword co,,and D=! >?" ):D:A: >?" and #$$)D >?. We are (i'in( the 'alue in after the S#:O7 &$. E2a01le a(e 240 of 250

As400 Stuff

S3A7DASA!O8A$$AG )O!=&# KKKKKKKKKKKKKKK 4e(innin( of data KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK 0000.01 0001.00 0002.00 0003.00 0004.00 000*.00 000-.00 000..00 0001.00 KK 0002.00 1001 0010.00 20 0011.00 1000 KKKKKKKKKKKKKKKKKK #nd of data KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK OB: B: DS &G 1001 DS &G 20 DS &G 1000 +un ti0e array :he run ti,e array ,eans the 'alue will be loaded durin( the runti,e only. :he 'alue will be dyna,ic. S3A7DASA!O8A$$AG $B7:=!# cKco,/ile ti,e array darr1 di c c c c c i arr1>i? s s do ds/ly add enddo seton 1 i 3 4 di,>3? ctdata /errcd>1?

2/ 0 inF>1?

a(e 241 of 250

As400 Stuff

KKKKKKKKKKKKKKK 4e(innin( of data KKKKKKKKKKKKKKKKKKKKKKKKKKKKK 0000.01 cKrunti,e array 0001.00 darr1 0002.00 di 0002.01 da 0002.02 dj 0003.00 c 0003.01 c 0003.02 cK 0003.03 c 0003.04 c 0003.0* c 0004.00 c 000*.01 c 000-.00 c 000..00 c j arr1>j? i s s s s do ds/ly e'al add enddo do ds/ly add enddo seton lr 1 j 12 12 arr1>i? arr1>i?La 1 i 10 di,>12?

2/ 0 inF>1? 3/ 0 2/ 0 inF>1?

KKKKKKKKKKKKKKKKKK #nd of data KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK looEu1, sorta, 2foot @ S3A7DASA!O8A$$AG SO$:A$$AG

KKKKKKKKKKKKKKK 4e(innin( of data KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK 0000.01 cKloo9u/"0footDsorta e0a,/les 0001.00 darr1 0002.00 di s s 4 0 di,>3? ctdata /errcd>1? 2/ 0 inF>1? a(e 242 of 250

As400 Stuff

0002.01 dj 0002.02 dd 0003.00 c 0004.00 c 000*.00 c 000-.00 c 000-.01 c 000-.02 c 000-.03 c 000-.04 c 000-.0* c 000-.0- c 000-.0. c 000-.01 000-.02 000-.10 000-.11 000-.12 000-.13 000..00 0001.00 KK 0002.00 1001 0010.00 2000 0011.00 1000 1000 i arr1>i?

s s do ds/ly add enddo sorta 0foot loo9u/ if ;found; ds/ly else ;notfou; ds/ly c c c c c c c d j endif ds/ly do 3

2/ 0 inF>1? 4/ 0

arr1 arr1 arr1 d 40

Kin40LKon

arr1>j? ds/ly add enddo seton 1 j

a(e 243 of 250

As400 Stuff

KKKKKKKKKKKKKKKKKK #nd of data KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK DS &G 1001 DS &G 2000 DS &G 1000 DS &G found DS &G 4001 DS &G 1000 DS &G 1001 DS &G 2000 )re runti0e array re runti,e array is in between these 2 conditions where the 'alue is static and the 'alue will be retrie'ed fro, dis9 and loaded into the array. As a result there is no need to retrie'e the 'alue e'ery ti,e fro, the dis9 and usa(e of /re runti,e array ,a9es it fast. We ,ust declare in 9eyword co,,and D=! >?" 6$O!6=&# >?" and #$$)D >?.

1. %&at is t&e different !et'een +E9 E and ./9=8 (1codes" $#AD# 1.:he ,atchin( records for table 2. We are usin( the loo/in( conce/t 3.:he indicator Set =n the #C 4. We are ,ost usin( in S#:%: or S#:&& )+A=7 :he first ,atchin( records only &oo/in( is not necessary :he indicator Set =n the += =t is not necessary

2. E21lain 4uild in function in =#E" OSB4S: C6tring na0e@ 6tring 1osition@ lengt&D

a(e 244 of 250

As400 Stuff

OA4S C9!solute -alue !y o0itting signD O#D=:) Cstring@ SAJD =n a a11lication if 'e 'ant to concatenate a string 'it& a nu0eric t&en 'e can use t&is HE =>. E2a01le@ S3A7DASA!O84B&=D #D=:) KKKKKKKKKKKKKKK 4e(innin( of data KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK 0001.00 da 0002.00 db 0003.00 dc 0004.00 dd 000*.00 de 000-.00 dout 000..00 c 0002.00 c 0010.00 c 0011.00 KKKKKKKKKKKKKKKKKK #nd of data KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK OB: B: DS &G shya, 0000000020sundar 0000000012ra,babu out s s s s s s e'al ds/ly seton lr 10a inF>;shya,;? 10/ 0 inF>20? 10a inF>;sundar;? 10s 0 inF>12? 10a inF>;ra,babu;? *0a outLaUOeditc>bH;P;?UcUOeditc>dH;P;?Ue

O$# &A)# C+e1lacing string, actual string, starting 1osition, offsetD /ere 'e are re1lacing senthil9u,ar fro0 1osition 4 to 3 !y 9u,. >&e out1ut 'ill !e sen9u,l9u,ar. S3A7DASA!O84B&=D $# &A)#

a(e 245 of 250

As400 Stuff

KKKKKKKKKKKKKKK 4e(innin( of data KKKKKKKKKKKKKKKKKKKKKKKKKKKK 0000.01 dKre/lace the strin( usin( 9eyword Ore/lace 0001.00 dc 0002.00 db 0003.00 c 0004.00 c 000*.00 c b s s e'al ds/ly seton lr 1-a inF>;senthil9u,ar;? 20a bLOre/lace>;9u,;HcH4H3?

KKKKKKKKKKKKKKKKKK #nd of data KKKKKKKKKKKKKKKKKKKKKKKKKKKKK OB: B: DS &G sen9u,l9u,ar

O:$=! CH>+=*#, H>+=*+D :he use of the :$=! functions is 'ery li,ited" in that they su//ort only the use of character 'ariables and data structures. 7u,eric fields and FeroAfill 'alues are not su//orted. :hey do" howe'er" /ro'ide so,e useful function for strin( handlin(. 6or e0a,/le" in $ % =<" one line of code is all that;s needed to leftA adjust a 'alue within a field. 6or e0a,/leH .....))$n016actor1UUUUUUUO/)ode>e0?6actor2UUUUUUU$esultUUUUUUU U&enUUDc+i&o#E . E270t.ust*aint . E-al .ust8a0ePH>ri0#C.ust8a0eD :y/ically" the O:$=! function is the only one of the three that (et used. :he other two" howe'er" do ha'e their /lace. O:$=! re,o'es trailin( and leadin( blan9s fro, a field" and returns the re,ainin( 'alue" in /lace" within the e0/ression. :he returned 'alue is treated si,ilar to a constant 'alue with leadin( or trailin( blan9s. O:$=!& re,o'es leadin( blan9s >tri,Aleft? fro, a field" and returns the 'alue in /lace" within the e0/ression. O:$=!$ re,o'es trailin( blan9s >tri,Ari(ht? fro, a field" and returns the 'alue in /lace" within the e0/ression. a(e 246 of 250

As400 Stuff

O6OB7D" O#O6" O#CBA&"OO #7 OS8400 <ersion 4" $elease 2 $ % =< su//orts the eli,ination of the $esultin( =ndicators. =n their /lace" se'eral new builtAin functions ha'e been introduced. !ost of these new builtAin function /ro'ide infor,ation about the result of 6ile o/erations si,ilar to the $esult indicators. 4ut instead of codin( $esultin( indicator 3" for e0a,/le" to chec9 for the endAofAfile condition" you si,/ly chec9 the 'alue of the O#O6 builtAin function. :he builtAin functions that re/lace the $esultin( =ndicators includeH O6OB7D" O#O6" O#CBA&. =n addition" there are OO #7" OS:A:BS" and O#$$O$. !ysteriously ,issin( is O&O)3 to chec9 for a record loc9 condition. H7(<8 returns an KO7 or KO66 condition if the /re'ious 6ile o/eration returns a recordAfound condition. :his is /articularly useful on the )+A=7 o/eration. $ealiFe" howe'er" that when )+A=7 sets on $esultin( indicator 1" a notA found condition is si(naled. Whereas" without codin( $esultin( =ndicator 1" the O6OB7D builtAin function returns the !ound condition. HE(7 can be used to chec9 for endAof file" be(innin( of file" or subfile full conditions. A $#AD and $#AD# return O#O6LKO7 if the end of file is reached. $#AD and $#AD # return O#O6LKO7 if the be(innin( of file is reached. :he W$=:# o/eration returns O#O6LKO7 if the W$=:# o/eration to a subfile detail record returned a subfileAfull condition. HE;<9# is used by the S#:&& o/eration to indicate that it detected a record in the file with a 9ey eEual to that of the 'alue s/ecified in 6actor 1. Since S#:&& does not read the record" does not loc9 the record" and does not co/y the data into the in/ut buffer" S#:&& is ,uch faster and less of an i,/act on the /erfor,ance of the a//lication than other o/erations" such as )+A=7. Bse )+A=7 when you need to retrie'e the record" use S#:&& and O#CBA& when you need to only chec9 for the e0istence of a record. H()E8 is used to chec9 to see if a file has already been o/ened. :he builtA in function returns KO7 if the file is o/ened" otherwise it returns KO66. O#&#! HE#E* 'ill dis1lay t&e array di0ension #&#! KKKKKKKKKKKKKKK 4e(innin( of data KKKKKKKKKKKKKKKKKKKKKKKKKKKKKK 0001.00 darr1 0002.00 dc 0003.00 c s e'al s 3s 0 di,>100? 3s 0 cLOele,>arr1?

a(e 247 of 250

As400 Stuff

0004.00 c 000*.00 c

ds/ly seton lr

KKKKKKKKKKKKKKKKKK #nd of data KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK OB: B: DS &G 100 OS=M# H6=QE 'ill dis1lay t&e siBe of t&e -aria!le S3A7DASA!O84B&=D S=M# KKKKKKKKKKKKKKK 4e(innin( of data KKKKKKKKKKKKKKKKKKKKKKKKKKKKK 0000.01 DK4G BS=7% :+=S )O!!A7D 6=7D S=M# O6 DA:A <A&B# 0001.00 darr1 0002.00 dds1 0003.00 dnu, 0004.00 c 000*.00 c 000-.00 c 000..00 c 0001.00 c 0002.00 c 0010.00 c 0011.00 c 0012.00 c 0013.00 c 0014.00 c nu, nu, nu, nu, ds/ly e'al ds/ly e'al ds/ly e'al ds/ly nu,LOsiFe>arr1HKall? nu,LOsiFe>arr1? nu,LOsiFe>b? s s s FAadd ,o'el e'al 2 ;senthil; 10/ 0 di,>10? 10/ 0 di,>20? 20/ 0 a b 20 0 10

nu,LOsiFe>a?

a(e 248 of 250

As400 Stuff

001*.00 c 001-.00 c 001..00 c 0011.00 c 0012.00 c nu, nu,

e'al ds/ly e'al ds/ly seton

nu,LOsiFe>ds1?

nu,LOsiFe>ds1HKall?

lr

KKKKKKKKKKKKKKKKKK #nd of data KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK OB: B: DS &G DS &G DS &G DS &G DS &G DS &G 6)#? O#D=:W 11 10 -0 120

/ References: &tt1@::'''.allinter-ie'.co0:=nter-ie'I;uestions:+),400.&t0l htt/H88/ublib.boulder.ib,.co,8iseries8'*r18ic22248boo9s8c022*01310.ht,_+ D$ $O%P # htt/H88/ublib.boulder.ib,.co,8iseries8'*r18ic22248boo9s8c022*013...ht,_+ D$6=&#P #

a(e 249 of 250

As400 Stuff

htt/H88faE.,idran(e.co,8data8cache813.ht,l htt/H88/ublib.boulder.ib,.co,8iseries8'*r28ic22248info8db/8rbafo,st122.ht, _+D$O 7C6 htt/H88www.(eocities.co,8Silicon<alley8+ills8--328o/nEryf.ht,l


htt/H88www.allinter'iew.co,8=nter'iewACuestions8$ %400.ht,l htt/H88su,edh.shende.(oo(le/a(es.co,8as400inter'iewEuestions/artii

a(e 250 of 250

Você também pode gostar