Adding "EQUALS" parameter to the Easytrieve Internal Sort statement
search cancel

Adding "EQUALS" parameter to the Easytrieve Internal Sort statement

book

Article ID: 43200

calendar_today

Updated On:

Products

PanAudit Plus Easytrieve Report Generator PAN/SQL

Issue/Introduction

Question:  

What we need is a way to have the EQUALS parameter included into the SORT statement that is passed to the SORT package, or a way to have the SORT package take EQUALS as the default for this particular sort. 

The SORT statement that we need to be passed to SORT is: 

SORT FIELDS=(1,4,BI,A,5,4,CH,A),EQUALS 

 

The problem we have, is that the file we are sorting has multiple records with the same exact sort key. At present, the records having the same sort key do NOT keep their input sequence in the output file. We need them to keep that sequence. 

For example, if we sort the following records by positions 1 to 4: 

 

0001 registro1 

0002 registro2 

0003 registro3 

0001 registro 4 

0004 registro 5 

0002 registro 6 

0006 registro 7 

0003 registro 8 

0006 registro 9 

 

The correct output sequence would be: 

 

0001 registro 1 

0001 registro 4 

0002 registro 2 

0002 registro 6 

0003 registro 3 

0003 registro 8 

0004 registro 5 

0006 registro 7 

0006 registro 9 

 

But the sequence we get is: 

 

0001 registro 4 

0001 registro 1 

0002 registro 6 

0002 registro 2 

0003 registro 8 

0003 registro 3 

0004 registro 5 

0006 registro 7  

0006 registro 9 

 

Answer: 

 

With the following code in your Easytrieve program;

 

SN-ITN-CONT 1 4 B 

SFECHA-AAAA 5 4 A 

SORT SALIDA TO SALIDA USING(SN-ITN-CONT SFECHA-AAAA) 

 

will generate SORT FIELDS=(1,4,BI,A,5,4,CH,A) 

 

EQUALS 

specifies that the original sequence must be preserved. 

An example would be; 

SORT FIELDS=(6,5,CH,A,22,8,ZD,D,4,2,ZD,A),EQUALS 

 

You can't specify EQUALS after the easytrieve SORT USING statement. But you can put the EQUALS option in the DFSPARM DD statement. 

 

When DFSORT is invoked programmatically (like we do with Easytrieve), then the options will be taken from the DFSPARM DD, SORTCNTL, and then PARAMETER LIST. --- We don't include the EQUALS parm in the parameter list string, but it can be included as follows;

 

//DFSPARM DD * 

EQUALS 

 

/*      

 

 

 

Environment

Release: EDBMSU00200-6.4-Easytrieve-Report Generator-Option for DB2-MSU
Component: