IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Conditional Elimination in the records


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Nimesh.Srivastava

New User


Joined: 30 Nov 2006
Posts: 78
Location: SINGAPORE

PostPosted: Thu Feb 01, 2007 2:30 am
Reply with quote

Hi,
I have a requirement that a FB LRECL 496
has records [in which the values are separated by comma] like
lets say for ex there are 5 records in the file
1) A,B,C,D,E,F,G
2) A,B,C,D,E,F1,G1
3) A,B,C,D,E,F1,G2
4) A,B,C,D,E,F2,G1
5) A,B,C,D,E,F2,G2
6) A,B1,C,D,E,F,G
7) A,B1,C,D,E,F2,G2

After the conversion job it should become
1) A,B,C,D,E,F,G
2) ,,,,,F1,G1
3) ,,,,,,G2
4) ,,,,,F2,G1
5) ,,,,,,G2
6) A,B1,C,D,E,F,G
7) ,B1,C,D,E,F2,G2

Hope I am able to convey what I need. Please let me know is it
possible to do via DFSORT.
Thanks
Nimesh
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Thu Feb 01, 2007 3:42 am
Reply with quote

It looks like you want to check each record against the previous record and substitute a comma for the fields up to the field that's different. But for:

5) A,B,C,D,E,F2,G2
6) A,B1,C,D,E,F,G

you have as output:

6) A,B1,C,D,E,F,G

Why wouldn't it be:

6) ,B1,C,D,E,F,G

since the A's match?

What do you want for output if all of the fields match, e.g.

7) A,B1,C,D,E,F2,G2
8) A,B1,C,D,E,F2,G2

What would the output record for 8) be?

Please explain the "rules" you want to use clearly.

Does 1) etc actually appear in the record or does the first field start in position 1?

Also, what is the actual minimum and maximum length of the fields (min=1, max=2 as shown in your example or something else?).
Back to top
View user's profile Send private message
Nimesh.Srivastava

New User


Joined: 30 Nov 2006
Posts: 78
Location: SINGAPORE

PostPosted: Thu Feb 01, 2007 7:34 pm
Reply with quote

Hi Frank,
Thanks for the prompt reply. Ok for

point 1: apologies it should actually read as
1) A,B,C,D,E,F,G
2) ,,,,,F1,G1
3) ,,,,,,G2
4) ,,,,,F2,G1
5) ,,,,,,G2
6) ,B1,C,D,E,F,G
7) ,,,,,F2,G2

point 2: for a duplicate condition
7) A,B1,C,D,E,F2,G2
8) A,B1,C,D,E,F2,G2

the last record should be eliminated I thought about this before
and thought if I sort unique records first this condition would never occur

point 3:
1), 2) are not there in the actual file its just that I put them to sequence the
records for understanding the file would actually be
A,B,C,D,E,F,G
A,B,C,D,E,F1,G1
A,B,C,D,E,F1,G2
A,B,C,D,E,F2,G1
A,B,C,D,E,F2,G2
A,B1,C,D,E,F,G
A,B1,C,D,E,F2,G2

point 4: there is no max or min length of the fields its acutally a .csv file
generated by a program and LRECL is given the maximum length of all fields combined
the fields would be separated by a delimiter ','.
The file format would always be FB both input and output.

point 5: the rules for output file would be a hierarchial formation as I explained in the
example above. The comma separated values can be nullable too
ex
A,B,C,D,E,F,G
A,B,C,D,,F1,G1
A,B,C,D,E,,G2

would become
A,B,C,D,E,F,G
,,,,,F1,G1
,,,,,,G2

Please let me know in case this information is insufficient.

Thanks
Nimesh
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Thu Feb 01, 2007 10:34 pm
Reply with quote

Hmmm ... I think I might know a way to do this with DFSORT/ICETOOL. But I don't want to waste time on a solution you won't be able to use. So before I work on it, I need some more information.

1) The solution will require DFSORT's PARSE function, so you need the April, 2006 DFSORT PTF. Do you have it? If you don't know, run this DFSORT job and look at the ICE201I message you get in //SYSOUT.

If you see:

ICE201I E

then you have the PTF and we can proceed. If you see:

ICE201I 0

then you don't have the PTF. Let me know either way.

2)
Quote:
point 4: there is no max or min length of the fields its acutally a .csv file
generated by a program and LRECL is given the maximum length of all fields combined
the fields would be separated by a delimiter ','.
The file format would always be FB both input and output.


Ok, it's a CSV file with 7 fields (right?), but each field still has to have a maximum length. The largest FB record is 32760 bytes so the total length of all of the fields can't exceed that. So is the maximum length for each field 20 bytes or 100 bytes or 1000 bytes or what? If different fields have different maximums, what are they? If all of the total of all of the maximum lengths is more than about 15000 bytes, my solution probably won't work.
Back to top
View user's profile Send private message
Nimesh.Srivastava

New User


Joined: 30 Nov 2006
Posts: 78
Location: SINGAPORE

PostPosted: Fri Feb 02, 2007 4:45 pm
Reply with quote

Hi Frank,
I couldn't find the DFSORT job I need to run, Please let me know where to pick it up from
Thanks
Nimesh
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Fri Feb 02, 2007 9:12 pm
Reply with quote

Oops. I forgot to paste it in. Here it is:

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD *
//SORTOUT DD DUMMY
//SYSIN    DD    *
  OPTION COPY


Make sure you have at least one space before OPTION.
Back to top
View user's profile Send private message
Nimesh.Srivastava

New User


Joined: 30 Nov 2006
Posts: 78
Location: SINGAPORE

PostPosted: Wed Feb 07, 2007 7:08 pm
Reply with quote

Hi Frank,
I think my shop has it, this is what I got after running the steps
Code:

ICE201I E RECORD TYPE IS F - DATA STARTS IN POSITION 1

Thanks
Nimesh
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Wed Feb 07, 2007 10:38 pm
Reply with quote

Yes, you have the PTF. But you didn't answer the other questions I asked previously:

Quote:
Ok, it's a CSV file with 7 fields (right?), but each field still has to have a maximum length. The largest FB record is 32760 bytes so the total length of all of the fields can't exceed that. So is the maximum length for each field 20 bytes or 100 bytes or 1000 bytes or what? If different fields have different maximums, what are they? If all of the total of all of the maximum lengths is more than about 15000 bytes, my solution probably won't work.
Back to top
View user's profile Send private message
Nimesh.Srivastava

New User


Joined: 30 Nov 2006
Posts: 78
Location: SINGAPORE

PostPosted: Thu Feb 08, 2007 5:54 pm
Reply with quote

The total length of the file 496 (=LRECL), and individual fields would not exceed the maximum. Infact the max length of the fields would be
A = 13
B = 35
C = 24
D = 33
E = 34
F = 32
G = 11
Thanks
Nimesh
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Fri Feb 09, 2007 1:53 am
Reply with quote

Well, this was quite a challenge but here's a DFSORT/ICETOOL job that will do what you asked for.

Code:

//S1    EXEC  PGM=ICETOOL
//TOOLMSG   DD  SYSOUT=*
//DFSMSG   DD  SYSOUT=*
//IN DD DSN=... input file (FB/496)
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//T2 DD DSN=&&T2,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//OUT DD DSN=....  output file (FB/496)
//TOOLIN   DD    *
COPY FROM(IN) USING(CTL1)
SPLICE FROM(T1) TO(T2) ON(561,8,ZD) -
  WITH(281,280) KEEPNODUPS USING(CTL2)
COPY FROM(T2) USING(CTL3)
/*
//CTL1CNTL DD *
  INREC PARSE=(%01=(ENDBEFR=C',',FIXLEN=40),
               %02=(ENDBEFR=C',',FIXLEN=40),
               %03=(ENDBEFR=C',',FIXLEN=40),
               %04=(ENDBEFR=C',',FIXLEN=40),
               %05=(ENDBEFR=C',',FIXLEN=40),
               %06=(ENDBEFR=C',',FIXLEN=40),
               %07=(FIXLEN=40)),
    BUILD=(%01,%02,%03,%04,%05,%06,%07,561:SEQNUM,8,ZD)
  OUTFIL FNAMES=T1,
    IFTHEN=(WHEN=(561,8,ZD,EQ,+1),
      BUILD=(X'FF',561:561,8,/,281:1,280,561:561,8,/,
       1,280,561:561,8,ZD,ADD,+1,TO=ZD,LENGTH=8)),
    IFTHEN=(WHEN=NONE,
      BUILD=(281:1,280,561:561,8,/,
       1,280,561:561,8,ZD,ADD,+1,TO=ZD,LENGTH=8))
/*
//CTL2CNTL DD *
  OUTFIL FNAMES=T2,
    IFTHEN=(WHEN=INIT,OVERLAY=(320:C',',360:C',',400:C',',
      440:C',',480:C',',520:C',')),
    IFTHEN=(WHEN=(1,1,CH,NE,C' ',AND,281,1,CH,NE,C' ',AND,
      1,39,CH,NE,281,39,CH),OVERLAY=(281:281,39)),
    IFTHEN=(WHEN=(1,1,CH,EQ,C' ',OR,281,1,CH,EQ,C' ',OR,
      1,39,CH,EQ,281,39,CH),OVERLAY=(281:39X),HIT=NEXT),
    IFTHEN=(WHEN=(41,1,CH,NE,C' ',AND,321,1,CH,NE,C' ',AND,
      41,39,CH,NE,321,39,CH),OVERLAY=(321:321,39)),
    IFTHEN=(WHEN=(41,1,CH,EQ,C' ',OR,25,2,CH,EQ,C' ',OR,
      4,2,CH,EQ,25,2,CH),OVERLAY=(321:39X),HIT=NEXT),
    IFTHEN=(WHEN=(81,1,CH,NE,C' ',AND,361,1,CH,NE,C' ',AND,
      81,39,CH,NE,361,39,CH),OVERLAY=(361:361,39)),
    IFTHEN=(WHEN=(81,1,CH,EQ,C' ',OR,361,1,CH,EQ,C' ',OR,
      81,39,CH,EQ,361,39,CH),OVERLAY=(361:39X),HIT=NEXT),
    IFTHEN=(WHEN=(121,1,CH,NE,C' ',AND,401,1,CH,NE,C' ',AND,
      121,39,CH,NE,401,39,CH),OVERLAY=(401:401,39)),
    IFTHEN=(WHEN=(121,1,CH,EQ,C' ',OR,401,1,CH,EQ,C' ',OR,
      121,39,CH,EQ,401,39,CH),OVERLAY=(401:39X),HIT=NEXT),
    IFTHEN=(WHEN=(161,1,CH,NE,C' ',AND,441,1,CH,NE,C' ',AND,
      161,39,CH,NE,441,39,CH),OVERLAY=(441:441,39)),
    IFTHEN=(WHEN=(161,1,CH,EQ,C' ',OR,441,1,CH,EQ,C' ',OR,
      161,39,CH,EQ,441,39,CH),OVERLAY=(441:39X),HIT=NEXT),
    IFTHEN=(WHEN=(201,1,CH,NE,C' ',AND,481,1,CH,NE,C' ',AND,
      201,39,CH,NE,481,39,CH),OVERLAY=(481:481,39)),
    IFTHEN=(WHEN=(201,1,CH,EQ,C' ',OR,481,1,CH,EQ,C' ',OR,
      201,39,CH,EQ,481,39,CH),OVERLAY=(481:39X),HIT=NEXT),
    IFTHEN=(WHEN=(241,1,CH,NE,C' ',AND,521,1,CH,NE,C' ',AND,
      241,39,CH,NE,521,39,CH),OVERLAY=(521:521,39)),
    IFTHEN=(WHEN=(241,2,CH,EQ,C' ',OR,521,1,CH,EQ,C' ',OR,
      241,39,CH,EQ,521,39,CH),OVERLAY=(521:39X,C','))
/*
//CTL3CNTL DD *
   INREC IFOUTLEN=496,
     IFTHEN=(WHEN=INIT,BUILD=(281,280,SQZ=(SHIFT=LEFT)))
   OUTFIL FNAMES=OUT,OMIT=(1,7,CH,EQ,C',,,,,,,')
/*


If the input is:

Code:

A,B,C,D,E,F,G         
A,B,C,D,E,F1,G1       
A,B,C,D,E,F1,G2       
A,B,C,D,E,F2,G1       
A,B,C,D,E,F2,G2       
A,B1,C,D,E,F,G         
A,B1,C,D,E,F2,G2       
A,B1,C,D,E,F2,G2       
A1,B1,C1,D1,E1,F1,G1   
A1,B1,C1,D1,,F2,G2     
A1,B1,C1,D1,E1,,G3     


OUT will have:

Code:

A,B,C,D,E,F,G             
,,,,,F1,G1               
,,,,,,G2                 
,,,,,F2,G1               
,,,,,,G2                 
,B1,C,D,E,F,G             
,,,,,F2,G2               
A1,B1,C1,D1,E1,F1,G1     
,,,,,F2,G2               
,,,,,,G3                 
Back to top
View user's profile Send private message
Nimesh.Srivastava

New User


Joined: 30 Nov 2006
Posts: 78
Location: SINGAPORE

PostPosted: Fri Feb 09, 2007 11:31 am
Reply with quote

Thanks a lot Frank... it works,
and once again many thanks for putting so much effort for my case.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Fri Feb 09, 2007 9:23 pm
Reply with quote

Quote:
Thanks a lot Frank... it works


Great. Thanks for letting me know.

Quote:
and once again many thanks for putting so much effort for my case.


I like a good DFSORT/ICETOOL challenge. icon_cool.gif
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts Pulling a fixed number of records fro... DB2 2
No new posts Join multiple records using splice DFSORT/ICETOOL 5
No new posts EZT program to build a flat file with... All Other Mainframe Topics 9
No new posts JCL sortcard to print only the records DFSORT/ICETOOL 11
Search our Forums:

Back to Top