Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Compare fixed lenght file with csv file

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
purushottam

New User


Joined: 26 Feb 2007
Posts: 37
Location: pune

PostPosted: Wed Apr 04, 2012 5:23 pm    Post subject: Compare fixed lenght file with csv file
Reply with quote

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
View user's profile Send private message

Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7315

PostPosted: Wed Apr 04, 2012 7:19 pm    Post subject: Reply to: Compare fixed lenght file with csv file
Reply with quote

What does your header record look like?
Back to top
View user's profile Send private message
purushottam

New User


Joined: 26 Feb 2007
Posts: 37
Location: pune

PostPosted: Wed Apr 04, 2012 7:33 pm    Post subject: Reply to: Compare fixed lenght file with csv file
Reply with quote

Header in file2

ACTION;SEQ;KKKKKKKKKK;..........
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7315

PostPosted: Wed Apr 04, 2012 7:40 pm    Post subject: Reply to: Compare fixed lenght file with csv file
Reply with quote

That's a file header? With the same key value as some data?
Back to top
View user's profile Send private message
purushottam

New User


Joined: 26 Feb 2007
Posts: 37
Location: pune

PostPosted: Wed Apr 04, 2012 7:48 pm    Post subject: Reply to: Compare fixed lenght file with csv file
Reply with quote

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
View user's profile Send private message
saiprasadh

Active User


Joined: 20 Sep 2006
Posts: 154
Location: US

PostPosted: Wed Apr 04, 2012 8:00 pm    Post subject:
Reply with quote

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
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7315

PostPosted: Wed Apr 04, 2012 9:39 pm    Post subject: Reply to: Compare fixed lenght file with csv file
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Execute JCL step based on the content... sprikitik JCL & VSAM 2 Tue Oct 03, 2017 10:03 am
This topic is locked: you cannot edit posts or make replies. PS file data should be passed as symb... d_sarlie JCL & VSAM 15 Tue Oct 03, 2017 5:18 am
No new posts Garbage on output file Hervey Martinez SYNCSORT 4 Wed Sep 27, 2017 12:50 am
No new posts File Aid tool to compare numeric data balaji81_k Compuware & Other Tools 2 Tue Sep 26, 2017 3:35 am
No new posts Compare yesterday's date to the one o... migusd SYNCSORT 11 Fri Sep 22, 2017 11:35 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us