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

Generate report with out using IF/EVALUATE


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
bbharathiraj
Warnings : 1

New User


Joined: 26 Oct 2006
Posts: 50
Location: Chennai

PostPosted: Tue May 22, 2012 10:19 am
Reply with quote

Dear Friends,

Below question was raised by my collegue. I tried all the way with my COBOL knoweldge but couldn't find solution icon_sad.gif

Question:
How to generate the below report with out using IF/EVALUATE with input file contains 2 fileds 1) Salary 2) Employee number.


Code:
Salary            NO OF Employee           TOTAL Employees
-------------------------------------------------------------------------
1000                         10                    10
2000                         20                    30
10000                       30                    70


Assume: Total record is 70 in input file

Is there any way in COBOL with out IF/EVALUATE
Back to top
View user's profile Send private message
Peter cobolskolan

Active User


Joined: 06 Feb 2012
Posts: 104
Location: Sweden

PostPosted: Tue May 22, 2012 10:30 am
Reply with quote

Are you sure your college is a programmer?
The basics in all programming languages are IFs and different types of EVALUATE.
Back to top
View user's profile Send private message
bbharathiraj
Warnings : 1

New User


Joined: 26 Oct 2006
Posts: 50
Location: Chennai

PostPosted: Tue May 22, 2012 10:34 am
Reply with quote

Yes. He is working with me for last 6 years as developer icon_smile.gif
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Tue May 22, 2012 11:20 am
Reply with quote

Just hard-code the report lines and DISPLAY them.

Unless you can come up with a very, very good reason for the question, we don't do "if magic could happen" answers.
Back to top
View user's profile Send private message
don.leahy

Active Member


Joined: 06 Jul 2010
Posts: 765
Location: Whitby, ON, Canada

PostPosted: Tue May 22, 2012 6:39 pm
Reply with quote

What is this, a bar bet?
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Tue May 22, 2012 6:49 pm
Reply with quote

Thanks for that Don, I had been thing it was something real but stupid :-)

OK, search for the Cobol Report Writer manual. That'll do what your colleague has challenged you to with Cobol. Summing, totally, control-breaks etc, all you do is define that they need to be done and with what fields, and the "Report Writer" does the rest.
Back to top
View user's profile Send private message
Pandora-Box

Global Moderator


Joined: 07 Sep 2006
Posts: 1592
Location: Andromeda Galaxy

PostPosted: Tue May 22, 2012 7:02 pm
Reply with quote

All I see is that a simple sort job would it for to get a report without IF / EVALUATE statements
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Tue May 22, 2012 7:09 pm
Reply with quote

Pandora-Box wrote:
All I see is that a simple sort job would it for to get a report without IF / EVALUATE statements


great! but:
bbharathiraj wrote:
Is there any way in COBOL with out IF/EVALUATE


need to stay on subject....
Back to top
View user's profile Send private message
Pandora-Box

Global Moderator


Joined: 07 Sep 2006
Posts: 1592
Location: Andromeda Galaxy

PostPosted: Tue May 22, 2012 7:12 pm
Reply with quote

my mistake thanks for correction icon_redface.gif
Back to top
View user's profile Send private message
bbharathiraj
Warnings : 1

New User


Joined: 26 Oct 2006
Posts: 50
Location: Chennai

PostPosted: Tue May 22, 2012 7:50 pm
Reply with quote

I just want to share with COBOL experts is there any solution for this since I take this question seriously.
I will post the possible solution if I get it from questioner

I think, as Bill recommended, Cobol Report writer might be the solution
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Tue May 22, 2012 8:33 pm
Reply with quote

First, it is an extremely poor question -- probably should be in the homework or interview questions section of this forum, not in the COBOL section.

Second, your colleague obviously wants you to explore COBOL Report Writer, which would be the ONLY way in COBOL to generate the given output without explicit IF statements (Report Writer has implicit IF statements for control breaks).

Third, COBOL Report Writer is NOT part of COBOL -- IBM lists it as a separate product with its own order number (5798-DYR, 5798-DZX for Report Writer versus 5655-S71 for Enterprise COBOL V4.1). So unless a site orders (and pays for) the Report Writer, that functionality will not be present so at many sites what you want to do is not possible, period.
Back to top
View user's profile Send private message
Pandora-Box

Global Moderator


Joined: 07 Sep 2006
Posts: 1592
Location: Andromeda Galaxy

PostPosted: Tue May 22, 2012 8:33 pm
Reply with quote

Hi Why dont you try this logic

Prerequisite the input file is sorted based on Salary

Code:
Open input
Open output report file
Write header
Read input file
Store salary in field ws-salary , ws-salary2
         Perform until EOF is reached         
              Perform Until ws-salary not = ws-salary2
                  Add 1 to no of employees 
                  Add 1 to Total-total employee
                  Read input-file
                  Store salary in field ws-salary
              End-Perform
              Write Salary , no of employees , total employees       to report
              reinitialize  no of employees
              move ws-salary to ws-salary2
         End-Perform


Experts correct me If I am wrong I just gave a shot never tested it
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: Tue May 22, 2012 10:00 pm
Reply with quote

Hello,

Looks pretty good to me providing there is no "scope creep". If there becomes an increase in the number of different "salaries", somethng would be needed to print headers on the next page.

Well done icon_smile.gif

d
Back to top
View user's profile Send private message
Pandora-Box

Global Moderator


Joined: 07 Sep 2006
Posts: 1592
Location: Andromeda Galaxy

PostPosted: Tue May 22, 2012 10:13 pm
Reply with quote

Thanks Dick and yes agreed to your point on the fresh header for next page

just trying to improve myself through vicarious experiences icon_smile.gif
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: Tue May 22, 2012 10:21 pm
Reply with quote

Hello,

Quote:
just trying to improve myself through vicarious experiences
Do continue at this - it works very well icon_wink.gif

d
Back to top
View user's profile Send private message
Pandora-Box

Global Moderator


Joined: 07 Sep 2006
Posts: 1592
Location: Andromeda Galaxy

PostPosted: Tue May 22, 2012 10:30 pm
Reply with quote

Sure cant stop myself icon_smile.gif
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Tue May 22, 2012 10:52 pm
Reply with quote

I kind of like that too, pandora-box.

You would need to read another record :-)

You could even do the pagination with PERFORM UNTILs. If the test is true, the perform does not get done.

Going back to your own Sort suggestion, it is also not so bad. Do the report in Sort, then simply read/write in the Cobol program. Just a perform-until-end-of-file type of thing.

OK, wouldn't meet the input file requirement. So, to keep to the "spirit" of the Cobol-only and the input file, it might, I don't know, be possible to do the formatting of the report as a Cobol internal sort, then just do the printing.

So, although probably not the expected answer, though maybe it is, it is certainly not a bad answer to an odd question, pandora-box.

Oh, dear, it might also be easier than we are thinking.

How about, use the salary as a subscript? Normalise it first, add one. At end of file, empty table (PERFORM UNTIL for table PERFORM UNTIL for non-zero), turn the subscript back to a salary, do the running total. Pagination as above.

'Nuff now.
Back to top
View user's profile Send private message
Pandora-Box

Global Moderator


Joined: 07 Sep 2006
Posts: 1592
Location: Andromeda Galaxy

PostPosted: Tue May 22, 2012 11:02 pm
Reply with quote

Thanks Bill icon_smile.gif

I was pretty doubtful of adding another read then realised I might need it though couldnt edit my post that point of time .

Wish I get the moderating access one day so I could edit my post any point it time

I did understand the logic of yours. ..

Got to try it later point in time icon_smile.gif

Thanks about that icon_smile.gif
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: Wed May 23, 2012 12:12 am
Reply with quote

Hello,

Quote:
Wish I get the moderating access one day so I could edit my post any point it time

Maybe someday icon_smile.gif

As far as editing, i believe you can edit within 10 minutes (not positive, 'cause i don't have the time limit icon_wink.gif )

If it is longer than the time limit and you want something changed, post this in the topic and someone will be able to make the change for you.
Back to top
View user's profile Send private message
bbharathiraj
Warnings : 1

New User


Joined: 26 Oct 2006
Posts: 50
Location: Chennai

PostPosted: Wed May 23, 2012 10:02 am
Reply with quote

Thanks Pandora!. its working icon_smile.gif
Back to top
View user's profile Send private message
Pandora-Box

Global Moderator


Joined: 07 Sep 2006
Posts: 1592
Location: Andromeda Galaxy

PostPosted: Wed May 23, 2012 10:13 am
Reply with quote

Glad its working
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1353
Location: Israel

PostPosted: Wed May 23, 2012 8:06 pm
Reply with quote

Nice work, Pandora-Box icon_smile.gif
Back to top
View user's profile Send private message
Pandora-Box

Global Moderator


Joined: 07 Sep 2006
Posts: 1592
Location: Andromeda Galaxy

PostPosted: Wed May 23, 2012 8:08 pm
Reply with quote

Thanks Marso
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Wed May 23, 2012 8:14 pm
Reply with quote

Pandora-Box,
though late, let me add my 'good job'!

worth much more than the question deserved.
Back to top
View user's profile Send private message
Pandora-Box

Global Moderator


Joined: 07 Sep 2006
Posts: 1592
Location: Andromeda Galaxy

PostPosted: Wed May 23, 2012 8:16 pm
Reply with quote

I am striving hard for more such good jobs :-) Hope i would be consistent :-)
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 -> COBOL Programming Goto page 1, 2  Next

 


Similar Topics
Topic Forum Replies
No new posts Generate random number from range of ... COBOL Programming 3
No new posts Need help on formatting a report DFSORT/ICETOOL 14
No new posts Creating Report using SORT DFSORT/ICETOOL 7
No new posts Ca7 long running jobs report All Other Mainframe Topics 1
No new posts Report of batch jobs JCL & VSAM 1
Search our Forums:

Back to Top