View previous topic :: View next topic
|
Author |
Message |
spradeepece
New User
Joined: 25 Jun 2008 Posts: 19 Location: Chennai
|
|
|
|
Is it possible to find the length of the string in a field (field - defined by columns). If yes I need the length of that string in the same record. End of the string within the specified field is determined by successive space characters.
For example, Input file has some data from column 1 to 9 of variable length.
Code: |
ABCDEFG
HIJKL MN
OP QRS
T UVW |
Output file should have the records with the length following them
Code: |
ABCDEFG 7
HIJKL MN 8
OP QRS 6
T UVW 5 |
|
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
How would this value be used?
If you explain the real goal, there should be less iterations to deal with the additional parts of the requirement. . . |
|
Back to top |
|
|
spradeepece
New User
Joined: 25 Jun 2008 Posts: 19 Location: Chennai
|
|
|
|
Ok.. Here is my real goal..
I have a flat file of record length of 3096 (FB file). I have records with messages of variable lengths, defined in Char format.
I need to load these records to a table, where this field is defined as Varchar. For a varchar, I need to know the length of the record to have it prefixed before the actual message.
The base line here is conversion of a data, from Char to Varchar using sort. |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
You can use OUTFIL with FTOV,VLTRIM=C' ' to convert the records to VB with an RDW (length is in 1,2,BI). Then you can subtract 4 from the 1,2,BI value to get the length of the data up to the first nonblank character.
Can the length be 1-3096? Do you want to display the data (up to 3096 bytes) with the length after it? If you show what you really want for output, I can show you how to do it. |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Here's a job that will do what you asked for in your first post. You can change it appropriately for other situations.
Code: |
//S1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD DSN=... input file (FB)
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//OUT DD DSN=... output file (FB)
//TOOLIN DD *
COPY FROM(IN) USING(CTL1)
COPY FROM(T1) TO(OUT) USING(CTL2)
/*
//CTL1CNTL DD *
OUTFIL FNAMES=T1,FTOV,VLTRIM=C' '
/*
//CTL2CNTL DD *
OUTFIL VTOF,
BUILD=(5,9,X,1,2,BI,SUB,+4,TO=ZD,LENGTH=1)
/*
|
|
|
Back to top |
|
|
spradeepece
New User
Joined: 25 Jun 2008 Posts: 19 Location: Chennai
|
|
|
|
Frank,
It worked.. Thanks a lot.. |
|
Back to top |
|
|
|