IBM MAINFRAME HELP & SUPPORT FORUMS
Technical Forums for IBM Mainframe Applications like COBOL, JCL, CICS, DB2, FileAid, DFSORT, Endevor, Xpediter, CoolGen, CA-7&11, AbendAid, IMS, IDMS, PL/I, MqSeries, SyncSort, Assembler, ChangeMan, Easytrieve, InterTest, REXX, CLIST etc...
 

How to eleminate duplicates.

THIS IS AN ARCHIVE FORUM: CLICK HERE TO GO TO THE ORIGINAL TOPIC
Goto page 1, 2  Next
 
       IBMMAINFRAMES.com - IBM Mainframe Support Forums Index -> Mainframe COBOL
View previous topic :: View next topic  
Author Message
satish123



Joined: 18 Jun 2006
Posts: 6

Posted: Fri Aug 22, 2008 11:50 am    Post subject: How to eleminate duplicates.  

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  
Aaru



Joined: 03 Jul 2007
Posts: 1148
Location: Mumbai - India

Posted: Fri Aug 22, 2008 11:57 am    Post subject: Reply to: How to eleminate duplicates.  

Sathish,

Explain your requirement clearly with the key positions and all, If you are OK doing this using SORT.
Back to top  
satish123



Joined: 18 Jun 2006
Posts: 6

Posted: Fri Aug 22, 2008 12:12 pm    Post subject: Reply to: How to eleminate duplicates.  

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  
Aaru



Joined: 03 Jul 2007
Posts: 1148
Location: Mumbai - India

Posted: Fri Aug 22, 2008 12:37 pm    Post subject: Reply to: How to eleminate duplicates.  

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  
smriti



Joined: 23 Apr 2007
Posts: 2
Location: hyderabad

Posted: Fri Aug 22, 2008 1:17 pm    Post subject:  

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  
satish123



Joined: 18 Jun 2006
Posts: 6

Posted: Fri Aug 22, 2008 2:24 pm    Post subject: Reply to: How to eleminate duplicates.  

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  
Aaru



Joined: 03 Jul 2007
Posts: 1148
Location: Mumbai - India

Posted: Fri Aug 22, 2008 2:34 pm    Post subject: Reply to: How to eleminate duplicates.  

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  
satish123



Joined: 18 Jun 2006
Posts: 6

Posted: Fri Aug 22, 2008 4:00 pm    Post subject: Reply to: How to eleminate duplicates.  

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  
Aaru



Joined: 03 Jul 2007
Posts: 1148
Location: Mumbai - India

Posted: Fri Aug 22, 2008 4:05 pm    Post subject: Reply to: How to eleminate duplicates.  

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  
dick scherrer



Joined: 23 Nov 2006
Posts: 8733
Location: 221 B Baker St

Posted: Fri Aug 22, 2008 7:47 pm    Post subject:  

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  
Sambhaji



Joined: 16 Feb 2007
Posts: 267
Location: Pune, India

Posted: Mon Aug 25, 2008 12:52 pm    Post subject:  

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  
Anuj D.



Joined: 22 Apr 2006
Posts: 2229
Location: Phoenix, AZ

Posted: Mon Aug 25, 2008 2:51 pm    Post subject:  

Hi,

Is this
Code: IF VAR1 NE TVAR1 THEN a COBOL syntax ?
Back to top  
Sambhaji



Joined: 16 Feb 2007
Posts: 267
Location: Pune, India

Posted: Mon Aug 25, 2008 3:07 pm    Post subject:  

Thanks for pointing this, it should be NOT=..
My apologies..
but this happens sometime when you are working multiple programming languages.. :( :( :(
Back to top  
Anuj D.



Joined: 22 Apr 2006
Posts: 2229
Location: Phoenix, AZ

Posted: Mon Aug 25, 2008 3:10 pm    Post subject:  

Hi,
Sambhaji wrote: Thanks for pointing this, it should be NOT=.. Not to worry, they say - some one is always watching.. :wink:
Back to top  
dick scherrer



Joined: 23 Nov 2006
Posts: 8733
Location: 221 B Baker St

Posted: Mon Aug 25, 2008 8:13 pm    Post subject:  

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  
 
       IBMMAINFRAMES.com - IBM Mainframe Support Forums Index -> Mainframe COBOL Goto page 1, 2  Next
Page 1 of 2
THIS IS AN ARCIVE FORUM IN READ ONLY MODE. IF YOU WANT TO ASK YOUR DOUBTS USE THE ACTUAL FORUM