Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Reformatting a VB record with multiple variable length field

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
marc_holmes

New User


Joined: 11 Jun 2014
Posts: 9
Location: England

PostPosted: Wed Jul 16, 2014 12:30 pm    Post subject: Reformatting a VB record with multiple variable length field
Reply with quote

I've got a VB file generated by a DB2 unload.

The first 5 bytes in each record are fixed. Field1.
Bytes 6 and 7 tell me (in hex) how long the next field is ("x1")
The next "x1" bytes are Field2.
The next two btes tell me how long Field3 is, followed by Field3, etc
And there's then one final fixed length field on the end.

e.g.
AAAAA..BBB..CCCCCCC..DDDDD..EEEEFFFF
(the dots represent field lengths for B, C and D and E, so x'0003', x'0007', x'0005' and x'0004' with FFFF being a fixed four byte field)

There are always the same number of fields (1 fixed + 4 variable + 1 fixed) and I know the maximum lengths of the variables.

I need this file either delimited or reformatted so all fields are fixed length.

Any help much apprciated.
Back to top
View user's profile Send private message

Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7226

PostPosted: Wed Jul 16, 2014 1:11 pm    Post subject: Reply to: Reformatting a VB record with multiple variable le
Reply with quote

OK, so you know the lengths... how big a secret is it?

If nothing is longer than 255 bytes, then you are guaranteed to have an X'00' separating each field (except the last).

If the fields can't be rearranged (last to first - whose idea was that?), then first thing will be JFY with SHIFT=RIGHT to jam the record into a fixed position, then JFY with SHIFT=LEFT to leave the fixed-length field behind.

Then you car PARSE using the X'00' and offsetting the start position of the PARSE by one for fields two, three and four (ADDPOS).

Then put together your PARSE'd fields, and pick up the fixed-length field you left after the end of the record.
Back to top
View user's profile Send private message
PeterHolland

Global Moderator


Joined: 27 Oct 2009
Posts: 2422
Location: Netherlands, Amstelveen

PostPosted: Wed Jul 16, 2014 1:11 pm    Post subject:
Reply with quote

I thought that DB2 unload can reformat (delimit) data during unload.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7226

PostPosted: Wed Jul 16, 2014 1:13 pm    Post subject: Reply to: Reformatting a VB record with multiple variable le
Reply with quote

An even better idea, Peter. If that can be done, it would be the best way.
Back to top
View user's profile Send private message
marc_holmes

New User


Joined: 11 Jun 2014
Posts: 9
Location: England

PostPosted: Wed Jul 16, 2014 1:22 pm    Post subject:
Reply with quote

Unfortunately getting the file done properly is not a goer. It's used by other systems that we can't change and there's no budget for getting a duplicate file created from source... :-(

Bill, the largest of the four can be upto 1500 bytes (x'05DC') so that won't work either.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7226

PostPosted: Wed Jul 16, 2014 1:38 pm    Post subject: Reply to: Reformatting a VB record with multiple variable le
Reply with quote

Is your data itself all "character" data?
Back to top
View user's profile Send private message
marc_holmes

New User


Joined: 11 Jun 2014
Posts: 9
Location: England

PostPosted: Wed Jul 16, 2014 1:50 pm    Post subject:
Reply with quote

It's a mix of alpha and numeric, with some punctuation.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7226

PostPosted: Wed Jul 16, 2014 2:27 pm    Post subject: Reply to: Reformatting a VB record with multiple variable le
Reply with quote

I'll take that as a Yes, then.

Means that X'00' through X'05' can't appear other than in the byte counts, but can appear in either byte of a count.

So, after the JFY stuff, FINDREP to replace the X'00' through X'05' by X'00'. Second FINREP to replace X'0000' by X'00FF' (doesn't matter what the FF part is, as long as it can't appear in character data). This is those where one of the small values happens to appear twice in the same two bytes.

Then proceed as before.
Back to top
View user's profile Send private message
marc_holmes

New User


Joined: 11 Jun 2014
Posts: 9
Location: England

PostPosted: Wed Jul 16, 2014 2:41 pm    Post subject:
Reply with quote

Thanks, I'll give it a go.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm
No new posts How to update a portion of text in a ... Bill Woodger DFSORT/ICETOOL 25 Wed Nov 09, 2016 9:41 pm
No new posts SQZ pipe delimited file with 1 column... Rick Silvers DFSORT/ICETOOL 2 Sun Nov 06, 2016 8:11 pm
No new posts Joinkeys operation when key1 and key2... Susanta DFSORT/ICETOOL 5 Wed Nov 02, 2016 5:35 pm
No new posts How to split the records using the am... vnktrrd DFSORT/ICETOOL 24 Fri Oct 28, 2016 7:33 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us