1 / 71

Procedures

Introduction to Procedures. Often we need the same or similar sequences of JCL statements: e.g., Compile, Link Edit, Go.Time consuming and errors likely if must re-enter same JCL repeatedly.Plus, JCL is complex to na

elom
Download Presentation

Procedures

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


    1. Procedures Department of Computer Science Northern Illinois University DeKalb, Illinois 60115

    2. Introduction to Procedures Often we need the same or similar sequences of JCL statements: e.g., Compile, Link Edit, Go. Time consuming and errors likely if must re-enter same JCL repeatedly. Plus, JCL is complex to nave users.

    3. Introduction to Procedures So, IBM has a facility for putting prewritten chunks of JCL (i.e, jobstreams) into a library. User can then invoke this prewritten job stream (the catalogued procedure) with just one line of JCL: //S1 EXEC PROC=IGYWCEG (Has JCL to compile, le, go.)

    4. Introduction to Procedures Using procs better than writing JCL one time and then modifying with text editor. Aside from mistakes in typing, youd have to always change parms passed for different programs. Procs let the user change and/or override some of the precoded JCL at EXEC time with a few simple statements.

    5. Introduction to Procedures There is also a facility called symbolic parameters which allow the proc writer to specify defaults for values of parameters (or leave them null). The procedure user lets the default values stand, or overrides/changes them from the same line that invokes the procedure.

    6. Introduction to Procedures Example: Assume the writer coded UNIT=DISK for some data set. Proc user can change this to UNIT=TAPE or PUB if this particular parameter was set up to be a symbolic parameter. Thus, catalogued procedures lead to improved productivity and fewer errors.

    7. Introduction to Procedures A catalogued procedure is simply a set of JCL statements that are placed in a PDS known as a procedure library. Executing the procedure is equivalent to performing all of the applications (jobsteps) defined in the procedure. 2 Basic Flavors of Procs: Instream Catalogued

    8. Instream Procedures Use this method when you first write a proc and want to test it. If changes need to be made, easier to do them instream than if the proc exists as a PDS member. With instream, you both write and test the procedure in the same jobstream.

    9. Instream Procedures //JOBCARD JOB , //DOG PROC //jcl statements //comprising the proc // PEND //S1 EXEC PROC=DOG Note that the name of an instream proc appears on proc card label. This is what you then EXEC.

    10. Instream Procedures Can have up to 15 instream procedures. Once defined instream and tested, you can then put a procedure into a procedure library and use it as catalogued procedure. //MYJOB JOB , //PROCLIB DD DSN=MYPROCLIB,DISP=SHR //S1 EXEC DOG

    11. Instream Procedures The proclib card, which must come right after the JOB card, identifies the PDS where the procedure resides. Must be there if this is a private user library. The name (DOG) is not necessarily the name that appeared on the PROC card. The name of a catalogued procedure is whatever name was assigned to the PDS member when stored.

    12. Instream Procedures In searching for a procedure, system looks: 1. Instream. 2. For a Proclib (private) statement. 3. In global procedure libraries (1. SYS1 & 2. Proclib).

    13. Coding a Simple Instream Procedure //PROCNAME PROC [optl symbolic parms] //JCL STATEMENTS COMPRISING THE PROC // PEND

    14. Coding a Simple Instream Procedure Procname 1-8 alphabetic/national, 1st must be alphabetic. This is the name of the proc when instream and is required. Is ignored if the proc is catalogued (name of catalogued proc = name assigned to PDS member). Must be a unique name in the JCL jobstream (i.e., no other card can have that label).

    15. Coding a Simple Instream Procedure PROC Required if instream and must be 1st statement. Optional if catalogued unless you want to assign default values to symbolic parms, then its required there as well.

    16. Coding a Simple Instream Procedure // PEND Required for instream procs. Do not use in catalogued procs. Can have an optional name in col 3, else leave at least one blank.

    17. Coding a Simple Instream Procedure Anything can go into a procedure except: EXEC statements that call other procedures (catalogued or instream) JOB /* // (null) JOBLIB card (STEPLIB is ok) DD * or DD DATA statements (instream markers)

    18. Coding a Simple Instream Procedure The value of writing/having procedures is lost if the user has to permanently change/modify the procedure every time a change is needed.

    19. Coding a Simple Instream Procedure Therefore, a user can modify the procedure at run time by: adding new DD statements. overriding, adding, or nullifying parameters on EXEC and DD statements. assigning values to symbolic parameters.

    20. Coding a Simple Instream Procedure Such changes/modifications are made to a copy of the procedure. The permanent version is not modified. Every user of a procedure gets a copy of it. Thus, can have simultaneous users.

    21. Modifying Parameters on an EXEC statement On the line that invokes the procedure, identify: parm-to-change, period, name of step parm refers to //P1 EXEC PROC=RUN,PARM.COB=LIB,STATE, // COND.STEP2=(4,LT)

    22. Modifying Parameters on an EXEC statement Cannot override PGM= in a procedure Can override PARM, COND, TIME, REGION

    23. Modifying Parameters on an EXEC statement Example #2: Say a procedure named LMERGE contains the following EXEC statements: //S1 EXEC PGM=FIRST,PARM=C,F,1997 //S2 EXEC PGM=NEXT You want to: nullify the parm on step1, and add a cond parm to step2...

    24. Modifying Parameters on an EXEC statement //CALL EXEC LMERGE,PARM.S1=, // COND.STEP2=(4,LT) You nullify a parm by coding = followed by nothing. Changes for parms to S1 must be done before doing changes for S2. I.e., the changes must be done in step order.

    25. Modifying Parameters on an EXEC Statement This means that proc user must know the names of the steps involved. Printpunch the procedure: //MYJOB JOB ,NAME,TYPRUN=SCAN (scans & prints JCL)

    26. Modifying Parameters on a DD Statement //STEPNAME.DDNAME DD new values: code these modifications and or additions after the statement that invokes the procedure.

    27. Modifying Parameters on a DD Statement //SX EXEC LMERGE //STPE2.XFILE DD DSN = NEWNAME DD statements containing the changes must be coded in the same order as the corresponding DD statements in the procedure.

    28. Modifying Parameters on a DD Statement Rule 1: If the added stepname.ddname card matches that of one in the proc, then the added card overrides the original as follows: If parms match: new value replaces value in proc. If parms dont match: new value is added to DD card in the proc. If added parm is nullified: if it matches a parm in proc, that value is also nullified. Non-referenced parms in the procedure remain untouched.

    29. Modifying Parameters on a DD Statement Example#2, a procedure called Drink: In step1 //DD1 DD DSN=WATER,UNIT=DISK,VOL=SER=ACA1-5, // DISP=SHR In step2 //DD2 DD DSN=BEER,UNIT=TAPE,SPACE=(TRK,(2,1)), // DISP=(NEW,PASS)

    30. Modifying Parameters on a DD Statement You want to: change Water to Tea add a DCB parm to DD1 change DD2 unit to Disk and add a Vol, Ser //S1 EXEC DRINK //STEP1.DD1 DD DSN=TEA,DCB=(LRECL=76,BLKSIZE=760) //STEP2.DD2 UNIT=DISK,VOL=SER=ACA101

    31. Modifying Parameters on a DD Statement Changing DCB keyword parms: Code only those you want to change; the rest stay unchanged. To nullify the DCB parm, you must nullify each subparm. //STEPN.XFILE DD DSB=(LRECL=,DSORG=,BLKSIZE=)

    32. Modifying Parameters on a DD Statement To nullify an entire DD card: //STEPN.XFILE DD DUMMY

    33. Modifying Parameters on a DD Statement Rule 2: The order of overriding DD statements must be the same as the DD statements appear in the procedure. i.e., in order by Step and in order by Name.

    34. Adding Brand New DD Statements Rule 3: New DD statements must follow the order of steps in the procedure I.e., COB cards must come before GO cards if thats the order of the steps in the proc.

    35. Adding Brand New DD Statements //COB.SYSIN DD * //GO.SYSOUT DD SYSOUT=*

    36. Adding Brand New DD Statements Example, instream...

    37. //MYJOB JOB , //RUN PROC //COB EXEC PGM=IGYCRCTL //SYSPRINT -------------- //SYSUTS ----------------- //SYSLIN --------------- //LKED EXEC PGM=HEWL,COND=(8,LT) //SYSLIN -------- //SYSLMOD DD DSN=&&TEMP(LMOD),UNIT=DISK,V=S=5, // DISP=(NEW,PASS),SPACE=(-----) //GO EXEC PGM=LMOD //STEPLIB DD DSN=&&TEMP, ------- // PEND

    38. Adding Brand New DD Statements Execute the procedure adding Parm to compile, changing Cond for link edit step, and passing a program parm...

    39. Adding Brand New DD Statements //Sn EXEC RUN,PARM.COB=APOST,LIB,COND.LKED=(4,LT), // PARM.GO=A add source code card //COB.SYSIN DD * or DD DSN= ----- change name and DISP of Syslmod library //LKED.SYSLMOD DD DSN=PERM(LMOD),DISP=(NEW,KEEP) change Lib name on STEPLIB and add Input/Outfile files //GO.STEPLIB DD DSN=PERM //GO.INPUT DD DSN= ----- //GO.OUTPUT DD DSN= -----

    40. Modifying DDs that Define Concatenated Data Sets Supply a ddcard for each ddcard in the concatenated data set in the procedure, even if you dont override every one of them.

    41. Example, in a procedure, in Step4, we have: //DDNAME DD DSN=A,DISP=PLD // DD DSN=B,U=D,V=S=4,DISP=OLD Want to change A and add DSN of C // EXEC PROC=WHATEVER //STEP4.DDNAME DD DSN=A1 This changes As name, leaves DISP alone // DD This leaves B alone by leaving blank // DD DSN=C,DISP=OLD This adds C

    42. Modifying DDs that Define Concatenated Data Sets Identifying changes, original lines: Instream Catalogued // // a JCL line you have added ++ XX proc statement not overriden +/ X/ proc statement overriden in part or whole ++* XX* comment from within proc *** *** comment you have added in JCL

    43. Symbolic Parameters These provide a way to alter values in a procedure at run time, from the EXEC card for the procedure. Example, you want a program to run on one of several data sets: //RUN PROC DATAIN=MYDATA,VDISK=ACA102,GOPARM=

    44. Symbolic Parameters When you code the procedure, on the PROC card you specify symbolic parameters DATAIN, VDISK, and GOPARM. First two have default values, and last one has default null value.

    45. Symbolic Parameters In the body of the procedure we have: //Sn EXEC PGM=CAT,PARM=&GOPARM //STEPLIB DD DSN= ----- //INPUT DD DSN=&DATAIN,U=D,V=S=&VDISK,DISP=SHR //OUTPUT DD SYSOUT=* // PEND

    46. Symbolic Parameters If you run this proc as it is, i.e., // EXEC PROC=RUN you will execute with the defaults. Every place the &symb parm appears in body gets substituted with default values assigned by proc writer.

    47. Symbolic Parameters If you want to change things: // EXEC PROC=RUN,DATAIN=HERDATA,VDISK=ACA101, // GOPARM=X When you write a procedure, you code the symb parms in the body of the procedure with an & in front. Every place the symbolic parameter appears gets substituted with either the default value (if one is provided) or the overriding value the user codes on the EXEC card for the procedure.

    48. Symbolic Parameters Format: 1-7 alphameric / national (#, @, $) characters preceded by a single & 1st char must be alphabetical or national Each symbolic parameter used in a procedure must be assigned a value or be nullified.

    49. Symbolic Parameters There are 2 ways to do this: First way: The person who uses the procedure codes every symbolic parameter on the EXEC statement which calls the procedure, either assigning it a value or nullifying it. Thus, user must know which symbolic parms are there and their names.

    50. Symbolic Parameters Second way: The programmer who writes the procedure assigns a default value to or nullifies each symbolic parm on the PROC statement (which must be 1st statement in an instream proc). Although the PROC statement is not always required for a catalogued procedure, it is required when symbolic parms are assigned defaults by the programmer.

    51. Symbolic Parameters Example for first way, a catalogued procedure named FARM: //S1 EXEC PGM=RABBIT,PARM=&DOPARM //STEPLIB DD DSN= ----- //INFILE DD DSN=&INSET,VOL=SER=&VOL //OUTFILE DD SYSOUT=*

    52. Symbolic Parameters User invokes the proc each symbolic parameter must be assigned a value or must be nullified: // EXEC PROC=FARM,DOPARM=01/22/97,INSET=MYDATA, // VOL=ACA103

    53. Symbolic Parameters Example for second way: //HELLO PROC DOPARM=,INSET=MYDATA,VOL= // same as before User codes: // EXEC FARM,VOL=ACA103

    54. Symbolic Parameters This example is going with the defaults assigned to DOPARM (null) and INSET (mydata) and assigning a value only to Vol. Here, the user does not have to specifically assign a value or null for each symbolic parm because this has been taken take of by the procedure writer.

    55. Symbolic Parameters This is the preferred way. It eliminates the amount of coding necessary each time the proc is invoked. Note, though, that the PROC statement is required and must be first.

    56. Symbolic Parameters Assigning a value to a symbolic parameter: symbparm=value Value: Enclose within single quotes if it contains special chars like comma, period, slash /, apostrophe, left or right parens, *, &, + , Hyphen (-), =, or blank.

    57. Symbolic Parameters Nullify a symbolic parm by coding parm= Can do this either as a default or user can do this to nullify a parm. Do not continue a value assignment onto another line.

    58. Symbolic Parameters Be careful with leading and trailing commas when working with symbolic parameters: Example: //RUN PROC XDISP=KEEP EXEC PROC=RUN.XDISP=PASS . . . // DISP=(NEW,&XDISP) DISP=(NEW,PASS) is OK

    59. Symbolic Parameters But if code: EXEC PROC=RUN,XDISP= (null) We get: // DISP=(NEW,) which is an error So, in the proc, code this as: //RUN PROC XDISP=,KEEP // DISP=(NEW&XDISP)

    60. Symbolic Parameters User must then also provide a comma when changing the default. Since its a comma, enclose in single quotes: // EXEC PROC=RUN,XDISP=,DELETE

    61. Symbolic Parameters Other things: Symbolic parms may be concatenated: //RUN PROC A=ABC,B=102 //NAME DD DSN=-----,VOL=SER=&A&B = = = Vol=Ser=ABC102

    62. Symbolic Parameters If a symbolic parm precedes information that does not vary, put a period after the parameter to distinguish it from the nonvarying information: VOL=SER=&PFIX103 code as VOL=SER=&PFIX.103 which expands correctly as VOL=SER=ACA103

    63. Symbolic Parameters A period is required after a symbolic parm if it precedes an alphabetic, numeric, or national character, or another period: DD DSN=&LOGON..NAMEFILE LOGON=Z12345 comes out as Z12345.NAMEFILE

    64. Symbolic Parameters If you want to override EXEC card parms, the overriding values must be in order by step: // EXEC PROC=DOG,COND.STEP2=(-----),PARM.STEP2=-----, // COND.STEP3=(-----)

    65. Symbolic Parameters Cannot override PGM= in a procedure, but you can have the program itself be a symbolic parameter: // EXEC PGM=&PGMNAME

    66. Backward References Works for Unit, DCB, Vol=Ser=, and DSN Save typing, typos.

    67. Backward References 1) Within same step: //STEP1 //INSET DD DSN=A,DCB=(-----) //OUTSET DD DSN=*.INSET,DCB=*.INSET

    68. Backward References 2) Within a previous job step: //STEP1 . //AFILE DD DSN=A,DCB=(-----) //STEP2 //BFILE DD DSN=B,DCB=*.STEP1.AFILE

    69. Backward References 3) In a step in a Procedure used by this job: //STEP3 EXEC PROC=A //STEP4 EXEC PROC=B //FILEC DD DSN=*.STEP3.COBSTEP.DD1 Says: Goback to STEP3, within that step locate the procedures COBSTEP, and find a ddcard named DD1 and copy its DSB here.

    70. Backward References 4) Can also refer back to a load module: //A EXEC PGM=HEWL . . . //SYSLMOD DD DSN=MYLIB(MEMA) //B EXEC PGM=MEMA ? Old way //STEPLIB DD DSN=LIB,-----

    71. Backward References Refer back: //B EXEC PGM=*.A.SYSLMOD will go back to stepAs syslmod card and execute the member found there.

More Related