Variable length field from a file using SORT



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

Variable length field from a file using SORT

Postby subasu » Tue Mar 24, 2009 3:21 pm

I have a requirement where I need to pick up a numeric value from a variable length field from a file. Is this possible using DFSORT? Like in the screenshot, the value 29 could be 329 or 2329 or 899033. There is no limit to the number.

"Loaded 29 rows into the database". This is the only line in the dataset where the count is present.
subasu
 
Posts: 1
Joined: Tue Mar 24, 2009 3:19 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Variable length field from a file using SORT

Postby Frank Yaeger » Tue Mar 24, 2009 9:26 pm

subasu,

You can use a DFSORT job like the following to write a record with the extracted number as 10 digits with leading zeros. I assumed your largest number is 10 digits but you can change that if appropriate.

//S1    EXEC  PGM=SORT                                       
//SYSOUT    DD  SYSOUT=*                                     
//SORTIN DD *                                               
... record                                                   
... record                                                   
Loaded 29123 rows into the database                         
... record                                                   
... record                                                   
//SORTOUT DD DSN=...  output file (FB/80)                                       
//SYSIN    DD    *                                           
  OPTION COPY                                               
  INCLUDE COND=(1,6,CH,EQ,C'Loaded')                         
  INREC PARSE=(%01=(ABSPOS=8,ENDBEFR=C' ',FIXLEN=10)),       
    BUILD=(%01,UFF,M11,LENGTH=10,80:X)                       
/*


For the example give, SORTOUT would have:

0000029123

For an input record of:

Loaded 29 rows into the database

SORTOUT would have:

0000000029

and so on.

You can change this job appropriately for what you want to do.
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: 1079
Joined: Sat Jun 09, 2007 8:44 pm
Has thanked: 0 time
Been thanked: 15 times


Return to DFSORT/ICETOOL/ICEGENER

 


  • Related topics
    Replies
    Views
    Last post