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

Help me to solve this logic.


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

New User


Joined: 01 Jul 2008
Posts: 32
Location: chennai

PostPosted: Mon Oct 26, 2009 2:09 pm
Reply with quote

I want to write a report having a date colume(current date)
which should indicate the very first occurence of the record .

ie. This date column should have current date if written for the first time
else if the same record has occured before then that date has to be fetched.


To write 00001 rec in the report i will check a ps file (only ps file could be used)
if 00001 is present then date will be fetched from ps file else 00001 rec should be written with
current date both report and the ps file.

Thus this ps file will have the first occurence date along with key.

The problem i face is i have to read the same file and write a new record in the same file.

Further if i have to delete some recs in ps based on some more conditions
Back to top
View user's profile Send private message
bhairon singh rathore

New User


Joined: 19 Jun 2008
Posts: 91
Location: banglore

PostPosted: Mon Oct 26, 2009 2:43 pm
Reply with quote

Hi edwin_infy,

You can use a new file with same format as your old PS file......and can do all write operation on it....then use new file for further reference.
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6250
Location: Mumbai, India

PostPosted: Mon Oct 26, 2009 2:51 pm
Reply with quote

Your post could win the most confusing post of the day award - I read it more than four times to dare to answer in. Please understand, on such forums, only communication media is the written-text in front of us, as striaght and clear you make it chances of geetting good advice is/are as higher.

edwin_infy wrote:
The problem i face is i have to read the same file and write a new record in the same file.
Please have a look on I-O mode in COBOL manuals. If you tell us exactly what error did you get and what you've tried - some one will be around with a better suggestion.
Back to top
View user's profile Send private message
edwin_infy

New User


Joined: 01 Jul 2008
Posts: 32
Location: chennai

PostPosted: Mon Oct 26, 2009 3:34 pm
Reply with quote

THe report should be like this

Last month report

Report :
Key First Date
___ __________

00001 xxxxxxxxxxxxxxxxxxxx01092009(Current report writing date)
00002 xxxxxxxxxxxxxxxxxxxx01092009
00003 xxxxxxxxxxxxxxxxxxxx01092009
00004 xxxxxxxxxxxxxxxxxxxx01092009
00005 xxxxxxxxxxxxxxxxxxxx01092009
00006 xxxxxxxxxxxxxxxxxxxx01092009


This is a monthly generately report: (Wont be kept in permanent storage)

For the this month

if 00001 record comes to be written in the same report i need to fetch
its date of first occurence.

00001xxxxxxxxxxxxxxxxxxxxx01092009(instead of todays date)
00002 xxxxxxxxxxxxxxxxxxxx01092009
00003 xxxxxxxxxxxxxxxxxxxx01092009
00007xxxxxxxxxxxxxxxxxxxxx01102009(very first occurence)
00008xxxxxxxxxxxxxxxxxxxxx01102009(very first occurence)

For Next month

00001XXXXXXXXXXXXXXXXXXXXX01092009
00007XXXXXXXXXXXXXXXXXXXXX01102009
00009XXXXXXXXXXXXXXXXXXXXX01112009.


For this i can use only PS to store the key and First occurence date.
Managing this PS is the issue.
AS i have to Read as well as write the same file.
Which is not possible in I/O mode.

Using a PS file is a good idea which am working now
any more simple way to do

thanks
Hope am clear this time.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Mon Oct 26, 2009 4:25 pm
Reply with quote

obviously the ps file must be Father-Son.

when/how do you decide a record is first occurence(sic)?
do you have another file that you use as input?
what is the source of the first occurrence of a record?
Back to top
View user's profile Send private message
GuyC

Senior Member


Joined: 11 Aug 2009
Posts: 1281
Location: Belgium

PostPosted: Mon Oct 26, 2009 4:47 pm
Reply with quote

It's a straightforward merge-program

with two inputs :
"first occurence" PS file
& source of report (cursor , other file ,...)

and two outputs :
report
& new "first occurence" PS file

In the JCL after you can copy the new first occurence file to the real "first occurence" file .
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Mon Oct 26, 2009 5:18 pm
Reply with quote

GuyC wrote:
It's a straightforward merge-program


Sorry Guy,

Only towards my children do I feel compelled to be psychic.
Back to top
View user's profile Send private message
GuyC

Senior Member


Joined: 11 Aug 2009
Posts: 1281
Location: Belgium

PostPosted: Mon Oct 26, 2009 5:21 pm
Reply with quote

Do you feel the need to be psychic to understand my answer or to match my answer to the Original Post ?
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Mon Oct 26, 2009 5:53 pm
Reply with quote

Since the Topic Starter did not bother to fully explain the situation,
and past experience has proven that it is often futile to assume anything about these posts,

yes, I feel I must be psychic to fully understand the problem.

Also, past experience has shown that when you force the person
with the problem
to fully explain, s/he often sees the light.

Yes, it did seem obvious that this was some kind of match-merge,
but since the TS did not bother to state that this was the case,
it seemed obvious that the TS was unable to describe the problem.

not once, but twice the TS provided an incomplete description.
if s/he can't describe the problem, there is little chance of s/he developing a solution.

Where/how are the first fields generated?
This particular problem could be easy or somewhat complicated.

l am more interested in the TS learning how to solve problems
as I am trying to impress everyone with my ability to solve this problem.
and you can read that anyway that you desire.
Back to top
View user's profile Send private message
edwin_infy

New User


Joined: 01 Jul 2008
Posts: 32
Location: chennai

PostPosted: Mon Oct 26, 2009 6:09 pm
Reply with quote

First fields are generated from another input file.

It cant be done with a simple merge.

if the question is not understood then it doesnt mean the TS is not able to solve problems.

I have acheive the same with a old and new (to write alone) concept.

THanks for all your help.
Back to top
View user's profile Send private message
GuyC

Senior Member


Joined: 11 Aug 2009
Posts: 1281
Location: Belgium

PostPosted: Mon Oct 26, 2009 6:14 pm
Reply with quote

It is easier to explain a problem when (one thinks) one knows the solution.

Feeding the TS crumb by crumb will eventually also get him there and s/he will have learnt it. But I feel it is a bit patronizing.

All I did is to point him to a possible method of solving it. Applying the method to his/her problem or deciding it isn't valid, is still his/hers responsability.

I didn't mean to impress. I don't think it was that impressive anyway.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Mon Oct 26, 2009 7:01 pm
Reply with quote

edwin_infy wrote:
more un-info,
whine,
sob,
i am miss-understood and unappreciated,
insincerity


I certainly stand corrected.
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: Mon Oct 26, 2009 9:53 pm
Reply with quote

Hello,

Well, i certainly stand confused. . . icon_confused.gif

I've read this a few times and all i believe i know is that this is not a 2-file merge and this will not work as a single PS file.

If you believe you know how to get the right "answer", you might consider creating a vsam file (or a temporary(?) database table) for the processing and then copy that content to the needed output PS file.
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 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 how to solve this power failure shutd... ABENDS & Debugging 5
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