Need to Compare same file and prepare output file



IBM's flagship sort product DFSORT for sorting, merging, copying, data manipulation and reporting. Includes ICETOOL and ICEGENER

Need to Compare same file and prepare output file

Postby rockstar2020 » Wed Jan 29, 2014 2:31 am

Hello All,
I'm very confused as to how to complete the below requirement. I tried using SORT but not got desired result.
input file
----------
START                                           AAAAAA 030054 000001 0801
 MIKE                   EMPLOYEE DETAILS
                        11111111111111111111111111111111111111111    XXXX
                        22222222222222222222222222222222222222222    XXXX
 MARK                   EMPLOYEE DETAILS
                        11111111111111111111111111111111111111111    YYYY
                        22222222222222222222222222222222222222222    YYYY
START                                           BBBBBB 030054 000001 0801
 JOHN                   EMPLOYEE DETAILS
                        11111111111111111111111111111111111111111    ZZZZ
                        22222222222222222222222222222222222222222    ZZZZ
 TREJ                   EMPLOYEE DETAILS
                        11111111111111111111111111111111111111111    WWWW
                        22222222222222222222222222222222222222222    WWWW
..


MIKE AAAAAA XXXX
MARK AAAAAA YYYY
JOHN BBBBBB ZZZZ
TREJ BBBBBB WWWW


As shown above START tells the start of the particular group of records. Just looking for an outline of how can I handle this situation.

Thanks A Lot!!!!
rockstar2020
 
Posts: 32
Joined: Wed Jan 08, 2014 3:51 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Need to Compare same file and prepare output file

 

Re: Need to Compare same file and prepare output file

Postby rockstar2020 » Wed Jan 29, 2014 2:33 am

2nd code is the output that i'm looking for which is combined of three different fields in three different places between 1st START and 2nd START.
rockstar2020
 
Posts: 32
Joined: Wed Jan 08, 2014 3:51 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Need to Compare same file and prepare output file

Postby NicC » Wed Jan 29, 2014 2:13 pm

please show what you have tried so far and the output obtained. Also, as usual, please specify LRECL, RECFM.
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 2690
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisys (almost)
Has thanked: 4 times
Been thanked: 105 times

Re: Need to Compare same file and prepare output file

Postby rockstar2020 » Wed Jan 29, 2014 3:00 pm

It's a flat file with FB and 80 as record length.. I've did this using a COBOL program but PL wants this to be done by using JCL. I tried using SORT/IF THEN to concatenate the fields but really couldn't get a hold of the logic to do so..

Any hint should be fine for me to proceed and really appreciate your time.. Thanks!!!
rockstar2020
 
Posts: 32
Joined: Wed Jan 08, 2014 3:51 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Need to Compare same file and prepare output file

Postby BillyBoyo » Wed Jan 29, 2014 4:08 pm

Look at IFTHEN=(WHEN=GROUP and PUSH. Probably. You've not given a lot of detail. Are there a fixed number of records in each group?
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times

Re: Need to Compare same file and prepare output file

Postby rockstar2020 » Wed Jan 29, 2014 4:37 pm

No between two START's there are no fixed records and also number of records under each name may vary.
FOR EXAMPLE, in MIKE 3 rows are available but under and 'XXXX" will be the same for all the 3 rows

Updated the input file as shown below and i hope its comprehensive

START                                AAAAAA 030054 000001 0801
MIKE                   EMPLOYEE DETAILS
             11122222222222222222222222222222222221111    XXXX
             22222223333334555555555555533333333332222    XXXX
             33333333333333234234234242424242424243333    XXXX
MARK                   EMPLOYEE DETAILS
             11112342432423423423423556767868767861111    YYYY
             22222223454345345345435309900009900902222    YYYY
START                                BBBBBB 030054 000001 0801
JOHN                   EMPLOYEE DETAILS
             11111111111112342342342499090909090901111    ZZZZ
TREJ                   EMPLOYEE DETAILS
             45434543535350090909124342342423424242424    WWWW
             23498732904579384758345873945873495734345    WWWW
KATE                   EMPLOYEE DETAILS
             00324234234923423748234723642734234242424    UUUU
    ..


Output Required---
MIKE AAAAAA XXXX
MARK AAAAAA YYYY
JOHN BBBBBB ZZZZ
TREJ BBBBBB WWWW
KATE BBBBBB UUUU
rockstar2020
 
Posts: 32
Joined: Wed Jan 08, 2014 3:51 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Need to Compare same file and prepare output file

Postby BillyBoyo » Wed Jan 29, 2014 5:02 pm

OK, WHEN=GROUP with BEGIN as C'START' in the correct place, PUSH the AAAAA/BBBBB to an extension to your record (if records are F 80, PUSH=(81:,SEQ=3,start,length). The SEQ must be enough digits to cover the maximum possible.

That will get the AAAAA/BBBBB onto each record in the group.

You then need a second WHEN=GROUP for non-blank in column 1, to get the name. PUSH to a further extended new field, the name and another SEQ. RECORDS=2. Don't worry that this will get the START as well, because you ignore it later by testing the field from SEQ not being 001 (or however long the field is).

In OUTFIL INCLUDE=(for the second SEQ field being a value of 2. Then format your output with BUILD.

These users thanked the author BillyBoyo for the post:
sureshpathi10 (Thu Jan 30, 2014 1:10 pm)
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times

Re: Need to Compare same file and prepare output file

Postby rockstar2020 » Thu Jan 30, 2014 1:37 am

You are just more than amazing Billy.. Followed your suggestions and it worked!!!
At first, I couldn't understand your descriptions but then followed step by step and understood your suggestions. I'm using these for the first time so it was a bit difficult for me but I enjoyed the experience.

I've a couple of questions but completed the my requirement though alternately.
1> How to include SPACES in BUILD as you can see I've used (7,1)
2> For the 1st PUSH parameter I've used SEQ=3, but I noticed it went from 001 to 477 and re-started back from 001 again and I dont understand why ?

I'm looking for some good documents/links on INREC, IF THEN, OUTREC, OVERLAY and other related important/useful parameters.
I've pasted my final code below for your reference
001900 //SYSIN    DD  *                                                 
002000         SORT FIELDS=COPY                                         
002100         OUTREC IFTHEN=(WHEN=GROUP,BEGIN=(1,5,CH,EQ,C'START'),   
002200           END=(1,3,CH,EQ,C'END'),PUSH=(81:SEQ=3,38,6)),         
002300                IFTHEN=(WHEN=GROUP,BEGIN=(1,1,CH,NE,C' '),       
002400                                  PUSH=(90:SEQ=3,1,4))           
002500           OUTFIL INCLUDE=(32,4,CH,EQ,C'MOVE'),                   
002510           BUILD=(93,4,7,1,84,6,7,1,59,4)                         


Once again thanks Billy, you're a genius!! I'm learning a lot...
rockstar2020
 
Posts: 32
Joined: Wed Jan 08, 2014 3:51 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Need to Compare same file and prepare output file

Postby BillyBoyo » Thu Jan 30, 2014 1:59 am

Well, wait until you see Kolusu :-)

The spaces are simple, you should use X. X = one space, 3X = three spaces, 20X =... well, I'm sure you've got that by now.

It is also possible to use C' ', but I think it clearer with X (it can't be a literal with a but typoed out).

The SEQ field will be a length of three, so have a maximum value of 999. It starts from 1 for each new group.

If you look at the forum, you should see a "sticky" offering DFSORT Reference Material. There is a Getting Started manual, an extensive Application Programming Guide (see under Books and Papers) and various publications on new functions as they were implemented. Also look out for the Smart Tricks publication.

There are many examples here, and on the sister site, Experts Forum, link at the bottom of the page.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times


Return to DFSORT/ICETOOL/ICEGENER

 


  • Related topics
    Replies
    Views
    Last post