how to insert a delimeter(;) between two words in a file

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

Moderators: Frank Yaeger, Moderator Group

Post Reply
Subha
Member
Posts: 13
Joined: Fri Jun 17, 2011 4:23 pm

how to insert a delimeter(;) between two words in a file

Post by Subha » Fri Jun 17, 2011 4:44 pm

hi,

i want to insert a delimeter (;) between two words in a file. can someone pls help? i am sure Frank Yeager can help. he is genious :)

input:
Pkg Create 159
Checked Out 0
Components Deleted 285
Source Staged 1749
Copybook Staged 379

output should be:
Pkg Create;159
Checked Out;0
Components Deleted;285
Source Staged;1749
Copybook Staged;379

when i tried following the output was like below.

Code: Select all

//SYSIN   DD *                                
  OPTION COPY                                 
  INREC BUILD=(1,80,SQZ=(SHIFT=LEFT,MID=C';'))
/* 


output was:
Pkg;Create;159
Checked;Out;0
Components;Deleted;285
Source;Staged;1749
Copybook;Staged;379

Thanks,
Subha

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 Jun 17, 2011 10:00 pm

Well, I can help, but first you have to do a better job of explaining what your data looks like and what you want to do with it.

Does the data consist of fields in fixed positions (e.g. alpha field is in positions 1,20 and numeric field2 is in positions 25-29)? If so, what is the starting position, length and format of each field?

Or does the data consist of alpha1, blank, alpha2, blank, numeric3? If so what is the maximum length of each field.

Can there be one alpha field followed by a numeric instead of two alpha fields followed by a numeric? You really need to do a better job of showing all of the possibilities for the input records you have to deal with if you want a complete solution.

What do you want the output records to look like exactly (fixed fields? delimited fields?).

It would help if you used the code tags for the data as you did for the control statements.
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

Subha
Member
Posts: 13
Joined: Fri Jun 17, 2011 4:23 pm

Post by Subha » Mon Jun 20, 2011 10:58 am

Hi Frank,
Thanks for trying to help me and for your time.

yes. the data consist of fields in fixed positions. alpha fields in positions 1-21 and numeric field is in positions 23-30.

also, the data consists of alpha1 blank alpha2 blank numeric3. numeric3 is fixed from position 23-30. but alpha1 and alpha2 are not fixed individually, they both have shared the positions from 1-21.

no. there cant be one alpha field follwed by numeric. there should be two alpha fields followed by numeric

in the ouput, delimeter has to be only between the alpha fields and numeric. delimeter should not be between alpha fields.

example data:

input file:

Code: Select all

Pkg Create            159 
Checked Out           0   
Components Deleted    285 
Source Staged         1749
Copybook Staged       379 
JCL Staged            335 
Proc Staged           23  
Parm Staged           94  
Other Stages          102 
Executables Generated 7319
Audit Run             345 

output file:

Code: Select all

Pkg Create;159            
Checked Out;0             
Components Deleted;285    
Source Staged;1749        
Copybook Staged;379       
JCL Staged;335            
Proc Staged;23            
Parm Staged;94            
Other Stages;102          
Executables Generated;7319
Audit Run;345


hope this explains the requirement.

Thanks,
Subha

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 Jun 20, 2011 9:53 pm

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/30)
//SORTOUT DD DSN=...  output file (FB/30)
//SYSIN DD *
  OPTION COPY
  INREC IFOUTLEN=30,
   IFTHEN=(WHEN=INIT,
    BUILD=(1,21,JFY=(SHIFT=LEFT,LEAD=C'"',TRAIL=C'";',LENGTH=24),
      23,8)),
    IFTHEN=(WHEN=INIT,
      BUILD=(1,32,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

Subha
Member
Posts: 13
Joined: Fri Jun 17, 2011 4:23 pm

Post by Subha » Tue Jun 21, 2011 12:35 pm

thank you so much :D
it worked :!: 8)

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