Upload
ravikiran8p
View
212
Download
0
Embed Size (px)
Citation preview
7/27/2019 COBOL_Training_Class-14.ppsx
1/16
IBM MAINFRAMES
COBOL Training Class-10
7/27/2019 COBOL_Training_Class-14.ppsx
2/16
Introduction to COPY Stat!nt
A COPYstatement is used to bring a series of prewritten
COBOL entries that have been stored in library, into a
program.
These are used at Common routines like error routine, date validation
routine are oded in a library and bring into the program
by COPY.
!aster files are used in multiple programs. Their layoutan be plaed in one opyboo" and be plaed wherever the
files are used. #t promotes program standardi$ation sine all
the programs share the same layout and the same data
names. !ostly %now asCOPYBOOK
7/27/2019 COBOL_Training_Class-14.ppsx
3/16
Introduction to COPY Stat!ntcontd""
Copyboo"s are stored as members in P&' library
and during ompilation time, they are inluded into
the program.
By default, the opyboo" library is 'Y'L#B.
Copyboo"s an be used in
ENVIRONMENT IVI!ION
"T" IVI!ION
PROCE#RE IVI!ION$
7/27/2019 COBOL_Training_Class-14.ppsx
4/16
Pur#os O$ COPY Stat!nt
This redues oding and debugging time. Change in
layout needs hange in opyboo" only. #t is enough if
we (ust reompile the program for ma"ing the new
opy effetive.
'ynta)*
COPY opyboo"+name
-PLAC#/0string+to+be+replaed BY replaing+
string1
7/27/2019 COBOL_Training_Class-14.ppsx
5/16
R#lacing o#tion %it& COPY
One opyboo" an be used with -PLAC#/0verb to replae
high+level 2ualifier of the all the variables with another
2ualifier.
)ample*COPY C3'TO!- -PLAC#/0 4C3'T5+4 BY 4C3'T6+4.
&elimiter %& &' should be used for replaing pseudo te)ts. The
replaing option does not alter the prewritten entries in the
library7 the hanges are made to the user8s soure program
only.
7/27/2019 COBOL_Training_Class-14.ppsx
6/16
Introduction to CALL Stat!nt
9hen a speifi funtionality need to be performed in more
than one program, it is best to write them separately and all
them into eah program.
The mainprogramthat referenes or alls a subprogram is
referred to as the allingprogram. The subprogramthat is
lin"ed and e)euted within the main program is referred to as
the alled program.
7/27/2019 COBOL_Training_Class-14.ppsx
7/16
Main Progra! in 'tails
Main Pro(ram
CALL statement is used for e)euting the sub+program from the
main program. A sample of CALL statement is given below*
C")) %P*MN"ME+' #!IN*BY REERENCE -!.V"R+,
BY CONTENT -!.V"R/$
P0!/A!5is alled here. 9'+:A-5 and 9'+:A-6 are
wor"ing storage items. 9'+:A-5 is passed by referene. 9'+:A-6 is passed by Content. BY -;-/C is default in
COBOL and need not be oded.
7/27/2019 COBOL_Training_Class-14.ppsx
8/16
Pass B( R$rnc ) Pass B( Contnt
BY REERENCE BY CONTENT
Call 4P0!/A!8 3'#/0BY -;-/Cws+var5.
Call 4P0!/A!8 3'#/0BY CO/T/Tws+var5.
#t is default in COBOL BY CO/T/T "ey word isre2uired
"ddressof ws+var5 is passed Valueof ws+var5 is passed
The sub+program
modifiations on the passedelements are visiblein themain program.
The sub+program
modifiations on the passedelements are loal to thatsub+program and notvisi0lein the main program.
7/27/2019 COBOL_Training_Class-14.ppsx
9/16
Su* Progra! in 'tails
PRO*R"M.I. COBOL?@ feature.
Alternatively C"NCE)issued after CALL, will set the sub+
program to initial state.
#f the sub program is modified then it needs to be reompiled.
The need for main program reompilation is deided by theompiler option used for the main program.
#f the YN"Mompiler is used, then there is no need to
reompile the main program. NOYN"Mis default that
e)pets the main program reompilation.
7/27/2019 COBOL_Training_Class-14.ppsx
10/16
Su* Progra! in 'tailscond""
L#/%A0'CT#O/is used to define all the reeiving data
items .
P-OC&3-:#'#O/3'#/0L%+:A-5,L%+:A-6
There is a one+one orrespondene between passed elementsand reeived elements BYPO'#T#O/. This implies that the
name of the identifiers in the alled and alling program need
not be the same >9'+:A-5 L%+:A-5 but the number of
elements and piture lause should be same. The last statement of your sub+program should be #T
P-O0-A!D0OBAC%. This returns the ontrol ba" to main
program. 3se 0OBAC% but not 'TOP-3/.
7/27/2019 COBOL_Training_Class-14.ppsx
11/16
'i$$rnc B+, Static ) '(na!ic CALL
#dentified by CALL literal
E12 C")) %PRO*N"ME'$
&efault ompiler option is
/O&Y/A!
#f subprogram undergoes
hanges main program subprogram both should be
reompiled
#dentified by variableshould
be populated at run time.
E32 C")) -!.PR*N"ME.
Compiler option is &Y/A!
-eompilation of subprogram
is enough
7/27/2019 COBOL_Training_Class-14.ppsx
12/16
Static ) '(na!ic Cond""
'ub modules are lin" edited
with main module
'i$e of load module is lar(e
astaess
)ess4le1i0le
9ill not be in initial state
the ne)t time it is alled
unless e)pliitly useINITI")O- CA/CL
after eah CALL
'ub modules are pi"ed up
during run
Load si$e is less
!lo5 ompared to stati
Morefle)ible
9ill be in initial state every
time it alled.
7/27/2019 COBOL_Training_Class-14.ppsx
13/16
MAIN PRORAM
IDENTIFICATION DIVISION.PROGRAM-ID. MAINPGM.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 Sales-Data. 05 WS-NO-UNITS PIC 9(!.
05 WS-COST PIC 9("!V9(#!.
05 WS-AMNT PIC 9($!V9(#!.
01WS-PGMNAMEPIC %(0&! VA'UE SU)PROG*.
PROCEDURE DIVISION.100-MAIN-'OGIC.
ACCEPTWS-NO-UNITS. ACCEPT WS-COST.ACCEPTWS-AMNT.
CA'' SU)PROG*+WS-PGMNAMEUSINGWS-NO-UNITS,WS-COST ,WS-
AMNT. STOP RUN.
7/27/2019 COBOL_Training_Class-14.ppsx
14/16
S.B PRORAM
IDENTIFICATION DIVISION.
PROGRAM-ID. SU)PROG IS INITIA' PROGRAM.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
'INKAGE SECTION.
01 'S-Sales-Data.
05 'S-NO-UNITS PIC 9(!.
05 'S-COST PIC 9("!V9(#!.
05 'S-AMNT PIC 9($!V9(#!.
PROCEDURE DIVISION USING 'S-NO-UNITS'S-COST'S-AMNT.
100-MAIN-'OGIC.
DISP'A 'S-SA'ES-DATA.
GO)ACK.
7/27/2019 COBOL_Training_Class-14.ppsx
15/16
PARM Para!tr
#t is used to aess the data that are e)ternal to the program.
ECL an send ma)imum 5FF haraters to a program thru
PA-!.
Lin"age setion !3'T be oded with a hal4 5ord 0inary4ield, prior to atual field. #f length field is not oded, the first
two bytes of the field oded in the lin"age setion will be filled
with length and so there are hanes of 6 bytes data trunation
in the atual field.F5 L%+&ATA.
F@ L%+L/0TG P#C 'H>FI CO!P.
F@ L%+:A-#ABL P#C >F?.
7/27/2019 COBOL_Training_Class-14.ppsx
16/16
T&an/ You