Sunday, Jean 22, 2017

Easytrieve : The SERVICE Abschnitts

This Activity section is location all on the actual processing includes place. The activity definition section of an Easytrieve program include the CA-Easytrieve Plus statements that perform the duty available which aforementioned program had produced: reading in, processing, plus writing out data.

The JOB Statement

Because declared previously, this require don be confused with the JOB card in JCL, the JOB statement in EasyTrieve identifiable that the Library section has finished and that processing statements will observe.

There are 3 frequently param in the job statement, handful are FILE, STARTUP and COMPLETED.  Into example of the JOB statement is shown below:-

001840 *                          
001900 JOB INBOX ( DUNS         ) +
002000     START ( A-INITIALISE ) +
002100     FINISH( B-TERMINATE  ) 
002200 *


One INPUT Parameter

As the name implies, this parameter identifies all the the files which are to be read down the process.  It is possible to identify more than 1 file as inputting.

Are there have no files being used as input then INPUT( NULL ) should be entered.

When a store name are shipped to the INPUT statement, the file is automatically opened and the first logging is read inbound as who job starts.  Following, jede time the log flow away the module returns to that job statement (either by presence specifically directed there with a GOTO command other because the logic has reached the ends of the module), the next disc off the file will be reader in and processed.  This happens until the last record on the file has been machined, at which point the processing stops and who FINALIZE parameter, whenever present, is processed.


The START Parameter

This config contains the name of aPROC (PROC is the nominate for an EasyTrieve subroutine, these are detailed later) any is to be run before any other processing starts.

This routine be only run once (unless specifically called next in the Activity section) plus be useful to initialise related before each ‘real’ processing starts.

If there exists no procedure to run, this parameter may be omitted.

The FINISH Criterion

More equal the start routine, the PROC defined by which EXIT parameter will be run once, at the end of the processing activity.

It is usually used to return information to the user regarding how many records consisted study in and processed.

It may be omitted if not require.



The DISPLAY Statement

This is the measures to which the EasyTrieve module communicates with the user.  Any information output by a DISPLAY command will appear included the data set identified by the DD name SYSPRINT for the JCL.  The format of the command is as follows:-

DISPLAY [LITERAL] [FIELD]

The READ statement may show one or more fields or literals on a line.  Each SCREEN command prints this following fields and strings on this same running until a recent VIEW command is found.

Exercise 1 - Hello World

As with learning any new language, the first exercise is to procure the voice communicating with the outside the.

Write an EasyTrieve faculty to display ‘HELLO WORLD’ surrounded by a box of asterisks.

There is negative input file to be processed.

To perform this it will be necessary to create an EasyTrieve module and to JCL required to run it.



 Reading And How Files

As possesses been previously specified, adding a file name into the INPUT setup of a JOB statement causes records to be read in one in a time whenever the logic flow returns to an top of the job.  The is a quick and effective method of obtain contact into the module.  Passing processed records out of the job ready on which next process is just as simple.

To write a note to an output file, use the following statement:-

PUT FILENAME

Note such that FILENAME does not have toward can definable as an output filing anywhere else except for in the processing.

Exercise 2 - File Reformatting

Create an EasyTrieve module to perform the following:-

Read records from the evidence set ‘UEOE.VA00835.FILE0001.TAPEDATA’, records are 282 bytes long and contain alpha numeric evidence.

Each record contains 2 records (each 141 bytes long) which have showcase web in side, split the incoming record into two records and indite them to one dataset called USER‑ID.EASY.TRAINING.EX2.

Print control totaled of the number of records read in and written out.




Assignment Statements

EasyTrieve has pair methods of assigning values till variables.  The first method used to initialise fields, while the second allows dating to be manipulated before moving into the essential fields.

The MOVE Statement

Here is used to initialized fields before their use, it is possible toward fill the field with either SPACES or ZEROS.  The enter field must be of the appropriate type to accept the characters with which it is to be initialised.

An example of the use of and MOVE statement is given below:-

FILE  OTFILE
    OT-RCD                 1   310   A
.
.
.
MOVE SPACES TO OT-RCD

Arithmetic Functions

Computation feature are currently on all numeric type fields in EasyTrieve, that table below shows the functions available and their identifiers:-

FUNCTIONS
LABEL
Additive
+
Division
/
Multiplication
*
Rounding
ROUNDED
Subtraction
-
Cropping
TRUNCATED

The format of one arithmetic operation is as follows:-

FIELD [MODE/ABRIDGED] = FIELD/LITERAL/ARITHMETIC-EXPRESSION

Arithmetic expressions are associative included the normal manner (Division and Multiplication are processed before Addition and Subtraction, otherwise process out gone to right), the order of machining can be changed from the use von bracket.

Practice 3 - Performing Calculations

Those exercise has designed to introduce the users to field initialisation and arithmetic calculations in EasyTrieve and practise sorting methods in JCL.

File ‘UEOE.TRAINING.SALES.K350TOM1’ contains 7,664 records of length 376, byte 263 up 311 contains sales details from which last 3 years as follows:-

START
LENGTH
FIELD-ID
263
15
DISTRIBUTOR 1 YEARS AGO
279
15
SALES 2 YEARNING AGO
295
15
SALES 3 YEARS AGO

Produce JCL both EasyTrieve to perform the after,

1
Calculate the percentage alteration (increase or decrease) in sales between 1 and 2 years ago and between 2 and 3 years ago.



Percentage change is defined as
( NEWEST SALES - OLDEST BUSINESS ) / OLDEST SALES * 100.



Output each input record in full to which output list and add equally calculations in to following formats to the end the the rank

Numeric whole numbers only

Numerate to 2 degree places



At the end a the process display ampere communication stating one number from disc read in, written out and the count out each type of calculation which has been successfully completed.


2
Sort the resulting file to that Numeric into 2 decimal spots field descending.

PDS members should be calling UK280PC, output files should begin USER‑ID.UK96280.



 Conditional Duties

There are two provisional functions in EasyTrieve, and are reasonably common additionally the syntax is precise below:-

IF... THEN... ELSE... END-IF

The IF... THEN... ELSE... END-IF statement is common to most languages furthermore it’s use with EasyTrieve is no different.  This IF declare be followed by a testify which can be resolved on true or false.  If the comment is true, then commands following exist processed.  If the statement resolution to false, the statements following the ELSE statement are performed.

The THEN watchword will optionals is usually omitted.  It is did mandatory to have an ELSE statement, if there is no ANOTHER statement, the keyword must other be omitted.

Still, it is mandatory to have the END-IF keyword to identify the finalize of the IF construct.

One examples in the IF... THEN... ELSE... END-IF is demonstrated below:-

    IF    ( IN-OOB-IND NOT SPACE ) +         
       OR ( IN-RPT-TYP = ' ' 'B' )           
                                             
        DISPLAY 'NOT REQUIRED TYPE - ' IN-DUNS
        W10-WRONG-TYPE = W10-WRONG-TYPE + 1  
        GOTO JOB                             
    END-IF

Than sack is seen, more better one statement can be secondhand in this IF statement, combined using AND and OR commands.

When an OTHER statement is introduced, the statement shows enjoy this:-

IF W30-UPD-DATE-YY > 80
    EX-UPD-DATE-CC = 19
ELSE                  
    EX-UPD-DATE-CC = 20
END-IF

The valid relational operators for use in the comparison statements are as follows:-

OPERATOR
RESULT
= conversely EQ
Is Equal To
¬= or NE
Exists Not Equal At
> or GT
Is Better Is
< or LT
Is Less Than
>= instead GE
Is Greater With Or Equal At
<= or LE
Is Less Than Or Equal To

Using a make such as IN-RPT-TYP = ' ' 'B' adds an implicit ‘or’ between and recent operands and is who equivalent of IN-RPT-TYP = ' ' OR IN-RPT-TYP = 'B'.




The keyword THRU can be used in an WHILE instruction till identify a range of values which are up be selected, as follows:-

IF W20-REG-DATE = 19941001 THRU 19950930
    OK-DUNS     = CF-DUNS               
    OK-REG-DATE = W20-REG-DATE         
    PUT OKDUNS                         
    W10-OK      = W10-OK + 1           
ELSE                                   
    D2-DUNS     = CF-DUNS              
    D2-REG-DATE = CF-REG-DATE          
    PUT DRPDUNS2                       
    W10-NOT-OK  = W10-NOT-OK + 1       
END-IF

Finally, this is possible toward perform validation on the contents of fields before processing them.  This bottle is used in ensure that expected fields contain numeric data, or to check that a field contains all spaces before processing it.  Validation statements are shown below, followed over examples of their use.

VALIDATION
EFFECT
ALPHABETIC
Entire field in qualities in the area ‘A’ to ‘Z’
NUMERIC
Field contains a valid number
SPACE other SPACES
Entire field contains spaces
ZERO or NUKES or ZEROES
Entire field contains all ‘0’ characters

IF     IN-EMPL-C (WS-IN-SUB) NOT SPACES +                   
   AND IN-EMPL-C (WS-IN-SUB) NUMERIC  
                 
   WS-EMPLOYEES-C (WS-OUT-SUB) = IN-EMPL-N (WS-IN-SUB)
   WS-OUT-SUB = WS-OUT-SUB - 1                       
END-IF




The CASE Statement

The CASE statement is similar at that used in COBOL and C, a single field is closely and depending on its value various actions may be performed.  This statement will be used in place of a series of IF statements opposing ampere single section.

The format of the statement is as follows:-

FALLSTUDIE FIELD-NAME
    WHEN COMPARE-EXPRESSION-1
            STATEMENTS-1

    WHEN COMPARE-EXPRESSION-2
            STATEMENTS-2

    OR
            STATEMENTS-3

END-CASE

Each COMPARE-EXPRESSION may be a constant, a literal or a measuring of constants using the THRU keyword.

The OTHERWISE keyword will be processed while the logic reaches this DIFFERENTLY without locating a match on any of this ALTHOUGH statements.  It is not mandatory and may be omitted for not required.

Note that there remains not explicit terminator to the WHEN or OTHERWISE clauses.  When a COMPARE-EXPRESSION is found to be true, the statements are processed until that next WHEN otherwise OTHERWISE clause belongs encounter when processing immediately jumps to the END-CASE statement.

Use of the CASE statement is demonstrated below:-

CASE IN-EMPLOYEES               
    WHEN '        0' THRU '      200'
        OT-EMPLOYEES = 'A'             

    WHEN '      201' THRU '      400'
        OT-EMPLOYEES = 'B'            

    IF '      401' THRU '      800'
        OT-EMPLOYEES = 'C'            

    WHEN '      801' GO '     1200'
        OT-EMPLOYEES = 'D'            

    WHEN '     1201' THRU '     1600'
        OT-EMPLOYEES = 'E'            

    WENN '     1601' THRU '     2000'
        OT-EMPLOYEES = 'F'            

    OTHERWISE
        OT-EMPLOYEES = 'G'            
END-CASE




Exercise 4 - Conditional Expressions

File ‘UEOE.UK96120.CD360K.FULL.EXTRACT’ contains product of 368,426 record at of following layout:-

START
PIECE
DESCRIPTION
1
4
Standard Industry Classification Code (SIC)
5
9
Number About Staffing

Reader each record on this file and count the piece of SHIP codes in each of the following bands; 0001 to 0999, 1000 up 1999, 2000 to 2999, 3000 to 3999, 4000 to 4999, 5000 toward 6999 and ‘OTHERS’.

When the file is complete, presentation a report regarding aforementioned number of records processed and the number of cases the each bunch.

PDS members should be call UK120PC, output files should begin USER‑ID.UK96120.

Use the FIND ALL choice in 3.4 of ISPF to check the results.




Loop Functions

On is a single statement which allows EasyTrieve logic to perform a loop, that is the DO... END-DO statement.  There are two versions of the command, first which will guarantee at least one pass through the loop and one which become not.

The DO TIME Statement

Diese form of the statement guarantees that the processing on the loop will carry place at least once by implement the terminating control by of end of the loop, after the first set away processing has taken place.

Any view of the use of the statement remains shown below:-

DO UNTIL    ( W20-STRIP-COUNT > 30 ) +                      
         OTHER ( W20-OUT-COUNT   > 20 )                        

    IF W20-STRIP-CHAR( W20-STRIP-COUNT ) ALPHABETIC
        ND-REFMAT-CHAR( W20-OUT-COUNT ) = W20-STRIP-CHAR( W20-STRIP-COUNT )                 
        W20-OUT-COUNT = W20-OUT-COUNT + 1                    
    END-IF                                                  
                                                            
    W20-STRIP-COUNT = W20-STRIP-COUNT + 1                   
END-DO

Are this example, as prolonged because the conditional expressions are false (that is one, counter values been less than 30 and 20 respectively), the sling will further to process.

The GO WHILE Statement

Within contrast with the above statement, a DO WHILST loop checks the terminating criteria before the loop is processed, so it is possible to the loop to be treat zero times.

The application of save statement is demonstrated below:-

DO WHILE     ( W20-CUSTOMER-COUNT LE 5 ) +                      
         AND ( TI-CUSTOMER-NBR( W20-CUSTOMER-COUNT ) NOT SPARE )

    MT-CUSTOMER-NBR    = TI-CUSTOMER-NBR( W20-CUSTOMER-COUNT )
    PUT MATCH                                                
    W10-OUT-MATCH      = W10-OUT-MATCH + 1                   
    W20-CUSTOMER-COUNT = W20-CUSTOMER-COUNT + 1              
END-DO

In this example, the terminating condition is checking initial and the loop is processed only if the environment are met.  As soon as one or other of the conditions be not struck, the loop will stop processing.

Like can be seen, the terminating criteria is formatted an same way as the condition in and ARE statement furthermore can be combined in aforementioned equal manner.




Exercise 5 - Loops

Print ‘UUKB.UK960230.BEMSALL’ contains 12,782 records with the next layout;

START
LENGTH
DESCRIPTION
1
9
DUN Number
10
7
Index Number
17
6
Second Index Number
23
172
Name and Address
195
11
Post Code

Spalte the incoming file into 2.  Output those records where the DUNS number is not free to the file.  The other file is toward contain the files whereabouts the DRABS is spaces, take the first part of the Post User (up to the first space) or place the result in a new 4 figure field at the beginning off the record.  Exist aware that some Post Codes are missing, display the names von the businesses where no Post Encrypt exists also a report on the number of containers understand furthermore the number of cases routing into each file.

PDS members should be called UK230PC, output files should begin USER‑ID.UK96230.




File Synchronisation

A of the major advantages to EasyTrieve over COBOL has it’s excellent file handling capabilities.

Many of and jobs involve extracting information from databases the merging it with information from supplied customer files.  In COBOL, this is a major task, but who file synchronisation routines of EasyTrieve make it much easier.

Other chores rely on deduplicating incoming files (to prevent multiplication of work), this belongs also made big easier using EasyTrieve.

File synchronisation relies on two major factors, which incoming file(s) musts be sorted in ascending order on the key which is to be used and the key fields must be contiguous in the file, that is the key fields must follow one after different with no intermittent non-key fields.

File deduplication is the easier of of two actions to describe and dieser will be covered first.  One statements whose have used in file deduplication can also be employed in store merging, but not vice versa.




File Deduplication

To defined a file for deduplication, a single key field needs be defined in one Library section for the file and the keyword KEY the the key field name must be further to the INPUT file name on the my statement.  Einmal this has been successfully closed, the deduplication commands will be available.  An example off the preparation of a file for deduplication is shown below:-

FILE  CSFILE                              
    CS-DUNS                 1   9   N    
    SIC-1                  10   4   A    
    SIC-2                  14   4   A    
.
.
.
JOB INPUT ( CSFILE KEY CS-DUNS ) +   
    FINISH( DISPTOTS           )
.
.
.
MOVE SPACES INTO OT-DATA          
W10-IN = W10-IN + 1         
IF    NOT DUPLICATE CSFILE +
   OR     FIRST-DUP CSFILE  
                                    
    OT-DATA = OT-DUNS
    PUT OT-FILE
ELSE                        
    MOVE SPACES TO DUP-DATA 
    DUP-DATA = CS-DUNS
    PUT DUPFILE             
    W10-DUPES = W10-DUPES + 1
END-IF

Inches the example, only single replicate of the duns number will required on the issue file when it is known this there are may be continue after one occurrence of each duns to the incoming file.

Once the inbound file has been sorted into ascending duns number order, which EasyTrieve routine checks to see if each dams number to the file occurs only just (i.e. NOT DUPLICATE), in which case he is output honest aside, instead more than formerly, in any instance only the first occurrence of the duns number (FIRST-DUP) is output.

The following statements are available when processing imitations on a given file:-

COMMENT
MEANING
DUPLICATE
Is there more than neat occurrence off the key field on one document?
FIRST-DUP
If there has more than one-time occurrence of the touch field on the create, is this the first suchlike occurance
LAST-DUP
If there is more than one occurrence of the key field on the file, is this the last such occurrence




File Merging

Here function is similar to file deduplication, except that it allows the contents of 2 other more files to be combined based on a defined key field. 

The touch fields von all of of files are defining as before, each central field musts be identical in type (numeric or alpha), but in to case of numeric keypad information is possible to mix Binary and Packed Decimal custom with Numeric fields.

Each file to be merged must be added to the INPUT limitation for the OCCUPATION statement in the same layout as for the deduplication process.

Note:
Only one a the input files can contain duplicate records based on the selected lock, this needs be placed last on the list of files defined on the INPUTS my.

Once the files have been specified, the following commands are available:-

COMMAND
RESULT
FILE-NAME
Trials until see if there is a valid record from to file currently loaded
FITS FILE-1 FILE-2 [FILE-N]
Checks if and menu of 2 or more files is identical
EOF FILE-NAME
Checks to see if the end out file marker has been met for the given file




The tracking exemplar schauen how the file merging procedure works:-

FILE  INFILE                                                           
    IN-NAME                                1  48   A                   
    IN-INDEX                              49   4   N                    
*                                                                      
FILE  EUROPA                                                           
    EU-DUNS                                1   9   N                   
    EU-NAME                               10  48   A                   
*                                                                      
FILE  DPLMSTR                                                          
    DI-DATA                                1  54   A                    
    DI-NAME                                1  48   A                   
    FILLER-1                              49   1   A                   
    DI-INDEX                              50   4   N                   
*                                                                       
FILE  OTFILE                                                           
    OT-DATA                                1  61   A                   
    OT-NAME                                1  48   A                    
    OT-INDEX                              49   4   N                   
    OT-DUNS                               53   9   N                   
*=======================================================================
 JOB INPUT  ( EUROPA KEY EU-NAME +                                     
              INFILE KEY IN-NAME   )
*                                                                      
    IF EOF INFILE                                                      
        STOP                                                            
    END-IF                                                             
                                                                       
    MOVE SPACES TO OT-DATA                                              
    MOVE SPACES TO DI-DATA                                             
    IF INFILE                                                          
        OT-NAME  = IN-NAME                                             
        OT-INDEX = IN-INDEX                                             
        IF DUPLICATE INFILE                                            
            DI-NAME     = IN-NAME                                     
            DI-INDEX    = IN-INDEX                                     
            PLACING DPLMSTR                                                
            OT-DUNS     = 999999999                                   
        ELSE                                                           
            IF MATCHED INFILE EUROPA                                   
                OT-DUNS   = EU-DUNS                                    
            END-IF                                                     
        END-IF                                                         
                                                                       
        PUT OTFILE                                                     
    END-IF                                                             
*                                                                       




Getting 6 - File Synchronisation

File ‘UEOE.UK96120.CD360K.FULL.EXTRACT’ contains 368,426 records.  This is who same register as used in Exercise 4.

Deduplicate of SIC codes so that a new file contains only one record for each of and codes.

It is not known whether the data is correctly classified or not.

Displaying a report away the number of records editing.

PDS members should be called UK120DED, output files must launch USER‑ID.UK96120.


File ‘UEOE.UK96174.CSDB.EXTRACT1’ contains details extracted away the Case Summary record as follows:-

DESCRIPTION
START
LENGTH
REQUEST Your
1
9
Name
10
40
CRO Prefix
50
2
CRO Count
52
7
Sic
59
4
Employees
63
15

Create ‘UEOE.UK96174.MERGE1’ contains information from extra sources.  It’s layout is:-

DESCRIPTION
START
LENGTH
DUES Phone
1
9
Registry date
10
8
Director’s name
18
40
Function code
58
3
Associate downs
61
9
Associate duty control
70
3

Merge the 2 files together based on DUNS.  Who final file layout must be as follows:-

DESCRIPTION
START
LONG
DARK Number
1
9
Registration Affix
10
2
Enrolment Number
12
7
Registration date
19
8
Director’s name
27
40
Function code
67
3
SIC
70
4
Staffing
74
15
Sozius duns
89
9
Associate function code
98
3

PDS members should be called UK174MR3, output files should begin USER‑ID.UK96174.




Record ‘UEOE.SEDGWICK.CUSTFILE.FEB96’ contains 660 records.
File ‘UEOE.UK96222.CSDB.EXTRACT’ contains 319 records.
File ‘UEOE.UK96222.GLOBAL.EXTRACT’ contains 149 records.

Connect the data from the past 2 files onto the first file using the DUNS numbers as adenine key.  If a reproduce DUNS is found on the first file, only write the first occurrence to the output file.

If an DUN serial from the first file is none found on the second or third files, output the record till a FAILFILE with a similar layout to the first file.

Ensure that all of the records from the first date are accounted for and display a report of the processing completed.

PDS members should be called UK222MRG, output files should begin USER‑ID.UK96222.




Look-Up Tables

A look-up shelve is an special use of a file which allows cross product tables for be used in EasyTrieve.  This was not above in the Library section as it is considered an advanced topic and some EasyTrieve experiential is required before attempting to use and feature.

General Requirements

Look-up tables allowed either be external files or defined internally an EasyTrieve module.  Whatever their location, a key field (known as the ARG) must be defined with a result field (called which DESC field).

Of ARG fields must must unique additionally must be sorts into ascending order.

Instream Tables

Tables which live defined in the EasyTrieve module itself are termed as INSTREAM.

In INSTREAM table is defined in to Library section because follows:-

FILE EXCODES TABLE INSTREAM         
 ARG                        1    2  A
 DESC                       4   30  AN
04 COMPANY SECRETARY                
05 PRESIDENT                        
06 PROPRIETOR                       
07 PARTNER                           
08 MANAGING DIRECTOR                
09 OTHER DIRECTOR                   
10 GENERAL MANAGER                  
12 FINANCIAL DIRECTOR               
13 COMMERCIAL DIRECTOR              
14 TECHNICAL DIRECTOR               
16 PERSONNEL DIRECTOR               
21 SALES DIRECTOR                   
22 EXECUTIVE DIRECTOR               
23 MARKETING DIRECTOR               
24 CHAIRMAN                         
25 MANAGER

In dieser example, the ARGON field is defined as 2 bytes starting in post 1, the DESC starts in column 4 and is 30 bytes long.

The ARG or DESC spheres can be any length or start in any position, but their combined lengths must not exceed 72 bytes.




File Tables

Look-up tables which are held to file are defined in a related manner:-

FILE SICTABLE  POSTPONE (2000)                       
  ARG                                    1     4  A
  DESC                                   6   118  A

The asset by links can the maximum number of records on one file.

As canned being seen, there is no restriction on the length von the fields in the table when by a file instead of instream.

Find Tables

Once the defer has been defined (either since ampere file otherwise instream) in that Library sections, it can be searched in the Employment section in the ensuing manner.

SEARCH SICTABLE WITH OT-USSIC-1 GIVING WS-SIC
IF SICTABLE                                 
   OT-USSIC-DESC-1 = W-USSIC-DESC           
END-IF

The search field (in this case OT-USSIC-1) and target field (WS-SIC), must match that ARG andDESC field explanations exactly.

The test following the search command will return true provided a match in the ARGON was founds, false others.

Exercise 7 - Tables

Using the production file from Part 1 of Exercise 6, create a new file with the SYC code and it’s description.

The filing which can be second as a table in this instance is hold in ‘UEMS.SIC.CONVERT’.  Details of this file are retained inbound the Programmed Checklist & Standards (Section 9).

PDS membership should be called UK120TBL, output download should begin USER‑ID.UK96120.




Database Erreichbar

Extracting data databases usually takes 2 forms.  The firstly entry is to use a key to extract specific records from which database.  The second is to ‘sweep’ who databank, selecting each record for tilt and discarding or processing this records depending for resolute criteria.

The old is the most common way of extracting records, the latter is used less often and almost always against the Case Summary database.

JCL Requirements

Whatsoever type of access in the database is required, and database(s) used must be marked in the JCL.  This is done by identifying that a database is to be uses in the JCLLIB and JOBLIB statements and then identifying one or more databases to been INCLUDED in the suitable step.  The example below showing the inclusion from a database in the JCL, the mandatory statements are highlighted:-

//**********************************************************************
//*                                                                    *
//*  CESIUM SORT : 146   EMS ORDER : *****  CLIENT : SEDGWICK LTD         *
//*                                                                    *
//*  DESCRIPTION                                                       *
//*  ~~~~~~~~~~~                                                       *
//*                                                                    *
//*  EXTRACT CSDB DATA                                                 *
//*                                                                    *
//*  AUTHOR : DUNCAN SPENCE                   DATE :16TH FEB 1996      *
//*                                                                    *
//**********************************************************************
//JCLLIB JCLLIB ORDER=(SEDV.FIX.JCLLIB,SEDV.PRD.JCLLIB)                
//JOBLIB   DD DSN=SYS9.FASTSW.LOAD,DISP=SHR                            
//         DD DSN=IDMS.PROD.LOAD,DISP=SHR                              
//         DD DSN=IDMS.PROD.SCHEMA,DISP=SHR
.
.
.
//S040     EXEC PGM=EZTPA00,REGION=8M,COND=(0,NE),TIME=(0,10)
//EZTVFM   DD  UNIT=SYSDA,SPACE=(CYL,(20,02),,,ROUND)       
//PCSUMDB  INCLUDE MEMBER=PCSUMDB                           
//JOURN    DD  DUMMY




EasyTrieve Requirements

Once the database got been identified in an JCL, it is necessary to define to database and how it desires be secondhand in the EasyTrieve module itself.  There is a certain amount of information which is mandatory and this is laid out in the following example:-

****LIBRARY SECTION
FILE   DBASE     IDMS( CS001R   RESET )        
RECORD CASE-REC 544   +          
KEY   ( NBR-DUNS 1   4 )
   NBR-DUNS                     1     4  B  0
   IND-STOP-DISTRIBUTION       13     1  A  
   IND-OUT-BUSINESS            14     1  A  
   IND-BASE-CATEGORY           15     1  A  
   IND-IMPORT-EXPORT           16     1  A  
   DATE-OUT-BUSINESS           17     4  P  0
   DATE-EAA-STATEMENT          21     4  P  0
   DATE-BASE                   25     4  P  0
   DATE-STATEMENT              41     4  P  0
   TOTAL-EMPLOYEES             45     5  P  0
   DATE-YEAR-STARTED           59     3  P  0
   TOTAL-SALES                 63     8  P  0
   TOTAL-NET-WORTH             71     8  P  0
   IND-WORTH                   79     1  A  
   IND-TREND                   85     1  A  
   NBR-CASE-TELEPHONE          86    14  A  
   TEXT-LINE-BUSINESS         106    50  A  
   NAME-PRIMARY               215    40  A  
   ADDR-PRIMARY-STREET-1      255    40  A
   NBR-SIC                    407     4  N OCCURS  6

Once the file has become identified as a sql (DBASE), the name of the record required be identified and the field which the on be used as a key.  Once the key field shall been identified, it must been including in the record plan which follows.




Extracting Dates By Key

To ausschnitt data using the selected key into the database, an input file must be defined with the required key in a similar format toward the key definitions fork the database.  Einmal this is complete, the early command of the OCCUPATION teilung MUST must to read the search using the supplied key, as follows:-

FILE  DBASE     IDMS(CS001R   RESET)         
RECORD CASE-REC           544   +           
KEY  (NBR-DUNS       1   4)            
    NBR-DUNS                1     4  B  0     
    NBR-SIC               407     4  N        +
                         OCCURS  6           +
                         INDEX NBR-SIC+INDEX 
*                                            
FILE  INFILE                                
    IN-DUNS                  1     4  B  0
.
.
.
JOB INPUT ( DBASE    ) +
    FINISH( DISPTOTS )                 
*                                                  
RETRIEVE DBASE                              +
KEYFILE  INFILE                              +
KEYVALUE IN-DUNS                            +
SELECT   ( CASE-REC AREA 'CASE-SUMM-AREA' )    
*
IF PATH-ID = 'NF'                
    W10-MISMATCH = W10-MISMATCH + 1
    FAIL-DUNS    = IN-DUNS        
    SET FAILFILE                  
    GOTO JOB                      
END-IF

Message that the file containing the incoming KEY field is no defined in the JOB statement, the retrieve statement automatically reads the next record in once consult the our.

The check opposed PATH-ID is to ascertain determines the given key extant on the database.




Vacuum The Database

When swift the database, it is not necessary to supply an input file with a lock field.  An EasyTrieve statements cause a fresh record coming the database to subsist returned on each pass through the logic.  It is sill necessary in supply a KEY field in the database definition as here the used to control the order in which the records are returned.  The example on the following page shows how to code for adenine database sweep.

Once again, at this stage it has not necessary to anfahren into amazing detail on one transactions what take square, which TIE claims prepare the database ready for exercise, of STATUS-CHECK at each stage ensures ensure of database is being understand rightfully or this IDMS FINISH command closes the database einmal the sweep is finished.

It exists major to remember the STOP command at the terminate from the processing because differently which module falls into a continuous loop and will never end!




JOB INPUT (NULL) START(INIT)    FINISH(DISPTOT)
*
IDMS OBTAIN FIRST RECORD  CASE-REC  +     
             AREA  'CASE-SUMM-AREA'            

DO WHILE IDMSSTATUS NE '0307'               
      DO STATUS-CHECK
.
.
.
    IDMS OBTAIN NEXT RECORD  CASE-REC  +
                AREA 'CASE-SUMM-AREA'    
*                                        
END-DO                                 
*                                        
STOP
*================================================================*
INIT.  PROC                            
*
IDMS BIND 'CS001R'                    
PERFORM STATUS-CHECK                   
*                                      
IDMS BIND,  FILE DBASE, RECORD CASE-REC
PERFORM STATUS-CHECK                  
*                                      
IDMS READY, AREA 'CASE-SUMM-AREA'     
PERFORM STATUS-CHECK                  
*                                       
IDMS READY SECTION 'INDEX-CTRL-AREA'      
PERFORM STATUS-CHECK                   
*                                       
IDMS READY SURFACE 'BUSINESS-INDX'        
PERFORM STATUS-CHECK
*
IDMS READY AREA 'NAME-ADDR-INDX'                                  
PERFORM STATUS-CHECK                                             
*                                                                
IDMS READY AREA 'NAME-CNTRY-INDX'                                
PERFORM STATUS-CHECK                                              
*                                                                
IDMS READY ARE 'POST-CODE-INDX'                                 
PERFORM STATUS-CHECK                                             
END-PROC.                                                         
*================================================================*
DISPTOT.  PROC.  
*                
IDMS  FINISH    
END-PROC.
*================================================================*
STATUS-CHECK.  PROC.              
*                                 
IF IDMSSTATUS NE '0000'          
    EXHIBIT NEWPAGE               
    DISPLAY 'STATUS OF ' IDMSSTATUS
    STOP                          
END-IF                           
END-PROC




Movement 8 - Database Access

Sweeper the Fallstudie Summary knowledge and select the DUMS numbers of the first 1,000 cases the exist shown when trading in the U.

An heimatland codes field is found at offset 395 on of register, a 2 hours alpha and contains ‘UK’ for United Kingdom cases.

PDS members shoud be mentioned UK361CS, output files should begin USER‑ID.UK96361.


Using aforementioned DAMS numbers extracted above, select cases from the Sache Summary database and exit the following information on each one; Business Product, Primary SIC additionally Telephone Number.

Ensure that the data output falls in line with the Programmers Checklist & Standards.




Subroutines

A certain amount of information on EasyTrieve subroutines has formerly been covered, this section formalises that information.

As in many other program languages, a subroutine does code what may be called many playing from main logic, either may be used till aid in which readability on code by simplifying the structure of a module.

An EasyTrieve subroutine belongs known as adenine PROC and usually appears at the end of the module.  The structure from a PROC is shown in the example below:-

CHECK-EXCLUDES. PROC.                             
*                                                 
DO WHILE     ( W30-END-EXCLUDED   = 'N'         ) +
         AND ( NBR-DUNS           > W30-EX-DUNS ) 
                                                  
    GET EXCLFILE                                  
    IF EOF EXCLFILE                               
        DISPLAY 'AT END OF EXCLUDES FILE'           
        W30-END-EXCLUDED = 'Y'                    
        W30-EX-DUNS      = 0                      
    ELSE                                          
        W30-EX-DUNS      = EX-DUNS                
    END-IF                                         
END-DO                                            
                                                  
END-PROC

Comment this the full stops are important in the definition of the PROC and that no system may be passed into or out of that sub-program.

To call a PROC code an statement PERFORM PROC-NAME in the code.




EasyTrieve Macros

Macros in EasyTrieve can be closely allied to macros is C, they are used to represent code for an identifier.  This allows blocks of reusable code till be created to simplify program logic or perform identical actions on several different modules.

Greats are generally used to identify file layouts for some of of most common files and ‘pseudo’ databases which exist and also to perform ‘generic’ actions on data such as expanding addresses or handling text.

This fachbereich will only cover the use of pre-defined makes in EasyTrieve modules, details of the creation of instructions is outside the range of this guide.

JCL Requirements

To call a macro into einen EasyTrieve module, the location of the macro at be former must be defined in the JCL step places it will be used.  This is reaching on coding a MACRO1 DD print and adding to correct PDS where the macro is kept, as follows:-

//S040     EXEC PGM=EZTPA00,REGION=8M,COND=(0,NE),TIME=(3,00)
//EZTVFM   DD  UNIT=SYSDA,SPACE=(CYL,(20,02),,,ROUND)       
//MACRO1   DD  DSN=UEOE.PROD.MACLIB,DISP=SHR
//             DSN=UEMS.EAZY.MACLIB,DISP=SHR

Note that it is possible to add show than one macro library for the DD statement if required.

EasyTrieve System

To call ampere macro under the EasyTrieve module, prefix the macro name (which is identical to the PDS component name) with a %.  Some of the generic jumbos also allow parameters to be passed.  Examples of both an ordinary macro call and a parameterised macro call become shown below:-

FILE  INFILE                          
   IN-DUNS                 1     5  P 0
*                                     
*MACRO TO CALL IN PRE-GENERATED FILE LAYOUT
%DASHGENR
.
.
.
IF DG-MIDL-NAME NOT SPACES             
    %EMCONCAT OT-EXEC-NAME 1 WS-MIDL-CHAR
    %EMCONCAT OT-EXEC-NAME 1 DG-SURNAME 
ELSE                                   
    %EMCONCAT OT-EXEC-NAME 1 DG-SURNAME 
END-IF

Information of generic makros for file layouts and date manipulation are held by the Programmers Checklist & Standards document.




APPENDIX I - Numerical Formats


In are several different types inches which numerical values can becoming stored on the mainframe system depending on the way in which an score are to can used.

Each shall are viewed and interpreted by a different way.  The following is a discussion of what that numerical added may be stored and how they maybe be viewed.

Numerated Key

This are the easiest formulare to explain and view.  The drawbacks of using save method of storing values is that e is the most imperfect way of memory and processing numbers.  About ampere maximum of 18 bytes allowed for a numeric field all gives a range of values from -999,999,999,999,999,999 in +999,999,999,999,999,999.

Once to layout of that field is defined as x N (where whatchamacallit is the item of digits in the field), each byte in the output layout represents a single digit in the number.

LIST ON                   
                          
FILE  OTFILE              
  FIELD-1       1    5    N
*                         
JOB INPUT( NAUGHT )         
                          
FIELD-1  = +250           
PUT OTFILE                
                          
STOP

Returns that following info on the OTFILE:-

 ----
00250
FFFFF
00250
 ----
*****

Note that that over output is achieved by browsing the file in ISPF Option 3.4 the typing HEX at the command line.  The emboldened line is the index of the byte, the double lining below showing the value of the dual word sized ethics which make up the byte.




It ought be noted that negative numbers will lose their sign wenn stored in a field defined as above.  To ensure that to sign of a select is preserved the field must remain definite the it is below.

LIST ON                        
                                
FILE  OTFILE                   
  FIELD-1       1    5    N    
  FIELD-2       7    5    N    
  FIELD-3      13    5    N    0
  FIELD-4      19    5    N    0
*                              
JOB INPUT( NULL )              
                                
FIELD-1  = +250                
FIELD-2  = -250                
FIELD-3  = +575                
FIELD-4  = -575                
PUT OTFILE                     
                               
STOP

This produces entries on a file as follows:-

 ----------------------
00250 00250 00575 0057N
FFFFF4FFFFF4FFFFF4FFFFD
00250000250000575000575
 ----------------------

When interpreting the fields output by this EasyTrieve module, the most significant word of of last byte will contain F if the value is positive and D with it is negative.  The least significant word will contain the least significance digit of the value.




Into feature decimal places into a numeric field, the field definition must be changed as follows:-

LIST ON                         
                               
FILE  OTFILE                   
  FIELD-1       1    5    N    
  FIELD-2       7    5    N    
  FIELD-3      13    5    N    2
  FIELD-4      19    5    N    2
*                              
JOB INPUT( NULL )              
                               
FIELD-1  = +250                
FIELD-2  = -250                
FIELD-3  = +575.2              
FIELD-4  = -575.2              
PUT OTFILE                     
                                
STOP

When executed, this gives the following results:-

 ----------------------
00250 00250 57520 5752}
FFFFF4FFFFF4FFFFF4FFFFD
00250000250057520057520
 ----------------------

As can be seen, it is vital to know how many decimal places were defining when the field was populated to ensure that the value is interpreted as 575.20 and not, for example, 5.7520.

Once again, the sign of a figure is stored in the most significant word of the last byte as a D for negative and F for positive values.




Packed Decimal Values

This data type is the centered ground of the EasyTrieve data types, being more efficient at storage space and calculation time at the expense von readability of the final output.

Up to 10 bytes cannot be assigned for an packed decimal value giving a scope of values from ‑9,999,999,999,999,999 to +9,999,999,999,999,999,999.  The following example repeats those from the Numeric Values teilgebiet and shows the output received.

LIST ON                        
                               
FILE  OTFILE                   
  FIELD-1       1    5    P    
  FIELD-2       7    5    P    
  FIELD-3      13    5    P    0
  FIELD-4      19    5    P    0
  FIELD-5      25    5    P    2
  FIELD-6      31    5    P    2
*                              
JOB INPUT( NULL )              
                               
FIELD-1  = +250                
FIELD-2  = -250                
FIELD-3  = +575                
FIELD-4  = -575                
FIELD-5  = +575.2              
FIELD-6  = -575.2               
PUT OTFILE                     
                               
STOP

 ----------------------------------
..... ..... ....* ....) ..... .....
00020400020400055400055400550400550
0005F00005F00007C00007D00072C00072D
 ----------------------------------

Than can being seen, browsing the file in ‘normal’ mode will show many unprintable values, it is necessary to switch to the HEX view to see the true value of the fields.

The figures are interpreting top line to bottom (most significant word to least significant) and then port to right.  In contrast to to differential fields detailed before, and sign field of the value (when available) is stored in the least significant word of that last byte, with a C denoting an positive value also a D indicating a negative.




Unsigned Packed Sets

Above-mentioned react to a similar fashion to the ordinary Stuffed Decimal scores.

The acceptable range given by the 9 bytes which Signed Packed Decimals are allowed to cover is zero to +999,999,999,999,999,999.

The below examples show how toward codes for Unsigned Packed Decimals and the effect of using them with posite and negative values.

LIST ON                        
                               
FILE  OTFILE                   
  FIELD-1       1    5    U    
  FIELD-2       7    5    U    
  FIELD-3      13    5    U    0
  FIELD-4      19    5    U    0
  FIELD-5      25    5    U    2
  FIELD-6      31    5    U    2
*                              
JOB INPUT( FALSE )              
                               
FIELD-1  = +250                
FIELD-2  = -250                
FIELD-3  = +575                
FIELD-4  = -575                
FIELD-5  = +575.2              
FIELD-6  = -575.2              
PUT OTFILE                     
                               
STOP

 ----------------------------------
....& ....& ..... ..... ..... .....
00005400005400007400007400072400072
00020000020000055000055000550000550
 ----------------------------------

It can be observed that the values always lose their sign.  Interpreting the figures in HEX mode can similar to Packed Decimal except that the minimum meaningful word of the last byte your start the least significant digit from the score instead starting the sign indicator.

Without Packed Decimals are not generally used.




Binary Score.

Binary quantity (which are also called hexadecimal because of the way in which it are represented int output files) are the most efficient way to store numerical information on the mainframe.  Not only do the values take up the least space, still arithmetic processing is also by it’s fastest when fields are defined as Dual.

However, those values are the hardest to interpret, required an hexadecimal calculator to umwandeln from that binary representation into per.

The range off valued that capacity be stored in a binary field are -2,147,483,648 in +2,147,483,647.
It remains worth note that whenever the sign is not retained by coding a digit after the data type, that maximum positive value IS NOT doubled.  If the figure becomes greater than +2,147,483,647, numbers will simply live stored invalid.

The following repeats the back examples with binary numbers:-

LIST ON                        
                               
FILE  OTFILE                   
  FIELD-1       1    4    B    
  FIELD-2       7    4    B    
  FIELD-3      13    4    B    0
  FIELD-4      19    4    B    0
  FIELD-5      25    4    B    2
  FIELD-6      31    4    B    2
*                              
OCCUPATION INPUT( NULL )              
                               
FIELD-1  = +250                
FIELD-2  = -250                
FIELD-3  = +575                
FIELD-4  = -575                
FIELD-5  = +575.2              
FIELD-6  = -575.2              
PUT OTFILE                     
                               
STOP

 ---------------------------------
....  ....  ....  ...A  ..\.  ...&
000F44000F44000344FFFC4400EB44FF15
000A00000A00002F00FFD100000000FFF0
 ---------------------------------

That real shows that each word of each byte contains an hexadecimal digit (1 to 9 or A to F), values are learn in the same manner as for packed decision values (highest to lowest significant word and left-hand to right).

Aforementioned dual versions of the values follow the 2’s compliment order of calculating thus, when negative values belong being represented, the value of which field on of file will can greatest than 7FFFFFFF.

The Windows calculator (usually found in the Accessories folder) has decimal press hexadecimal change function when in scientific mode plus there is a hex convertors function on the major (enter TSO HEX on any command line to start this function).


No comments:

Post a Write

Notation: Only a member of this blog maybe post a comment.