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

Need a SORT job


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
hariibm

New User


Joined: 05 Feb 2007
Posts: 61
Location: Chennai

PostPosted: Tue Mar 18, 2008 5:41 pm
Reply with quote

Hi,

I need a SORT job for the below requirement.

I have two different types of records in a file.

formats of records as below.

record description of 1st type:

Object x(15) ex: "part "
ID x(6)
A 9(3)
B 9(3)
C 9(3)
Part-No 9(6)
FILLER x(20)


record description of 2nd type:
Object x(15) ex: "part name "

Part-No 9(6)
Part-Name x(20)

My required output should be as below:

Object x(15) ex: "part "

ID x(6)
A 9(3)
B 9(3)
C 9(3)
Part-No 9(6)
Part-Name x(20)
FILLER x(20)


The file can contain other types of record also..
Object field will decide the value in it. in my output the other types of records should be eliminated and only the "Part" objects must be present.

Thanks & Regards,
Hari
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Tue Mar 18, 2008 10:07 pm
Reply with quote

It's not clear what you want to do. What field or fields are you matching on?

Please show an example of your input records with actual values and what you expect for the output records. Explain the "rules" for getting from input to output based on the example. Give the RECFM and LRECL of the input file.
Back to top
View user's profile Send private message
hariibm

New User


Joined: 05 Feb 2007
Posts: 61
Location: Chennai

PostPosted: Tue Mar 18, 2008 10:24 pm
Reply with quote

Hi Yeager,

There can be different types of records in a file.

ex:
Part type record:
Object A B C Part-No FILLER
--------------------------------------------------------------------
PART 100 022 012 123456


Part name type record:

Object Part-No Part-Name
-------------------------------------------------------
Part name 123456 SCREW


and my output should look like below

Object A B C Part-No Part-Name FILLER
--------------------------------------------------------------------
PART 100 022 012 123456 SCREW

so, the matching should be done on Part-no of "part" and "part-name" type records.

My output should only have the "Part" records and all other records(other records have some other value for the object field) must be eliminated.


Thanks,
Hari
Back to top
View user's profile Send private message
hariibm

New User


Joined: 05 Feb 2007
Posts: 61
Location: Chennai

PostPosted: Tue Mar 18, 2008 10:35 pm
Reply with quote

I hope, this time it would be readable.


Object A B C Part-No FILLER
--------------------------------------------------------------------
PART 100 022 012 123456



Object Part-No Part-Name
-------------------------------------------------------
Part Name 123456 screw

Output is like this:

Object A B C Part-No PART-NAME FILLER
--------------------------------------------------------------------
PART 100 22 12 123456 screw
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Tue Mar 18, 2008 10:56 pm
Reply with quote

Again, what is the RECFM and LRECL of the input file?

Can you have more than one record with the same part no in either or both types of records? If so, what would you want to do about that?

Please show a more extensive example of input records and expected output records with all variations (match, no match, dups if possible).

You can use code tags to make it readable.
Back to top
View user's profile Send private message
hariibm

New User


Joined: 05 Feb 2007
Posts: 61
Location: Chennai

PostPosted: Tue Mar 18, 2008 11:13 pm
Reply with quote

Hi,

Record format is fixed. and the LRECL is 800.

PART 100 012 011 123456
PART 100 230 410 111111
PART 099 210 102 222222
AAA 123 123 ABCDE
AAA 099 123 BDECF
BBB 029 AB DEF 123


Part Name 123456 Screw
Part Name 111111 Bolt
Part Name 222222 Mirror

PART 100 012 011 123456 screw
PART 100 230 410 111111 Bolt
PART 099 210 102 222222 Mirror

Part records can have duplicates, in that case part name will be the same for the duplicate part records.

Part name records will not have duplicates.

All the parts appearing in Part records will definitely have the Part name records.

Input file can also have AAA, BBB records. But they must not appear in the output file.

Thanks & Regards,
Hari.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Tue Mar 18, 2008 11:34 pm
Reply with quote

Quote:
Part records can have duplicates, in that case part name will be the same for the duplicate part records.


Sigh. Does that mean you want only one record with the same Part-No for output or all of the records with the same Part-No? Was it too much trouble to include this case in your example as I requested?

For example, if your input file had:

Code:

PART            100  230 410  111111
PART            100  230 410  111111
Part Name      111111 Bolt


would you want one record or two records for output?
Back to top
View user's profile Send private message
hariibm

New User


Joined: 05 Feb 2007
Posts: 61
Location: Chennai

PostPosted: Tue Mar 18, 2008 11:41 pm
Reply with quote

No.

Sorry for the confusion.

PART 100 114 011 123456
PART 001 002 005 123456
PART 999 888 777 123456

In the above case, the output should be like this..


PART 100 114 011 123456 Screw
PART 001 002 005 123456 Screw
PART 999 888 777 123456 Screw

And Part name record will not appear in the output and only the part name from that records is refered to write in to the ouput file.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Wed Mar 19, 2008 12:55 am
Reply with quote

Now I'm even more confused. You said you had two types of records in the input file, PART records and Part name records. I showed those two types in my input file example:

Code:

PART            100  230 410  111111
PART            100  230 410  111111
Part Name      111111 Bolt


and asked if the output would have one record (only one PART record) or two records (both PART records). Your answer was No (?). Then you showed an input file example with ONLY PART records with a different Part-no then I showed and kept all of the duplicate records for the output with the Part-Name from the input record you didn't show.

At this point, I can only guess at what you want. I'm guessing that you might have an input file like this:

Code:

PART            100  012 011  123456
PART            100  230 410  111111
PART            100  230 410  111111
PART            099  210 102  222222
AAA             123  123 ABCDE
AAA             099  123 BDECF
BBB             029  AB  DEF 123
PART            100  114 011  123456
PART            001  002 005  123456
PART            999  888 777  123456
Part Name      123456 Screw
Part Name      111111 Bolt
Part Name      222222 Mirror


and you would want the output file to be this:

Code:

PART            100  230 410  111111 Bolt
PART            100  230 410  111111 Bolt
PART            100  012 011  123456 Screw
PART            100  114 011  123456 Screw
PART            001  002 005  123456 Screw
PART            999  888 777  123456 Screw
PART            099  210 102  222222 Mirror


If so, then you can use a DFSORT/ICETOOL job like the following:

Code:

//S1    EXEC  PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG  DD SYSOUT=*
//IN DD DSN=...  input file (FB/800)
//OUT DD DSN=...  output file (FB/800)
//TOOLIN DD *
SPLICE FROM(IN) TO(OUT) ON(31,6,ZD) -
 WITHALL WITH(1,30) USING(CTL1)
/*
//CTL1CNTL DD *
  INCLUDE COND=(1,15,CH,EQ,C'PART',OR,1,15,CH,EQ,C'Part Name')
  INREC IFTHEN=(WHEN=(1,15,CH,EQ,C'Part Name'),
    BUILD=(31:16,6,37:22,20,801:C'0')),
   IFTHEN=(WHEN=NONE,OVERLAY=(801:C'1'))
  SORT FIELDS=(31,6,ZD,A,801,1,CH,A)
  OUTFIL FNAMES=OUT,BUILD=(1,800)
/*
Back to top
View user's profile Send private message
hariibm

New User


Joined: 05 Feb 2007
Posts: 61
Location: Chennai

PostPosted: Wed Mar 19, 2008 1:05 am
Reply with quote

Thanks yeager.
I wanted this exactly.


Thanks,
Hari
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Wed Mar 19, 2008 2:30 am
Reply with quote

Good. icon_biggrin.gif
Back to top
View user's profile Send private message
hariibm

New User


Joined: 05 Feb 2007
Posts: 61
Location: Chennai

PostPosted: Wed Mar 19, 2008 6:00 pm
Reply with quote

Hi Yeager,

The requirement is changed now and the files are VB.

Please give the sort JCL for the same requirement.

And also please explain the below statements if possible as I did not understand.

ON(31,6,ZD)
WITH(1,30)
BUILD=(31:16,6,37:22,20,801:C'0')
Back to top
View user's profile Send private message
sclater

New User


Joined: 22 Jun 2007
Posts: 14
Location: South Africa

PostPosted: Wed Mar 19, 2008 6:17 pm
Reply with quote

Hi hariibm,

To quote Frank
"All of the DFSORT/ICETOOL documentation is available online from:

Use [URL] BBCode for External Links

If you're not familiar with DFSORT and DFSORT's ICETOOL, I'd suggest reading through "z/OS DFSORT: Getting Started". It's an excellent tutorial, with lots of examples, that will show you how to use DFSORT, DFSORT's ICETOOL and DFSORT Symbols. "
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Wed Mar 19, 2008 9:38 pm
Reply with quote

Here's a DFSORT/ICETOOL job for VB files:

Code:

//S1    EXEC  PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG  DD SYSOUT=*
//IN DD DSN=...  input file (VB)
//OUT DD DSN=...  output file (VB)
//TOOLIN DD *
SPLICE FROM(IN) TO(OUT) ON(36,6,ZD) -
 WITHALL WITH(6,30) USING(CTL1)
/*
//CTL1CNTL DD *
  OPTION VLSCMP
  INCLUDE COND=(5,15,CH,EQ,C'PART',OR,5,15,CH,EQ,C'Part Name')
  INREC IFTHEN=(WHEN=(5,15,CH,EQ,C'Part Name'),
    BUILD=(1,4,5:C'0',36:20,6,42:26,20)),
   IFTHEN=(WHEN=NONE,BUILD=(1,4,5:C'1',6:5))
  SORT FIELDS=(36,6,ZD,A,5,1,CH,A)
  OUTFIL FNAMES=OUT,BUILD=(1,4,5:6)
/*


For completed details on DFSORT's SPLICE operator, see:

publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/ICE1CA20/6.13?DT=20060615185603
Back to top
View user's profile Send private message
hariibm

New User


Joined: 05 Feb 2007
Posts: 61
Location: Chennai

PostPosted: Thu Mar 20, 2008 12:50 am
Reply with quote

Hi Frank,

I am confused with the lengths in my example given. Below is the actual requirement.
Please provide JCL for this requirement. The input records are as below.

Code:
----+----1----+----2----+----3----+----4----+----5----+----6----+
--------  PART           01232K01121{03051AZZZZ-------------     
--------  PART           01232B01421A09011AXXXX-------------     
--------  PART           01122{08015{01021AMMMM-------------     
++++++++  NAME    ZZZZHARI            4                         
++++++++  NAME    XXXXRAMU            2                         



The LRECL is 800 and RECFM is VB.

And the output should be like this..

Code:
----+----1----+----2----+----3----+----4----+----5----+----6----+---
--------  PART           01232K01121{03051AZZZZ-------------HARI   
--------  PART           01232B01421A09011AXXXX-------------RAMU   
--------  PART           01122{08015{01021AMMMM-------------       



The record types can be either 'PART' or 'NAME'
So, the matching should be done between the records for the part number.

Part number for PART records starts at position 44 and at position 19 for the NAME records.
The part number length is 4.

Whenever there is a matching found for the Part number exists in PART records and NAME records, then the name of the part should appear at the end of the PART records. And if the no match found, the part name will be space.

PART records length is 60 and NAME records length is 40(not LRECLs).
My output should only contain the PART records.

And at the end, the result file should be sorted on the field starting from position 26 to 31(the picture clause for it is: S9(4)V9(2).

Thanks in Advance.

Hari.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Thu Mar 20, 2008 1:19 am
Reply with quote

Have you even tried to work this out for yourself based on the previous example?

You've changed the requirement 3 times already. How many more changes will there be? Come back tomorrow morning and assure me there will be no more changes in the requirement and I'll give you one final solution.
Back to top
View user's profile Send private message
hariibm

New User


Joined: 05 Feb 2007
Posts: 61
Location: Chennai

PostPosted: Thu Mar 20, 2008 1:42 am
Reply with quote

Hi Frank,

There is no change in the requirement. I assure you that this is the final one.
Please give me the JCL.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Thu Mar 20, 2008 2:37 am
Reply with quote

Here's the DFSORT/ICETOOL job:

Code:

//S1    EXEC  PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG  DD SYSOUT=*
//IN DD DSN=... input file
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//OUT DD DSN=...  output file
//TOOLIN DD *
SPLICE FROM(IN) TO(T1) ON(49,4,CH) KEEPNODUPS KEEPBASE -
 WITHALL WITH(6,60) USING(CTL1)
SORT FROM(T1) TO(OUT) USING(CTL2)
/*
//CTL1CNTL DD *
  OPTION VLSCMP
  INCLUDE COND=(15,4,SS,EQ,C'PART,NAME')
  INREC IFTHEN=(WHEN=(15,4,CH,EQ,C'NAME'),
    BUILD=(1,4,5:C'0',49:23,4,66:27,16)),
   IFTHEN=(WHEN=NONE,BUILD=(1,4,5:C'1',6:5))
  SORT FIELDS=(49,4,ZD,A,5,1,CH,A)
  OUTFIL FNAMES=T1,OMIT=(16,4,CH,NE,C'PART'),
     BUILD=(1,4,5:6)
/*
//CTL2CNTL DD *
  SORT FIELDS=(30,6,ZD,A)
/*
Back to top
View user's profile Send private message
hariibm

New User


Joined: 05 Feb 2007
Posts: 61
Location: Chennai

PostPosted: Wed Mar 26, 2008 8:58 pm
Reply with quote

Hi Frank,

Thanks for the JCL above.

Please tell me which option of the SPLICE allows the duplicates from the OVERLAY record?
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Wed Mar 26, 2008 9:10 pm
Reply with quote

Quote:
Please tell me which option of the SPLICE allows the duplicates from the OVERLAY record?


WITHALL tells ICETOOL to splice the base record with each overlay record if that's what you mean.
Back to top
View user's profile Send private message
hariibm

New User


Joined: 05 Feb 2007
Posts: 61
Location: Chennai

PostPosted: Thu Mar 27, 2008 10:58 am
Reply with quote

I have used DFSORT SPLICE for one of my requirements.
I am getting the results as below.


If there is no base record for a particular key, I am getting only one overlay record spliced(others are eliminated from the output).

If there are more than one base records for a particular key, I am getting only one overlay record spliced and also one base record.

I need the results as below:

If there is no base record for a particular key, I should get all the overlay records in the output and spaces for the positions where the base record should have values in the output.

If there are more than one base records for a given key, I should get all the overlay records in the output. And for the Base record positions in the output file, i should get the values from the first base record(since there are more than one base records for a given key). And I should not get any base record

Please let me know with which options I can handle this.

Note: I am just using the KEEPNODUPS option with my SPLICE operand(except WITHALL and WITH)
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Thu Mar 27, 2008 7:29 pm
Reply with quote

Hello,

Please post some example input and output data that demonstrate your situation as well as the jcl and control statements for this process.
Back to top
View user's profile Send private message
hariibm

New User


Joined: 05 Feb 2007
Posts: 61
Location: Chennai

PostPosted: Thu Mar 27, 2008 9:49 pm
Reply with quote

As in my first example,

If I have a data like this.. in the input file,

Code:
----+----1----+----2----+----3----+----4----+----5----+----6----+
--------  PART           01232K01121{03051AZZZZ-------------     
--------  PART           01232B01421A09011AXXXX-------------     
--------  PART           01122{08015{01021AMMMM-------------     
--------  PART           01122{08015{01021AMMMM-------------     
++++++++  NAME    ZZZZHARI            4                         
++++++++  NAME    XXXXRAMU            2                 



The output I am getting is like below..

Code:
----+----1----+----2----+----3----+----4----+----5----+----6----+---
--------  PART           01232K01121{03051AZZZZ-------------HARI   
--------  PART           01232B01421A09011AXXXX-------------RAMU   
--------  PART           01122{08015{01021AMMMM-------------       


The part number MMMM is appearing twice in the input file.. For this part there is no 'NAME' record.
So, I am getting only one record in the output for the part MMMM.


I am using this below SPLICE command.

SPLICE FROM(IN) TO(OUT) ON(48,4,CH) WITHALL KEEPNODUPS -
WITH(5,60)

I am using the 'NAME' record as the base and 'PART as the overlay records.

Please let me know how what changes can be done in SPLICE to get all the records of PART(overlay) if there is no part 'NAME'(base record) reocrd exists for a given key.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Thu Mar 27, 2008 10:11 pm
Reply with quote

If you go back to the example I showed, you'll see I have the KEEPBASE operand for the SPLICE operator. It's missing from your SPLICE operator.
You need KEEPBASE to keep the first duplicate without a match.

If adding KEEPBASE doesn't give you what you want, then show me your complete ICETOOL job.
Back to top
View user's profile Send private message
hariibm

New User


Joined: 05 Feb 2007
Posts: 61
Location: Chennai

PostPosted: Tue Apr 01, 2008 8:35 pm
Reply with quote

Hi Frank,
Atlast my problem got resolved.
Thanks a lot for the solution.

I have a question about the base and overlay records.

As I understood, the base records are assumed as NAME records and overlay records as PART records.

My question is how does the SPLICE command consider the base records as NAME and overlay records as PART records.
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 -> DFSORT/ICETOOL Goto page 1, 2  Next

 


Similar Topics
Topic Forum Replies
No new posts Need to set RC4 through JCL SORT DFSORT/ICETOOL 5
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts JCL sort card - get first day and las... JCL & VSAM 9
No new posts Sort First/last record of a subset th... DFSORT/ICETOOL 7
No new posts how to calculate SUM value for VB fil... DFSORT/ICETOOL 1
Search our Forums:

Back to Top