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
 

 

Length of a character string?

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: Length of a character string?
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    Post subject:
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

Senior Member


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

PostPosted: Thu Jun 07, 2012 5:43 pm    Post subject:
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7231

PostPosted: Thu Jun 07, 2012 6:32 pm    Post subject: Reply to: Length of a character string?
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

Site Director


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

PostPosted: Thu Jun 07, 2012 7:58 pm    Post subject:
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    Post subject: Re: Length of a character string?
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    Post subject:
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    Post subject:
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7231

PostPosted: Mon Jun 11, 2012 2:07 pm    Post subject: Reply to: Length of a character string?
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    Post subject:
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7231

PostPosted: Mon Jun 11, 2012 2:42 pm    Post subject: Reply to: Length of a character string?
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    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 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
This topic is locked: you cannot edit posts or make replies. Checking wether a string starts from ... sundaram.naveen CLIST & REXX 9 Thu Oct 06, 2016 11:56 am
This topic is locked: you cannot edit posts or make replies. DSList (3.4) cannot display Chinese c... jacobdng TSO/ISPF 4 Wed Oct 05, 2016 2:51 pm
No new posts Format to pipe delimited with variabl... pshongal SYNCSORT 6 Wed Sep 14, 2016 2:48 pm


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