Card to SUM the amounts of similar items



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

Card to SUM the amounts of similar items

Postby ghosts » Mon Mar 25, 2013 1:06 pm

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
ghosts
 
Posts: 12
Joined: Fri Mar 22, 2013 5:11 pm
Has thanked: 2 times
Been thanked: 0 time

Re: Card to SUM the amounts of similar items

 

Re: Card to SUM the amounts of similar items

Postby BillyBoyo » Mon Mar 25, 2013 1:16 pm

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?
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times

Re: Card to SUM the amounts of similar items

Postby ghosts » Mon Mar 25, 2013 1:17 pm

yes
ghosts
 
Posts: 12
Joined: Fri Mar 22, 2013 5:11 pm
Has thanked: 2 times
Been thanked: 0 time

Re: Card to SUM the amounts of similar items

Postby ghosts » Mon Mar 25, 2013 3:02 pm

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
ghosts
 
Posts: 12
Joined: Fri Mar 22, 2013 5:11 pm
Has thanked: 2 times
Been thanked: 0 time

Re: Card to SUM the amounts of similar items

Postby BillyBoyo » Mon Mar 25, 2013 3:37 pm

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.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times

Re: Card to SUM the amounts of similar items

Postby ghosts » Thu Mar 28, 2013 10:51 pm

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
Last edited by ghosts on Thu Mar 28, 2013 10:59 pm, edited 1 time in total.
ghosts
 
Posts: 12
Joined: Fri Mar 22, 2013 5:11 pm
Has thanked: 2 times
Been thanked: 0 time

Re: Card to SUM the amounts of similar items

Postby BillyBoyo » Thu Mar 28, 2013 10:55 pm

How did you edit your first post?
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times

Re: Card to SUM the amounts of similar items

Postby ghosts » Thu Mar 28, 2013 11:01 pm

:D thought I could edit....neways i have put a new post
ghosts
 
Posts: 12
Joined: Fri Mar 22, 2013 5:11 pm
Has thanked: 2 times
Been thanked: 0 time

Re: Card to SUM the amounts of similar items

Postby skolusu » Fri Mar 29, 2013 12:10 am

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))
Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort

These users thanked the author skolusu for the post:
ghosts (Fri Mar 29, 2013 1:03 pm)
skolusu
 
Posts: 586
Joined: Wed Apr 02, 2008 10:38 pm
Has thanked: 0 time
Been thanked: 39 times

Re: Card to SUM the amounts of similar items

Postby ghosts » Fri Mar 29, 2013 1:03 pm

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
ghosts
 
Posts: 12
Joined: Fri Mar 22, 2013 5:11 pm
Has thanked: 2 times
Been thanked: 0 time

Next

Return to DFSORT/ICETOOL/ICEGENER

 


  • Related topics
    Replies
    Views
    Last post