Portal | IBM Manuals | Downloads | Products | Refer | Info | Programs | JCLs | Forum Rules*| Site Map | Mainframe CD 
IBMMAINFRAMES.com - IBM Mainframe Support Forums Index
 
Register
 
IBMMAINFRAMES.com - IBM Mainframe Support Forums Index FAQ Search Memberlist Usergroups Profile Log in to check your private messages Log in
 
How to eleminate duplicates.
Goto page 1, 2  Next
 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> Mainframe COBOL
Author Message
satish123
Warnings : 1

New User


Joined: 18 Jun 2006
Posts: 6

PostPosted: Fri Aug 22, 2008 11:50 am    Post subject: How to eleminate duplicates.
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
References
Aaru

Senior Member


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

PostPosted: Fri Aug 22, 2008 11:57 am    Post subject: Reply to: How to eleminate duplicates.
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    Post subject: Reply to: How to eleminate duplicates.
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: 1136
Location: Mumbai - India

PostPosted: Fri Aug 22, 2008 12:37 pm    Post subject: Reply to: How to eleminate duplicates.
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    Post subject:
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    Post subject: Reply to: How to eleminate duplicates.
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: 1136
Location: Mumbai - India

PostPosted: Fri Aug 22, 2008 2:34 pm    Post subject: Reply to: How to eleminate duplicates.
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    Post subject: Reply to: How to eleminate duplicates.
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: 1136
Location: Mumbai - India

PostPosted: Fri Aug 22, 2008 4:05 pm    Post subject: Reply to: How to eleminate duplicates.
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

Global Moderator


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

PostPosted: Fri Aug 22, 2008 7:47 pm    Post subject:
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
Sambhaji
Warnings : 1

Active User


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

PostPosted: Mon Aug 25, 2008 12:52 pm    Post subject:
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 D.

Global Moderator


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

PostPosted: Mon Aug 25, 2008 2:51 pm    Post subject:
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
Sambhaji
Warnings : 1

Active User


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

PostPosted: Mon Aug 25, 2008 3:07 pm    Post subject:
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 D.

Global Moderator


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

PostPosted: Mon Aug 25, 2008 3:10 pm    Post subject:
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

Global Moderator


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

PostPosted: Mon Aug 25, 2008 8:13 pm    Post subject:
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
Display posts from previous:   
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> Mainframe COBOL All times are GMT + 6 HoursGoto page 1, 2  Next
Page 1 of 2