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
 

 

Logic for this file handling
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
mflax

New User


Joined: 01 Sep 2006
Posts: 17
Location: Delhi

PostPosted: Fri Apr 13, 2007 8:41 am    Post subject: Logic for this file handling
Reply with quote

I have a input file as given and need to write output file with the records with different second column record. also zero is not considered as different it is same for all

I nto getting how to code, plz help.

INPUT
A 1
A 1
A 1
A 2
B 1
B 2
C 1
C 1
D 3
D 0
E 9
E 0

OUTPUT
A 1
A 1
A 1
A 2
B 1
B 2
Back to top
View user's profile Send private message

William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3158
Location: Tucson AZ

PostPosted: Fri Apr 13, 2007 9:49 am    Post subject:
Reply with quote

What happened to
C 1
C 1
D 3
D 0
E 9
E 0
and what does "also zero is not considered as different" mean?
Back to top
View user's profile Send private message
mflax

New User


Joined: 01 Sep 2006
Posts: 17
Location: Delhi

PostPosted: Fri Apr 13, 2007 10:04 am    Post subject: Re: logic for this file handling
Reply with quote

"also zero is not considered as different"

means, if first record is have a 3 and second is have a 0 then it is not different and is considered same. so along with record for C, D & E also did not go to output file.

all these records i write in another file.
Back to top
View user's profile Send private message
guptae

Moderator


Joined: 14 Oct 2005
Posts: 1187
Location: Bangalore,India

PostPosted: Fri Apr 13, 2007 10:19 am    Post subject:
Reply with quote

Hi Mflax,


Quote:
means, if first record is have a 3 and second is have a 0 then it is not different and is considered same

Then why following are not coming in to o/p file
C 1
C 1
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3158
Location: Tucson AZ

PostPosted: Fri Apr 13, 2007 10:21 am    Post subject:
Reply with quote

I still do not understand. The only logic I can see it read file, write file, do it six times and stop.
Is that what you want?
Back to top
View user's profile Send private message
Devzee

Active Member


Joined: 20 Jan 2007
Posts: 684
Location: Hollywood

PostPosted: Fri Apr 13, 2007 11:03 am    Post subject:
Reply with quote

By looking at your i/p and o/p, this is what i think you are looking for.

Starting with record type 1 followed by record type 2 is considered one group of records and written to output file?

Confirm this or give more details
Back to top
View user's profile Send private message
mahi

New User


Joined: 04 Apr 2006
Posts: 86
Location: Pune

PostPosted: Fri Apr 13, 2007 11:45 am    Post subject:
Reply with quote

Wht I understtod from his I/P and O/P is:
He wants to write output when there are different second record fields like a 1 , a 2 so write all the records start with A. If the input is having only one like D3 it is not considerd as different and not to written to the Output.
Back to top
View user's profile Send private message
agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 685
Location: Earth

PostPosted: Fri Apr 13, 2007 5:43 pm    Post subject:
Reply with quote

mflax,
Your example is not sufficient for us to understand your logic. ( I suppose there are some people with me icon_smile.gif )
If you could elaborate or post a different example, that would be great.
Back to top
View user's profile Send private message
mflax

New User


Joined: 01 Sep 2006
Posts: 17
Location: Delhi

PostPosted: Sun Apr 15, 2007 12:13 am    Post subject: Re: Logic for this file handling
Reply with quote

Quote:
I still do not understand. The only logic I can see it read file, write file, do it six times and stop.
Is that what you want?

icon_sad.gif icon_sad.gif

Okie, I try restating it in a better way.

One record in the I/p file is having many fields. I need to check for two of them. (lets say one record is a combination of field F1, F2, F3 & F4.
Now for all the records having similar value of F1, if value of F3 is same across then it goes to one file else other file. when checking for similarity of F3, 0 is exception and not considered different to any number.

I havent kept values of F2 & F4 in the example.

INPUT
A 1
A 1
A 1
A 2 (for all the recs of F1=A, F3 is not same across)
B 1
B 2 (for all the recs of F1=B, F3 is not same across)
C 1
C 1 (for all the recs of F1=C, F3 is same across)
D 3
D 0 (for all the recs of F1=D, F3 is not same across but 0 is exception)
E 9
E 0 (for all the recs of F1=E, F3 is not same across but 0 is exception)

So F1= A & F1=B goes one place, C D E goes another.
Back to top
View user's profile Send private message
mflax

New User


Joined: 01 Sep 2006
Posts: 17
Location: Delhi

PostPosted: Sun Apr 15, 2007 12:32 am    Post subject: Re: Logic for this file handling
Reply with quote

Quote:
Wht I understtod from his I/P and O/P is:
He wants to write output when there are different second record fields like a 1 , a 2 so write all the records start with A. If the input is having only one like D3 it is not considerd as different and not to written to the Output.

This is SHE, not HE icon_lol.gif
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10201
Location: italy

PostPosted: Sun Apr 15, 2007 12:32 am    Post subject: Re: Logic for this file handling
Reply with quote

Hi !

You say that Your file is composed of these records

a 1
a 1
a 1
a 2

and so on

I think that we all agree on saying that

f1 = a f2 = 1

then You start talking about f3 and f4

Now I start loosing You and Your way of describing things ...

also in Your first post You speak about differences
different from what ??

what are the two terms of the comparison

I might be dumb but I do not understand the logic

regards

e.s
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10201
Location: italy

PostPosted: Sun Apr 15, 2007 12:44 am    Post subject: Re: Logic for this file handling
Reply with quote

Hi !

I just got some light ...

Quote:

INPUT
A 1
A 1
A 1
A 2
B 1
B 2
C 1
C 1
D 3
D 0
E 9
E 0


The gentleman means
the first column is the key

write to file number 1 all the records where the second column is 0
---- /d 0/e 0/
write to file number 1 all the records where there is a single occurrence of the key ( because ... there is nothing to compare with)
---- /e 9/d 3/

write to file number 1 all the records where the second column has the same value for all the occurences of the same key
---- /c 1/c 1/

write to file number 2 all the records where for the same key there are different values of the second column
---- /a 1/a 1/a 1/a 2/

HOMEWORK AGAIN

regards

e.s
Back to top
View user's profile Send private message
mflax

New User


Joined: 01 Sep 2006
Posts: 17
Location: Delhi

PostPosted: Sun Apr 15, 2007 1:34 am    Post subject: Re: Logic for this file handling
Reply with quote

Quote:
I think that we all agree on saying that

f1 = a f2 = 1

then You start talking about f3 and f4

Now I start loosing You and Your way of describing things ...

Sir, I am sorry to for the cofusion. but did u miss this line in my post earlier.
"I havent kept values of F2 & F4 in the example. "

Quote:
write to file number 1 all the records where the second column is 0
No. record having 0 doesnt come in comparison, this record goes in the file where other record for that key is going.
Quote:
write to file number 1 all the records where there is a single occurrence of the key ( because ... there is nothing to compare with)
Yepp.
Quote:
write to file number 1 all the records where the second column has the same value for all the occurences of the same key
Yepp.
Quote:
write to file number 2 all the records where for the same key there are different values of the second column
Yepp.

Quote:
HOMEWORK AGAIN
Means what.
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: Sun Apr 15, 2007 2:04 am    Post subject:
Reply with quote

Hello,

It would be good if you start over with a more clear definition of your requirement. Do not use F1 and A and such. Use something that represents what is being processed - Order Items, or People, or whatever.

Make sure to have a good sample of the input and exactly what the output should be. Don't put anything extra in and please don't leave anything out. Whatever you post, it must demonstrate the rules you need to implement. It is sometimes tough to guess the rules from data - especially if there is data that doesn't demonstrate the "rules".

This
Quote:
Quote:
HOMEWORK AGAIN
Means what.

is because many students post class problems in the forums and the way this was presented it looks more like a school problem than a business requirement.
Back to top
View user's profile Send private message
mflax

New User


Joined: 01 Sep 2006
Posts: 17
Location: Delhi

PostPosted: Sun Apr 15, 2007 2:43 pm    Post subject: Re: Logic for this file handling
Reply with quote

Hi Dick, I try to make it more sensible. File is having records for Acct Numbers where there can be multiple records for a single Acct #.

Each Acct# is assigned to a name and I have to filter out all records for such Acct# which is assigned to more than one Name.

Exception here are the "0000" which doesnt mean Acct # is assign to a different person.

Thus from the file below, record for Acct# 1111 goes into filtering, others goes into a different file.

Code:
Input
Acct#   Acct Name
1111   John
1111   John
1111   John
1111   Dave
2222   Dick
2222   Dick
3333   Mflax
3333   0000


Please tell me, if it requires more clarity.
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: Sun Apr 15, 2007 3:10 pm    Post subject:
Reply with quote

Hello,

If i understand the requirement, i believe this is a better start, but i still have a question.

How many records of the 1111 Acct# should be in the output file (1, 2. or 4)? What is the maximum number of names a particular Acct might have?

For starters, your input needs to be in sequence by Acct# and Name.

If you write code that will read the Acct#/Name file, you could define an array in working-storage that has enough entries to handle the maximum number of names for one acct.

As each record is read, the Acct# is compared to the previous Acct#. If it the same as the previous, the name would be moved to the next entry in the array. If the Name is 0000, skip the record.

If the Acct# read is not the same as the previous, start at the brginning of the array check if any different names have been moved into the array for this Acct (i.e. more than one). If there is more than one name, start at the beginning of the array again and write the needed info to the "filtering" file - what is needed will depend on the answer to the question at the start of this reply. After each "set" is written to the output file, the array needs to be cleared for the next set.

Be sure to process the last set when end-of-file is reached. There may be a set in the array that needs to be written or if there is only one entry, it would be skipped.

Good luck icon_smile.gif
Back to top
View user's profile Send private message
mflax

New User


Joined: 01 Sep 2006
Posts: 17
Location: Delhi

PostPosted: Sun Apr 15, 2007 9:53 pm    Post subject: Re: Logic for this file handling
Reply with quote

Thank You so much Dick.

The problem I didnt go with array, was not being sure of number of entries for a perticular set of records for an Acct#. I found them a little tough to code anyway.

Wondering, Is there any other way, we can do this icon_question.gif
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3158
Location: Tucson AZ

PostPosted: Sun Apr 15, 2007 10:14 pm    Post subject: Re: Logic for this file handling
Reply with quote

mflax wrote:
The problem I didnt go with array, was not being sure of number of entries for a perticular set of records for an Acct#. I found them a little tough to code anyway.

Wondering, Is there any other way, we can do this icon_question.gif
As for the number of entries, pick a number, make it big and every time you increment you subscript or counter or index, check it against the max value.
They, arrays, are very simple to code and easy to learn. Just picture each element as a cubby hole or file folder with a number on 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: Sun Apr 15, 2007 11:26 pm    Post subject:
Reply with quote

You're welcome icon_smile.gif

Just a thought - if you are going to work with computers for your career (doesn't really matter which platform(s)), arrays are a way of life. Bacically every application uses them in one way or another. Now is an excellent time to get familiar/comfortable with them.

If you begin to design/code, we can offer suggestions when you have questions. I'd suggest putting your thoughts on paper as some kind of diagram or flow-chart - a "picture" often is easier to "see" than words. With your diagram and some sample data (similar to what you posted originally - you will want some Acct#s that should be selected and some that should not), you could "play computer" and make sure your design will create the desired output.

If you have a couple of sets of data that in one case has the first Acct# selected and another that does not and sets of data where the last Acct# is selected and another where it is not, you will be ready to put your design into code and test it. This "play computer" data could also be your initial test data. Once the code tests correstly with your data, it is time to try a run with some of the "real" data.

There are other ways to do this, but they take more work and will most likely use much more machine resources. Besides, someday you will be faced with a situation that must be done with an array (i.e. existing code that must be modified due to a production abend).

If you begin now, you have us to help with the learning icon_smile.gif
Back to top
View user's profile Send private message
mflax

New User


Joined: 01 Sep 2006
Posts: 17
Location: Delhi

PostPosted: Mon Apr 16, 2007 11:25 am    Post subject: Re: Logic for this file handling
Reply with quote

William/Dick, Thanks agian. You are right, need to join the mosters.

Could you give me a simple example of array handling in COBOL, and I'll try my best to explore it in my situation.
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 Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm
No new posts File Aid to File Manager conversion murali3955 IBM Tools 4 Thu Nov 24, 2016 3:41 pm
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm
No new posts CICS Roll back partially - Need to re... dwijadas CICS 4 Wed Nov 16, 2016 4:30 pm
No new posts Problem in writing Output file vickey_dw COBOL Programming 5 Mon Nov 14, 2016 11:14 pm


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