Page 1 of 2

hw 2 eliminate dup rec present in ps file using cobol

PostPosted: Tue Oct 18, 2011 9:33 am
by avinash-3
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

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

PostPosted: Tue Oct 18, 2011 2:38 pm
by BillyBoyo
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.

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

PostPosted: Tue Oct 18, 2011 2:43 pm
by avinash-3
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

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

PostPosted: Tue Oct 18, 2011 2:49 pm
by BillyBoyo
OK, so read the second part of my post and see if there is anything unclear.

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

PostPosted: Tue Oct 18, 2011 2:54 pm
by avinash-3
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.

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

PostPosted: Tue Oct 18, 2011 3:04 pm
by BillyBoyo
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.

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

PostPosted: Tue Oct 18, 2011 3:10 pm
by avinash-3
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

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

PostPosted: Tue Oct 18, 2011 7:42 pm
by BillyBoyo
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?

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

PostPosted: Tue Oct 18, 2011 8:01 pm
by enrico-sorichetti
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

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

PostPosted: Tue Oct 18, 2011 10:43 pm
by dick scherrer
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. . .