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

How to eleminate duplicates.


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

New User


Joined: 18 Jun 2006
Posts: 6

PostPosted: Fri Aug 22, 2008 11:50 am
Reply with quote

How can I eliminate duplicate

I have:

Supplier-code Supplier-Issue-Type
B235A Shortage
A123A No PPC
A123A Shortage
A123A Lead Time
C123C Lead Time

I want:
Supplier-code Supplier-Issue-Type
B235A Shortage
A123A Lead Time
C123C Lead Time

Priority will be Lead Time, Shortage, No PPC.

Can any one suggest me the best way to do this??
Back to top
View user's profile Send private message
Aaru

Senior Member


Joined: 03 Jul 2007
Posts: 1287
Location: Chennai, India

PostPosted: Fri Aug 22, 2008 11:57 am
Reply with quote

Sathish,

Explain your requirement clearly with the key positions and all, If you are OK doing this using SORT.
Back to top
View user's profile Send private message
satish123
Warnings : 1

New User


Joined: 18 Jun 2006
Posts: 6

PostPosted: Fri Aug 22, 2008 12:12 pm
Reply with quote

Hi Aaru

Thanks for your reply.

The key field here is Supplier-code, The records have same Supplier-code with different Supplier-Issue-Type which are No PPC, Shortage, and Lead Time. The Supplier-Issue-Types will be first No PPC, for the same Supplier Code then changes to shortage, and lead time. I need to show the Supplier code with Lead time as Supplier-Issue-Type as it was latest status.

Can you tell me how can I do by sort?
Back to top
View user's profile Send private message
Aaru

Senior Member


Joined: 03 Jul 2007
Posts: 1287
Location: Chennai, India

PostPosted: Fri Aug 22, 2008 12:37 pm
Reply with quote

satish,

Quote:
Can you tell me how can I do by sort?


Need few more details. If there are many supplier types for a supplier code then will it be in the same order as mentioned in your post (No PPC, followed by shortage and then lead time)
Back to top
View user's profile Send private message
smriti

New User


Joined: 23 Apr 2007
Posts: 2
Location: hyderabad

PostPosted: Fri Aug 22, 2008 1:17 pm
Reply with quote

Hi Satish,

I guess u can sort on the field (supplier code) and then use
SUM FILEDS = NONE (To eliminate duplicates)
Also, for just retrieving the supplier-issue-type you need to use INCLUDE COND.

Thanks,
Smriti.
Back to top
View user's profile Send private message
satish123
Warnings : 1

New User


Joined: 18 Jun 2006
Posts: 6

PostPosted: Fri Aug 22, 2008 2:24 pm
Reply with quote

Yes If there are many supplier Issue types for a supplier code they will come as order.

These are cobol stored proc, I don't have any jcl for this. Java prog is direcly calling them.
Back to top
View user's profile Send private message
Aaru

Senior Member


Joined: 03 Jul 2007
Posts: 1287
Location: Chennai, India

PostPosted: Fri Aug 22, 2008 2:34 pm
Reply with quote

Sathish,

Quote:
I need to show the Supplier code with Lead time as Supplier-Issue-Type as it was latest status.


Check this JCl.

Code:
//S1    EXEC  PGM=ICETOOL                                               
//TOOLMSG   DD  SYSOUT=*                                               
//DFSMSG   DD  SYSOUT=*                                                 
//IN DD *                                                               
B235A SHORTAGE                                                         
A123A NO PPC                                                           
A123A SHORTAGE                                                         
A123A LEAD TIME                                                         
C123C LEAD TIME                                                         
/*                                                                     
//TEMP1   DD DSN=&&W1RP2,DISP=(MOD,PASS),                               
//      DSORG=PS,RECFM=FB                                               
//OUT DD SYSOUT=*                                                       
//TOOLIN   DD    *                                                     
  COPY FROM(IN) TO(TEMP1) USING(CTL1)                                   
  SELECT FROM(TEMP1) TO(OUT) ON(1,5,CH) FIRST USING(CTL2)               
/*                                                                     
//CTL1CNTL DD *                                                         
  OPTION COPY                                                           
  OUTREC IFTHEN=(WHEN=INIT,OVERLAY=(31:SEQNUM,6,ZD,RESTART=(1,5)))     
/*                                                                     
//CTL2CNTL DD *                                                         
  SORT FIELDS=(1,5,CH,A,31,6,CH,D)                                     
  OUTFIL FNAMES=OUT,BUILD=(1,30)                                       
/*                                                                     


output:

Code:
A123A LEAD TIME 
B235A SHORTAGE   
C123C LEAD TIME 


It displays the supplier-code with the latest suppliertype.
Back to top
View user's profile Send private message
satish123
Warnings : 1

New User


Joined: 18 Jun 2006
Posts: 6

PostPosted: Fri Aug 22, 2008 4:00 pm
Reply with quote

Hi Aaru

Thanks for ur code.


We do not use JCL. All I need to do in only in cobol program.

Thanks
Satish
Back to top
View user's profile Send private message
Aaru

Senior Member


Joined: 03 Jul 2007
Posts: 1287
Location: Chennai, India

PostPosted: Fri Aug 22, 2008 4:05 pm
Reply with quote

Sathish,

Your second post on this topic says

Quote:
Can you tell me how can I do by sort?


and now you are back saying

Quote:
We do not use JCL.


Anyways it's OK.

Quote:
All I need to do in only in cobol program.


Are you going to execute this without using a JCL????
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19243
Location: Inside the Matrix

PostPosted: Fri Aug 22, 2008 7:47 pm
Reply with quote

Hello,

How many rows might this stored procedure need to process?

It should be fairly simple to process what you wan directly in the cobol code.

You need to define the rules for how which duplicate to keep is determined. A more complete set of sample input and output to demonstrate the rules will get better replies as well. For example, why was "A123A Lead Time" kept and the other 2 discarded? What whould happen if those rows were returned in a different order?
Back to top
View user's profile Send private message
Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Mon Aug 25, 2008 12:52 pm
Reply with quote

OK LETS STICK TO COBOL NOW....

I assume for perticular key you want latest desc.
i.e. No PPC desc will be present if ther is unique row
Shortage if two and
Lead Time if three and so on...

input file ifile
B235A Shortage
A123A No PPC
A123A Shortage
A123A Lead Time
C123C Lead Time

Code:

*INREC
01 INREC.
02 VAR1 PIC X(5).
02 VAR2 PIC X(10).
*OUTREC.
01 OUTREC PIC X(15).
.
.
01 VTEMP.
02 TVAR1 PIC X(5).
02 TVAR2 PIC X(10).
.
.
.
.
*PROCEDURE DIVISION
OPEN INPUT INFILE.
OPEN OUTPUT OUTFILE.
READ INFILE AT END MOVE 'Y' TO EOF.
MOVE INREC TO VTEMP.
PERFORM READPARA UNTIL EOF EQ 'Y'.
'
'
'
READPARA.
READ INFILE AT END MOVE 'Y' TO EOF.
IF VAR1 NE TVAR1 THEN
MOVE VTEMP TO OUTREC
WRITE OUTFILE
ELSE
MOVE VAR2 TO TVAR2
END IF.


let us know if some thing else is the requirement....
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


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

PostPosted: Mon Aug 25, 2008 2:51 pm
Reply with quote

Hi,

Is this
Code:
IF VAR1 NE TVAR1 THEN
a COBOL syntax ?
Back to top
View user's profile Send private message
Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Mon Aug 25, 2008 3:07 pm
Reply with quote

Thanks for pointing this, it should be NOT=..
My apologies..
but this happens sometime when you are working multiple programming languages.. icon_sad.gif icon_sad.gif icon_sad.gif
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


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

PostPosted: Mon Aug 25, 2008 3:10 pm
Reply with quote

Hi,
Sambhaji wrote:
Thanks for pointing this, it should be NOT=..
Not to worry, they say - some one is always watching.. icon_wink.gif
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19243
Location: Inside the Matrix

PostPosted: Mon Aug 25, 2008 8:13 pm
Reply with quote

Hello,

Quote:
but this happens sometime when you are working multiple programming languages..
This happens when untested suggestions/solutions are posted. It would be better to test the solution before posting. Many of us work in multiple environments, but when we test a suggestion, we test in the environment related to the topic.

One could always (and some folks do) add a disclaimer that "i didn't test this, but i think it will work". . .
Back to top
View user's profile Send private message
Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Tue Aug 26, 2008 11:05 am
Reply with quote

I will take care in future Dick
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19243
Location: Inside the Matrix

PostPosted: Tue Aug 26, 2008 11:13 am
Reply with quote

Not to worry - and thanks for the follow-up icon_smile.gif

d
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 How to remove block of duplicates DFSORT/ICETOOL 8
This topic is locked: you cannot edit posts or make replies. Compare files with duplicates in one ... DFSORT/ICETOOL 11
No new posts Merging 2 files but ignore duplicate... DFSORT/ICETOOL 1
No new posts COUNT the number of duplicates DFSORT/ICETOOL 3
This topic is locked: you cannot edit posts or make replies. SUM FIELDS=NONE in reverse - Get dupl... DFSORT/ICETOOL 9
Search our Forums:

Back to Top