Friday, November 16, 2012

Passing Parameters to Easytrieve programs


Processing JCL Parameters

This example obtains a parameter coded on a JCL EXEC statement and uses it to control the selection of records.

A START procedure receives control at the beginning of the job. This procedure calls a subprogram which moves the PARM information into a CA-Easytrieve Plus field. A JCL parameter can be from 1 to 100 characters long. The maximum length of the field you defined (PARM-DATA in this case) must be specified in PARM-LTH. The subprogram, EZTPX01, move up to 10 characters from the JCL PARM-DATA, in this example.

If no JCL parameter is specified on the EXEC statement, PARM-LTH includes a zero after calling EZTPX01. If more than 10 characters are specified, the PARM is truncated to 10 characters.

In this example, the expected JCL parameter is defined to be three digits; the first digit specifies the region number and the next two contain the branch number. The format and content of the parameter is validated after calling EZTPX01. A PARM-LTH of 10 was used to detect either a missing JCL parameter or one which is not the correct length. If PARM-LTH = 3 was coded, CA-Easytrieve Plus could not detect a parameter which was longer than 3, since EZTPX01 would truncate it to three characters.

Note: The use of field redefinition defines subfields of the JCL parameter. The value of the JCL parameter is 302 for this example.

The EZTPX01 routine is distributed as part of the CA-Easytrieve Plus system.

Example program:

1 *
2 * EXAMPLE 15.14
3 *
4 FILE PERSNL FB(150 1800)
5 %PERSNL
35 *
36 * JCL PARM DECODE DEFINITIONS
37 *
38 PARM-INFO W 12 A
39 PARM-LTH PARM-INFO 2 B
40 PARM-DATA PARM-INFO +2 10 A
41 *
42 SELECT-REGION PARM-DATA 1 N
43 SELECT-BRANCH PARM-DATA +1 2 N
44 *
45 *
46 JOB START(PARM-ANALYSIS)
47 IF REGION = SELECT-REGION AND BRANCH = SELECT-BRANCH
48 PRINT
49 END-IF
50 *
51 * MOVE THE JCL PARM INTO THE PARM-INFO W-FIELD AND VALIDATE IT
52 *
53 * THE JCL PARM MUST BE 3 DIGITS OF THE FORM RBB
54 * WHERE R IS THE REGION NUMBER AND BB IS THE BRANCH NUMBER
55 *
56 PARM-ANALYSIS. PROC
58 PARM-LTH = 10
59 CALL EZTPX01 USING (PARM-REGISTER PARM-INFO)
60 IF PARM-LTH NE 3
61 DISPLAY SKIP 3 '******* MISSING OR INVALID JCL PARM'
62 STOP EXECUTE
63 END-IF
64 IF SELECT-REGION NE 1 THRU 4
65 DISPLAY SKIP 3 '******* INVALID REGION NUMBER'
66 STOP EXECUTE
67 END-IF
68 IF SELECT-BRANCH NE 1 THRU 5
69 DISPLAY SKIP 3 '******* INVALID BRANCH NUMBER'
70 STOP EXECUTE
71 END-IF
72 END-PROC
73 *
74 REPORT LINESIZE 70
75 TITLE 'EMPLOYEES IN REGION' -2 SELECT-REGION -
'BRANCH' -2 SELECT-BRANCH
76 LINE NAME-FIRST NAME-LAST EMP#

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.