You are on page 1of 14

WORK WITH LOGICAL-FILE

Day 4
Logical Files:
Overview:
This module enables the student to understand the concept of Logical File.
Outline:
Topics covered,
Logical fle creation
Concept of Keyed !e"uential access
Commands related to fles
Obective:
#y the end of this module, the student should be able to$
Create a Logical fle
%nderstand the part of Logical fles.
Commands related to fles.
& Du'e!tar Technologies (vt. Ltd. )*)4
No part of this document can be copied, reproduced in any form, complete or partial without written consent from DukeStar Technologies Pvt.
Ltd.
WORK WITH LOGICAL-FILE
Day 4
Logical File:
+ logical fle is provide access the data stored in one or more physical fles. The features
uni"ue to logical fles include the follo,ing$
). Logical fles do not contain data.
-. +ccess one or more physical fles in an arrival se"uence or in any single or multiple
feld .'ey/ value order.
0. + physical fle may be processed by any number of logical fles.
4. T,o or more logical fles may share the same access path.
1. 2mit and select criteria may be specifed in a logical fle to process only the
re"uired physical fle data.
3. + logical fle may include multiple record formats. 4ach format ho,ever must relate
to one or more physical fles and include at least one 'ey feld.
5. 2ne logical fle ,ith multiple record formats may process only the re"uired physical
fle data.
6. + logical fle ,ith multiple record formats may be used to process the data from
more than one physical fle. The fle record formats accessed may be of di7erent
lengths.
8 During processing a physical fle9s feld attributes may be changed by a logical fle.
:o,ever, the data stored in the physical fle not be modifed.
Logical fles may be specifed as either nonoin or oin. + non;oin logical fle processes
each record individually from one or more physical fles. <oin logical fles ho,ever create a
single record from the selected felds from t,o or more physical fles.
The t!"e of logical fle .non;oin or ;oin/ specifed is determined in the related DD! coding.
=n the follo,ing te>t, the processing logic and DD! synta> for non;oin logical fles are
introduced frst, follo,ed by the coding re"uirements associated ,ith ;oin logical fles.
#O#$OI# LOGICAL FILE% &O#E-RECOR' FOR(AT)
+ll logical fles are formatted and defned by DD! coding. The DD! coding for non;oin
logical fles is specifed in the follo,ing order.
). File level entries .optional/
-. ?ecord level entries
0. Field level entries .optional/
4. Key feld level entries .optional/
1. !elect*omit level entries .optional/.
@onA;oin logical fles may specify more than one record format. =f t,o or more physical fles
,ith di7erent record formats are to be used by a logical fle, separate (F=L4 'ey,ords must
be specifed. Bhen the record formats are the same, only one (F=L4 'ey,ords is re"uired.
+ ma>imum of 0- physical fles may be referenced in one (F=L4 'ey,ord.
Bhen t,o or more physical fles ,ith a logical fle accesses di7erent record formats.
C@2@4 may be specifed as a 'ey feld substance for any of the follo,ing conditions$
). The related 'eyfelds from the physical fles do not have the same attributes.
-. The 'ey felds from the physical fles have the same attributes, but they are not to
be merged and se"uenced together.
!pecify the entries in the follo,ing order to defne a simple or multiple format logical fle$
). FileAlevel entries .optional/
-. ?ecordAlevel entries
0. FieldAlevel entries .optional/
4. Key feld level entries .optional/
1. !elect and omitAfeld level entries .optional/
& Du'e!tar Technologies (vt. Ltd. -*)4
No part of this document can be copied, reproduced in any form, complete or partial without written consent from DukeStar Technologies Pvt.
Ltd.
WORK WITH LOGICAL-FILE
Day 4
:o, to create simple logical fleD Create student pf fle as discussed above. Li'e physical
fle create logical fle as sho,n belo,. (ress *F+, -
I# #E.T %TE/ 0O1 HA2E TO WRITE %O1RCE T0/E A% *LF, - %O1RCE (E(3ER 4
Start Source Entry Utility (STRSEU)

Type choices, press Enter.

Source file . . . . . . . . . . > MYDDS Name, !R"
#i$rary . . . . . . . .> !%&'U&'D Name, #(%#, )UR#(%, !R"
Source mem$er . . . . . . . . . #STUDENT Name, !R", SE#E)T
Source type . . . . . . . . . . #* Name, S+ME, %+S, %+S!...
Te,t -.escription/ . . . . . . . -#01()+# *(#E *0R STUDENT/











%ottom
*23E,it *43!rompt *53Refresh *'63)ancel *'237o8 to use this .isplay
*643More 9eys
PRESS ENTER SO THAT YOU GET THE FOLLOWING SCREEN
)olumns . . . : ' ;' E.it S7EET<=SR)
SEU33> #STUDENT
*MT #* .....+..........T.Name>>>>>>.#en>>TDp%......*unctions>>>>>>>>>>>>>>>>>>
%e?innin? of .ata
@@@@@@@
@@@@@@@
@@@@@@@
@@@@@@@
@@@@@@@
@@@@@@@
@@@@@@@
@@@@@@@
@@@@@@@
@@@@@@@
@@@@@@@
@@@@@@@
@@@@@@@
@@@@@@@
@@@@@@@
En. of .ata

*23E,it *43!rompt *53Refresh *A3RetrieBe *'&3)ursor *''3To??le
*'C3Repeat fin. *';3Repeat chan?e *643More 9eys
Mem$er #STUDENT a..e. tofile !N&'U&'D<MYDDS.
>
AFTER T0/I#G *I/LF, A% %HOW# A3O2E 1%ER GET% THE FOLLOWI#G /RO(/T
& Du'e!tar Technologies (vt. Ltd. 0*)4
No part of this document can be copied, reproduced in any form, complete or partial without written consent from DukeStar Technologies Pvt.
Ltd.
WORK WITH LOGICAL-FILE
Day 4
)olumns . . . : ' ;' E.it !%&'U&'D<MYDDS
SEU33> #STUDENT
*MT #* .....+..........T.Name>>>>>>.#en>>TDp%......*unctions>>>>>>>>>>>>>>>>>>
%e?innin? of .ata
@@@@@@@
En. of .ata





!rompt type . . . #* SeDuence num$er . . . EFFFFF

Name Data Decimal
Type Name #en?th Type !ositions Use
*unctions

*23E,it *43!rompt *53Refresh *''3!reBious recor. *'63)ancel *623Select prompt
*643More 9eys
Enter re5erence 6le using */FILE&FILE #A(E), 5unction 7e! as well as recor8
5or9at na9e as s:own below :
)olumns . . . : ' ;' E.it !%&'U&'D<MYDDS
SEU33> #STUDENT
*MT #* .....+..........T.Name>>>>>>.#en>>TDp%......*unctions>>>>>>>>>>>>>>>>>>
%e?innin? of .ata
&&&'.&& + R SR !*(#E(STUDENT)
En. of .ata







!rompt type . . . #* SeDuence num$er . . . &&&'.&&
Name Data Decimal
Type Name #en?th Type !ositions Use
R SR
*unctions
!*(#E(STUDENT)
*23E,it *43!rompt *53Refresh *''3!reBious recor.
*'63)ancel *623Select prompt *643More 9eys
Enter 7e! 6el8 o5 re5erre8 ":!sical 6le :
& Du'e!tar Technologies (vt. Ltd. 4*)4
No part of this document can be copied, reproduced in any form, complete or partial without written consent from DukeStar Technologies Pvt.
Ltd.
File name using (F=L4./
WORK WITH LOGICAL-FILE
Day 4
)olumns . . . : ' ;' E.it !%&'U&'D<MYDDS
SEU33> #STUDENT
*MT #* .....+..........T.Name>>>>>>.#en>>TDp%......*unctions>>>>>>>>>>>>>>>>>>
%e?innin? of .ata
&&&'.&& + R SR !*(#E(STUDENT)
&&&6.&& G R0##
En. of .ata





!rompt type . . . #* SeDuence num$er . . . &&&6.&&
Name Type Name #en?th Type Decimal !ositions Use
G R0##
*unctions
*23E,it *43!rompt *53Refresh *''3!reBious recor.
*'63)ancel *623Select prompt *643More 9eys

/ress F; an8 use o"tion <= to co9"ile t:e above 6le an8 create obect in
/3><1><O an8 Run?r! co99an8 5or above logical 6le gives 5ollowing out"ut:
Display Report
Report 8i.th . . . . . : 2A
!osition to line . . . . . Shift to column . . . . . .
#ine ....>....'....>....6....>....2....>....
R0## SN+ME ))D )0RS +DD )(TY
&&&&&' '&' sneha BB "% pune pune
&&&&&6 '&6 ramesh hh ) mum$ai mum$ai
&&&&&2 '&2 titu iii +S mum$ai pune
&&&&&4 '&4 rahul +S4&& "% pune pune
En. of report










%ottom
*23E,it *'63)ancel *'A3#eft *6&3Ri?ht *6'3Split
?eference fle name and 'ey feld gives all feld from related physical fle. #ut in logical fle
user is able to select particular feld as sho,n belo,. <ust insert the re"uired feld name as
per above defne se"uence$
& Du'e!tar Technologies (vt. Ltd. 1*)4
No part of this document can be copied, reproduced in any form, complete or partial without written consent from DukeStar Technologies Pvt.
Ltd.
Key feld name
Key
Field
@ame
WORK WITH LOGICAL-FILE
Day 4
)olumns . . . : ' ;' E.it !%&'U&'D<MYDDS
SEU33> #STUDENT
*MT #* .....+..........T.Name>>>>>>.#en>>TDp%......*unctions>>>>>>>>>>>>>>>>>>
%e?innin? of .ata
&&&'.&& + R RSTUDENT !*(#E(STUDENT)
&&&6.&& + R0##
&&&2.&& + SN+ME
&&&4.&& + )0RS
&&&5.&& + G R0##
En. of .ata


*23E,it *43!rompt *53Refresh *A3RetrieBe *'&3)ursor *''3To??le
*'C3Repeat fin. *';3Repeat chan?e *643More 9eys
H )0!YR(17T (%M )0R!. 'AI', 6&&6.
Above logical 6le s:ows 5ollowing out"ut:
1se R1#@R0 co99an8 on co99an8 "ro9"t to see t:e out"utA
Display Report
Report 8i.th . . . . . : 'A
!osition to line . . . . . Shift to column . . . . . .
#ine ....>....'....>....
R0## SN+ME )0RS
&&&&&' '&' sneha BB
&&&&&6 '&6 ramesh hh
&&&&&2 '&2 titu iii
&&&&&4 '&4 rahul +S4&&
En. of report










%ottom
*23E,it *'63)ancel *'A3#eft *6&3Ri?ht *6'3Split

Also !ou are able to 8e6ne 9ulti5or9at logical 6le as s:own below:
)olumns . . . : ' ;' E.it !%&'U&'S<MYDDS
SEU33> #STUDENT
& Du'e!tar Technologies (vt. Ltd. 3*)4
No part of this document can be copied, reproduced in any form, complete or partial without written consent from DukeStar Technologies Pvt.
Ltd.
WORK WITH LOGICAL-FILE
Day 4
*MT #* .....+..........T.Name>>>>>>.#en>>TDp%......*unctions>>>>>>>>>>>>>>>>>>
%e?innin? of .ata
&&&'.&& + R RS !*(#E(STUDENT)
&&&6.&& + R0##
&&&2.&& + SN+ME
&&&4.&& + )0RS
&&&5.&& + G R0##
&&&5.&'
&&&C.&& + R R)0RS !*(#E()0RS)
&&&;.&& + G ))D
En. of .ata






*23E,it *43!rompt *53Refresh *A3RetrieBe *'&3)ursor *''3To??le
*'C3Repeat fin. *';3Repeat chan?e *643More 9eys

HOW TO 1%E COLH'G - *TE.T, KBW:
Colu9ns A A A : < C< E8it /3><1><'B(0''%
SEU33> #STUDENT
*MT #* .....+..........T.Name>>>>>>.#en>>TDp%......*unctions>>>>>>>>>>>>>>>>>>
%e?innin? of .ata
&&&'.&& + R RS !*(#E(STUDENT)
&&&6.&& + R0## )0#7D1(-R0## N0/)
&&&2.&& + N+ME TEJT(-STUDENT DET+(#/)
&&&4.&& + )0RS
&&&5.&& + G R0##
En. of .ata









*23E,it *43!rompt *53Refresh *A3RetrieBe *'&3)ursor *''3To??le
*'C3Repeat fin. *';3Repeat chan?e *643More 9eys
H )0!YR(17T (%M )0R!. 'AI', 6&&6.
O1T/1T OF COLH'G - TE.T KE0WOR' :
Display Report
Report 8i.th . . . . . : 6'
!osition to line . . . . . Shift to column . . . . . .
& Du'e!tar Technologies (vt. Ltd. 5*)4
No part of this document can be copied, reproduced in any form, complete or partial without written consent from DukeStar Technologies Pvt.
Ltd.
WORK WITH LOGICAL-FILE
Day 4
#ine ....>....'....>....6.
R0## N0 SN+ME )0RS
&&&&&' '&' sneha BB
&&&&&6 '&6 ramesh hh
&&&&&2 '&2 titu iii
&&&&&4 '&4 rahul +S4&&
En. of report








%ottom
*23E,it *'63)ancel *'A3#eft *6&3Ri?ht *6'3Split

The following keywords are select and omit level keywords:
1.COMP 2.RANGE 3. VALUE
HOU TO USE ABOVE KEYWORD WITH SELECT & OMIT:
)olumns . . . : ' ;' E.it !%&'U&'D<MYDDS
SEU33> #STUDENT
*MT #* .....+..........T.Name>>>>>>.#en>>TDp%......*unctions>>>>>>>>>>>>>>>>>>
%e?innin? of .ata
&&&'.&& + R RS !*(#E(STUDENT)
&&&6.&& + R0## )0#7D1(-R0## N0/)
&&&2.&& + N+ME TEJT(-STUDENT DET+(#/)
&&&4.&& + )0RS
&&&4.&' + G R0##
&&&5.&& + S R0## )0M!(1T '&6)
En. of .ata


!rompt type . . . #* SeDuence num$er . . . &&&4.&'

Name Data Decimal
Type Name #en?th Type !ositions Use
S R0##
*unctions
)0M!(1T '&6)

*23E,it *43!rompt *53Refresh *''3!reBious recor.
*'63)ancel *623Select prompt *643More 9eys
+bove feld sho,s the follo,ing output$
& Du'e!tar Technologies (vt. Ltd. 6*)4
No part of this document can be copied, reproduced in any form, complete or partial without written consent from DukeStar Technologies Pvt.
Ltd.
F2?
!4L4CT
K*B
F2? T:4 !4L4CT4D
WORK WITH LOGICAL-FILE
Day 4
Display Report
Report 8i.th . . . . . : 6'
!osition to line . . . . . Shift to column . . . . . .
#ine ....>....'....>....6.
R0## N0 SN+ME )0RS
&&&&&' '&2 titu iii
&&&&&6 '&4 rahul +S4&&
En. of report











%ottom
*23E,it *'63)ancel *'A3#eft *6&3Ri?ht *6'3Split

Like that we are able to use range and value keyword with logical fle. Now use of omits keyword
with logical fle.
)olumns . . . : ' ;' E.it !%&'U&'D<MYDDS
SEU33> #STUDENT
*MT #*.....+..........T.Name>>>>>>.#en>>TDp%......*unctions>>>>>>>>>>>>>>>>>>
%e?innin? of .ata
&&&'.&& + R RS !*(#E(STUDENT)
&&&6.&& + R0## )0#7D1(-R0## N0/)
&&&2.&& + N+ME TEJT(-STUDENT DET+(#/)
&&&4.&& + )0RS
&&&4.&' + G R0##
&&&5.&& + 0 R0## )0M!(1T '&6)
En. of .ata









*23E,it *43!rompt *53Refresh *A3RetrieBe *'&3)ursor *''3To??le
*'C3Repeat fin. *';3Repeat chan?e *643More 9eys
H )0!YR(17T (%M )0R!. 'AI', 6&&6.
Note: Omit keyword is always used with DYNSLT to omit the value. This is logical fle level
keyword.
Out"ut o5 above *o9it, 7e!wor8 is as s:own below see it using R1#@R0
co99an8 on co99an8 line:
& Du'e!tar Technologies (vt. Ltd. 8*)4
No part of this document can be copied, reproduced in any form, complete or partial without written consent from DukeStar Technologies Pvt.
Ltd.
WORK WITH LOGICAL-FILE
Day 4
Display Report
Report 8i.th . . . . . : 6'
!osition to line . . . . . Shift to column . . . . . .
#ine ....>....'....>....6.
R0## N0 SN+ME )0RS
&&&&&' '&& +%) +S4&&
&&&&&6 '&' sneha BB
En. of report








%ottom
*23E,it *'63)ancel *'A3#eft *6&3Ri?ht *6'3Split
0ou can use t:is 7Bw on one 6el8 - one 6le as s:own below
)olumns . . . : ' ;' E.it !%&'U&'D<MYDDS
SEU33> #STUDENT
*MT #* .....+..........T.Name>>>>>>.#en>>TDp%......*unctions>>>>>>>>>>>>>>>>>>
%e?innin? of .ata
&&&'.&& + R RS !*(#E(STUDENT)
&&&6.&& + R0## )0#7D1(-R0## N0/)
&&&2.&& + SN+ME TEJT(-STUDENT DET+(#/)
&&&4.&& + )0RS
&&&5.&& + G R0##
&&&C.&& + 0 R0## )0M!(E= '&6)
&&&;.&& + S R0## )0M!(1T '&&)
En. of .ata







*23E,it *43!rompt *53Refresh *A3RetrieBe *'&3)ursor *''3To??le
*'C3Repeat fin. *';3Repeat chan?e *643More 9eys
H )0!YR(17T (%M )0R!. 'AI', 6&&6.
0UT!UT 0* T7(S )0M!+R(S0N (S
& Du'e!tar Technologies (vt. Ltd.
)E*)4
No part of this document can be copied, reproduced in any form, complete or partial without written consent from DukeStar Technologies Pvt.
Ltd.
WORK WITH LOGICAL-FILE
Day 4
Display Report
Report 8i.th . . . . . : 6'
!osition to line . . . . . Shift to column . . . . . .
#ine ....>....'....>....6.
R0## N0 SN+ME )0RS
&&&&&' '&' SNE7+ ""
&&&&&6 '&2 titu iii
En. of report











%ottom *23E,it *'63)ancel *'A3#eft *6&3Ri?ht *6'3Split
1se o5 value 7e!wor8 :
columns . . . : ' ;' E.it !%&'U&'D<MYDDS
SEU33> #STUDENT *MT
#* .....+..........T.Name>>>>>>.#en>>TDp%......*unctions>>>>>>>>>>>>>>>>>>
%e?innin? of .ata
&&&'.&& + R RS !*(#E(STUDENT)
&&&6.&& + R0## )0#7D1(-R0## N0/)
&&&2.&& + N+ME TEJT(-STUDENT DET+(#/)
&&&4.&& + )0RS
&&&4.&' + G R0##
&&&C.&& + 0 R0## "+#UES('&6)
&&&;.&& + S R0## )0M!(1T '&&)
En. of .ata









*23E,it *43!rompt *53Refresh *A3RetrieBe *'&3)ursor *''3To??le
*'C3Repeat fin. *';3Repeat chan?e *643More 9eys
2utput of this 'ey,ord is ,here roll number having value )E- gets omitted.
& Du'e!tar Technologies (vt. Ltd.
))*)4
No part of this document can be copied, reproduced in any form, complete or partial without written consent from DukeStar Technologies Pvt.
Ltd.
WORK WITH LOGICAL-FILE
Day 4
Display Report
Report 8i.th . . . . . : 6'
!osition to line . . . . . Shift to column . . . . . .
#ine ....>....'....>....6.
R0## N0 SN+ME )0RS
&&&&&' '&' sneha BB
&&&&&6 '&2 titu iii
En. of report













%ottom
*23E,it *'63)ancel *'A3#eft *6&3Ri?ht *6'3Split

& Du'e!tar Technologies (vt. Ltd.
)-*)4
No part of this document can be copied, reproduced in any form, complete or partial without written consent from DukeStar Technologies Pvt.
Ltd.
WORK WITH LOGICAL-FILE
Day 4
@uestions relate8 to above session:
;A<: Flat Files
Create Fat fle using the command C?T(F and specifying the record length. +dd records to
the fle by using %(DDT+ command. Gie, the contents of the fle by using the ?%@H?I
command. Try if you can see the DD! for the same.
;AD: /:!sical - Logical Files
Brite the DD! source to create a (hysical fle.
Create the follo,ing physical fles and populate them ,ith data$
C1%T(
#oA Fiel8 #a9e Lengt: 'ata
T!"e
Ke! 'escri"tion
) C/HO#E )E,E ( K Customer (hone @o
- CL#A(E )E + Customer Last
@ame
0 CF#A(E )E + Customer First
@ame
4 CA''R -E + Customer +ddress
1 C3ILL 3,- ( Customer #illing
+mount
3 COWE' 3,- ! +mount 2,ned
5 C/0'T 3,E ! (ayment Date
6 %TAT1% ) + Customer !tatus
:int $ %se Te>t 'ey,ord.
C%!TJ
C%!TJ
@o.
Field @ame Lengt: 'ata
T!"e
Ke! 'escri"tion
) C(:2@4 )E,E ( K Customer (hone
@o
- CA(/' 3,- ( +mount (aid
0 C'TRC 3,E ( Date received
1. Create a logical fle CUSTL1 over CUST 'eyed on (ayment date and select those
records ,here address is (une .%sing C2J(/.
!. Create a logical fle CUSTL! over CUST and select the records ,ith bill amount
ranging from )EEE.EE to 8888.88 .%sing ?+@K4/.
". Create a logical fle CUST" over CUST and the records ,ith status e"ual to .L+9
or L=9/ active*inactive .using G+L%4!/.
#. Create a logical fle CUSTL# over CUST and rename the feld CO$%D to &TOD
and update the data using the fle.
'. Chec' all the logical fles associated ,ith CUST using command D!(D#?.
(. Create a <oin logical fle over CUST and CT)&NS ;oined on C*+ON% and arrange
the duplicate records according to +mount (aid.
,. Create a feld reference fle and use its reference to create a physical fle
CUST1.identical to CUST
-. +dd a physical fle member to fle CUST using command &DD*.. +dd data to it.
;A<: Create a physical fle %*L ,ith the follo,ing DD!
& Du'e!tar Technologies (vt. Ltd.
)0*)4
No part of this document can be copied, reproduced in any form, complete or partial without written consent from DukeStar Technologies Pvt.
Ltd.
WORK WITH LOGICAL-FILE
Day 4
#oA Fiel8 #a9e Length Data Type Description
) E(/#O 1,E ( 4mployee number
- E(/#( -E + 4mployee @ame
0 E(/A'' -E + 4mployee +ddress
4 E(/%AL 5,- ( 4mployee !alary
1 E(/'/T )E + 4mployee Dept.
). +dd the primary 'ey constraint .%sing +DD(FC!T/ named C!T) on (F %*L.
-. +dd records using DF% and observe the e7ect on addition of duplicate records.
0. ?emove the constraint C!T) using the command ?JG(FC!T.
4. +dd the %ni"ue 'ey constraint .%sing +DD(FC!T/ named C!T- on (F %*L.
1. +dd records using DF% and observe the e7ect on addition of duplicate records.
3. ?emove the constraint C!T- using the command ?JG(FC!T.
;A;AD : Create a physical fle EMPLD ,ith the follo,ing DD!
#oA Fiel8 #a9e Lengt: 'ata T!"e 'escri"tion
) E(/#O 1,E ( 4mployee @o
- E(/'/T )E + 4mployee @ame
). +dd referential constraint C!T0 on the (F 4J(LD giving parent fle name as %*L.
Try to delete a dependent record from %*LD. ?emove the constraint CST" using
the command ?JG(FC!T.
-. +dd a physical fle trigger on %*LD ,ith trigger time as C#4F2?4, event as
C=@!4?T and (rogram @ame as Test. .2b;ect of this program ,ill be copied into your
library/.
0. @ame the t,o types of logical fles. :o, do they di7er in processing logicD
4. Bhen a logical fle references one or more physical fles, ,hat is automatically built
by each logical fle to control processingD
1. Bhat is the function of a (F=L4 'ey,ordD
3. :o, many physical fles ,ill be accessed by the non;oin logical feD
5. Bhat is he function of the F2?J+T 'ey,ordD
6. Bhat is function of the D4!C4@D 'ey,ordD
& Du'e!tar Technologies (vt. Ltd.
)4*)4
No part of this document can be copied, reproduced in any form, complete or partial without written consent from DukeStar Technologies Pvt.
Ltd.

You might also like