The following code outputs a work file that is not the same as when I send it to HTML. When run to the screen, the COMPUTE column shows 4-35 for the 1st record as desired. When run to a file, the original field value is pre-pended to the 4-35 resulting in 34354-35.
Would someone mind testing my code to see if my code is wrong... ...or if I have a 7.6.7 problem...
APP PREPENDPATH IBISAMP APP FI DNL012H01 DISK BASEAPP/DNL012H01 TABLE FILE CAR PRINT COMPUTE R1B01/A8 = EDIT(WEIGHT,'$$$9-99'); AS 'TEST' COUNTRY CAR MODEL BODYTYPE SEATS DEALER_COST RETAIL_COST SALES LENGTH WIDTH HEIGHT WEIGHT WHEELBASE FUEL_CAP BHP RPM MPG ACCEL
ON TABLE NOTOTAL ON TABLE HOLD AS DNL012H01 FORMAT ALPHA END
File Output...
34354-35 ENGLAND JAGUAR V12XKE AUTO CONVERTIBLE 2 42002-00 ENGLAND JAGUAR XJ12L AUTO SEDAN 5 40000-00 ENGLAND JENSEN INTERCEPTOR III SEDAN 4 22412-41 ENGLAND TRIUMPH TR7 HARDTOP 2 20500-50 JAPAN DATSUN B210 2 DOOR AUTO SEDAN 4 22192-19 JAPAN TOYOTA COROLLA 4 DOOR DIX AUTO SEDAN 4 23053-05 ITALY ALFA ROMEO 2000 GT VELOCE COUPE 2 23203-20 ITALY ALFA ROMEO 2000 SPIDER VELOCE ROADSTER 2 25905-90 ITALY ALFA ROMEO 2000 4 DOOR BERLINA SEDAN 4 37007-00 ITALY MASERATI DORA 2 DOOR COUPE 2 25715-71 W GERMANY AUDI 100 LS 2 DOOR AUTO SEDAN 5 24004-00 W GERMANY BMW 2002 2 DOOR SEDAN 5 24004-00 W GERMANY BMW 2002 2 DOOR AUTO SEDAN 4 00-00 W GERMANY BMW 3.0 SI 4 DOOR SEDAN 5This message has been edited. Last edited by: bbollmann,
Brian Bollmann Spartan Light Metal Products WebFocus 7.6.4 / iSeries / WebSphere
November 21, 2008, 05:09 PM
Darin Lee
Use SET HOLDLIST=PRINTONLY at the beginning of your procedure. The tells WF to only hold those items in the hold file that would also be displayed on the screen. So you won't get both the original AND the re-defined field.
Regards,
Darin
In FOCUS since 1991 WF Server: 7.7.04 on Linux and Z/OS, ReportCaster, Self-Service, MRE, Java, Flex Data: DB2/UDB, Adabas, SQL Server Output: HTML,PDF,EXL2K/07, PS, AHTML, Flex WF Client: 77 on Linux w/Tomcat
November 23, 2008, 03:02 PM
Waz
Brian, you are using an EDIT with mask on a numeric field, I would suggest using FTOA first to convert to an alpha field, then add the '-'
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!
November 23, 2008, 03:14 PM
Danny-SRL
One can use EDIT with a mask on a numeric field. Just know that the outcome is always alpha. See the following:
-* File bbollmann1.fex
DEFINE FILE CAR
SALES2/A3=EDIT(SALES,'999');
RCOST7/A3=EDIT(RCOST,'$$$$999');
END
TABLE FILE CAR
PRINT SALES SALES2 RCOST RCOST7
BY COUNTRY BY CAR BY BODY
END
COUNTRY CAR BODYTYPE SALES SALES2 RETAIL_COST RCOST7
------- --- -------- ----- ------ ----------- ------
ENGLAND JAGUAR CONVERTIBLE 0 000 8,878 878
SEDAN 12000 012 13,491 491
JENSEN SEDAN 0 000 17,850 850
TRIUMPH HARDTOP 0 000 5,100 100
FRANCE PEUGEOT SEDAN 0 000 5,610 610
ITALY ALFA ROMEO COUPE 12400 012 6,820 820
ROADSTER 13000 013 6,820 820
SEDAN 4800 004 5,925 925
MASERATI COUPE 0 000 31,500 500
JAPAN DATSUN SEDAN 43000 043 3,139 139
TOYOTA SEDAN 35030 035 3,339 339
W GERMANY AUDI SEDAN 7800 007 5,970 970
BMW SEDAN 8950 008 5,940 940
8900 008 6,355 355
14000 014 13,752 752
18940 018 14,123 123
14000 014 9,097 097
15600 015 9,495 495
This message has been edited. Last edited by: Danny-SRL,
Daniel In Focus since 1982 wf 8.202M/Win10/IIS/SSA - WrapApp Front End for WF
November 24, 2008, 04:21 AM
GamP
Brian, Darin is right. Because the compute uses a real field to calculate it's result, that real field is also retrieved from the database. When holding HTML this is an implicit noprint field. But when putting it into a hold file all fields used to create the result will be stored in the hold file. Unless you use SET HOLDLIST=PRINTONLY, or ON TABLE SET HOLDlIST PRINTONLY.
GamP
- Using AS 8.2.01 on Windows 10 - IE11.
in Focus since 1988
November 24, 2008, 06:31 AM
Waz
Although you can use EDIT on a numeric, the documentation states
quote:
The EDIT function extracts characters from or adds characters to an alphanumeric string.
Be careful!
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!
November 24, 2008, 07:39 AM
Danny-SRL
Waz,
If you can get your hands on a M/F focus manual of the 1980's, you will see that EDIT with a mask is said to also work on numeric fields. I hope that what is the the newer manuals is an omission, otherwise many legacy applications out there are going to suffer from a serious bout of upward compatibility.
Up till now - and during the last 25 years - there has never been a problem. But, of course, all that could change...
Daniel In Focus since 1982 wf 8.202M/Win10/IIS/SSA - WrapApp Front End for WF
November 24, 2008, 09:05 AM
PBrightwell
You can even use EDIT to convert from numeric to alpha, but there are differences between using EDIT and FTOA. With EDIT, it will treat a number as an integer and will not translate the decimal portion. EDIT also zero fills the number and can convert a number up to 9 digits. FTOA blank fills the new field and can convert up to 16 digits and will retain decimal values. You can also convert from an alpha to a numeric but the same restrictions apply.
Pat WF 7.6.8, AIX, AS400, NT AS400 FOCUS, AIX FOCUS, Oracle, DB2, JDE, Lotus Notes
November 24, 2008, 03:59 PM
Waz
Daniel, I just was concerned that IBI may "Code tighten" and it will all fail.
I've since lost my FOCUS 4.5, 5 or was it 5.5 manual, had many dog eared pages, great reference manual, impossible to read though.
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!
November 25, 2008, 05:50 PM
StuBouyer
Waz,
As both uses of EDIT are covered in the Functions Reference Version 7 Release 6.1 and higher manual (DN3501785.0408) you are probably safe.
EDIT: Extracting or Adding Characters - pg 35
EDIT: Converting the Format of a Field - pg 141
Cheers
Stu
WebFOCUS 8.2.03 (8.2.06 in testing)
November 25, 2008, 05:58 PM
Darin Lee
Guys, Guys, (and Gals),
The issue doesn't really have anything to do with the EDIT function. How did we get there? He just wanted to know why he saw additional fields in his hold file that did not display in his report.
He's redefined a real field using the same name so the report only prints the column once, but when you ON TABLE HOLD it would hold both the original real field used in the DEFINE and the newly defined value. SET HOLDIST=PRINTONLY solves the problem.
Regards,
Darin
In FOCUS since 1991 WF Server: 7.7.04 on Linux and Z/OS, ReportCaster, Self-Service, MRE, Java, Flex Data: DB2/UDB, Adabas, SQL Server Output: HTML,PDF,EXL2K/07, PS, AHTML, Flex WF Client: 77 on Linux w/Tomcat
November 26, 2008, 03:46 PM
Waz
Guys, sorry about the rantings, but I was only concerned about supported code. If one day it fails you won't have a leg to stand on.
The important thing is Brian has an answer to his problem.
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!
December 05, 2008, 03:09 PM
bbollmann
Sorry I didn't come back to this sooner... ...Darin's original reply worked so well I forgot all about the posts.
SET HOLDLIST=PRINTONLY
The EDIT discussion was helpful too!
Brian Bollmann Spartan Light Metal Products WebFocus 7.6.4 / iSeries / WebSphere