Page 1 of 1

Matrix logic using ICETOOL.

Posted: Sat Jul 23, 2011 5:45 pm
by kunnu
Hi,

Could you please help me in getting the desired output through ICETOOL.

Explanation:
The records from both the input files should be matched based on the field EMPNO and needs to be written in the fashion as shown below. The output should written as a matrix form which you will be able to exactly understand by looking at the output structure.

In the input file-1 if it has one record for e.g take a record with EMPNO = 100 and the fie-2 has 2 records then it will write the output as 2 occurences of the EMPNO giving 2X1 matrix keeping the LOC field as same of the above for both the records in the output. Similarly the same thing happens for all the records with different EMPNO.

There is one more logic as you can see in the structure the input file-2 has one more field NAME. The name field will be overlayed in the output file as shown.

The length of each field EMPNO, LOC and NAME can assumed as 10 bytes. Input files can have RECFM=FB and LRECL=80,

Please refer to the below output structure for more clarity.

Code: Select all


Input:
File-1

EMPNO   LOC 
100     MUM-A      
200     DEL-B 
200     DEL-C
300     COI-A 
300     COI-B 
300     COI-C
400     KOL-P
400     KOL-Q
600     CHE-Z
 
File-2

EMPNO   LOC       NAME
100     MUM-P   
100     MUM-Q 
200     DEL-R
300     COI-S
300     COI-T     BECKY
300     COI-U
300     COI-V
400     KOL-E     RONAL3
400     KOL-F     RONAL2

500     NOI-G

Output:

100     MUM-A
100     MUM-A
200     DEL-B
200     DEL-C
300     COI-A
300     COI-B
300     COI-C
300     COI-A     BECKY
300     COI-B     BECKY
300     COI-C     BECKY
300     COI-A
300     COI-B
300     COI-C
300     COI-A
300     COI-B
300     COI-C
400     KOL-P     RONAL3 
400     KOL-Q     RONAL3
400     KOL-P     RONAL2
400     KOL-Q     RONAL2


Note:
If the BECKY would have been on this record "300 COI-U BECKY" then the output would be as below. I have shown the below output only for EMPNO = 300 and so on.

Code: Select all


Input

300     COI-S
300     COI-T
300     COI-U     BECKY
300     COI-V

Output:

300     COI-A
300     COI-B
300     COI-C
300     COI-A
300     COI-B
300     COI-C
300     COI-A     BECKY
300     COI-B     BECKY
300     COI-C     BECKY
300     COI-A
300     COI-B
300     COI-C

Posted: Tue Jul 26, 2011 1:37 am
by Frank Yaeger
You can use a DFSORT job like the following to do what you asked for:

Code: Select all

//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//IN1 DD *
100       MUM-A
200       DEL-B
200       DEL-C
300       COI-A
300       COI-B
300       COI-C
400       KOL-P
400       KOL-Q
600       CHE-Z
//IN2 DD *
100       MUM-P
100       MUM-Q
200       DEL-R
300       COI-S
300       COI-T
300       COI-U     BECKY
300       COI-V
400       KOL-E     RONAL3
400       KOL-F     RONAL2
500       NOI-G
//SORTOUT DD SYSOUT=*
//SYSIN DD *
  JOINKEYS F1=IN2,FIELDS=(1,10,A),SORTED
  JOINKEYS F2=IN1,FIELDS=(1,10,A),SORTED
  REFORMAT FIELDS=(F2:1,20,F1:21,60)
  OPTION COPY
/*