I'm new to web focus so my quesiton might be rather basic. I'm trying to figure out what code/funtion to use to break out a value in a field. I'm hoping that a define statement could be used. The data currently has two pieces of information concatenated together - booking number and passenger number. The booking number portion of the value can change in length, but the passenger number value is alwys the last three charcters In example 9TRS6A01A, the booking number is 9TRS6A and the passenger number is 01A. I know in excel and Access that a function can be used to count the length of the field and then use a left Function statement minus three to get only the booking number value. Does such functions exist in Web Focus or is there any other technique that I should use so I can create a field value that is only the booking number?
ThanksThis message has been edited. Last edited by: Kerry,
Platform: IBM P5
Operating System: AIX
EXCEL, PDF, HTML
You'll have to download the "Using Functions" manual for this. See the doc link in the upper right corner of this page. And yes, you can do this in a DEFINE or a COMPUTE.
You will first use the ARGLEN function to determine how many significant characters, not trailing spaces, are in the field. You can then use this number and some arithmetic to figure out how to use two SUBSTR functions to extract the two fields. For instance, in your example, ARGLEN would return a 9. By subtracting 3, you would know the length of the booking number, etc.
To my fellow posters, don't post the code just yet. Let's see what Cruzer can do with the hints above.
Cruzer, if this doesn't help, post again and we'll give you more clues.
Prod: WF 7.7.01 Dev: WF 7.6.9-11
Admin, MRE,self-service; adapters: Teradata, DB2, Oracle, SQL Server, Essbase, ESRI, FlexEnable, Google
Another, maybe simpler, method would be to do an edit on the right justified field. You can do this in define or compute as a one-liner: something like edit(rjust(field,.,.),'$..$999').
And Ginny is right - look up the Using Functions manual, it descibes it all.
You could also use the reverse() function, grab the first three characters with an edit, and then use reverse on your output to get it back to the correct value.
HP-UX - Reporting Server, Windows 2008 - Client, MSSQL 2008, FOCUS Databases, Flat Files
HTML, Excel, PDF
I find function in Focal Forum like Linus suggest by search "right character". I still no understand why people not use search in Focal Forum. Many other forum use search but Focal Forum have tech support as well.
Each search find me many post, I read and learn. Lots of solution very quick
Client Server 8.1.05: Apache; Tomcat;Windows Server 2012
Reporting Server 8.1.05; Oracle; MS SQL; Windows Server 2012
Also download "Creating Reports with WebFOCUS Language" for your version. On very basic questions like this, you are apt to be told to read the manual.
WF 7.6.8, AIX, AS400, NT
AS400 FOCUS, AIX FOCUS,
Oracle, DB2, JDE, Lotus Notes
They are all good sugestions.
Here's another thought. If the two pieces of information are seperated by a character (space, dash, tilde, etc) look up POSIT to help determine the length of both pieces of information. This way if the length of the passenger number ever changes, you do not have to change your code.
In FOCUS Since 1990
Production 8.2 Windows
to me such a skill would be a pre-requisite for a position here as a WF developer - the ability to take the initiative to look it up yourselves
Developer Studio 7.64
Output: mostly HTML, also Excel and PDF
"Never attribute to malice that which can be adequately explained by stupidity." - Heinlein's Razor
While I do think it's necessary to point out to people that the there is search function for the forum, it's not always that easy when you are completely new.
I know when I first started writing reports in webfocus, I was bewildered by the conflicting choices to getting things done. Coming from a limited language background (RPG), having multiple ways to total columns (SUBTOTAL,SUB-TOTAL(WHAT?), SUBFOOT etc.) was just not getting into my thick skull. I searched, got a hundred posts but was unable to decipher which pertained to my situation.
But with the help of people like Susannah, Ginny, MGrackin, pietro, etc. And yeah, they chastised me for not searching properly, but eventually I was able to move forward and get a grip around how this WF thing works. So sometimes just asking a question and getting a reasonable answer, or just a hint on what to search for, can do more for person and get them to a point where they can be more self-sufficient, faster than just reading forums and manuals.
Michael Kors (USA), Inc.
Windows Server 2005
Windows Server 2008
|Powered by Social Strata|