Focal Point
SOLVED: READ command is adding the length to the start of my variables

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/1987091206

April 15, 2011, 10:34 AM
bhudson
SOLVED: READ command is adding the length to the start of my variables
I'm trying to display a user-friendly representation of the report criteria in the header of a report that I'm working on. This is an HTML report, and I pass in region, district and territory IDs from the submission form, but I want to display the selected region/district/territory names rather than their IDs. I have a hold file that I -include for the form, that already does the lookups, so I -include that in the report as well, and reference it like so:

TABLE FILE TERR_DATA_HOLD
BY REGION_NAME
BY DISTRICT_NAME
BY TERRITORY_CLIENT_ID
WHERE REGION_ID EQ '&Region';
WHERE DISTRICT_ID EQ '&District';
WHERE TERRITORY_ID EQ '&Territory';
ON TABLE HOLD FORMAT ALPHA AS CRITERIA_NAMES
END
-RUN
-READ CRITERIA_NAMES &RegionCriteriaName.A30. &DistrictCriteriaName.A30. &TerritoryCriteriaName.A20.
-RUN

-SET &RegionCriteriaText = IF &Region EQ _FOC_NULL THEN 'All Regions' ELSE 'Region: ' | &RegionCriteriaName;
-SET &DistrictCriteriaText = IF &District EQ _FOC_NULL THEN 'All Districts' ELSE 'District: ' | &DistrictCriteriaName;
-SET &TerritoryCriteriaText = IF &Territory EQ _FOC_NULL THEN 'All Territories' ELSE 'Territory: ' | &TerritoryCriteriaName;


But when I display &RegionCriteriaName in the report header, it shows up as something like "000007Central". The length of the region name is placed at the start of the variable. I suppose I could just trim off the first 6 characters (since it appears to be consistently using 6 characters for the length), but I would rather understand why it is adding that, and if there is a better way to get the data into a variable.

I'm very new to WebFOCUS and I've learned most of what I know from the forums. Thanks for any help you can provide.

This message has been edited. Last edited by: bhudson,


WebFOCUS 7.7
Windows, All Outputs
April 15, 2011, 10:55 AM
ABT
it is happening because your source is a variable length field and those first 6 or so numerics are the length of the text that it contains. basically, edit() it out.

-ABT


------------------------------------
WF Environment:
------------------------------------
Server/Client, ReportCaster, Dev Studio: 7.6.11
Resource Analyzer, Resource Governor, Library, Maintain, InfoAssist
OS: Windows Server 2003
Application/Web Server: Tomcat 5.5.25
Java: JDK 1.6.0_03
Authentication: LDAP, MRREALM Driver
Output: PDF, EXL2K, HTM

------------------------------------
Databases:
------------------------------------
Oracle 10g
DB2 (AS/400)
MSSQL Server 2005
Access/FoxPro
April 15, 2011, 10:56 AM
ABT
or redefine the source field in the Define to a fixed length field.

- ABT


------------------------------------
WF Environment:
------------------------------------
Server/Client, ReportCaster, Dev Studio: 7.6.11
Resource Analyzer, Resource Governor, Library, Maintain, InfoAssist
OS: Windows Server 2003
Application/Web Server: Tomcat 5.5.25
Java: JDK 1.6.0_03
Authentication: LDAP, MRREALM Driver
Output: PDF, EXL2K, HTM

------------------------------------
Databases:
------------------------------------
Oracle 10g
DB2 (AS/400)
MSSQL Server 2005
Access/FoxPro
April 16, 2011, 02:08 AM
Waz
Or just use the format on the request with a save.
TABLE FILE TERR_DATA_HOLD
SUM REGION_NAME/A30
    DISTRICT_NAME/A30
    TERRITORY_CLIENT_ID/A20
BY REGION_NAME NOPRINT
BY DISTRICT_NAME NOPRINT
BY TERRITORY_CLIENT_ID NOPRINT
WHERE REGION_ID EQ '&Region';
WHERE DISTRICT_ID EQ '&District';
WHERE TERRITORY_ID EQ '&Territory';
ON TABLE SAVE FORMAT
END
-RUN
-READ CRITERIA_NAMES &RegionCriteriaName.A30. &DistrictCriteriaName.A30. &TerritoryCriteriaName.A20.
-RUN



Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!

April 21, 2011, 04:44 PM
bhudson
Thanks all. ABT's solution took care of the issue. However, I think Waz's idea will result in more succinct code in this particular case, so I'll probably update the code to do that instead.


WebFOCUS 7.7
Windows, All Outputs