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

Accumulate the amounts in various fields


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
rakeshnaredlla

New User


Joined: 04 Aug 2008
Posts: 26
Location: Hyderabad

PostPosted: Sat Sep 27, 2008 12:38 am
Reply with quote

Hi

Requirement 1:
My requirement is to accumulate the amounts of various fields and display . The fields are declared as s9(9)v99. The requirement also states that of these fields I need to excluding one field from getting accumulated into the remaining fields and have to accumulate it seperatly and display.The input file has record lenght of 419 and these fields
start from cols pos 307 and ends at cols pos 372 excluding the record count in the below mentioned example.Each field has a lenght of 11 . I even have to display the record count. I need to use the DFSORT or SYNCSORT here.Please find the example below.

Input data
Code:

record counts    field1   field2    field3      field4   field5   field6 
         1     -220.00     0.00      0.00        0.00     0.00     0.00
         2        0.00   100.00      0.00        0.00     0.00     0.00
         3        0.00     0.00    500.00        0.00     0.00     0.00
         4        0.00     0.00      0.00      100.00     0.00     0.00
         5        0.00     0.00      0.00        0.00   200.00     0.00
         6        0.00     0.00      0.00        0.00     0.00   100.00
         7      900.00     0.00      0.00        0.00     0.00     0.00
         8        0.00     0.00    100.00        0.00     0.00     0.00
Output should appear like this:

Code:
Record count = 8
Gross amounts (field1+field2+field4+field5+field6) = 1180.00
Gross amount in field3=600.00


field3 starts at cols pos 329 and ends at 339.


Requirement2:
I need to sort the above Input file so that all the least amounts should appear at end of the file.We never know which field has the least amount.

Please provide me the sysin cards for the above ..2 requirement.
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: Sat Sep 27, 2008 3:35 am
Reply with quote

Here's a DFSORT job that will do what you asked for Requirement 1. I didn't know what you wanted for the length of the output records, so I used 70.

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=...  input file (FB/419)
//SORTOUT DD DSN=..  output file (FB/70)
//SYSIN    DD    *
  OPTION COPY
  INREC OVERLAY=(420:307,11,SFF,ADD,318,11,SFF,ADD,
    340,11,SFF,ADD,351,11,SFF,ADD,362,11,SFF,TO=ZD,LENGTH=11)
  OUTFIL REMOVECC,NODETAIL,
    BUILD=(70X),
    TRAILER1=('Record count = ',COUNT=(EDIT=(IIT)),/,
    'Gross amounts (field1+field2+field4+field5+field6) =',
      TOT=(420,11,ZD,EDIT=(IIIIIIIIT.TT)),/,
    'Gross amount in field3 =',
      TOT=(329,11,SFF,EDIT=(IIIIIIIIT.TT)))
/*


SORTOUT would have:

Code:

Record count =   8                                               
Gross amounts (field1+field2+field4+field5+field6) =     1180.00
Gross amount in field3 =      600.00                             


I don't understand your requirement 2. Different records have different least amounts for the different fields, so what does it mean when you say "the least amounts should appear at end of the file". Do you want one output record with the minimum amount for each field or what?

Show an example of input records with minimums other than 0.00 and the expected output, and explain the rules for getting from input to output.
Back to top
View user's profile Send private message
rakeshnaredlla

New User


Joined: 04 Aug 2008
Posts: 26
Location: Hyderabad

PostPosted: Sat Sep 27, 2008 4:02 am
Reply with quote

Frank I want to sort the inputfile in descending order so that all negative amount should come at the end of the file. Please find the example below
Input data
Code:
record counts    field1   field2    field3      field4   field5   field6 
         1       -10.00    0.00      0.00        0.00     0.00     0.00
         2        0.00     100.00    0.00        0.00     0.00     0.00
         3        0.00     0.00      -100.00     0.00     0.00     0.00
         4        0.00     0.00      0.00        -500.00  0.00     0.00
         5        0.00     0.00      0.00        0.00     -200.00  0.00
         6        0.00     0.00      0.00        0.00     0.00     -300.00
         7        900.00   0.00      0.00        0.00     0.00     0.00
         8        0.00     0.00      0.00        -110.00  0.00     0.00

Output data
Code:
record counts    field1   field2    field3      field4   field5   field6 
         1        900.00   0.00      0.00        0.00     0.00     0.00
         2        0.00     100.00    0.00        0.00     0.00     0.00 
         3       -10.00    0.00      0.00        0.00     0.00     0.00 
         4        0.00     0.00     -100.00      0.00     0.00     0.00
         5        0.00     0.00      0.00        -110.00  0.00     0.00
         6        0.00     0.00      0.00        0.00     -200.00  0.00
         7        0.00     0.00      0.00        0.00     0.00     -300.00
         8        0.00     0.00      0.00        -500.00  0.00     0.00           
         
Back to top
View user's profile Send private message
rakeshnaredlla

New User


Joined: 04 Aug 2008
Posts: 26
Location: Hyderabad

PostPosted: Sat Sep 27, 2008 4:36 am
Reply with quote

Frank Thankq for the Sysin card I tried to use this sysin card .When I checking for any syntax errors in the JCL I am getting an error which is below:
8 DSS10065E PARAMETER 'TO' IS UNIDENTIFIED.
8 DSS10065E PARAMETER 'LENGTH' IS UNIDENTIFIED.


I am Suspecting this might be a verison problem.

I even tried with the below sysin card :
INREC OVERLAY=(420:307,11,SFF,ZD,11,ADD,318,11,SFF,ZD,11,ADD,
340,11,SFF,ZD,11,ADD,351,11,SFF,ZD,11,ADD,362,11,SFF,ZD,11)


But it didn't work .I am getting a SYNTAX Error .

Please let me know your thoughts on this .
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Sat Sep 27, 2008 4:43 am
Reply with quote

Hello,

Did you submit the job or did you only try to run it thru some jcl checker?

If you did not submit the job, do so now and post back if there are any problems. Most JCL checkers do not know all of the valid syntax for the sort and so throw "errors" that are not necessarily errors.
Back to top
View user's profile Send private message
rakeshnaredlla

New User


Joined: 04 Aug 2008
Posts: 26
Location: Hyderabad

PostPosted: Sat Sep 27, 2008 5:45 am
Reply with quote

I was using the JCL checker....After Submitting the JOB I am getting the desired output now...
Thanqqqqq.....
Back to top
View user's profile Send private message
quanzhong

New User


Joined: 12 Aug 2008
Posts: 46
Location: china

PostPosted: Sat Sep 27, 2008 8:30 am
Reply with quote

Hi, frank,

for requirement 1
Code:

    'Gross amounts (field1+field2+field4+field5+field6) =',
      TOT=(420,11,ZD,EDIT=(IIIIIIIIT.TT)),/,
    'Gross amount in field3 =',
      TOT=(329,11,SFF,EDIT=(IIIIIIIIT.TT)))

there many fileds, so the TOT's length maybe over 11, is there any way to code it more flexible? thanks
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Sat Sep 27, 2008 10:01 am
Reply with quote

quanzhong,

You can always modify it to increase the number of EDITed characters so as to accomodate more digits
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: Sat Sep 27, 2008 9:36 pm
Reply with quote

Quote:
I want to sort the inputfile in descending order so that all negative amount should come at the end of the file


Assuming there is only one non-zero number per record as shown in your example, which is the only way it would make sense, you can use a DFSORT job like the following to do what you asked for:

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=...  input file (FB/419)
//SORTOUT DD DSN=..  output file (FB/419)
//SYSIN    DD    *
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(420:11C'0')),
    IFTHEN=(WHEN=(307,11,SFF,NE,0),OVERLAY=(420:307,11)),
    IFTHEN=(WHEN=(318,11,SFF,NE,0),OVERLAY=(420:318,11)),
    IFTHEN=(WHEN=(329,11,SFF,NE,0),OVERLAY=(420:329,11)),
    IFTHEN=(WHEN=(340,11,SFF,NE,0),OVERLAY=(420:340,11)),
    IFTHEN=(WHEN=(351,11,SFF,NE,0),OVERLAY=(420:351,11)),
    IFTHEN=(WHEN=(362,11,SFF,NE,0),OVERLAY=(420:362,11))
  SORT FIELDS=(420,11,SFF,D)
  OUTREC BUILD=(1,419)
/*


Note that you could do both of your requirements in one ICETOOL job.
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: Sat Sep 27, 2008 9:43 pm
Reply with quote

Quote:
there many fileds, so the TOT's length maybe over 11, is there any way to code it more flexible?


EDIT can handle up to 31 digits. From your latest input example, it appears that your totals might be negative, so you'll probably want a sign too. If you want the totals to have a sign and 15 digits, you could use this:

Code:

  OPTION COPY                                                 
  INREC OVERLAY=(420:307,11,SFF,ADD,318,11,SFF,ADD,           
    340,11,SFF,ADD,351,11,SFF,ADD,362,11,SFF,TO=ZD,LENGTH=11) 
  OUTFIL REMOVECC,NODETAIL,                                   
    BUILD=(70X),                                               
    TRAILER1=('Record count = ',COUNT=(EDIT=(IIT)),/,         
    'Gross amounts (field1+field2+field4+field5+field6) =',   
      TOT=(420,11,ZD,EDIT=(SIIIIIIIIIIIIT.TT),SIGNS=(,-)),/,   
    'Gross amount in field3 =',                               
      TOT=(329,11,SFF,EDIT=(SIIIIIIIIIIIIT.TT),SIGNS=(,-)))   
/*
Back to top
View user's profile Send private message
rakeshnaredlla

New User


Joined: 04 Aug 2008
Posts: 26
Location: Hyderabad

PostPosted: Mon Sep 29, 2008 12:49 pm
Reply with quote

Frank

The sysin you supplied is failing . I am not getting the desired output.

Please find the requirement

I have to accumulate the amounts of all the records excluding one field which I have mentioned at Cols pos 329.


Please find the input which i have used
Code:
---1----+----2----+----3----+----4----+----5----+----6----+----7---
***************************** Top of Data *************************
0000000000{0000000000{0000099990{0000000000{0000000000{0000000000{
0000000000{0000450000{0000000000{0000000000{0000000000{0000000000{
0000000000{0000000000{0000000000{0000070000{0000000000{0000000000{
0000000000{0000000000{0000000000{0000000000{0000010000}0000000000{
0000000000{0000000000{0000000000{0000000000{0000000000{0000020000}
0000000000{0000002000{0000000000{0000000000{0000000000{0000000000{


The output which I am getting is

Code:
RECORD COUNT =   6                                                    ,
GROSS AMOUNTS (FIELD1+FIELD2+FIELD4+FIELD5+FIELD6) =           552.00 ,
GROSS AMOUNT IN FIELD3 =          9999.00                             ,



The desired output is
Code:
RECORD COUNT =   6                                                    ,
GROSS AMOUNTS (FIELD1+FIELD2+FIELD4+FIELD5+FIELD6) =           49200.00 ,
GROSS AMOUNT IN FIELD3 =          9999.00                             ,


Please let me know your feedback
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: Mon Sep 29, 2008 10:02 pm
Reply with quote

Sigh.

Garbage in, garbage out!!

You showed your example input records as having values in the form sddddddddd.dd, so I used SFF format to handle them. But the latest example you show indicates that your input records really have plain ZD values, so you need to use ZD format to handle them. I can only go by what you tell me.

Given that you really have ZD values, the control statements should be as follows:

Code:

  OPTION COPY
  INREC OVERLAY=(420:307,11,ZD,ADD,318,11,ZD,ADD,
    340,11,ZD,ADD,351,11,ZD,ADD,362,11,ZD,TO=ZD,LENGTH=11)
  OUTFIL REMOVECC,NODETAIL,
    BUILD=(70X),
    TRAILER1=('Record count = ',COUNT=(EDIT=(IIT)),/,
    'Gross amounts (field1+field2+field4+field5+field6) =',
      TOT=(420,11,ZD,EDIT=(IIIIIIIIT.TT)),/,
      TOT=(420,11,ZD,EDIT=(SIIIIIIIIIIIIT.TT),SIGNS=(,-)),/,
    'Gross amount in field3 =',
      TOT=(329,11,ZD,EDIT=(SIIIIIIIIIIIIT.TT),SIGNS=(,-)))
Back to top
View user's profile Send private message
rakeshnaredlla

New User


Joined: 04 Aug 2008
Posts: 26
Location: Hyderabad

PostPosted: Tue Sep 30, 2008 8:22 pm
Reply with quote

Thank You FranK, Its working now. Thanks a lot .................. icon_biggrin.gif icon_biggrin.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 -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts Concatenate 2 fields (usage national)... COBOL Programming 2
No new posts Cobol COMP-2 fields getting scrambled... Java & MQSeries 6
No new posts Converting unpacked fields to pack us... SYNCSORT 4
No new posts Data for newly added fields not displ... IMS DB/DC 6
This topic is locked: you cannot edit posts or make replies. SUM FIELDS=NONE in reverse - Get dupl... DFSORT/ICETOOL 9
Search our Forums:

Back to Top