SORT and COUNT using DFSORT/ICETOOL



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

SORT and COUNT using DFSORT/ICETOOL

Postby bitbybit » Thu Nov 08, 2012 7:14 am

My i/p has 2 fields that are in binary value.
fld1 is pic - x(1) at position 5
fld2 is pic x(2) at position 8

1. I need to sort the file by fld2 asc and then fld1 asc
2. I need to count the number of records in the i/p for each combination of fld2/fld1 and display that info (fld2 - fld1 - count)

the display of fld2 and fld1 shld be in decimal format.

for ex- fld1 vlaue is 1010011 , display - 83
fld2 value is 10100111010011 , display - 10707
bitbybit
 
Posts: 29
Joined: Fri Jul 13, 2012 10:05 pm
Has thanked: 6 times
Been thanked: 0 time

Re: SORT and COUNT using DFSORT/ICETOOL

Postby BillyBoyo » Thu Nov 08, 2012 1:39 pm

And what problem did you encounter? Please show what you have done so far, and what is blocking you, and someone will be around to help.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: SORT and COUNT using DFSORT/ICETOOL

Postby enrico-sorichetti » Thu Nov 08, 2012 2:40 pm

somehow this post seems a duplicate of
ibm-cobol/topic8429.html
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 2994
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 164 times

Re: SORT and COUNT using DFSORT/ICETOOL

Postby bitbybit » Tue Nov 13, 2012 7:51 pm

Hi enrico-sorichetti, I posted both questions, But, they r not same. This one is a DFsort/ICEtool question about how I can sort by binary flds and mainly to count #of records for each fld1/fld2 combinations. The other one is how to convert binary to decimal in a Cobol program for display purposes, totally different questions.
bitbybit
 
Posts: 29
Joined: Fri Jul 13, 2012 10:05 pm
Has thanked: 6 times
Been thanked: 0 time

Re: SORT and COUNT using DFSORT/ICETOOL

Postby bitbybit » Tue Nov 13, 2012 7:57 pm

Hi BiilyBoyo, I have tried some things with my limited knowledge of ICEtool, nothing wrked. So, first I converted the binary flds vlaues to char values, then sort the file by converted char values, then send it thru another cobol pgm that counts records for each combination of fld2/fld1, write the counts in sysout. It wrked and served my purpose, but I would like to know if there is an easier way to do that in dfsort/icetool.
bitbybit
 
Posts: 29
Joined: Fri Jul 13, 2012 10:05 pm
Has thanked: 6 times
Been thanked: 0 time

Re: SORT and COUNT using DFSORT/ICETOOL

Postby enrico-sorichetti » Tue Nov 13, 2012 8:21 pm

did You try looking at he manual for the conversions supported by dfsort and relative format ...
even a googling for DSFORT SUPPORTED CONVERSIONS
returned the page of the manual with the "on the spot" example

INREC OVERLAY=(<ov_position>:<in_position<,<in_length>,BI,TO=ZD,LENGTH=<ov_length>)


for Your case ...
INRECINREC OVERLAY=(ZD_FIELD1_POS:5,1,BI,TO=ZD,LENGTH=4,ZD_FIELD2_POS:8,2,BI,TO=ZD,LENGTH=6)


and then process the zd_ stuff

TESTED
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 2994
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 164 times

Re: SORT and COUNT using DFSORT/ICETOOL

Postby bitbybit » Wed Nov 14, 2012 4:15 am

I was able to convert the binary to decimal using dfsort, but the 2nd bullet point is the main thing, How do I get a count of input records for each combination of Fld2/fld1? I didnt get any resoponse here, I eneded up writing a simple cobol pgm to get those counts and spit a report. 2nd part of my question is still un-answered.
bitbybit
 
Posts: 29
Joined: Fri Jul 13, 2012 10:05 pm
Has thanked: 6 times
Been thanked: 0 time

Re: SORT and COUNT using DFSORT/ICETOOL

Postby BillyBoyo » Wed Nov 14, 2012 4:29 am

You asked and then went "away" for five days. You didn't show anything you tried when you came back, and now...

Anyway, if you "extend" your record by adding a value of "one" to the end (if fixed-length) of the record, then SUM on that extended "one".

The "one" can be of the form C'01', C'001', C'0001' etc depending on how many records are the maximum you can ever expect on your file (I'd always go "10 times bigger").

After the SUM, in OUTREC for instance, use BUILD to get rid of the extension.

EG. If you record is 80-bytes fixed and you can expect up to 87000 records,

  INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:C'000001')
  SORT (your sort keys)
  SUM (81,6,ZD)
  OUTREC BUILD=(your-first-key-converted,X,your-second-key-converted,X,81,6,ZD)


The Xs represent one blank, and are just for spacing the output in this example.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: SORT and COUNT using DFSORT/ICETOOL

Postby bitbybit » Thu Nov 15, 2012 10:40 pm

I am getting a syntax error??

//SYSIN     DD *                                 
 INREC IFTHEN=(WHEN=INIT,OVERLAY=(75:C'000001') 
 SORT FIELDS=(34,4,CH,A,51,4,CH,A)               
 SUM (75,6,ZD)                                   
 OUTREC BUILD=(34,4,CH,X,51,4,CH,X,75,6,ZD)     


Syntax error???
ICE000I 1 - CONTROL STATEMENTS FOR 5694-A01, Z/OS DFSORT V1R12 - 12:04 ON THU NO
           INREC IFTHEN=(WHEN=INIT,OVERLAY=(75:C'000001')                       
                                                         $                     
ICE007A 0 SYNTAX ERROR                                                         
           SORT FIELDS=(34,4,CH,A,51,4,CH,A)                                   
           SUM (75,6,ZD)                                                       
               $                                                               
ICE007A 1 SYNTAX ERROR                                                         
           OUTREC BUILD=(34,4,CH,X,51,4,CH,X,75,6,ZD)                           
                               $                                               
ICE007A E SYNTAX ERROR                                                         
ICE012A 1 MISSING FIELDS OPERAND DEFINER                                       
ICE751I 0 C5-K62149 C6-K90026 C7-K58148 C8-K67572 E7-K70685                     
ICE052I 3 END OF DFSORT


Code'd
bitbybit
 
Posts: 29
Joined: Fri Jul 13, 2012 10:05 pm
Has thanked: 6 times
Been thanked: 0 time

Re: SORT and COUNT using DFSORT/ICETOOL

Postby BillyBoyo » Thu Nov 15, 2012 10:58 pm

Well, fix them :-)

I've left a closing bracket off - easy to spot?

You even written a SUM like that? I did, but it needs FIELDS=

You don't need any of the FORMATs in the simple BUILD

  OUTREC BUILD=(34,4,X,51,4,X,75,6)


I provided a terrible mess for you, but if you are going to learn you should have been able to fix them all yourself. Look at stuff that works. Look at the manual. Note where the error pointer ($) is. It's not too difficult.

These users thanked the author BillyBoyo for the post:
bitbybit (Fri Nov 16, 2012 12:39 am)
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Next

Return to DFSORT/ICETOOL/ICEGENER

 


  • Related topics
    Replies
    Views
    Last post