Parse in ICETOOL.

In this Mainframe Forum - You can post your queries on DFSORT, ICETOOL , SyncSort & JCL Utilities

Moderators: Frank Yaeger, Moderator Group

Post Reply
kunnu
Member
Posts: 18
Joined: Sat Jan 08, 2011 12:38 am
Location: Mumbai

Parse in ICETOOL.

Post by kunnu » Mon May 09, 2011 8:56 pm

Hi,

Could you please help me in getting the desired output.

Explanation:
The input is a comma delimited and want the output to be written as replacing comma with * as shown below. Also the field STATUS and its value in all the records and header should be written as %, The EMPNO should be written as the second field in the output whereas the first field will be DEPT. The FIXLENGTH of each field can be taken as 10.

Code: Select all

Input: 

EMPNO,DEPT,DESG,SAL,GENDER,NAME,AGE
00001,001,SP,MONTHLY,MALE,JACK TORO,27 
002,02,AP,YEARLY,FEMALE,BILLIE GILLS,38  
03,003,AP,HALF,MALE,STUART H JACK,23 
0004,04,SP,QUARTELY,MALE,YACK SUNOKI,35 
00005,005,AP,MONTHLY,FEMALE,LARA MIDDLE,26   


Output: 

DEPT*EMPNO*%*SAL*GENDER*NAME*AGE
001*00001*%*MONTHLY*MALE*JACK TORO*27  
02*002*%*YEARLY*FEMALE*BILLIE GIL*38  
003*03*%*HALF*MALE*STUART H J*23  
04*0004*%*QUARTELY*MALE*YACK SUNOK*35  
005*00005*%*MONTHLY*FEMALE*LARA MIDDL*26   
Thanks in advance.
Kunnu.

User avatar
Frank Yaeger
Moderator
Posts: 812
Joined: Sat Feb 18, 2006 5:45 am
Location: San Jose, CA
Contact:

Post by Frank Yaeger » Mon May 09, 2011 10:29 pm

You can use a DFSORT job like the following to do what you asked for. I assumed your input file has RECFM=FB and LRECL=80, but the job can be changed appropriately for other attributes.

Code: Select all

//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
EMPNO,DEPT,DESG,SAL,GENDER,NAME,AGE
00001,001,SP,MONTHLY,MALE,JACK TORO,27
002,02,AP,YEARLY,FEMALE,BILLIE GILLS,38
03,003,AP,HALF,MALE,STUART H JACK,23
0004,04,SP,QUARTELY,MALE,YACK SUNOKI,35
00005,005,AP,MONTHLY,FEMALE,LARA MIDDLE,26
/*
//SORTOUT DD SYSOUT=*
//SYSIN DD *
  OPTION COPY
  INREC IFOUTLEN=80,
    IFTHEN=(WHEN=INIT,FINDREP=(INOUT=(C',',C'*',C' ',X'FF'))),
    IFTHEN=(WHEN=INIT,
     PARSE=(%01=(ENDAT=C'*',FIXLEN=10),
            %02=(ENDAT=C'*',FIXLEN=10),
            %=(ENDAT=C'*'),
            %03=(FIXLEN=80)),
   BUILD=(%02,%01,C'%*',%03)),
  IFTHEN=(WHEN=INIT,BUILD=(1,80,SQZ=(SHIFT=LEFT))),
  IFTHEN=(WHEN=INIT,FINDREP=(IN=X'FF',OUT=C' '))
/*
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort

kunnu
Member
Posts: 18
Joined: Sat Jan 08, 2011 12:38 am
Location: Mumbai

Post by kunnu » Mon May 09, 2011 10:52 pm

Thanks a ton Frank.....If you dont mind could you please explain what the below lines of code is doing

IFTHEN=(WHEN=INIT,FINDREP=(INOUT=(C',',C'*',C' ',X'FF'))), and
IFTHEN=(WHEN=INIT,FINDREP=(IN=X'FF',OUT=C' '))

User avatar
Frank Yaeger
Moderator
Posts: 812
Joined: Sat Feb 18, 2006 5:45 am
Location: San Jose, CA
Contact:

Post by Frank Yaeger » Tue May 10, 2011 1:52 am

Since you have embedded blanks in the NAME field, we need to replace each blank with another character (X'FF') to prevent SQZ from removing the blanks. So the first FINDREP replaces a blank with a X'FF' while also replacing a comma with an asterisk. The second FINDREP, replaces each X'FF' with a blank to get your embedded blanks back.
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort

kunnu
Member
Posts: 18
Joined: Sat Jan 08, 2011 12:38 am
Location: Mumbai

Post by kunnu » Wed May 11, 2011 7:13 pm

Hi Frank,

I have executed the above code but it is not giving the required output also as mentiond above.

for e.g. in the input name field is given as ,BILLIE GILLS, and in the output it should be as *BILLIE GIL* whereas the code which I executed showed as *BILLIE GILLS*. Could you please help with this issue. I have once again added some input below and the expected result.

Please do have a look at the below input and output as for the last record for the name field it writes the output for only 9 bytes as the 10th byte is space.

Input:

EMPNO,DEPT,DESG,SAL,GENDER,NAME,AGE
00001,001,SP,MONTHLY,MALE,JACK TORO,27
002,02,AP,YEARLY,FEMALE,BILLIE GILLS,38
03,003,AP,HALF,MALE,STUART H JACK,23
0004,04,SP,QUARTELY,MALE,YACK SUNOKI,35
00005,005,AP,MONTHLY,FEMALE,LARA MIDDLE,26
00006,006,KA,MONTHLY,FEMALE,DAVIDJONE SAL,27


Output:

DEPT*EMPNO*%*SAL*GENDER*NAME*AGE
001*00001*%*MONTHLY*MALE*JACK TORO*27
02*002*%*YEARLY*FEMALE*BILLIE GIL*38
003*03*%*HALF*MALE*STUART H J*23
04*0004*%*QUARTELY*MALE*YACK SUNOK*35
005*00005*%*MONTHLY*FEMALE*LARA MIDDL*26
006*00006*KA*MONTHLY*FEMALE*DAVIDJONE*27

User avatar
Frank Yaeger
Moderator
Posts: 812
Joined: Sat Feb 18, 2006 5:45 am
Location: San Jose, CA
Contact:

Post by Frank Yaeger » Wed May 11, 2011 9:31 pm

You mean you really want to truncate the names to 10 characters? I assumed you just counted the characters in the name wrong and wanted the full names. If you really want to truncate the names, then you can use this DFSORT job. Note that if an embedded blank is the 10th character (as in your last record), the blank will be kept. I wasn't sure if that's what you wanted or not.

Code: Select all

//S1 EXEC PGM=SORT                                               
//SYSOUT DD SYSOUT=*                                             
//SORTIN DD *                                                    
EMPNO,DEPT,DESG,SAL,GENDER,NAME,AGE                              
00001,001,SP,MONTHLY,MALE,JACK TORO,27                           
002,02,AP,YEARLY,FEMALE,BILLIE GILLS,38                          
03,003,AP,HALF,MALE,STUART H JACK,23                             
0004,04,SP,QUARTELY,MALE,YACK SUNOKI,35                          
00005,005,AP,MONTHLY,FEMALE,LARA MIDDLE,26                       
00006,006,KA,MONTHLY,FEMALE,DAVIDJONE SAL,27                     
//SORTOUT DD SYSOUT=*                                            
//SYSIN DD *                                                     
  OPTION COPY                                                    
  INREC IFOUTLEN=80,                                             
    IFTHEN=(WHEN=INIT,FINDREP=(INOUT=(C' ',X'FF'))),             
    IFTHEN=(WHEN=INIT,                                           
     PARSE=(%01=(ENDBEFR=C',',FIXLEN=10),                        
            %02=(ENDBEFR=C',',FIXLEN=10),                        
            %=(ENDAT=C','),                                      
            %04=(ENDBEFR=C',',FIXLEN=10),                        
            %05=(ENDBEFR=C',',FIXLEN=10),                        
            %06=(ENDBEFR=C',',FIXLEN=10),                        
            %07=(ENDBEFR=C',',FIXLEN=10)),                       
   BUILD=(%02,X,%01,C' % ',%04,X,%05,X,                          
      %06,X,%07)),                                               
  IFTHEN=(WHEN=INIT,BUILD=(1,80,SQZ=(SHIFT=LEFT,MID=C'*'))),     
  IFTHEN=(WHEN=INIT,FINDREP=(IN=X'FF',OUT=C' '))                 
/*
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort

kunnu
Member
Posts: 18
Joined: Sat Jan 08, 2011 12:38 am
Location: Mumbai

Post by kunnu » Wed May 11, 2011 11:18 pm

Thanks once again for your quick reply.

The expected output exactly is my requirement which I have mentioned above.
And yes as mentioned in my last record even, I dont want the blank (as on the 10th character) to be appeared in the output. So the output should be just *DAVIDJONE* i.e blank to be truncated when the 10th byte is a blank.

Thanks in advance.
Kunnu.

kunnu
Member
Posts: 18
Joined: Sat Jan 08, 2011 12:38 am
Location: Mumbai

Post by kunnu » Thu May 12, 2011 1:54 pm

Hi Frank,

Sorry to bother you but can you please help me with this.

User avatar
dbzTHEdinosauer
Moderator
Posts: 981
Joined: Mon Oct 02, 2006 8:31 pm

Post by dbzTHEdinosauer » Thu May 12, 2011 2:44 pm

last line from this:

Code: Select all

IFTHEN=(WHEN=INIT,FINDREP=(IN=X'FF',OUT=C' '))
to this:

Code: Select all

IFTHEN=(WHEN=INIT,FINDREP=(IN=X'FF',OUT=C' ')),
IFTHEN=(WHEN=INIT,FINDREP=(IN=C' *',OUT=C'*'))
Dick Brenholtz
JCL, SQL and code in programs have an irritating habit of doing what you say,
not what you meant.

User avatar
Frank Yaeger
Moderator
Posts: 812
Joined: Sat Feb 18, 2006 5:45 am
Location: San Jose, CA
Contact:

Post by Frank Yaeger » Thu May 12, 2011 11:05 pm

Hi Frank,

Sorry to bother you but can you please help me with this.
I'm on vacation this week, so just saw your note. Dick has already given you the solution.
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort

kunnu
Member
Posts: 18
Joined: Sat Jan 08, 2011 12:38 am
Location: Mumbai

Post by kunnu » Sun May 29, 2011 10:28 pm

Thanks for the solution Frank and Dick.

In the above given input i have a got a small requirement. Please help me on this.
In the input after the age field there are blank hexadecimal values i.e. there should not be F0F0F0F0 just complete blank hexadecimal. I want the same blanks to be copied in the output file as mentioned above. whereas with the solution given by you writes the output file but converts the blank hexadecimals to hexadecimals with the values as F0F0F0F0.

Could you please help by altering the given solution as above to provide me the hexadecimal blanks in the output. You can still refer the same above input and output.

Thanks in advance.
Kunnu.

kunnu
Member
Posts: 18
Joined: Sat Jan 08, 2011 12:38 am
Location: Mumbai

Post by kunnu » Mon May 30, 2011 9:52 pm

Hello,

Please can you help me on the above issue.

Thanks in advance
Kunnu

User avatar
Frank Yaeger
Moderator
Posts: 812
Joined: Sat Feb 18, 2006 5:45 am
Location: San Jose, CA
Contact:

Post by Frank Yaeger » Tue May 31, 2011 10:15 pm

No, I can't help you because I don't know what it is you're doing to get X'F0's. I certainly don't get them when I run my job with YOUR input. I'm assuming by blank hexadecimal you mean X'40'. My job would NOT convert the trailing blanks to trailing character 0s. So either your input is different than you show in your post, or you changed something in the job I gave you.

You'd have to show me your input in hex, the output you got in hex, and the complete JES log for your run for me to help you.
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort

Post Reply

FREE TUTORIALS

Tutorials
Free tutorials from mainframegurukul
  • JCL Tutorial
    Covers all important JCL concepts.
  • Cobol Tutorial
    This tutorials covers all Cobol Topics from STRING to COMP-3.
  • DB2 Tutorial
    DB2 Tutorial focuses on DB2 COBOL Programming.
  • SORT Tutorial
    This Tutorial covers all important aspects of DFSORT with examples
  • CICS Tutorial
    This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming.
Interview
Mainframe Interview questions



Other References
Mainframe Tools and others