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

Logic help using perform Loops


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

New User


Joined: 28 Jul 2005
Posts: 58

PostPosted: Thu Dec 22, 2005 2:35 pm
Reply with quote

Hi friends,

I want to write a outputfile reading from Inputfile.
Input file willbe having the data's like.
Partno unit cost
32567 8885 2.37 ---this is for 2005 year
for 2006,2007.2008,2009,2010 we have to calculate based on the 2005 year
2005 2006 2007 2008 2009 2010

0.98 0.991 0.999 1.059 1.0352 1.057

Output file should be like.
Partno unit cost
32567 8885 2.37 (-----2005)
32567 8885 2.3487 ( ------2006( 2.37 * 0.991))
32567 8885 2.3676 (-----2007(2.3487 * 0.999))
32567 8885 2.5098 (------2008(2.3676 * 1.059))

like this I should get output file for 5 years.
how to do this using loop, i can do perfom 1 by 1 until i=5, but the rate .991, .999 will be changing. howto use this in loop
can you give some idea for this.

Thanks and Regards,
Suganthy.
Back to top
View user's profile Send private message
veenag_gopal

New User


Joined: 14 Nov 2005
Posts: 14
Location: India

PostPosted: Thu Dec 22, 2005 3:11 pm
Reply with quote

There is a input file having 3 columns.
fetch the cost and multiply it with the numbers to give a new cost.

1.You can use an accept statement to accept the various values inside the loop and inside the loop itself you can use the display statements to display various values for your reference .
2.you can send all the values through parm in jcl and use reference modification to take those values and calculate.
This is quite cumbersome so i suggest you stick to the first method .
3.You can also use a file which has year and the numbers and use the file using the read statement and calculate.

And then using variables for the hyphens and opening and the closing brackets or hardcoding the brackets you can string the values into a variable and write it into the output file.If still any doubts please tell.

I think while stringing the asterics you have to use back slash to avoid any compile error; i think logic error.
icon_rolleyes.gif
Back to top
View user's profile Send private message
priyesh.agrawal

Senior Member


Joined: 28 Mar 2005
Posts: 1448
Location: Chicago, IL

PostPosted: Thu Dec 22, 2005 4:28 pm
Reply with quote

suganthyprabha,

Is there any reason behind the values given for each years.

or any relationship between the values by which you can find values for next year.

Regards,

Priyesh.
Back to top
View user's profile Send private message
suganthyprabha

New User


Joined: 28 Jul 2005
Posts: 58

PostPosted: Thu Dec 22, 2005 4:34 pm
Reply with quote

Hi Priyesh,

Actually this is not my requirement. One of my friend asked to me.

So i don't know the relationship. So i will ask her, Then i will post it.

Thanks and Regards,
Suagnthy.
Back to top
View user's profile Send private message
raghunathns

Active User


Joined: 08 Dec 2005
Posts: 127
Location: rochester

PostPosted: Thu Dec 22, 2005 7:49 pm
Reply with quote

If the rate is fixed the store in working storage. otherwise read from file and store in 'ws-rate-d' elements

01 ws-rate-d.
05 rate1 pic 9v999 value 0.991
05 rate2 pic 9v999 value 0.999
........
01 ws-rate redefines ws-rate-d.
05 ws-rate occurs 5 times pic 9v999

Perform varying i from 2 by 1 until i > 5
amt(i) = amt(i-1) * ws-rate(i-1)
*** 2.3487=( 2.37 * 0.991) ********
end-perform

is that you are looking for.
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

 


Similar Topics
Topic Forum Replies
No new posts Use of Perform Thru Exit COBOL Programming 6
No new posts Finding faulty logic Subscript out of... COBOL Programming 5
This topic is locked: you cannot edit posts or make replies. Need assistance in job scheduling logic. Mainframe Interview Questions 2
No new posts Rexx Logic error while adding seperat... CLIST & REXX 3
No new posts PL/1 Callback address logic in z/OS C... PL/I & Assembler 1
Search our Forums:

Back to Top