Sum an alphanumeric fields



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

Sum an alphanumeric fields

Postby danylele74 » Thu Jul 03, 2014 2:10 am

Hi everybody, I have this problem: I have to sum alphanumeric fields using JCL but I can not find the solution.

Input file

KEY        VALUE 
----+----1----+----1----+----1----+----1
0000000100 +0000000500,34
0000000100 +0000023344,00
0000000200 +0000002200,99
0000000200 -0000001500,99
0000000300 -0000000100,00



Output file

KEY        VALUE   
----+----1----+----1----+----1----+----1
0000000100 +0000023844,34
0000000200 +0000000700,00
0000000300 -0000000100,00

Can you help me?

Thanks.
danylele74
 
Posts: 12
Joined: Thu Jul 03, 2014 2:00 am
Has thanked: 0 time
Been thanked: 0 time

Re: Sum an alphanumeric fields

Postby BillyBoyo » Thu Jul 03, 2014 4:38 am

Presuming that your data is already in sequence, you should look at the OUTFIL reporting functions.

You'll need OUTFIL with REMOVECC,NODETAIL, SECTIONS for your key, and TRAILER2 with TOT, where you can use SFF for the field type, where the signn should be taken into account automatically, and the comma ignored. You can use EDIT to format the total into the same manner of display as your source.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: Sum an alphanumeric fields

Postby danylele74 » Thu Jul 03, 2014 10:06 am

Thanks.
Can you show me an example about OUTFIL and REMOVECC, TRAILER2, etc. ??

the KEY field is numeric.
danylele74
 
Posts: 12
Joined: Thu Jul 03, 2014 2:00 am
Has thanked: 0 time
Been thanked: 0 time

Re: Sum an alphanumeric fields

Postby NicC » Fri Jul 04, 2014 2:57 am

Cannot be done in JCL. JCL is not for this sort of problem. Moving to DFSort section. If you are using Syncsort then say so and it will be moved again.
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 3025
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisies (almost)
Has thanked: 4 times
Been thanked: 136 times

Re: Sum an alphanumeric fields

Postby Magesh23586 » Sat Jul 05, 2014 6:33 pm

Here is the code for you
//STEP01 EXEC PGM=SORT                               
//SORTIN DD *                                         
0000000100 +0000000500.34                             
0000000100 +0000023344.00                             
0000000200 +0000002200.99                             
0000000200 -0000001500.99                             
0000000300 -0000000100.00                             
//SORTOUT DD SYSOUT=*                                 
//SYSOUT DD SYSOUT=*                                 
//SYSIN DD *                                         
  SORT FIELDS=COPY                                   
  OUTFIL FNAMES=SORTOUT,REMOVECC,NODETAIL,           
  SECTIONS=(1,10,SKIP=P,                             
  TRAILER3=(1:1,10,X,TOT=(12,14,                     
         SFF,EDIT=(STTTTTTTTTT.TT),SIGNS=(+,-))))     
/*                                                   


You may refer following link, as you are beginner
http://ibmmainframes.com/post-7535.html

Hope this helps,

Thanks
Magesh
Magesh23586
 
Posts: 36
Joined: Sat Jul 05, 2014 5:36 pm
Has thanked: 1 time
Been thanked: 3 times

Re: Sum an alphanumeric fields

Postby BillyBoyo » Mon Jul 07, 2014 5:01 am

Magesh23586, that should be about right. I'd only query the SKIP=P. With the REMOVECC it may not matter, but better not to include it, I think.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: Sum an alphanumeric fields

Postby BillyBoyo » Mon Jul 07, 2014 10:16 pm

It seems this doesn't give you all your data. However, we had no way to know.

If you are a beginner, it is best to stay in this forum. The other where you posted is for those with more experience.

Modify the following for your exact positions and lengths (an any typos I've made).

     TRAILER3=(1,10,
               11,4000,
               TOT=(4011,14,                     
                     SFF,EDIT=(STTTTTTTTTT.TT),SIGNS=(+,-),
               4015,6000)))


I've spread the code out as it is always easier to read, understand, and change, that way.

Remember, we only know what you show us. You showed us a short record, so Magesh23586 provided you with code for a short record.

Also note, that with something working, you can search for other examples of TRAILER3 and get a better idea of how it works, and also consult the manuals. You will learn more and faster if you do the work from guidance, rather than just copy and paste.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: Sum an alphanumeric fields

Postby danylele74 » Tue Jul 08, 2014 3:27 pm

Unfortunately in the output file (at the bottom right of the record) I find the range containing the calculated sum.

Is it possible to remove it without losing the data contained in the input file ?

This is my JCL


//STEP060  EXEC PGM=SORT,REGION=0M,COND=(0,NE)                     
//SYSOUT   DD SYSOUT=*                                             
//SORTIN   DD DISP=SHR,DSN=XSE005.IMP000.IM1IM71.DATAPLUS.SORT3   
//SORTOUT  DD DISP=OLD,DSN=XSE005.IMP000.IM1IM71.DATAPLUS.SORT4   
//SYSIN    DD *                                                   
    SORT FIELDS=(13,9,CH,A),FORMAT=BI                             
    OUTFIL REMOVECC,NODETAIL,                                     
    SECTIONS=(13,9,                                               
    TRAILER3=(1:1,9980,X,                                         
         TOT=(3674,19,SFF,EDIT=(STTTTTTTTTTTTTTT.TT),SIGNS=(+,-))))



Thank you

p.s.
Input and output files have lenght 10000.
danylele74
 
Posts: 12
Joined: Thu Jul 03, 2014 2:00 am
Has thanked: 0 time
Been thanked: 0 time

Re: Sum an alphanumeric fields

Postby BillyBoyo » Tue Jul 08, 2014 5:12 pm

Still not clear what you want. You have an alpha-numeric value you want "summed". Do you want the result of the summing to be in the original location? Let's assume Yes for now.

    TRAILER3=(1:1,3673,X,                                         
         TOT=(3674,19,SFF,EDIT=(STTTTTTTTTTTTTTT.TT),SIGNS=(+,-)),
               3693,xxxx))
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: Sum an alphanumeric fields

Postby danylele74 » Tue Jul 08, 2014 7:58 pm

yes, I want the result of the summing to be in the original location (position 3674,19)
danylele74
 
Posts: 12
Joined: Thu Jul 03, 2014 2:00 am
Has thanked: 0 time
Been thanked: 0 time

Next

Return to DFSORT/ICETOOL/ICEGENER

 


  • Related topics
    Replies
    Views
    Last post