View previous topic :: View next topic
Author
Message
SORTQUERY New User Joined: 14 Jul 2010Posts: 13 Location: United States
Hi,
Following is my requirement -
Input file has Order data - Each Order has different record types starting from record type 100 to record type 2900 e.g.
0100 XXXXXX
0200 YYYYYY
0300 ZZZZZZ
1000 AAAAA
.
.
2900 BBBB
This set will be repeated for each Invoice -
My requirement is to get the records in the following order for only Order type = A, this can be identified in 1000 record. I have a ket on 20,37.
1000
0200
0300
2400
2200
2300
2500
2100
since I am filtering 1000 records for only Type A orders, I need to delete other record types which dosent have corresponding 1000 type record.
I could do this in 2 step.
Step 1 - SYNCTOOL step to create get the records in the required order
and then create a file with only 1000 records.
Code:
//MATCH EXEC PGM=SYNCTOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//INP1 DD DSN=INPUT1,
// DISP=SHR
//MATCH1 DD DSN=TEMP1,
// DISP=(NEW,CATLG,DELETE),
// RECFM=FB,LRECL=1918,
// AVGREC=K,
// SPACE=(1918,(100,40),RLSE)
//MATCH2 DD DSN=TEMP2,
// DISP=(NEW,CATLG,DELETE),
// RECFM=FB,LRECL=1918,
// AVGREC=K,
// SPACE=(1918,(100,40),RLSE)
//*
//TOOLIN DD *
COPY FROM(INP1) TO(MATCH1) USING(CTL1)
SORT FROM(INP1) TO(MATCH2) USING(CTL2)
/*
//CTL1CNTL DD *
INCLUDE COND=(1,4,CH,EQ,C'1000',AND,311,1,CH,EQ,C'A')
OUTREC FIELDS=(1,1918)
/*
//CTL2CNTL DD *
INCLUDE COND=(1,4,CH,EQ,C'0200',OR,
1,4,CH,EQ,C'0300',OR,
1,4,CH,EQ,C'1000',OR,
1,4,CH,EQ,C'2100',OR,
1,4,CH,EQ,C'2200',OR,
1,4,CH,EQ,C'2300',OR,
1,4,CH,EQ,C'2400',OR,
1,4,CH,EQ,C'2500')
INREC IFTHEN=(WHEN=(1,4,CH,EQ,C'1000'),
BUILD=(1:1,1918,1919:C'A')),
IFTHEN=(WHEN=(1,4,CH,EQ,C'0200'),
BUILD=(1:1,1918,1919:C'B')),
BUILD=(1:1,1918,1919:C'B')),
IFTHEN=(WHEN=(1,4,CH,EQ,C'0300'),
BUILD=(1:1,1918,1919:C'C')),
IFTHEN=(WHEN=(1,4,CH,EQ,C'2400'),
BUILD=(1:1,1918,1919:C'D')),
IFTHEN=(WHEN=(1,4,CH,EQ,C'2200'),
BUILD=(1:1,1918,1919:C'E')),
IFTHEN=(WHEN=(1,4,CH,EQ,C'2300'),
BUILD=(1:1,1918,1919:C'F')),
IFTHEN=(WHEN=(1,4,CH,EQ,C'2500'),
BUILD=(1:1,1918,1919:C'G')),
IFTHEN=(WHEN=(1,4,CH,EQ,C'2100'),
BUILD=(1:1,1918,1919:C'H'))
SORT FIELDS=(20,37,CH,A,1919,1,CH,A),EQUALS
OUTREC FIELDS=(1,1918)
/*
Step 2:
Use JOINKEYS between MATCH1 and MATCH2 file to get rid of records which dosent have corresponding 1000 records.
Code:
//SORTCPY1 EXEC PGM=SORT,
// PARM='RC16=ABE'
//SORTMSG DD SYSOUT=*
//SYSIN DD *
JOINKEYS FILE=F1,FIELDS=(20,37,A) SORTED
JOINKEYS FILE=F2,FIELDS=(20,37,A) SORTED
JOIN UNPAIRED,F1
REFORMAT FIELDS=(F1:1,1918,F2:1,1)
SORT FIELDS=COPY
OUTFIL FILES=OUT,INCLUDE=(1919,1,CH,NE,C' '),
OUTREC=(1,1918)
/*
//SORTJNF1 DD DSN=TEMP2,
// DISP=SHR
//SORTJNF2 DD DSN=TEMP2,
// DISP=SHR
//SORTOUT DD DSN=OUTPUT,
// DISP=(,CATLG,DELETE),
// RECFM=FB,LRECL=1918,
.
.
Is there a way to get the second sort step in the first SYNCTOOL step itself or is there any better way to acieve this?
Thanks
Back to top
Arun Raj Moderator Joined: 17 Oct 2006Posts: 2481 Location: @my desk
Quote:
Is there a way to get the second sort step in the first ICETOOL step itself
Yes, you can.
Back to top
SORTQUERY New User Joined: 14 Jul 2010Posts: 13 Location: United States
Can you please let me know how or provide me some reference material for the same...I could'nt get any on teh web.
Thanks
Back to top
Arun Raj Moderator Joined: 17 Oct 2006Posts: 2481 Location: @my desk
Syncsort Manuals are copyrighted material and hence you wont find them in the web. You can request one instead from Syncsort support or send a PM to Alissa Margulies mentioning your CPU details.
Does the Invoice number have the same value for a single 'set' of records?
Is it the invoice number that you're trying to match in your second sort at pos 20,37?
Does the '1000' record always have Order Type='A'?
Can the 'Order Type' field have duplicate values in a single 'set'?
Back to top
SORTQUERY New User Joined: 14 Jul 2010Posts: 13 Location: United States
This data is only related to an Order, not Invoice - Sorry about the typo and confusion.
20,37 is my key - it has the Group number who has placed the order. All the record type will have the same Group Number for one Order.
There are multiple type of Orders, I need to process only Order Type = 'A'.
There will be only 1 '1000' type record for a particular Order.
Thanks
Back to top
Arun Raj Moderator Joined: 17 Oct 2006Posts: 2481 Location: @my desk
Quote:
20,37 is my key - it has the Group number who has placed the order. All the record type will have the same Group Number for one Order
For a set of records having the same 'Group Number', will the Order type be same?
Is it compulsory for a 'Group' to have a '1000' type record?
Back to top
SORTQUERY New User Joined: 14 Jul 2010Posts: 13 Location: United States
yes, Order type will be the same - that is present in 1000- type record.
Each set will always have 1 1000- record type.
Thanks
Back to top
Arun Raj Moderator Joined: 17 Oct 2006Posts: 2481 Location: @my desk
SORTQUERY wrote:
yes, Order type will be the same - that is present in 1000- type record.
Sorry, I got engaged with some tasks and could n't check your post.
May be I am missing something here. If Order Type is the same for all the records in a group, can't it be in any record, a '0100' record or '0200' or any other record type in the group. If that is the case, you can modify your INCLUDE COND to have ONLY order groups having Order Type='A' and do it in a single SORT.
Code:
//SYSIN DD *
INCLUDE COND=((1,4,CH,EQ,C'0200',OR,
1,4,CH,EQ,C'0300',OR,
1,4,CH,EQ,C'1000',OR,
1,4,CH,EQ,C'2100',OR,
1,4,CH,EQ,C'2200',OR,
1,4,CH,EQ,C'2300',OR,
1,4,CH,EQ,C'2400',OR,
1,4,CH,EQ,C'2500'),AND,
311,1,CH,EQ,C'A')
INREC IFTHEN=(WHEN=(1,4,CH,EQ,C'1000'),
BUILD=(1:1,1918,1919:C'A')),
IFTHEN=(WHEN=(1,4,CH,EQ,C'0200'),
BUILD=(1:1,1918,1919:C'B')),
BUILD=(1:1,1918,1919:C'B')),
IFTHEN=(WHEN=(1,4,CH,EQ,C'0300'),
BUILD=(1:1,1918,1919:C'C')),
IFTHEN=(WHEN=(1,4,CH,EQ,C'2400'),
BUILD=(1:1,1918,1919:C'D')),
IFTHEN=(WHEN=(1,4,CH,EQ,C'2200'),
BUILD=(1:1,1918,1919:C'E')),
IFTHEN=(WHEN=(1,4,CH,EQ,C'2300'),
BUILD=(1:1,1918,1919:C'F')),
IFTHEN=(WHEN=(1,4,CH,EQ,C'2500'),
BUILD=(1:1,1918,1919:C'G')),
IFTHEN=(WHEN=(1,4,CH,EQ,C'2100'),
BUILD=(1:1,1918,1919:C'H'))
SORT FIELDS=(20,37,CH,A,1919,1,CH,A),EQUALS
OUTREC FIELDS=(1,1918)
Back to top
Please enable JavaScript!