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

Length of a character string?


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

Active User


Joined: 20 Dec 2005
Posts: 137
Location: Denmark

PostPosted: Thu Jun 07, 2012 2:56 pm
Reply with quote

Hi,

Is it be possible to find the length of a character string with DFSORT?

I need to load data with the DB2 LOAD utility, and I need this for the purpose of finding the length of a varchar column.

I know it could be done by using the RDW, but I'm looking for a simpler solution. Is there one - or is this feature missing from DFSORT..?

Thanks,
Claes
Back to top
View user's profile Send private message
Claes Norreen

Active User


Joined: 20 Dec 2005
Posts: 137
Location: Denmark

PostPosted: Thu Jun 07, 2012 4:30 pm
Reply with quote

I need to find the length of a character string. I.e.:

XXXXXXXXXX (10)
AAAA (4)
ABCDEFG (7)

By isolating the string in a record that would hold the longest string, I could extract the length from the RDW. However, that's not a very straight forward solution. So I was looking for an easier way to deal with it using DFSORT. But not sure if DFSORT can even do that? If not, I would like it for a future enhancement. icon_cool.gif
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


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

PostPosted: Thu Jun 07, 2012 5:43 pm
Reply with quote

Claes,

Quote:
I know it could be done by using the RDW, but I'm looking for a simpler solution.
If you are dealing with VB files, RDW is important and contains the length. said that,I'm not sure if you've already tried this:
Code:
//SHOWV    EXEC PGM=ICEMAN               
//SYSOUT   DD   SYSOUT=*                 
//SORTIN   DD  DSN=...input 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
Bill Woodger

Moderator Emeritus


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

PostPosted: Thu Jun 07, 2012 6:32 pm
Reply with quote

Is it just one character string? Is you file FB or VB?

Alternatively, just a big bunch of IFTHENs looking for the trailing pad character of your field, size increasing one at a time (start decreasing) and you have the size of your field.
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: Thu Jun 07, 2012 7:58 pm
Reply with quote

Hello Claes Norreen,

Welcome back!

FWIW - Claes Norreen is one of the more senior people who visit here, though it has been a long while since his last visit.

If there is only one variable length field in the file (and the file is vb) the string length might be determined using the rdw.
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Thu Jun 07, 2012 9:44 pm
Reply with quote

Claes Norreen wrote:
Hi,

Is it be possible to find the length of a character string with DFSORT?

I need to load data with the DB2 LOAD utility, and I need this for the purpose of finding the length of a varchar column.

I know it could be done by using the RDW, but I'm looking for a simpler solution. Is there one - or is this feature missing from DFSORT..?

Thanks,
Claes



It depends on how big of a field it is that we are talking. Is it the only field in the file?
Back to top
View user's profile Send private message
Claes Norreen

Active User


Joined: 20 Dec 2005
Posts: 137
Location: Denmark

PostPosted: Mon Jun 11, 2012 1:48 pm
Reply with quote

Hi all,

I've been away a few days, but I'm back now. Thanks for your replies. icon_smile.gif

The field in question has a max. of 250 chars. So, although a bunch of IFTHENs could do it (thanks Bill), thats not really an option.

The fields is just one of many fields. As I say, I know I could isolate the field in a VB dataset, and extract the length of it from the RDW - but I was looking for something more simple.

Kolusu - maybe you can add this to your long list of future enhancements? ;-)
Back to top
View user's profile Send private message
Claes Norreen

Active User


Joined: 20 Dec 2005
Posts: 137
Location: Denmark

PostPosted: Mon Jun 11, 2012 1:49 pm
Reply with quote

dick scherrer wrote:
Hello Claes Norreen,

Welcome back!

FWIW - Claes Norreen is one of the more senior people who visit here, though it has been a long while since his last visit.

If there is only one variable length field in the file (and the file is vb) the string length might be determined using the rdw.


Thanks, Dick! icon_smile.gif
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: Mon Jun 11, 2012 2:07 pm
Reply with quote

If it is just the one field you need the length of, and assuming you have fixed-length records, if you just make the field the last one and FTOV with TRIM then the difference in the record-length compared to the maximum length will tell you.

If this does not suit, don't discount the IFTHENs. No-one wants to type out (or even an "EDIT JOB") 250 IFTHENs, changing each one, but you could generate (from DFSORT or some other software of your choice) the IFTHENs with all the changes in. I think this is the route I'd go.

Test with a few bytes so you have all the code you need. Then look for some examples, if choosing DFSORT, of REPEAT. In a new step, USE REPEAT to generate 250 "model" IFTHENs, use INREC or OUTREC to change each on, use a count of 250 to get the closing bracket on the last.
Back to top
View user's profile Send private message
Claes Norreen

Active User


Joined: 20 Dec 2005
Posts: 137
Location: Denmark

PostPosted: Mon Jun 11, 2012 2:31 pm
Reply with quote

Bill, yes that's possible icon_smile.gif I could just generate the TOOLIN/xxxxCNTL cards using the software we got here, and get it done that way. Thanks for your input and time. icon_smile.gif

Though, I still think it would be a nice addition to our beloved tool. ;-)
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: Mon Jun 11, 2012 2:42 pm
Reply with quote

No problem. Good luck. 250X is 250 spaces, so you don't need huge strings across multiple lines wondering about the continuations...

Edit: Unlike my implication, you don't need to generate for each run, of course :-)

If your file is already variable and field has no embedded blanks (unlikely) you could search the DFSORT forum for HUMPHREY.
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 Replace each space in cobol string wi... COBOL Programming 3
No new posts PARSE Syntax for not fix length word ... JCL & VSAM 7
No new posts Sortjoin and Search for a String and ... DFSORT/ICETOOL 1
Search our Forums:

Back to Top