extract fixed field, remove trailing blanks and add char

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

Moderators: Frank Yaeger, Moderator Group

Post Reply
pangwong
Member
Posts: 5
Joined: Wed Aug 19, 2009 11:39 pm
Location: tor

extract fixed field, remove trailing blanks and add char

Post by pangwong » Thu Aug 20, 2009 12:03 am

Using ICEMAN, I would like to extract a fixed field from each record of an input file, create a new output file with the trailing blanks removed, and a character '~' suffixed.
This fixed field contains naming information, starts from position 26 for 59 bytes.

Code: Select all

input:
451902xxxxxxxxxx~|00119~|xxxx223 CANADA INC                          |~

desired output:
451902xxxxxxxxxx~|00119~|xxxx223 CANADA INC~|~ 
Thanks,

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 Aug 20, 2009 1:00 am

If I understand correctly what you want, then this DFSORT job should do it:

Code: Select all

//S1    EXEC  PGM=SORT
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=... input file
//SORTOUT DD DSN=...  output file
//SYSIN    DD    *
  OPTION COPY
  INREC IFTHEN=(WHEN=INIT,PARSE=(%01=(ABSPOS=26,ENDBEFR=C'|',       
    FIXLEN=59)),BUILD=(1,25,%01)),                                  
    IFTHEN=(WHEN=INIT,                                              
      OVERLAY=(26:26,59,JFY=(SHIFT=LEFT,TRAIL=C'~|~',LENGTH=62)))   
/*
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

pangwong
Member
Posts: 5
Joined: Wed Aug 19, 2009 11:39 pm
Location: tor

Post by pangwong » Thu Aug 20, 2009 11:47 pm

Thanks Frank,
Your step works but I neglected another requirement, to append the 3rd field to the end of the "justified/squeezed" 2nd field.
I can get it to work by running multiple steps, but unable to with a single step. Any help is greatly appreciated.

Input file records:
fixed field 1: 1 - 25
fixed field 2: 26 - 85 >> contains naming info, ie. company name.
fixed field 3: 86 - 100

Desired output file records:
fixed field 1: 1 - 25
field 2: extracted content from 26 - 85, remove trailing spaces and add trailer
character "~". this field would start from position 26 and end at the
trailer character "~".
field 3: append to the end of field 2.

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

Post by Frank Yaeger » Fri Aug 21, 2009 1:49 am

I can't figure out what exactly your records look like with respect to the | and ~ characters included in the input records and to be included in the output records.

Please show a better example of your input records (more than one) and expected output records with all of the fields included.

Also, tell me the RECFM and LRECL of the input and output files.
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

pangwong
Member
Posts: 5
Joined: Wed Aug 19, 2009 11:39 pm
Location: tor

Post by pangwong » Fri Aug 21, 2009 5:58 pm

Hi Frank, here are 2 input records....
both files are RECFM = FB, LRECL = 100
Thanks

input record 1
field 1 ( column 1-25 )
451902XXXXXXXXXX~|00119~|
field 2 ( column 26 - 85, data is left justified )
6411223 CANADA INC
field 3 ( column 86 - 100 )
|~2009-08-17~~|

input record 2
field 1 ( column 1 )
451902XXXXXXXXXX~|00119~|
field 2 ( column 26 - 85, data is left justified )
WORKFORCE PLANNING INC
field 3
|~2009-08-17~~|

to look like:
451902XXXXXXXXXX~|00119~|6411223 CANADA INC~|~2009-08-17~~|.............
451902XXXXXXXXXX~|00119~|WORKFORCE PLANNING INC~|~2009-08-17~~|....

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

Post by Frank Yaeger » Fri Aug 21, 2009 8:22 pm

Ok, but what do the dots at the end of the output record represent? Are there more fields in the input records that you didn't show, or are they blanks, or what?

Out of curiosity, what are the ~ characters for ... they seem to be used rather inconsistently.
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

pangwong
Member
Posts: 5
Joined: Wed Aug 19, 2009 11:39 pm
Location: tor

Post by pangwong » Fri Aug 21, 2009 9:54 pm

there are no more fields, the dots represent blanks...
the ~ character at the end of each field is a required spec by a UFS application. This output file will need to be converted to UTF-8 format.

Thanks

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

Post by Frank Yaeger » Sat Aug 22, 2009 1:23 am

Here's a DFSORT job that will do what you asked for:

Code: Select all

//S1    EXEC  PGM=SORT
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=...  input file (FB/100)
//SORTOUT DD DSN=...  output file (FB/100)
//SYSIN    DD    *
  OPTION COPY
  INREC IFOUTLEN=100,
   IFTHEN=(WHEN=INIT,BUILD=(1,25,C'"',
     26,60,JFY=(SHIFT=LEFT,TRAIL=C'~"',LENGTH=62),
     86,15)),
   IFTHEN=(WHEN=INIT,OVERLAY=(26:26,78,SQZ=(SHIFT=LEFT,PAIR=QUOTE))),
   IFTHEN=(WHEN=INIT,FINDREP=(IN=C'"',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

pangwong
Member
Posts: 5
Joined: Wed Aug 19, 2009 11:39 pm
Location: tor

Post by pangwong » Sat Aug 22, 2009 10:58 pm

Thank you very much Frank, desired output is achieved with your help. I have been reading your forum with interest, you are always willing to help with utmost courtesy.

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