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
 

 

Generate report with out using IF/EVALUATE
Goto page 1, 2  Next
 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Generate report with out using IF/EVALUATE
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    Post subject: Reply to: logic with out IF/Evaluate
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    Post subject: Reply to: logic with out IF/Evaluate
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7241

PostPosted: Tue May 22, 2012 11:20 am    Post subject: Reply to: logic with out IF/Evaluate
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: 641
Location: Whitby, ON, Canada

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

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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7241

PostPosted: Tue May 22, 2012 6:49 pm    Post subject: Reply to: logic with out IF/Evaluate
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

Moderator


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

PostPosted: Tue May 22, 2012 7:02 pm    Post subject:
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    Post subject:
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

Moderator


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

PostPosted: Tue May 22, 2012 7:12 pm    Post subject:
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    Post subject: Reply to: logic with out IF/Evaluate
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: 7914
Location: Bellevue, IA

PostPosted: Tue May 22, 2012 8:33 pm    Post subject:
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

Moderator


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

PostPosted: Tue May 22, 2012 8:33 pm    Post subject:
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

Site Director


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

PostPosted: Tue May 22, 2012 10:00 pm    Post subject: Reply to: logic with out IF/Evaluate
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

Moderator


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

PostPosted: Tue May 22, 2012 10:13 pm    Post subject:
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

Site Director


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

PostPosted: Tue May 22, 2012 10:21 pm    Post subject: Reply to: logic with out IF/Evaluate
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

Moderator


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

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

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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7241

PostPosted: Tue May 22, 2012 10:52 pm    Post subject: Reply to: logic with out IF/Evaluate
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

Moderator


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

PostPosted: Tue May 22, 2012 11:02 pm    Post subject:
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

Site Director


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

PostPosted: Wed May 23, 2012 12:12 am    Post subject:
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    Post subject: Reply to: logic with out IF/Evaluate
Reply with quote

Thanks Pandora!. its working icon_smile.gif
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 -> COBOL Programming 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 Detailed Transaction History report f... Kyle Carroll CICS 5 Tue Oct 18, 2016 12:42 am
No new posts Easytrieve - Report writing - Only 1 ... Abhi Nature CA Products 2 Wed Sep 14, 2016 11:40 am
No new posts Daily report to be extracted from CA ... polymathtarun DFSORT/ICETOOL 5 Mon Jul 11, 2016 4:33 pm
No new posts Report view in Mobile devices Robert Sample All Other Mainframe Topics 0 Thu Jun 23, 2016 7:05 pm
No new posts COBOL Report view in Mobile devices balaji81_k COBOL Programming 4 Thu Jun 23, 2016 6:41 pm


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