IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

get length of variable length field


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
guptae

Moderator


Joined: 14 Oct 2005
Posts: 1208
Location: Bangalore,India

PostPosted: Sat Jun 11, 2011 12:00 am
Reply with quote

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
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1788
Location: Bloomington, IL

PostPosted: Sat Jun 11, 2011 12:14 am
Reply with quote

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 icon_question.gif
Back to top
View user's profile Send private message
sqlcode1

Active Member


Joined: 08 Apr 2010
Posts: 577
Location: USA

PostPosted: Sat Jun 11, 2011 12:53 am
Reply with quote

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
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Sat Jun 11, 2011 1:08 am
Reply with quote

And what are you wanting the LRECL and RECFM of the output file to be?
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Sat Jun 11, 2011 1:33 am
Reply with quote

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. . . icon_wink.gif
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Sat Jun 11, 2011 2:37 am
Reply with quote

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
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Sat Jun 11, 2011 4:14 am
Reply with quote

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
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6250
Location: Mumbai, India

PostPosted: Mon Jun 13, 2011 7:21 pm
Reply with quote

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
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Mon Jun 13, 2011 11:10 pm
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Store the data for fixed length COBOL Programming 1
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts PARSE Syntax for not fix length word ... JCL & VSAM 7
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
Search our Forums:

Back to Top