|
View previous topic :: View next topic
|
| Author |
Message |
purushottam
New User
Joined: 26 Feb 2007 Posts: 37 Location: pune
|
|
|
|
Please help me with the below
I need to compare two PS files and get the matching records from file 2 in output but one of the Input is CSV file. Input records looks something like below
Input1:
XXXXXXXXXXXXXXKKKKKKKKKKYYYYYYYYYY........
It's a FB file with LREC of 528 and key position is from 15 to 24. File1 will not have duplicates
Input2: It contains header in 1st row and then records
ACTION;SEQ;KKKKKKKKKK;..........
UPDATE;1;0122222222;............
where KKKKKKKKKK is key
It's a FB file with LREC of 200. Key position is not fixed as it is csv file.File 2 may contain duplicates, I need to get those all duplicate records in output(if matching record is found in file1). of course it should exclude header record while comparing but in output I need header as in file 2.
PS: Level of DFSORT 'ICE201I H RECORD TYPE '
Thanks,
Puru |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
| What does your header record look like? |
|
| Back to top |
|
 |
purushottam
New User
Joined: 26 Feb 2007 Posts: 37 Location: pune
|
|
|
|
Header in file2
ACTION;SEQ;KKKKKKKKKK;.......... |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
| That's a file header? With the same key value as some data? |
|
| Back to top |
|
 |
purushottam
New User
Joined: 26 Feb 2007 Posts: 37 Location: pune
|
|
|
|
No, File2 is something like below
Header - ACTION;SEQ;KEY;..........
Data - UPDATE;1;0122222222;............
File1
XXXXXXXXXXXXXX999999999YYYYYYYYYY........
I have replaced 'KKKKKKKKKK' with KEY to eliminate confusion |
|
| Back to top |
|
 |
saiprasadh
Active User
Joined: 20 Sep 2006 Posts: 154 Location: US
|
|
|
|
Please use below mentioned sort card
| Code: |
//STEP001 EXEC PGM=SORT
//*
//INPUT1 DD *
1234567890
1234567891
1234567892
1234567893
/*
//INPUT2 DD *
ACTION;SEQ;KEY;
UPDATE;1;1234567890
DELETE;2;1234567890
UPDATE;1;1234567892
UPDATE;1;1234567893
DELETE;2;1234567893
UPDATE;1;1234567894
/*
//SYSOUT DD SYSOUT=*
//SORTOUT DD SYSOUT=*
//*
//SYSIN DD *
JOINKEYS F1=INPUT1,FIELDS=(15,10,A)
JOINKEYS F2=INPUT2,FIELDS=(23,10,A)
REFORMAT FIELDS=(F2:1,80)
SORT FIELDS=COPY
OUTFIL FNAMES=SORTOUT,REMOVECC,
HEADER1=(1:C'ACTION;SEQ;KEY;',80:X),
OUTREC=(1:1,80,SQZ=(SHIFT=LEFT))
/*
//JNF2CNTL DD *
INREC PARSE=(%01=(ENDBEFR=C';',FIXLEN=10),
%02=(ENDBEFR=C';',FIXLEN=10),
%03=(ENDBEFR=C';',FIXLEN=10)),
BUILD=(1:%01,11:C';',12:%02,22:C';',23:%03,33:C';',80:X)
/* |
Output:
| Code: |
ACTION;SEQ;KEY;
UPDATE;1;1234567890;
DELETE;2;1234567890;
UPDATE;1;1234567892;
UPDATE;1;1234567893;
DELETE;2;1234567893; |
|
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
I've tested (lightly) with 80-byte records.
First step generates a "header" indicator in the position of the key of the fixed-layout file.
That dataset is the first IN1 dataset, with the main dataset concatenated to it.
The key for the variable-format file is inserted at the front of each record, in first 10 bytes.
The REFORMAT gets the data from the original variable-format record for each matched output record.
The file header does not have to be created, as it is forced to "match" through the inclusion of the header from the firs step.
| Code: |
//HDRGEN EXEC PGM=SORT
//SORTIN DD dsn=same input as main file, but only one record read, to get dcb info for output and overlay for the header to concatenate
//SYSOUT DD SYSOUT=*
//SORTOUT DD DSN=&&HEADER,UNIT=SYSDA,SPACE=(TRK,1),DISP=(,PASS)
//SYSIN DD *
OPTION COPY,STOPAFT=1
OUTFIL OVERLAY=(15:C'ACTION ')
//MTCHFILE EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTOUT DD SYSOUT=*
//SYSIN DD *
JOINKEYS F1=IN1,
FIELDS=(15,10,
A),
SORTED,
NOSEQCK
JOINKEYS F2=IN2,
FIELDS=(01,10,
A),
SORTED,
NOSEQCK
REFORMAT FIELDS=(F2:11,80)
OPTION COPY
//JNF2CNTL DD *
INREC IFTHEN=(WHEN=INIT,
PARSE=(%01=(ENDBEFR=C';',FIXLEN=07),
%=(ENDBEFR=C';'),
%02=(ENDBEFR=C';',FIXLEN=10))),
IFTHEN=(WHEN=INIT,
BUILD=(%01,3X,1,80)),
IFTHEN=(WHEN=(1,7,CH,NE,C'ACTION '),
OVERLAY=(1:%02))
/*
//IN1 DD DSN=&&HEADER,DISP=(OLD,PASS)
// DD *
XXXXXXXXXXXXXX0122222222YYYYYYYYYY........
1234567890
1234567891
1234567892
1234567893
//IN2 DD *
ACTION;SEQ;KEY;
UPDATE;1;0122222222;............
UPDATE;1;1234567890
DELETE;2;1234567890
UPDATE;1;1234567892
UPDATE;1;1234567893
DELETE;2;1234567893
UPDATE;1;1234567894
|
|
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|