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

How to fetch a complete record


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
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
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
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:

Use [URL] BBCode for External Links
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
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

Moderator Emeritus


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

PostPosted: Mon Feb 09, 2009 11:55 am
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
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 Developer


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

PostPosted: Mon Feb 09, 2009 10:36 pm
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
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
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
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
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 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