Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Arithmetic Operation
Goto page 1, 2  Next
 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
Rohit Umarjikar

Senior Member


Joined: 21 Sep 2010
Posts: 1610
Location: NY,USA

PostPosted: Wed Apr 11, 2012 7:48 pm    Post subject: Arithmetic Operation
Reply with quote

I have 3 input files,
1) First file:
Total1
---------
05
2)Second file:
Total1
---------
20

output file should be.

Percentage
--------------
25

Now, I have one more file which contains total percentage,

3)Third file:
Percentage
-------------
90

Here, I have to check if 25>90 then set the return code of the step to 8 else set the return code to 4.
Back to top
View user's profile Send private message

Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7232

PostPosted: Wed Apr 11, 2012 7:53 pm    Post subject: Reply to: Arithmatic Operation
Reply with quote

Well, we'd need the full shebang,

Recfms/lrecls of all files. Start/length of all fields relevant. Sample data for all three input files, in the Code tags please.

Are the RC values fixed in stone?
Back to top
View user's profile Send private message
Rohit Umarjikar

Senior Member


Joined: 21 Sep 2010
Posts: 1610
Location: NY,USA

PostPosted: Wed Apr 11, 2012 7:57 pm    Post subject:
Reply with quote

I have 3 input files,
1) First file:
Code:
Total1
---------
05

2)Second file:
Code:
Total1
---------
20


output file should be.

Code:
Percentage
--------------
25


Now, I have one more file which contains total percentage,

3)Third file:
Code:
Percentage
-------------
90


Here, I have to check if 25>90 then set the return code of the step to 8 else set the return code to 4.

Its FB file and LRECL=20 for all of the files.
Please treat the values provided as the sample data.I mean all the time these 3 input files will be containing only one record.
Yes the RC values are fixed in all the time.
Back to top
View user's profile Send private message
Rohit Umarjikar

Senior Member


Joined: 21 Sep 2010
Posts: 1610
Location: NY,USA

PostPosted: Wed Apr 11, 2012 8:11 pm    Post subject:
Reply with quote

Code:
total
-----
20


Please ignore this reply alone.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7232

PostPosted: Wed Apr 11, 2012 8:15 pm    Post subject: Reply to: Arithmatic Operation
Reply with quote

You are showing three records on each input file. Do you mean one data record plus two heading records?

Isn't this a bit of "overkill"?
Back to top
View user's profile Send private message
Rohit Umarjikar

Senior Member


Joined: 21 Sep 2010
Posts: 1610
Location: NY,USA

PostPosted: Wed Apr 11, 2012 8:28 pm    Post subject:
Reply with quote

Sorry for getting you misunderstood on this,
Just the numbers are the actual data present in al off these files, please idnore all the headers and '---'.
Back to top
View user's profile Send private message
Rohit Umarjikar

Senior Member


Joined: 21 Sep 2010
Posts: 1610
Location: NY,USA

PostPosted: Wed Apr 11, 2012 9:14 pm    Post subject:
Reply with quote

Hello Bill,
Please consider it as a only data records, no headers and '-----'.
Back to top
View user's profile Send private message
prino

Active Member


Joined: 07 Feb 2009
Posts: 984
Location: Oostende, Belgium

PostPosted: Wed Apr 11, 2012 9:45 pm    Post subject:
Reply with quote

The time between your first and last posting is 1h26m. Wasn't that enough to code a simple COBOL, PL/I or REXX program to do what's needed?
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1738
Location: Bloomington, IL

PostPosted: Wed Apr 11, 2012 10:38 pm    Post subject:
Reply with quote

prino wrote:
The time between your first and last posting is 1h26m. Wasn't that enough to code a simple COBOL, PL/I or REXX program to do what's needed?

Wrote, compiled, linked, and tested a PL/I program in 00:33. My mainframe is running hella slow due to storage issues just now, else I probably could have knocked ten minutes off that time.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Wed Apr 11, 2012 10:43 pm    Post subject:
Reply with quote

Quote:
Here, I have to check if 25>90 then set the return code of the step to 8 else set the return code to 4.


Passing back RC=4 or RC=8 with DFSORT is not straightforward. Passing back RC=0 or RC=4 would be.

As others have said, DFSORT is probably NOT the ideal program for this kind of thing. We could probably cobble something together to do it but a simple program in PL/I, REXX, COBOL, etc would probably be a better choice.
Back to top
View user's profile Send private message
Rohit Umarjikar

Senior Member


Joined: 21 Sep 2010
Posts: 1610
Location: NY,USA

PostPosted: Thu Apr 12, 2012 1:46 pm    Post subject:
Reply with quote

Akatsukami, Prino:
Yes, you all are right, but I don't have a requirement to include any COBOL, REXX,PL/I modules, otherwise I would not have posted this here.
Moreover, I am trying to do this with the help of SAS (Client is ok with it)parallely, but any help related to DFSORT would be appriciated.

Quote:
Passing back RC=4 or RC=8 with DFSORT is not straightforward. Passing back RC=0 or RC=4 would be.


I am ok with these RC (i.e. 0 and 4)
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7232

PostPosted: Thu Apr 12, 2012 1:51 pm    Post subject:
Reply with quote

Rohit Umarjikar wrote:
[...]

I am ok with these RC (i.e. 0 and 4)


Funny. I thought I asked about that yesterday. Maybe I was misunderstood.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7232

PostPosted: Thu Apr 12, 2012 2:38 pm    Post subject: Reply to: Arithmatic Operation
Reply with quote

Here's the cobble requested:

Since there are only a total of three input records, and their order can be guaranteed if you get the concatenation correct, this uses two GROUPs to pass data from one record to another and then calculate on that another record.

If you bust your warning percentage, no record is written to file F1 OUTFIL, and the NULLOFL=RC4 gets you your 4. If not busted, a record of inconsequential content is written and you get the 0 because there is data on the file.

Don't gouge yourself on the nails. An expert cobbler could make a better job of it, I'm sure.

Code:
//STEP0100 EXEC PGM=SORT
//SYSOUT   DD SYSOUT=*
//SORTOFF1 DD DUMMY this is to get the RC0/RC4, but content is not relevant
//SORTIN   DD your amout used dataset
//         DD your maximum amount dataset
//         DD your warning percentage dataset
//SORTOUT  DD your calculated percentage output dataset
//SYSIN    DD *
  OPTION COPY
  INREC IFTHEN=(WHEN=GROUP,RECORDS=3,PUSH=(21:1,2,SEQ=1)),
        IFTHEN=(WHEN=(23,1,CH,EQ,C'2'),
               OVERLAY=(5:21,2,ZD,MUL,+100,
                                  DIV,1,2,ZD,
                                  TO=ZD,LENGTH=2))
  OUTREC IFTHEN=(WHEN=GROUP,BEGIN=(23,1,CH,EQ,C'2'),PUSH=(30:5,2)),
         IFTHEN=(WHEN=(23,1,CH,EQ,C'3',
                  AND,30,2,CH,GT,1,2,CH),
               OVERLAY=(5:C'X'))
  OUTFIL INCLUDE=(23,1,CH,EQ,C'2'),BUILD=(5,2,80:X)
  OUTFIL FILES=F1,INCLUDE=(5,1,CH,NE,C'X',
                      AND,23,1,CH,EQ,C'3'),BUILD=(1,80),
                      NULLOFL=RC4
Back to top
View user's profile Send private message
Rohit Umarjikar

Senior Member


Joined: 21 Sep 2010
Posts: 1610
Location: NY,USA

PostPosted: Thu Apr 12, 2012 4:53 pm    Post subject:
Reply with quote

Thanks Bill,
I would try this one.
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Thu Apr 12, 2012 9:43 pm    Post subject:
Reply with quote

Rohit Umarjikar,

The condition to set the RC is
Code:

IF (file1 value + file2 value ) = File3 Value
    SET RC=0
ELSE
    SET RC=4
END-IF


Use the following DFSORT JCL which will give you the desired results. Just concatenate file1 and file2 and treat it as single file and sum the values.
Code:

//STEP0100 EXEC PGM=SORT                         
//SYSOUT   DD SYSOUT=*                           
//INA      DD DSN=Your input Lrecl 20 File1,DISP=SHR                 
//         DD DSN=Your input Lrecl 20 File2,DISP=SHR
//*           
//INB      DD Your input Lrecl 20 File3,DISP=SHR
//SORTOUT  DD SYSOUT=*                           
//SYSIN    DD *                                 
  JOINKEYS F1=INA,FIELDS=(21,1,A)               
  JOINKEYS F2=INB,FIELDS=(21,1,A),SORTED,NOSEQCK
  REFORMAT FIELDS=(F1:1,3,F2:1,3)               
  INCLUDE COND=(1,3,ZD,EQ,4,3,ZD)               
  OPTION COPY,NULLOUT=RC4       
//*               
//JNF1CNTL DD *                                 
  INREC BUILD=(C'0',1,2,21:C'1')                 
  SUM FIELDS=(1,3,ZD)                           
//*                                             
//JNF2CNTL DD *                                 
  OPTION STOPAFT=1                               
  INREC BUILD=(C'0',1,2,21:C'1')                 
//*
Back to top
View user's profile Send private message
Rohit Umarjikar

Senior Member


Joined: 21 Sep 2010
Posts: 1610
Location: NY,USA

PostPosted: Fri Apr 13, 2012 7:19 pm    Post subject:
Reply with quote

Kolusu,

Thanks for the update.

But I don't see the % is getting calculated based on the file1 and file 2. I actually would like to get % done by the use of file1 and file2 record and then check that % value with % value present in the file3.

Hope I am keeping my words same.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Fri Apr 13, 2012 7:48 pm    Post subject:
Reply with quote

and the posts go on and on and on and on...
Back to top
View user's profile Send private message
Rohit Umarjikar

Senior Member


Joined: 21 Sep 2010
Posts: 1610
Location: NY,USA

PostPosted: Fri Apr 13, 2012 8:02 pm    Post subject:
Reply with quote

Sometimes....icon_smile.gif
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Fri Apr 13, 2012 8:44 pm    Post subject:
Reply with quote

Rohit Umarjikar wrote:
Kolusu,

Thanks for the update.

But I don't see the % is getting calculated based on the file1 and file 2. I actually would like to get % done by the use of file1 and file2 record and then check that % value with % value present in the file3.

Hope I am keeping my words same.


Ok My mistake about not calculating the % but how did you arrive at the percentage?

5 = (20 * X)/100 and now I need to calculate the X?

in the above case X would result in 25.

What happens if File1 value is greater than file 2 value? or it exceeds 100?
Back to top
View user's profile Send private message
Rohit Umarjikar

Senior Member


Joined: 21 Sep 2010
Posts: 1610
Location: NY,USA

PostPosted: Mon Apr 16, 2012 7:50 pm    Post subject:
Reply with quote

Quote:
Ok My mistake about not calculating the % but how did you arrive at the percentage?

5 = (20 * X)/100 and now I need to calculate the X?

in the above case X would result in 25.

What happens if File1 value is greater than file 2 value? or it exceeds 100?


Yes, you are right the 25 value should be the %.
And file1 value will be at max equals to file 2 value so it will be max of 100%.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Performing arithmetic on input field zh_lad DFSORT/ICETOOL 17 Tue Dec 06, 2016 8:04 pm
No new posts Joinkeys operation when key1 and key2... Susanta DFSORT/ICETOOL 5 Wed Nov 02, 2016 5:35 pm
No new posts Joinkeys operation betwen VB and FB file Susanta SYNCSORT 4 Sun Sep 25, 2016 9:49 pm
No new posts how to eliminate records from operati... PUMA DFSORT/ICETOOL 5 Tue Dec 23, 2014 4:42 pm
No new posts Operation with 3 files sun_job DFSORT/ICETOOL 5 Wed Oct 15, 2014 6:46 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us