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
 

 

Getting a particular field from one record in every record

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
Joseph Selwin

New User


Joined: 24 Nov 2008
Posts: 6
Location: Chennai

PostPosted: Mon Nov 24, 2008 6:23 pm    Post subject: Getting a particular field from one record in every record
Reply with quote

Input File:
LRECL=15

111BBBBBPCCCCCN
222BBBBBQCCCCCN
333BBBBBPCCCCCY
444BBBBBPCCCCCN
555BBBBBQCCCCCY

1.I Need to group the record based on the 9th byte. i.e either 'P' or 'Q'
2.Then in a particular group i need to check the 15th byte. Only one record in that group will have 'Y' in the 15th byte.
3.I need to append the First 3 bytes of this record to rest of the records in the group

Hence the output File will be of LRECL=18

111BBBBBPCCCCCN333
222BBBBBQCCCCCN555
333BBBBBPCCCCCY333
444BBBBBPCCCCCN333
555BBBBBQCCCCCY555

Thanks in advance
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 Nov 24, 2008 10:13 pm    Post subject:
Reply with quote

Chennai,

There are a number of ways you could do this with DFSORT. Here's one simple way using DFSORT Symbols.

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=...  input file (FB/15)
//SORTOUT DD DSN=&&S1,UNIT=SYSDA,SPACE=(TRK,(1,1)),DISP=(,PASS)
//SYSIN    DD    *
  OPTION COPY,STOPAFT=2
  INCLUDE COND=(9,1,SS,EQ,C'PQ',AND,15,1,CH,EQ,C'Y')
  INREC IFOUTLEN=80,
   IFTHEN=(WHEN=(9,1,CH,EQ,C'P'),
    BUILD=(C'PAPP,''',1,3,C'''')),
   IFTHEN=(WHEN=NONE,
    BUILD=(C'QAPP,''',1,3,C''''))
/*
//S2    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SYMNAMES DD DSN=&&S1,DISP=(OLD,PASS)
//SORTIN DD DSN=...  input file (FB/15)
//SORTOUT DD DSN=...  output file (FB/18)
//SYSIN    DD    *
  OPTION COPY
  INREC IFTHEN=(WHEN=(9,1,CH,EQ,C'P'),OVERLAY=(16:PAPP)),
        IFTHEN=(WHEN=(9,1,CH,EQ,C'Q'),OVERLAY=(16:QAPP))
/*
Back to top
View user's profile Send private message
Joseph Selwin

New User


Joined: 24 Nov 2008
Posts: 6
Location: Chennai

PostPosted: Mon Nov 24, 2008 11:31 pm    Post subject:
Reply with quote

Thanks Frank

I fear if this will work when several groups (number cannot be predicted) are present (not only P and Q)and also the value in the 9th byte cannot be predicted. So i cannot use "WHEN=(9,1,CH,EQ,C'P')".

Is there any other solution for this? icon_confused.gif
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 Nov 24, 2008 11:42 pm    Post subject:
Reply with quote

I based my "solution" on your example. If you need a different solution for different variations, show me a better example or examples illustrating those variations and explain the complete "rules" for what you're trying to do.
Back to top
View user's profile Send private message
Joseph Selwin

New User


Joined: 24 Nov 2008
Posts: 6
Location: Chennai

PostPosted: Tue Nov 25, 2008 8:58 am    Post subject:
Reply with quote

Hi Frank.

Consider the following as input file. Not only P or Q it may have any alphabet which cannot be predicted. Also the number of groups cant be predicted. Hence i could not hard code the values. Only thing i know i should group them based on the 9th byte whatever the value might be. If none of the 15th byte in a group has 'Y' then they should be directed to other file.

111BBBBBPCCCCCN
222BBBBBQCCCCCN
333BBBBBPCCCCCY
444BBBBBPCCCCCN
555BBBBBQCCCCCY
666BBBBBRCCCCCN
777BBBBBSCCCCCN
888BBBBBPCCCCCN
999BBBBBSCCCCCN
000BBBBBRCCCCCY

Hence Output should look like

Output File 1:
111BBBBBPCCCCCN333
222BBBBBQCCCCCN555
333BBBBBPCCCCCY333
444BBBBBPCCCCCN333
555BBBBBQCCCCCY555
666BBBBBRCCCCCN000
888BBBBBPCCCCCN333
000BBBBBRCCCCCY000

Output File 2:
777BBBBBSCCCCCN
999BBBBBSCCCCCN
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: Tue Nov 25, 2008 10:40 pm    Post subject:
Reply with quote

Here's a DFSORT/ICETOOL job that will do what you asked for. It uses DFSORT's new WHEN=GROUP function available with z/OS DFSORT V1R5 PTF UK90013 (July, 2008). If you don't have that PTF installed, ask your System Programmer to install it (it's free).

Code:

//S1   EXEC  PGM=ICETOOL
//TOOLMSG   DD  SYSOUT=*
//DFSMSG    DD  SYSOUT=*
//IN DD DSN=...  input file (FB/15)
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//OUT1 DD DSN=...  output file1 (FB/18)
//OUT2 DD DSN=...  output file2 (FB/15)
//TOOLIN DD *
SORT FROM(IN) TO(T1) USING(CTL1)
SORT FROM(T1) USING(CTL2)
/*
//CTL1CNTL DD *
  INREC OVERLAY=(20:SEQNUM,8,ZD)
  SORT FIELDS=(9,1,CH,A,15,1,CH,D)
  OUTREC IFTHEN=(WHEN=INIT,
      OVERLAY=(28:SEQNUM,8,ZD,RESTART=(9,1))),
    IFTHEN=(WHEN=GROUP,BEGIN=(28,8,ZD,EQ,1),
      PUSH=(16:1,3,19:15,1))
/*
//CTL2CNTL DD *
  SORT FIELDS=(20,8,ZD,A)
  OUTFIL FNAMES=OUT1,INCLUDE=(19,1,CH,EQ,C'Y'),
    BUILD=(1,18)
  OUTFIL FNAMES=OUT2,SAVE,BUILD=(1,15)
/*
Back to top
View user's profile Send private message
Joseph Selwin

New User


Joined: 24 Nov 2008
Posts: 6
Location: Chennai

PostPosted: Wed Nov 26, 2008 8:11 am    Post subject:
Reply with quote

Thanks Frank. I will try this today.
Back to top
View user's profile Send private message
Joseph Selwin

New User


Joined: 24 Nov 2008
Posts: 6
Location: Chennai

PostPosted: Wed Nov 26, 2008 8:45 am    Post subject:
Reply with quote

Hi Frank

we dont have when=group function available. Is there any other method for this?.
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: Wed Nov 26, 2008 9:53 pm    Post subject:
Reply with quote

Here's a DFSORT/ICETOOL job that will do it with SPLICE instead of WHEN=GROUP:

Code:

//S2   EXEC  PGM=ICETOOL
//TOOLMSG   DD  SYSOUT=*
//DFSMSG    DD  SYSOUT=*
//IN DD DSN=...  input file (FB/15)
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//OUT1 DD DSN=...  output file1 (FB/18)
//OUT2 DD DSN=...  output file2 (FB/15)
//TOOLIN DD *
SPLICE FROM(IN) TO(T1) ON(9,1,CH) KEEPBASE KEEPNODUPS -
  WITHALL WITH(1,15) WITH(20,8) USING(CTL1)
SORT FROM(T1) USING(CTL2)
/*
//CTL1CNTL DD *
  INREC OVERLAY=(16:1,3,19:15,1,20:SEQNUM,8,ZD)
  SORT FIELDS=(9,1,CH,A,15,1,CH,D)
/*
//CTL2CNTL DD *
  SORT FIELDS=(20,8,ZD,A)
  OUTFIL FNAMES=OUT1,INCLUDE=(19,1,CH,EQ,C'Y'),
    BUILD=(1,18)
  OUTFIL FNAMES=OUT2,SAVE,BUILD=(1,15)
/*
Back to top
View user's profile Send private message
Joseph Selwin

New User


Joined: 24 Nov 2008
Posts: 6
Location: Chennai

PostPosted: Mon Dec 01, 2008 11:29 pm    Post subject: Thanks
Reply with quote

It worked
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: Tue Dec 02, 2008 12:09 am    Post subject:
Reply with quote

Well, you know I do test these jobs before I post them. icon_cool.gif
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 7 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 SORT VSAM file with each field one by... maxsubrat DFSORT/ICETOOL 6 Tue Mar 14, 2017 1:07 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 outrec field outside range Danielle.Filteau SYNCSORT 10 Sat Mar 04, 2017 2:37 am


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