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.
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.04
Upgrade:
WebFOCUS 8.2.07
OS:
Linux
Outputs:
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.