Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Need to splice the record based on a key

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: Need to splice the record based on a key
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 Moderator


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

PostPosted: Sat Dec 19, 2009 1:03 am    Post subject:
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    Post subject:
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 Moderator


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

PostPosted: Sun Dec 20, 2009 7:05 am    Post subject:
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    Post subject:
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    Post subject:
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 Moderator


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

PostPosted: Mon Dec 21, 2009 10:57 pm    Post subject:
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    Post subject:
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    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Record Not found in AlX but record re... mukun264 COBOL Programming 5 Fri Mar 24, 2017 9:28 am
No new posts Count the length of the record & ... sreekusr DFSORT/ICETOOL 4 Thu Mar 23, 2017 7:52 pm
No new posts JCL to Set Return code based on DB2 S... vinu78 DB2 17 Mon Mar 13, 2017 9:47 pm
No new posts IMS DB-How to update a record (a sing... Nic Clouston IMS DB/DC 9 Thu Mar 09, 2017 4:38 pm
No new posts Inserting records based on conditions vickey_dw DFSORT/ICETOOL 9 Wed Feb 22, 2017 1:33 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us