View previous topic :: View next topic
|
Author |
Message |
satish123 Warnings : 1 New User
Joined: 18 Jun 2006 Posts: 6
|
|
|
|
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
Senior Member
Joined: 03 Jul 2007 Posts: 1287 Location: Chennai, India
|
|
|
|
Sathish,
Explain your requirement clearly with the key positions and all, If you are OK doing this using SORT. |
|
Back to top |
|
|
satish123 Warnings : 1 New User
Joined: 18 Jun 2006 Posts: 6
|
|
|
|
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
Senior Member
Joined: 03 Jul 2007 Posts: 1287 Location: Chennai, India
|
|
|
|
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
New User
Joined: 23 Apr 2007 Posts: 2 Location: hyderabad
|
|
|
|
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 Warnings : 1 New User
Joined: 18 Jun 2006 Posts: 6
|
|
|
|
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
Senior Member
Joined: 03 Jul 2007 Posts: 1287 Location: Chennai, India
|
|
|
|
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 Warnings : 1 New User
Joined: 18 Jun 2006 Posts: 6
|
|
|
|
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
Senior Member
Joined: 03 Jul 2007 Posts: 1287 Location: Chennai, India
|
|
|
|
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
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
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 |
|
|
Escapa
Senior Member
Joined: 16 Feb 2007 Posts: 1399 Location: IL, USA
|
|
|
|
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 Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6248 Location: Mumbai, India
|
|
|
|
Hi,
Is this
Code: |
IF VAR1 NE TVAR1 THEN |
a COBOL syntax ? |
|
Back to top |
|
|
Escapa
Senior Member
Joined: 16 Feb 2007 Posts: 1399 Location: IL, USA
|
|
|
|
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 Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6248 Location: Mumbai, India
|
|
|
|
Hi,
Sambhaji wrote: |
Thanks for pointing this, it should be NOT=.. |
Not to worry, they say - some one is always watching.. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
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 |
|
|
Escapa
Senior Member
Joined: 16 Feb 2007 Posts: 1399 Location: IL, USA
|
|
|
|
I will take care in future Dick |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Not to worry - and thanks for the follow-up
d |
|
Back to top |
|
|
|