How to read values in a comma separated VB file



IBM's flagship sort product DFSORT for sorting, merging, copying, data manipulation and reporting. Includes ICETOOL and ICEGENER

How to read values in a comma separated VB file

Postby Eswarbabu » Thu Apr 19, 2012 5:57 pm

Hi,

My requirement is to read a value occuring after 'n' commas (say 'n' as 10) in a Variable Block file.

Eg: 20120312,000044,22,,,,,,,,,,,,,,,,,44,,,

Lets assume that i have to retrieve the value '44'. How to accomplish it using ICETOOL/DFSORT. Request your help.
Eswarbabu
 
Posts: 9
Joined: Tue Dec 27, 2011 12:29 pm
Has thanked: 0 time
Been thanked: 0 time

Re: How to read values in a comma separated VB file

 

Re: How to read values in a comma separated VB file

Postby Frank Yaeger » Thu Apr 19, 2012 10:51 pm

Your description is a bit confusing. You say "after 10 commas" but you show other fields before the 10 commas. Are there always 3 fields before the 10 commas or can there be a different number of fields before the 10 commas? Usually, we would be looking for a specific delimited field, for example, the 10th delimited field. VB records like that might look as follows:

20120312,000044,22,,,,,,,44,,,,,       
1,2,3,4,5,6,7,8,9,10,11               


You could use a DFSORT job like the following to extract the 10th field:

//S1  EXEC  PGM=ICEMAN                                               
//SYSOUT DD SYSOUT=*                                                 
//SORTIN DD DSN=...  input file (VB)                                 
//SORTOUT DD DSN=...  output file (VB)     
//SYSIN    DD *                                                     
  OPTION COPY                                                       
  INREC PARSE=(%=(ENDBEFR=C','),%=(ENDBEFR=C','),%=(ENDBEFR=C','),
    %=(ENDBEFR=C','),%=(ENDBEFR=C','),%=(ENDBEFR=C','),             
    %=(ENDBEFR=C','),%=(ENDBEFR=C','),%=(ENDBEFR=C','),             
    %10=(ENDBEFR=C',',FIXLEN=5)),                                   
    BUILD=(1,4,%10)                                                 


Set FIXLEN to the maximum length for the 10th field (it was 2 in your example, but I assumed it could be up to 5).

If you're not familiar with DFSORT and DFSORT's ICETOOL, I'd suggest reading through "z/OS DFSORT: Getting Started". It's an excellent tutorial, with lots of examples, that will show you how to use DFSORT, DFSORT's ICETOOL and DFSORT Symbols. You can access it online, along with all of the other DFSORT books, from:

http://www.ibm.com/support/docview.wss? ... g3T7000080
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
User avatar
Frank Yaeger
Global moderator
 
Posts: 1080
Joined: Sat Jun 09, 2007 8:44 pm
Has thanked: 0 time
Been thanked: 14 times

Re: How to read values in a comma separated VB file

Postby Eswarbabu » Wed May 09, 2012 10:45 am

Thank you Frank.

I have another query. How to verify the parsed value for a string and include the records that satisfy my condition.

Example: i have to check the retrieved value for the string (say) 'XXXX' (if %01 equates 'XXXX') and only if the check holds fine, i have to include the record in my output.

Input file: VB, LRECL 180
Output file: FB, LRECL 47

I Herewith attach my code to convert vb to fb, as well as to retain the parsed fields i wish in the output.

(attachments deleted)
Eswarbabu
 
Posts: 9
Joined: Tue Dec 27, 2011 12:29 pm
Has thanked: 0 time
Been thanked: 0 time

Re: How to read values in a comma separated VB file

Postby NicC » Wed May 09, 2012 12:16 pm

Please do not post attachments - not everybody can read them and it takes up Frank's and Kolusu's time which could be better spent answering other queries and doing their DFSORT development work. I am going to delete them (the attachments, that is, not Frank and Kolusu).
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 2690
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisys (almost)
Has thanked: 4 times
Been thanked: 105 times

Re: How to read values in a comma separated VB file

Postby skolusu » Wed May 09, 2012 9:13 pm

Eswarbabu wrote:Thank you Frank.

I have another query. How to verify the parsed value for a string and include the records that satisfy my condition.

Example: i have to check the retrieved value for the string (say) 'XXXX' (if %01 equates 'XXXX') and only if the check holds fine, i have to include the record in my output.

Input file: VB, LRECL 180
Output file: FB, LRECL 47

I Herewith attach my code to convert vb to fb, as well as to retain the parsed fields i wish in the output.

(attachments deleted)


Eswarbabu,

Use OUTFIL with INCLUDE/OMIT to write out the desired records. I haven't seen the attachments. So I will go with assuming that you are using Frank's above shown parse controlled cards, the parsed field 10 is at pos 5 for a length of 5 bytes. We check if that value is 'xxxxx' and if it is then we write out and convert the file to FB.

ex:

  OUTFIL INCLUDE=(5,5,CH,EQ,C'XXXXX'),VTOF
Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
skolusu
 
Posts: 586
Joined: Wed Apr 02, 2008 10:38 pm
Has thanked: 0 time
Been thanked: 39 times


Return to DFSORT/ICETOOL/ICEGENER

 


  • Related topics
    Replies
    Views
    Last post