Focal Point
Decode

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

December 20, 2006, 06:02 PM
db
Decode
I'm trying to put 3 Access types in the ABCGRP, but when I run a report to list the ABCGRP, I only get the AAs. How do I code my form to include AA BB and CC in ABCGRP?

ACSTYPE/A5=IF EDIT(ACCESS,'9') EQ 'M' OR 'O'
THEN 'MGR' ELSE
IF ACCESS EQ 'AA' OR 'BB' OR 'CC'
THEN 'ABCGRP'
ELSE DECODE ACCESS
('XX' 'Admin'
'YY' 'REPS'
'XY' 'SUP'
'ZZ' 'REC'
'XZ' 'X_MGR
ELSE '** Missing **');
END
December 20, 2006, 07:20 PM
susannah
-first db, your field size has to be big enough to hold your largest element. In your case A5 wasn't big enough to hold the '** Missing **' value. Then you might enjoy this rewrite:
ACSTYPE/A13=IF ACCESS LIKE 'M_' OR 'O_' THEN 'MGR' ELSE
IF ACCESS EQ 'AA' OR 'BB' OR 'CC'
THEN 'ABCGRP'
ELSE DECODE ACCESS
('XX' 'Admin'
'YY' 'REPS'
'XY' 'SUP'
'ZZ' 'REC'
'XZ' 'X_MGR'
ELSE '** Missing **');
END
-* you might enjoy this rewrite
-* ..good eyes John, thanks

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




In Focus since 1979///7706m/5 ;wintel 2008/64;OAM security; Oracle db, ///MRE/BID
December 20, 2006, 08:00 PM
db
Thanks for the reply Susannah, my field size was a typo, it should have been set to A16. I have a report that prints by the decoded field, the problem is that the list is not picking up the BB and CC in the ABCGRP, only the AA. I checked over my form and tried to set the value to be any of the 3,(value="AA, BB, CC") and (value=ABCGRP) but it still does not work. I'll keep searching, there must be an error else where in the scheme of things. I like the rewrite and will use it. Thanks for the quick response.
December 21, 2006, 04:34 AM
hammo1j
No ending quote on X_MGR



Server: WF 7.6.2 ( BID/Rcaster) Platform: W2003Server/IIS6/Tomcat/SQL Server repository Adapters: SQL Server 2000/Oracle 9.2
Desktop: Dev Studio 765/XP/Office 2003 Applications: IFS/Jobscope/Maximo
December 24, 2006, 08:53 PM
Piipster
I tried this in R714 and it works fine:

DEFINE FILE EMPDATA
CTR/I5 = IF LAST CTR EQ 9 THEN 1 ELSE LAST CTR + 1;
ACCESS/A2 = DECODE CTR ( 1 'AA' 2 'BB' 3 'CC' 4 'XX' 5 'YY' 6 'XY'
7 'ZZ' 8 'XZ' 9 'M1');

ACSTYPE/A15=IF EDIT(ACCESS,'9') EQ 'M' OR 'O'
THEN 'MGR' ELSE
IF ACCESS EQ 'AA' OR 'BB' OR 'CC'
THEN 'ABCGRP'
ELSE DECODE ACCESS
('XX' 'Admin'
'YY' 'REPS'
'XY' 'SUP'
'ZZ' 'REC'
'XZ' 'X_MGR'
ELSE '** Missing **');
END
TABLE FILE EMPDATA
PRINT CTR ACCESS
BY ACSTYPE
BY PIN
END

What is the format of your ACCESS field? Have you printed it out along with the field you are creating? What do you get for the BB and CC fields.

And finally, try something simple like:
IF (ACCESS EQ 'AA' OR 'BB' OR 'CC')...


ttfn, kp


Access to most releases from R52x, on multiple platforms.
December 25, 2006, 04:27 AM
OPALTOSH
Why not make it simpler by removing the IF altogrether?

ACSTYPE/A15=IF EDIT(ACCESS,'9') EQ 'M' OR 'O'
THEN 'MGR' ELSE
DECODE ACCESS
('AA' 'ABSGRP'
'BB' 'ABCGRP'
'CC' 'ABCGRP'
'XX' 'Admin'
'YY' 'REPS'
'XY' 'SUP'
'ZZ' 'REC'
'XZ' 'X_MGR'
ELSE '** Missing **');