Page 1 of 2

Card to SUM the amounts of similar items

PostPosted: Mon Mar 25, 2013 1:06 pm
by ghosts
Hi, please help me with the below requirement

I have a input as below
aaabbb11.00
aaabbb22.00
dddrrr23.34
dddrrr65.89
dddrrr89.33

I want a sort card to get output as below (sum of similar items)
aaabbb33.00
dddrrr178.56

please help me

Code'd

Re: Card to SUM the amounts of similar items

PostPosted: Mon Mar 25, 2013 1:16 pm
by BillyBoyo
Please use the Code button, not Italics. Use Preview to check what it looks like before Submit.

Do your samples exactly describe what you want?

Re: Card to SUM the amounts of similar items

PostPosted: Mon Mar 25, 2013 1:17 pm
by ghosts
yes

Re: Card to SUM the amounts of similar items

PostPosted: Mon Mar 25, 2013 3:02 pm
by ghosts
i tried with the below on my actual data

SORT FIELDS=(5,50,CH,A)
SUM FIELDS=(55,16,FL)


but im getting the below error
ICE218A 0 57 BYTE VARIABLE RECORD IS SHORTER THAN 70 BYTE MINIMUM FOR          FIELDS


i got some info from the DFSORT error manual
http://publib.boulder.ibm.com/infocente ... Fdfsor.htm

but, actually no resolution is provided there.....request you to please help me with this

Re: Card to SUM the amounts of similar items

PostPosted: Mon Mar 25, 2013 3:37 pm
by BillyBoyo
Well, you have a least one "short" record on your file, lesser in length than 55,16. So you have to find out what it/they are.

FL isn't what you think it is. It is in "internal floating point" item. Try the effect of UFF (Unsigned Free Format) instead for manipulating the number.

Re: Card to SUM the amounts of similar items

PostPosted: Thu Mar 28, 2013 10:51 pm
by ghosts
Hi, actually my requirement is extended a bit now. Here is my new requirement. Request you to please help me

Input:(xml with variable value within the tags)
<name>aaa</name><lname>bbbb</lname><amt>11<amt>
<name>aaa</name><lname>bbbb</lname><amt>134<amt>
<name>qqqqqq</name><lname>ggggg</lname><amt>15688<amt>
<name>qqqqqq</name><lname>ggggg</lname><amt>15.12<amt>
<name>qqqqqq</name><lname>ggggg</lname><amt>1.44<amt>
<name>hhhhh</name><lname>weqwer</lname><amt>265.69<amt>


Required output:(without xml tags and should have sum of all <amt>)
aaa      bbbb      1145.00
qqqqqq ggggg    15704.56
hhhhh   weqwer 265.69


Awaiting a response. Thanks

Re: Card to SUM the amounts of similar items

PostPosted: Thu Mar 28, 2013 10:55 pm
by BillyBoyo
How did you edit your first post?

Re: Card to SUM the amounts of similar items

PostPosted: Thu Mar 28, 2013 11:01 pm
by ghosts
:D thought I could edit....neways i have put a new post

Re: Card to SUM the amounts of similar items

PostPosted: Fri Mar 29, 2013 12:10 am
by skolusu
Your sample data amounts and the totals you show on the output does not match. I am assuming that it is a typo. Use the following DFSORT JCL which will give you the desired results.

I assumed that your input RECFM=V and output is also V and you just the name, lname and the amt in the output.

I also assumed that the name and lname fields are 30 bytes each and the amt is 15 bytes including decimals.

//STEP0100 EXEC PGM=SORT                                             
//SYSOUT   DD SYSOUT=*                                               
//SORTIN   DD DISP=SHR,DSN=Your input VB file
//SORTOUT  DD SYSOUT=*                                               
//SYSIN    DD *                                                     
  INREC IFTHEN=(WHEN=INIT,                                           
  PARSE=(%01=(STARTAFT=C'<NAME>',ENDBEFR=C'</NAME>',FIXLEN=30),     
     %02=(STARTAFT=C'<LNAME>',ENDBEFR=C'</LNAME>',FIXLEN=30),       
     %03=(STARTAFT=C'<AMT>',ENDBEFR=C'.',ENDBEFR=C'<AMT>',FIXLEN=13),
     %04=(ENDBEFR=C'<AMT>',FIXLEN=2)),                               
  BUILD=(1,4,%01,%02,%03,JFY=(SHIFT=RIGHT),%04,UFF,EDIT=(TT))),     
  IFTHEN=(WHEN=INIT,OVERLAY=(65:65,15,SFF,PD,LENGTH=8))             
                                                                     
  SORT FIELDS=(5,60,CH,A)                                           
  SUM FIELDS=(65,8,PD) 
  OUTREC OVERLAY=(65:65,8,PD,EDIT=(IIIIIIIIIIIT.TT))     
//*



If you need a FB file then remove the OUTREC statement and use the following
OUTFIL VTOF,BUILD=(5,60,65,8,PD,EDIT=(IIIIIIIIIIIT.TT))

Re: Card to SUM the amounts of similar items

PostPosted: Fri Mar 29, 2013 1:03 pm
by ghosts
Thanks skolusu, it is running without errors, but I have a huge input dataset, I need to verify whether I got correct summed amounts

Thanks all for the help. I will let you know once I verify the output