Page 1 of 1

To compare a dataset and generate output file.

PostPosted: Sun Oct 23, 2011 8:07 pm
by kimir
I have the below requirement.
Input file.
AAAA BBBB CCCC H 123456 DDDD
AAAA BBBB CCCC B 456789 DDDD
AAAA BBBB CCCC O 741258 DDDD
EEEE FFFF GGGG H 111222 HHHH
EEEE FFFF GGGG B 111777 HHHH
UUUU YYYY QQQQ O 789456 ZZZZ

Output file.
AAAA BBBB CCCC 123456 456789 741258 DDDD
EEEE FFFF GGGG 111222 111777 <space>HHHH
UUUU YYYYY QQQQ<space><space>789456 ZZZZ

Thank You.

Re: To compare a dataset and generate output file.

PostPosted: Sun Oct 23, 2011 11:10 pm
by enrico-sorichetti
unless You come out with some additional criteria,
it will be impossible to decide in which column to store the <numeric> fields
the only possible pattern will be to put the <spaces> at the end of each triplet

Re: To compare a dataset and generate output file.

PostPosted: Mon Oct 24, 2011 12:02 am
by dick scherrer
Hello and welcome to the forum,

When you post the required info, also repost the data using the "Code" tag which will maintain alignment and make the post more readable. There is a Preview function so you can see your post as it will appear to the forum. When you are satisfied with your post appears, Submit.

In sentence form, post the processing rules.

Re: To compare a dataset and generate output file.

PostPosted: Mon Oct 24, 2011 3:25 am
by BillyBoyo
Your output has records containing data from groups of one, two or three input records. We need to know the "key" that is used to know that the records are in the same group.

It looks like you are converting the H/B/O followed by a number to three columns, number(H), number(B), number (O), with the irrelevant columns blank, but we can't be certain.

We need a full description, we can't really help with what you have provided so far.

Re: To compare a dataset and generate output file.

PostPosted: Mon Oct 24, 2011 11:15 pm
by Frank Yaeger
Kimir,

You can use a DFSORT/ICETOOL job like the following to do what you asked for. I assumed your input file has RECFM=FB and LRECL=80, but the job can be changed appropriately for other attributes.

//S1    EXEC  PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG  DD SYSOUT=*
//IN DD *
AAAA BBBB CCCC H 123456 DDDD
AAAA BBBB CCCC B 456789 DDDD
AAAA BBBB CCCC O 741258 DDDD
EEEE FFFF GGGG H 111222 HHHH
EEEE FFFF GGGG B 111777 HHHH
UUUU YYYY QQQQ O 789456 ZZZZ
//OUT DD SYSOUT=*
//TOOLIN DD *
SPLICE FROM(IN) TO(OUT) ON(1,14,CH) KEEPNODUPS WITHEACH -
  WITH(23,6) WITH(30,6) USING(CTL1)
//CTL1CNTL DD *
  INREC IFTHEN=(WHEN=(16,1,CH,EQ,C'H'),
    BUILD=(1,15,16:18,6,37:25,4,80:X)),
   IFTHEN=(WHEN=(16,1,CH,EQ,C'B'),
    BUILD=(1,15,23:18,6,37:25,4)),
   IFTHEN=(WHEN=(16,1,CH,EQ,C'O'),
    BUILD=(1,15,30:18,6,37:25,4))
/*

Re: To compare a dataset and generate output file.

PostPosted: Tue Oct 25, 2011 7:58 pm
by kimir
Hi Frank,
Thanks for the quick response. Can you tell me what

WITHEACH WITH(23,6) WITH (30,6)

does. As the last position in the input file is at column 28 and also, the space after 123456 begins at 24 pos.
Understanding this will help me customize the solution provided by you.

Thank You.

Re: To compare a dataset and generate output file.

PostPosted: Tue Oct 25, 2011 10:51 pm
by Frank Yaeger
For complete details on all of the options of DFSORT/ICETOOL's SPLICE operator, see:

http://publibz.boulder.ibm.com/cgi-bin/ ... 0608113434

If the last field starts in 28 instead of 24, then just change the control statements in CTL1CNTL to:

//CTL1CNTL DD *                               
  INREC IFTHEN=(WHEN=(16,1,CH,EQ,C'H'),       
    BUILD=(1,15,16:18,6,37:28,4,80:X)),       
   IFTHEN=(WHEN=(16,1,CH,EQ,C'B'),           
    BUILD=(1,15,23:18,6,37:28,4)),           
   IFTHEN=(WHEN=(16,1,CH,EQ,C'O'),           
    BUILD=(1,15,30:18,6,37:28,4))             

Re: To compare a dataset and generate output file.

PostPosted: Thu Nov 03, 2011 11:25 pm
by kimir
Hi Frank,
I am facing an odd situation. As per your suggestions, I customized the solution to my requirement.By using KEEPNODUPS and WITHEACH I am getting single row for each row present for the key.However,there are two issues that I am facing.
1.Data is getting concatenated even though I have rechecked the column positions.
AAAA BBBB CCCC <Space><Space> 7412BB DDDD --> 58 is truncated and replace by blanks.
Is there a way to over come this? I have rechecked the column positions to make sure there is no mistake here.

2. The last condition in IFTHEN is over writing all the other values. To illustrate using my above record layout,even though the first 3 rows have different values for H,B and O, the output is
AAAA BBBB CCCC <Space><Space> 741258 DDDD (Even though H and B have numbers associated with them, they are being overwritten)
instead of
AAAA BBBB CCCC 123456 456789 741258 DDDD
Is there a way we can retain the values for a record originally BUILT when comparison happens between the base record and the overlay records(for any combination between H,B and O)?

Waiting for your guidance on the same...

Thank you,
Kimir.

Re: To compare a dataset and generate output file.

PostPosted: Fri Nov 04, 2011 1:16 am
by Frank Yaeger
When I run this DFSORT job:

//S1    EXEC  PGM=ICETOOL                                   
//TOOLMSG DD SYSOUT=*                                       
//DFSMSG  DD SYSOUT=*                                       
//IN DD *                                                   
AAAA BBBB CCCC H 123456    DDDD                             
AAAA BBBB CCCC B 456789    DDDD                             
AAAA BBBB CCCC O 741258    DDDD                             
EEEE FFFF GGGG H 111222    HHHH                             
EEEE FFFF GGGG B 111777    HHHH                             
UUUU YYYY QQQQ O 789456    ZZZZ                             
//OUT DD SYSOUT=*                                           
//TOOLIN DD *                                               
SPLICE FROM(IN) TO(OUT) ON(1,14,CH) KEEPNODUPS WITHEACH -   
  WITH(23,6) WITH(30,6) USING(CTL1)                         
//CTL1CNTL DD *                                             
  INREC IFTHEN=(WHEN=(16,1,CH,EQ,C'H'),   
    BUILD=(1,15,16:18,6,37:28,4,80:X)),   
   IFTHEN=(WHEN=(16,1,CH,EQ,C'B'),         
    BUILD=(1,15,23:18,6,37:28,4)),         
   IFTHEN=(WHEN=(16,1,CH,EQ,C'O'),         
    BUILD=(1,15,30:18,6,37:28,4))         


I get the following output:
AAAA BBBB CCCC 123456 456789 741258 DDDD
EEEE FFFF GGGG 111222 111777        HHHH
UUUU YYYY QQQQ               789456 ZZZZ


This corresponds to the output you said you wanted:

AAAA BBBB CCCC 123456 456789 741258 DDDD
EEEE FFFF GGGG 111222 111777 <space>HHHH
UUUU YYYYY QQQQ<space><space>789456 ZZZZ


If you are getting a different output, then there's something different between your job and my job that you're not telling me about. Perhaps the positions and lengths of your fields are NOT what I think they are? If you look at my example, you'll see how I assumed the data looked in //IN. If it doesn't look that way, then you have to tell me exactly how it does look. If you have additional data that isn't getting the output you want, then you need to show me that additional data.

Also, it would help if you posted the complete JES log for your run so I can see what you're doing exactly.