SORT in Easytrieve

You can Sort a file into another file in Easytrieve. The Syntax is

 SORT file-name-1 +
 TO file-name-2 +
 USING (field-name [D]...) +
 [BEFORE proc-name]

Let us see a couple of sample programs to explain.

Simple Sort on a key

The below program will simply

 FILE INFILE FB(80 960)
   ACCOUNT-NO  1 8 N
*
 FILE OUTFILE
*
 SORT INFILE TO OUTFILE USING ACCOUNT-NO

being updated..

EDIT MASKS – Masking variables in Easytrieve

have you already read Easytrieve Variable declaration?

For creating reports, or printing (displaying) numeric variables, we will always need masking. It can be used to print the decimal character for the variables that have implied decimal

 WS-SSN W 9 N MASK '999-99-9999'
 ...
 MOVE 123456789 TO WS-SSN
 DISPLAY ' WS-SSN : ' WS-SSN

This will be printed as

 WS-SSN : 123-45-6789

Edit mask pattern is created by using combinations of the following characters:

9 — causes a digit to print. (including leading zeros)

Z — causes a digit to print (except for leading zeros)

$ — causes a currency symbol to print prior to the first non-zero digit

more examples to come..

DISPLAY statement in Easytrieve

DISPLAY statement in Easytrieve is exactly the same as in COBOL.

 WS-VAR1 W 20 A VALUE 'I AM INITIALIZED HERE'
 ...
 DISPLAY 'value of WS-VAR1 is: ' WS-VAR1

This will be printed as

 value of WS-VAR1 is: I AM INITIALIZED HERE

If you want to continue the DISPLAY statement in multiple lines, use ‘+’ symbol as continuation character

 WS-VAR1 W 20 A VALUE 'I AM INITIALIZED HERE'
 ...
 DISPLAY 'value of WS-VAR1 is: ' +
         WS-VAR1

Easytrieve – Variable initialization (VALUE clause)

have you already read Easytrieve Variable declaration?

Initialising a variable in Easytrieve, can be done using VALUE Clause.

 WS-VAR1 W 20 A VALUE 'I AM INITIALIZED HERE'

CA11-U11RMS Restart utility parameters

CA11 is a utility from Computer Associates that helps to re-run a job multiple times and also to restart from abended steps, taking care of what files to be used when we rerun.

We need to specify a restart parameter that tells CA11 – how we want the job to be run. Valid parameters are nP, nR, nN and more (n = 0,1,2,3,..)

P for Production run (0P, 1P, 2P, .. nP)

When we submit a job for first time, a parameter of ‘0P’ will be passed.
Due to any failure, if we need to run the job for a second time, and start from first step, pass a parameter ‘1P’.
If that fails again, and you need to run again from the beginning, use ‘2P’. (and so on…)
R for Restart/Rerun (1R, 2R, .. nR)

N for Null (1N, 2N,.. nN)

Note: if you do not change the number n in the parameter you will be getting a user abend U0060 saying that the parameter was not changes since the last run. However if your job has been completed successfully and you are rerunning the job, you do not need to change the number n.

DIRECT YES and DIRECT NO options in BMC unload plus

DIRECT YES:

When we use DIRECT YES option, BMC Unload Plus utility (ADUUMAIN) reads data directly from the table space data set or image copy data set and uses a SELECT-like syntax for data selection.

We can unload all data from a table-space without requiring written SELECT statements.

The data can be sorted by clustering key or partitioning key.

DIRECT NO:

When we use DIRECT NO option, BMC Unload Plus utility uses DB2 dynamic SQL to process the SELECT statement.

Data type conversions can be performed using DIRECT NO (which is not available with DIRECT YES).

 

STRING and UNSTRING verbs in COBOL

STRING WS-VAR1 ',' WS-VAR2 DELIMITED BY SIZE INTO WS-STRING

UNSTRING ws-comma-separated
  DELIMITED BY ','
    INTO  WS-parm1
        , WS-parm2
        , WS-parm3
        , WS-parm4
        , WS-parm5
 END-UNSTRING

DB2 commands : TERM, START, STOP, DIS

– DIS or -Display : Display a status of tablespace (ie READ-WRITE / COPY-PENDING / CHECK-PENDING / READ ONLY)

-DIS  DATABASE(dbname) SPACENAM(tbspace)

more on Display Database

Stop / Start a tablespace / indexspace:

-STOP  DATABASE(dbname) SPACENAM(tbspace)
-START  DATABASE(dbname) SPACENAM(tbspace) ACCESS(FORCE)

Start: publib.boulder.ibm.com/../bjncstdb999243.htm

Stop: publib.boulder.ibm.com/../bjncstod999243.htm
How to find a table’s Database name and tablespace name?

SELECT DBNAME, TSNAME FROM
SYSIBM.SYSTABLES WHERE NAME = [table name]
 AND OWNER = [qualifier] ;
SELECT DBNAME, TSNAME FROM
SYSIBM.SYSTABLES WHERE NAME = 'SYSDUMMY1' AND
OWNER = 'SYSIBM';

Terminating a BMC (or any DB2) utility:
issue the Terminate Utility command:
-TER UTILITY([util id])
TERM: publib.boulder.ibm.com/../ctermu.htm

Symbolic parameters in JCL using SET statement

Symbolic parameters used in JCL can be assigned a value using the SET statement.

//      SET INFILE=MY.DATA.SET.HERE

You can also give an eight character (upto 8 char) name to this statement.

//MYVARS SET INFILE=MY.DATA.SET.HERE

Multiple variables can be defined in a SET statement – separated by comma.

//MYVARS SET INFILE1=MY.DATA.SET.HERE,PARM1='KARTHIK'

Learn more

Sort-card to split a file into multiple files (OUTFIL,FNAMES,SAVE)

Let’s say we have a file with first byte having 2 different values ‘A’ or ‘B’ or any other character.
We are going to create a file with all records starting with A (DD name SORTXXA), a second file with all records starting with B (DD name SORTXXB), a third file (DD name SORTXXX) with remaining records.

 SORT FIELDS=COPY
 OUTFIL FNAMES=SORTXXA,INCLUDE=(1,1,CH,EQ,C'A') 
 OUTFIL FNAMES=SORTXXB,INCLUDE=(1,1,CH,EQ,C'B')   
 OUTFIL FNAMES=SORTXXX,SAVE  
« Previous PageNext Page »