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
 

 

How to fetch a complete record

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

Active User


Joined: 06 Sep 2007
Posts: 112
Location: India

PostPosted: Thu Feb 05, 2009 10:56 am    Post subject: How to fetch a complete record
Reply with quote

Hi

I've an input file with user details as follows: The first field is username , 2nd field is primary subjects and 3rd field is secondary subject.

Code:
USER1       COMPUTER     MATHS
                SCIENCE        ECONOMICS
                HISTORY        BIOLOGY

USER2       HINDI           GEOGRAPHY 
                MATHS           HISTORY
                ENG               COMPUTER

USER3       HISTORY        ENG               
                MATHS           HINDI



Now i want the user record details wherever the subject(irrespective of primary or secondary) is ENG.

Hence my o/p should be 2nd and 3rd user details : i.e .

Code:
USER2       HINDI           GEOGRAPHY 
                MATHS           HISTORY
                ENG               COMPUTER

USER3       HISTORY        ENG               
                MATHS           HINDI


Can this be achieved using DFSORT.


Thanks
Ambili
Back to top
View user's profile Send private message

Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Fri Feb 06, 2009 12:39 am    Post subject:
Reply with quote

Ambili S,


The following DFSORT JCL will give you the desired results.

I assumed that your input is FB recfm and 80 byte LRECL
You can use the WHEN=GROUP function of DFSORT available with z/OS DFSORT V1R5 PTF UK90013 (July, 2008) to retain the group of records like this:

Code:

//STEP0100 EXEC PGM=ICETOOL                                         
//TOOLMSG  DD SYSOUT=*                                             
//DFSMSG   DD SYSOUT=*                                             
//IN       DD *                                                     
USER1 COMPUTER MATHS                                               
       SCIENCE ECONOMICS                                           
       HISTORY BIOLOGY                                             
USER2    HINDI GEOGRAPHY                                           
         MATHS HISTORY                                             
           ENG COMPUTER                                             
USER3  HISTORY ENG                                                 
         MATHS HINDI                                               
//T1       DD DSN=&&T1,DISP=(,PASS),SPACE=(CYL,(1,1),RLSE)         
//OUT      DD SYSOUT=*                                             
//TOOLIN   DD *                                                     
  SORT FROM(IN) USING(CTL1)                                         
  SORT FROM(T1) USING(CTL2)                                         
//CTL1CNTL DD *                                                     
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,4,CH,EQ,C'USER'),               
  PUSH=(81:ID=8,SEQ=8)),                                           
  IFTHEN=(WHEN=(1,80,SS,EQ,C'ENG'),OVERLAY=(97:C'Y'))               
  SORT FIELDS=(81,8,CH,A,97,1,CH,D)                                 
  OUTREC IFTHEN=(WHEN=GROUP,BEGIN=(97,1,CH,EQ,C'Y'),PUSH=(97:97,1))
  OUTFIL FNAMES=T1,INCLUDE=(97,1,CH,EQ,C'Y')                       
//CTL2CNTL DD *                                                     
  SORT FIELDS=(81,16,CH,A)                                         
  OUTFIL FNAMES=OUT,BUILD=(1,80)                                   
/*


If you don't have the July, 2008 PTF installed, ask your System Programmer to install it (it's free).

For complete details on the new WHEN=GROUP and the other new functions available with PTF UK90013, see:

www.ibm.com/systems/support/storage/software/sort/mvs/ugpf/
Back to top
View user's profile Send private message
Ambili S

Active User


Joined: 06 Sep 2007
Posts: 112
Location: India

PostPosted: Mon Feb 09, 2009 11:40 am    Post subject:
Reply with quote

Hi

I am getting "STATEMENT DEFINE ERROR" while running the above JCL. I am able to use, ICETOOL and the INREC=WHEN syntax. But with WHEN=GROUP i am getting error.

I tried using FINDREP syntax to replace all 'User' to 'Name' .

//TOOLIN DD *
COPY FROM(IN) USING(CTL1)
//CTL1CNTL DD *
OPTION COPY
INREC FINDREP=(IN=C'USER',OUT=C'NAME'),
OUTFIL FNAMES=OUT,BUILD=(1,80)
/*

I am getting error "INVALID INREC OR OUTREC STATEMENT OPERAND" .
Please let me know if there's anything wrong in the syntaxes for both the cases .

thanks
Back to top
View user's profile Send private message
dick scherrer

Site Director


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

PostPosted: Mon Feb 09, 2009 11:55 am    Post subject:
Reply with quote

Hello,

Please post the complete diagnostic info rather than cut and paste pieces.

When posting messages, it is best to include the message id.
Back to top
View user's profile Send private message
Ambili S

Active User


Joined: 06 Sep 2007
Posts: 112
Location: India

PostPosted: Mon Feb 09, 2009 12:11 pm    Post subject:
Reply with quote

Hi

In the first case where i mentioned about "statement define error" the message id is ICE005A and
here the JCL used is same as given by the moderator.

For the second case where i used FINDREP the syntax error
is ICE007A and the jcl is as follows

//STEP1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN same as mentioned in my first post
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//OUT DD sysout=*
//TOOLIN DD *
COPY FROM(IN) USING(CTL1)
//CTL1CNTL DD *
OPTION COPY
INREC FINDREP=(IN=C'USER',OUT=C'NAME'),
OUTFIL FNAMES=OUT,BUILD=(1,80)
/*


Thanks
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 Feb 09, 2009 10:36 pm    Post subject:
Reply with quote

Code:

   INREC FINDREP=(IN=C'USER',OUT=C'NAME'),
   OUTFIL FNAMES=OUT,BUILD=(1,80)


This is incorrect syntax because of the comma at the end of the INREC statement. This would be correct syntax:

Code:

   INREC FINDREP=(IN=C'USER',OUT=C'NAME')
   OUTFIL FNAMES=OUT,BUILD=(1,80)


However, you won't be able to use FINDREP or WHEN=GROUP if you don't have the July, 2008 PTF installed. Ask your System Programmer to install it.
Back to top
View user's profile Send private message
Ambili S

Active User


Joined: 06 Sep 2007
Posts: 112
Location: India

PostPosted: Tue Feb 10, 2009 8:02 am    Post subject:
Reply with quote

Hi Frank

I was under the assumption that if SPLICE,WHEN=INIT,SELECT with FIRSTDUP etc is working then FINDREP and WHEN=GROUP would also work.

I didn't knew it had to be installed . Thanks for the solution.

Thanks
Ambili
Back to top
View user's profile Send private message
Ambili S

Active User


Joined: 06 Sep 2007
Posts: 112
Location: India

PostPosted: Tue Feb 24, 2009 10:23 am    Post subject:
Reply with quote

Hi Kolusu,

I tried submitting the below JCL(as suggested by you above).

Code:
//STEP0100 EXEC PGM=ICETOOL                                         
//TOOLMSG  DD SYSOUT=*                                             
//DFSMSG   DD SYSOUT=*                                             
//IN       DD *                                                     
USER1 COMPUTER MATHS                                               
       SCIENCE ECONOMICS                                           
       HISTORY BIOLOGY                                             
USER2    HINDI GEOGRAPHY                                           
         MATHS HISTORY                                             
           ENG COMPUTER                                             
USER3  HISTORY ENG                                                 
         MATHS HINDI                                               
//T1       DD DSN=&&T1,DISP=(,PASS),SPACE=(CYL,(1,1),RLSE)         
//OUT      DD SYSOUT=*                                             
//TOOLIN   DD *                                                     
  SORT FROM(IN) USING(CTL1)                                         
  SORT FROM(T1) USING(CTL2)                                         
//CTL1CNTL DD *                                                     
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,4,CH,EQ,C'USER'),               
  PUSH=(81:ID=8,SEQ=8)),                                           
  IFTHEN=(WHEN=(1,80,SS,EQ,C'ENG'),OVERLAY=(97:C'Y'))               
  SORT FIELDS=(81,8,CH,A,97,1,CH,D)                                 
  OUTREC IFTHEN=(WHEN=GROUP,BEGIN=(97,1,CH,EQ,C'Y'),PUSH=(97:97,1))
  OUTFIL FNAMES=T1,INCLUDE=(97,1,CH,EQ,C'Y')                       
//CTL2CNTL DD *                                                     
  SORT FIELDS=(81,16,CH,A)                                         
  OUTFIL FNAMES=OUT,BUILD=(1,80)                                   
/*

This gave me the desired output. But in Substring when i tried with 'BIO' option instead of 'ENG' the output i obtained was same as the input.
I couldn't figure out what went wrong.
Also could you please throw more light on the OUTREC WHEN=GROUP syntax given above.

Thanks
Ambili
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Tue Feb 24, 2009 11:03 pm    Post subject: Reply to: How to fetch a complete record
Reply with quote

Ambili S,

My apologies. There is a slight bug which I did not account for in my initial posting.

Use the following JCL
Code:

//STEP0100 EXEC PGM=ICETOOL                                       
//TOOLMSG  DD SYSOUT=*                                             
//DFSMSG   DD SYSOUT=*                                             
//IN       DD *                                                   
USER1 COMPUTER MATHS                                               
       SCIENCE ECONOMICS                                           
       HISTORY BIOLOGY                                             
USER2    HINDI GEOGRAPHY                                           
         MATHS HISTORY                                             
           ENG COMPUTER                                           
USER3  HISTORY ENG                                                 
         MATHS HINDI                                               
//T1       DD DSN=&&T1,DISP=(,PASS),SPACE=(CYL,(1,1),RLSE)         
//OUT      DD SYSOUT=*                                             
//TOOLIN   DD *                                                   
  SORT FROM(IN) USING(CTL1)                                       
  SORT FROM(T1) USING(CTL2)                                       
//CTL1CNTL DD *                                                   
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,4,CH,EQ,C'USER'),             
  PUSH=(81:ID=8,SEQ=8)),                                           
  IFTHEN=(WHEN=(1,80,SS,EQ,C'BIO'),OVERLAY=(97:C'Y'))             
  SORT FIELDS=(81,8,CH,A,97,1,CH,D)                               
  OUTREC IFTHEN=(WHEN=GROUP,BEGIN=(97,1,CH,EQ,C'Y'),PUSH=(98:81,8))
  OUTFIL FNAMES=T1,INCLUDE=(98,8,CH,EQ,81,8,CH)                   
//CTL2CNTL DD *                                                   
  SORT FIELDS=(81,16,CH,A)                                         
  OUTFIL FNAMES=OUT,BUILD=(1,80)                                   
Back to top
View user's profile Send private message
Ambili S

Active User


Joined: 06 Sep 2007
Posts: 112
Location: India

PostPosted: Wed Feb 25, 2009 9:06 am    Post subject: Reply to: How to fetch a complete record
Reply with quote

Hi Skolusu

Thanks . It worked. icon_smile.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 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 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 To Merge mutliple records into a sing... anandgbe DFSORT/ICETOOL 6 Wed Feb 22, 2017 8:49 am
No new posts How to update a portion of text in a ... Bill Woodger DFSORT/ICETOOL 25 Wed Nov 09, 2016 9:41 pm


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