hw 2 eliminate dup rec present in ps file using cobol



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

hw 2 eliminate dup rec present in ps file using cobol

Postby avinash-3 » Tue Oct 18, 2011 9:33 am

hi

pls any body tell me how to eliminate duplicates records present in the ps file by using cobol program.
the input ps file format as fallows

X02AAAABBBBB00.11
C03AAAABBBBB00.19
C01AAAABBBBB00.22
D04AAAABBBBB00.33
C05AAAABBBBB00.45
C03AAAABBBBB00.19
Z08AAAABBBBB00.65
C02AAAABBBBB00.12
N07AAAABBBBB00.69
C01AAAABBBBB00.22
N07AAAABBBBB00.69

i am able to sort the file but not able to eliminate du[licates. pls any one can help me.
thanking u
avinash-3
 

Re: hw 2 eliminate dup rec present in ps file using cobol

Postby BillyBoyo » Tue Oct 18, 2011 2:38 pm

Are you saying that a SORT solution would be OK, or does it need to be a Cobol solution?

In SORT, look up "sum" in your manual.

You do need to know which one to keep, whether you need to accumulate data...

In Cobol, keeping first if duplicate and no accumulation

Have a WS field to store your key in. Initial value of HIGH-VALUES.

Having read an input record, test against saved key. If equal, ignore processing so another is read.
When writing, store current key in WS key defined above.

Different outline code is needed depending on the specifics of your requirement.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: hw 2 eliminate dup rec present in ps file using cobol

Postby avinash-3 » Tue Oct 18, 2011 2:43 pm

thank u billy ,,

i need cobol solution. i want to delete duplicates present in the first file and i want to copy remaining things to second ps file. first i sorted the file. can u post me code related to dis one
avinash-3
 

Re: hw 2 eliminate dup rec present in ps file using cobol

Postby BillyBoyo » Tue Oct 18, 2011 2:49 pm

OK, so read the second part of my post and see if there is anything unclear.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: hw 2 eliminate dup rec present in ps file using cobol

Postby avinash-3 » Tue Oct 18, 2011 2:54 pm

understood da logic but nt aware of writing code pls can u help me in writing logic der. i ll post my code here. pls change modifications for eliminating duplicates. pls help me in solving dis qs.
avinash-3
 

Re: hw 2 eliminate dup rec present in ps file using cobol

Postby BillyBoyo » Tue Oct 18, 2011 3:04 pm

How long is he 'key' that you want to match on? Define a PIC X of that length, with VALUE HIGH-VALUES. Ensure you have a definition of the whole key in the record area.

After the read, test if these two keys are equal. If so, ignore the current record and otherwise continue. Where you get to write a record, save that key in the WS defined. Not really much to it. The "tricky" bit would be neatly ignoring-and-reading-next.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: hw 2 eliminate dup rec present in ps file using cobol

Postby avinash-3 » Tue Oct 18, 2011 3:10 pm

input file: X02AAAABBBBB00.11
C03AAAABBBBB00.19
C01AAAABBBBB00.22
D04AAAABBBBB00.33
C05AAAABBBBB00.45
Z08AAAABBBBB00.65
C02AAAABBBBB00.12
N07AAAABBBBB00.69
C01AAAABBBBB00.22
N07AAAABBBBB00.69

cobol pgm:
IDENTIFICATION DIVISION.
PROGRAM-ID. PROG.
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT IN-FILE ASSIGN TO DDIN
ORGANIZATION IS SEQUENTIAL
ACCESS MODE IS SEQUENTIAL.
SELECT OUT-FILE ASSIGN TO DDOUT
ORGANIZATION IS SEQUENTIAL
ACCESS MODE IS SEQUENTIAL.
SELECT WORK-FILE ASSIGN TO DDWORK.
DATA DIVISION.
FILE SECTION.
FD IN-FILE.
01 IN-RECORD.
05 IN-POLICYNUMBER PIC X(03).
05 IN-NAME PIC X(04).
05 IN-INSADDRESS PIC X(05).
05 IN-AMOUNT PIC 9(5)V99 COMP-3.
05 FILLER PIC X(64).
FD OUT-FILE.
01 OUT-RECORD.
05 OUT-POLICYNUMBER PIC X(03).
05 OUT-NAME PIC X(04).
05 OUT-INSADDRESS PIC X(05).
05 OUT-AMOUNT PIC 9(5)V99 COMP-3.
05 FILLER PIC X(64).
SD WORK-FILE.
01 SORT-REC.
05 SORT-POLICYNUMBER PIC X(03).
05 SORT-NAME PIC X(04).
05 SORT-INSADDRESS PIC X(05).
05 SORT-AMOUNT PIC 9(5)V99 COMP-3.
05 FILLER PIC X(64).
WORKING-STORAGE SECTION.
PROCEDURE DIVISION.
MAIN-PARA.
SORT WORK-FILE ON ASCENDING KEY SORT-POLICYNUMBER
USING IN-FILE GIVING OUT-FILE.
STOP RUN.

edit me for da code changes for eliminating duplicates.. plase need it very urgent.. thanks billy in advance
avinash-3
 

Re: hw 2 eliminate dup rec present in ps file using cobol

Postby BillyBoyo » Tue Oct 18, 2011 7:42 pm

Where would I find the time to do that for you?

You need an enormously simple Cobol program which reads a file and writes to a seperate file. Then you need to include the logic outlined.

Have you got a course book? Course notes? Search on the internet for a sample reading/writing program?
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: hw 2 eliminate dup rec present in ps file using cobol

Postby enrico-sorichetti » Tue Oct 18, 2011 8:01 pm

edit me for da code changes for eliminating duplicates.. plase need it very urgent.. thanks billy in advance

what kind of stupid request/requirement/expectation is that ? :evil:

answering is on/based
our time
free of charge
the benevolence factor earned by the TS
interest of the topic
attitude of the TS

in other words if, when, how, we feel appropriate

... the topic is boring,
... Your attitude ( urgency claim ) irritating like sanded toilet paper
... which means benevolence factor close to 0

chances of getting benevolent replies close to 0

if You have time constraint You might want to peruse a different type of consultancy ( FEE )

and finally if You had searched the forums You would have found quite a few hints on how to proceed
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 2994
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 164 times

Re: hw 2 eliminate dup rec present in ps file using cobol

Postby dick scherrer » Tue Oct 18, 2011 10:43 pm

Hello,

pls help me in solving dis qs
First - lose the kiddie-chat-speak. Use real words and sentences.

edit me for da code changes for eliminating duplicates.. plase need it very urgent.. thanks billy in advance
We don't do urgent. And it is pretty much a guarantee that this (class?) exercise is not critical to an organization.

pls change modifications for eliminating duplicates.
This forum intends to help you learn - NOT do your work for you.

If you are stuck, you need to explain where you are stuck. Someone will be able to offere suggestions. . .
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Next

Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post