View previous topic :: View next topic
|
Author |
Message |
guptae
Moderator
Joined: 14 Oct 2005 Posts: 1208 Location: Bangalore,India
|
|
|
|
I have a file which contains a variable length string. I want to calculate the length of that field and put it in first 2 bytes (hex value)
i/p file
xxabcdefghijklmno
o/p
abcdefghijklmno
when you browse it in hex its actually x'000f' in first two bytes |
|
Back to top |
|
|
Akatsukami
Global Moderator
Joined: 03 Oct 2009 Posts: 1788 Location: Bloomington, IL
|
|
|
|
guptae wrote: |
I have a file which contains a variable length string. I want to calculate the length of that field and put it in first 2 bytes (hex value)
i/p file
xxabcdefghijklmno
o/p
abcdefghijklmno
when you browse it in hex its actually x'000f' in first two bytes |
Sounds like you've achieved your ambition |
|
Back to top |
|
|
sqlcode1
Active Member
Joined: 08 Apr 2010 Posts: 577 Location: USA
|
|
|
|
guptae,
Quote: |
I want to calculate the length of that field and put it in first 2 bytes (hex value) |
You are saying you want to put the length in first 2 bytes in output.
Quote: |
i/p file
xxabcdefghijklmno
o/p
abcdefghijklmno |
You sample data and expected output is completely reversed!!! Is that a typo? What is LRECL and RECFM of the input file?
Thanks, |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
And what are you wanting the LRECL and RECFM of the output file to be? |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hi Enrico,
Quote: |
I want to calculate the length of that field and put it in first 2 bytes (hex value) |
Quote: |
o/p
abcdefghijklmno |
I don't see the length in the sample output - hex or otherwise. . .
Another cold one, perhaps. . . |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Ekta,
Please indicate the RECFM and LRECL of the input file and expected output file.
Show an example of the input records and expected output records in hex
(include the RDW if its VB). |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
guptae wrote: |
I have a file which contains a variable length string. I want to calculate the length of that field and put it in first 2 bytes (hex value)
Code: |
i/p file
xxabcdefghijklmno
o/p
abcdefghijklmno |
when you browse it in hex its actually x'000f' in first two bytes |
It seems that if you "code" it, there is something there.
So, input with two bytes waiting to get a length. Text of variable length (how identified, trailing blanks in fixed, length in variable, we don't know).
Output to be two byte binary with length of variable text.
If variable, very easy. xx = (record-lenth-from-RDW (ie start 1, length 2, binary)- 6).
If fixed with trailing blanks, what about embedded blanks? If no, some scan from the front to the first blank. If yes, scan from the length (of the fixed record, I'm sure it must be available) in reverse for first non-blank.
OK, a few dots and crosses remain to be resolved. |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
|
|
Something like this?:
Code: |
//VB EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=... VB FILE,DISP=SHR
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
OUTREC BUILD=(1,4,1,2,BI,C'|',5)
/* |
|
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
The OP has been asked for various important information such as the RECFM and has not replied. I suggest we refrain from speculating/guessing about the solution until he responds. |
|
Back to top |
|
|
|