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

Need to splice the record based on a key


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

New User


Joined: 11 Dec 2007
Posts: 82
Location: hyderabad

PostPosted: Fri Dec 18, 2009 11:54 pm
Reply with quote

Hi All,

Can you please provide me a sort solution for this

i need to splice the record based on a key, record format is VB and LRECL is 3000

input file, key preset at 12th position (including RDW actual position is 8th)
Code:

....1234.................................................................XXXXXXXXXXXX
....1235.................................YYYYYYYYYY...................................
....1234.................................................................AAAAAAAAAAAA
....1235.................................zzzzzzzzzz.....................................
....1234.................................................................CCCCCCCCCCCC
....1235.................................MMMMMMMMMM................................
....1234.................................................................BBBBBBBBBBBB


if key is 1234 i need to extract the values at byte 200 to 211 (12 bytes)
if key is 1235 i need to extract the values at byte 150 to 159 (10 bytes)

my output should be written to a 80 FB file like this

Code:

1234  AAAAAAAAAAAA
1234  BBBBBBBBBBBB
1234  CCCCCCCCCCCC
1234  XXXXXXXXXXXX
1235  MMMMMMMMMM
1235  YYYYYYYYYY
1235  ZZZZZZZZZZ
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: Sat Dec 19, 2009 1:03 am
Reply with quote

You don't need SPLICE for this.

Here's a DFSORT job that will do what you asked for:

Code:

//S1    EXEC  PGM=SORT
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=..  input file (VB)
//SORTOUT DD DSN=...  output file (FB/80)
//SYSIN    DD    *
  INREC IFTHEN=(WHEN=(12,4,CH,EQ,C'1234'),
    BUILD=(1,4,12,4,2X,200,12)),
   IFTHEN=(WHEN=(12,4,CH,EQ,C'1235'),
    BUILD=(1,4,12,4,2X,150,10,2X))
  SORT FIELDS=(5,4,CH,A,11,12,CH,A)
  OUTFIL VTOF,BUILD=(5,18,80:X)
/*
Back to top
View user's profile Send private message
Mazahar

New User


Joined: 11 Dec 2007
Posts: 82
Location: hyderabad

PostPosted: Sat Dec 19, 2009 9:24 am
Reply with quote

Thanks Frank,

Along with this can we get counts also with the sort? for example....same problem i explined above....need counts also......
Code:

....1234.................................................................XXXXXXXXXXXX
....1235.................................YYYYYYYYYY...................................
....1234.................................................................XXXXXXXXXXXX
....1234.................................................................AAAAAAAAAAAA
....1234.................................................................XXXXXXXXXXXX
....1235.................................zzzzzzzzzz.....................................
....1235.................................YYYYYYYYYY...................................
....1234.................................................................CCCCCCCCCCCC
....1235.................................YYYYYYYYYY...................................
....1235.................................MMMMMMMMMM................................
....1234.................................................................BBBBBBBBBBBB
....1235.................................MMMMMMMMMM................................


if you see above file we have couple of values at places with dupicates...i need output something like

Code:

1234  AAAAAAAAAAAA               1
1234  BBBBBBBBBBBB               1
1234  CCCCCCCCCCCC               1
1234  XXXXXXXXXXXX               3 
1235  MMMMMMMMMM                 2   
1235  YYYYYYYYYY                 3
1235  ZZZZZZZZZZ                 1
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: Sun Dec 20, 2009 7:05 am
Reply with quote

Here's a DFSORT job for your new requirement:

Code:

//S1    EXEC  PGM=SORT
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=..  input file (VB)
//SORTOUT DD DSN=...  output file (FB/80)
//SYSIN    DD    *
  INREC IFTHEN=(WHEN=(12,4,CH,EQ,C'1234'),
    BUILD=(1,4,12,4,200,12)),
   IFTHEN=(WHEN=(12,4,CH,EQ,C'1235'),
    BUILD=(1,4,12,4,150,10,2X))
  SORT FIELDS=(5,12,CH,A)
  OUTFIL VTOF,REMOVECC,NODETAIL,
    BUILD=(80:X),
    SECTIONS=(5,12,
      TRAILER3=(12,4,2X,9,12,21:COUNT=(M10,LENGTH=14)))
/*
Back to top
View user's profile Send private message
Mazahar

New User


Joined: 11 Dec 2007
Posts: 82
Location: hyderabad

PostPosted: Sun Dec 20, 2009 4:17 pm
Reply with quote

Frank,

Code:
SYSIN    DD    *
  INREC IFTHEN=(WHEN=(12,4,CH,EQ,C'1234'),
    BUILD=(1,4,12,4,200,12)),
   IFTHEN=(WHEN=(12,4,CH,EQ,C'1235'),
    BUILD=(1,4,12,4,150,10,2X))
  SORT FIELDS=(5,12,CH,A)
  OUTFIL VTOF,REMOVECC,NODETAIL,
    BUILD=(80:X),
    SECTIONS=(5,12,
      TRAILER3=(12,4,2X,9,12,21:COUNT=(M10,LENGTH=14)))


everything is fine, but can u please explain me why we are sorting on (5.12.ch.a) ?? when my requirement is if key is 1234(at 12th position) i need to extract the values at byte 200 to 211 (12 bytes) and if key is 1235(at 12th postion) i need to extract the values at byte 150 to 159 (10 bytes). i hope sort should be (5,16,ch,a).....please correct me if i am wrong.

as well can please explain below statments also in details...
SECTIONS=(5,12,
TRAILER3=(12,4,2X,9,12,21:COUNT=(M10,LENGTH=14))) [/code]

One more thing, what this code will do to a file which is having other records with different key like 1111 or 2222 in input file, but we are notmentioning them in IF condition..

Thanks a lot for all your help
Back to top
View user's profile Send private message
Mazahar

New User


Joined: 11 Dec 2007
Posts: 82
Location: hyderabad

PostPosted: Sun Dec 20, 2009 5:29 pm
Reply with quote

Frank,

never mind.....I understood why you gave... (5.12.ch.a)

but can you please explain me the below statement

Code:
SECTIONS=(5,12,
      TRAILER3=(12,4,2X,9,12,21:COUNT=(M10,LENGTH=14)))
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: Mon Dec 21, 2009 10:57 pm
Reply with quote

Actually, it should be 5,16 - just a typo.

The OUTFIL statement uses NODETAIL to tell DFSORT not to write the data records. SECTIONS tells DFSORT where the key is so it can determine the sections. TRAILER3 writes a record for each key with the indicated fields and the COUNT of records in that section.
Back to top
View user's profile Send private message
Mazahar

New User


Joined: 11 Dec 2007
Posts: 82
Location: hyderabad

PostPosted: Tue Dec 22, 2009 6:57 pm
Reply with quote

Frank, As always and usual....IT WORKED. Thanks a lot.
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

 


Similar Topics
Topic Forum Replies
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts FINDREP - Only first record from give... DFSORT/ICETOOL 3
No new posts To find whether record count are true... DFSORT/ICETOOL 6
No new posts Validating record count of a file is ... DFSORT/ICETOOL 13
Search our Forums:

Back to Top