Focal Point
Dynamic column name in a table file

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

November 28, 2007, 10:51 AM
Jérény Deidda
Dynamic column name in a table file
Hi,

I don't know how to call a dynamic column name in a table file. I have to run a PRINT in a TABLE FILE and one of the selected field depends on the value of one of another field.

  
DEFINE FILE MYTAB
DYNFIELD/A8 = DECODE GEVGRPUNI('01' GEVFLAGA '02' GEVFLAGF '03' GEVFLAGO '04' GEVFLAGF ELSE GEVFLAGA);
END

TABLE FILE MYTAB
PRINT DYNFIELD
END


In the result grid, instead of having the value of the dynamic field, I see the result value of the decode.

To sum up, I want to have this:

Y
N
Y
N
N

But I become this:

GEVFLAGA
GEVFLAGO
GEVFLAGF
GEVFLAGO
GEVFLAGO

Is there a syntax problem or is it impossible to use this solution?


WebFOCUS 7.6.4 running on Windows
Output formats : PDF, Excel and HTML
My blog
November 28, 2007, 11:06 AM
Francis Mariani
"The DECODE function assigns values based on the coded value of an input field" - it decodes string or numeric values not column values. To do what you want, simply change the DECODE to IF THEN ELSE:

DEFINE FILE MYTAB
DYNFIELD/A8 = 
IF GEVGRPUNI EQ '01' THEN GEVFLAGA ELSE
IF GEVGRPUNI EQ '02' THEN GEVFLAGF ELSE
IF GEVGRPUNI EQ '03' THEN GEVFLAGO ELSE
IF GEVGRPUNI EQ '04' THEN GEVFLAGF ELSE GEVFLAGA;
END

TABLE FILE MYTAB
PRINT DYNFIELD
END 



Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
November 28, 2007, 02:52 PM
GinnyJakes
Just a couple of questions.

Is DYNFIELD a different value on each record in MYTAB or is it constant for the entire report?

If I understand you correctly, if DYNFIELD is '01', you want to 'PRINT GEVFLAGA'?

Please confirm. The answers will help us develop a solution for you.


Ginny
---------------------------------
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
November 29, 2007, 04:53 AM
Jérény Deidda
For Francis:

Thanks a lot for the solution, that's exactly what I wanted to do.

For GinnyJakes:

DYNFIELD can be different for each record.
I wanted to have "PRINT GEVFLAGA" or "PRINT GEVFLAGF" or "PRINT GEVFLAGL" or "PRINT GEVFLAGO" regarding the value of GEVGRPUNI.

For Admin:

this topic can be closed.

This message has been edited. Last edited by: Jérény Deidda,


WebFOCUS 7.6.4 running on Windows
Output formats : PDF, Excel and HTML
My blog
November 29, 2007, 10:34 AM
Francis Mariani
Jérény, thank you for sharing pictures of your wonderful home Smiler


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server