Focal Point
[SOLVED] dynamic columns

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

November 21, 2008, 07:12 AM
Juanfi
[SOLVED] dynamic columns
Hi!!

I wanna do the following and I do a lot of tries but it has been impossible:

Example:

I have the next code:

TABLE FILE SQLOUT
NAME
COMPUTE PAG/P20CS = PAGE; NOPRINT
COMPUTE VIS1/A7 = IF (IMOD(PAG,2,'I2') NE 0) THEN ' ' ELSE 'NOPRINT'; NOPRINT
COMPUTE VIS2/A7 = IF (IMOD(PAG,2,'I2') EQ 0) THEN ' ' ELSE 'NOPRINT'; NOPRINT
IMP1 AS ‘Value1’
IMP2 AS ‘Value2’
ON TABLE PCHOLD FORMAT PDF


END

What I want to do is to print NAME in both pages, IMP1 in odd pages and IMP2 in even pages. That is:

Page 1:
NAME IMP1
Xxxxx 25
Aaaaaa 56

Page 2:
NAME IMP2
Xxxxx 57
Aaaaaa 89

PAGE gives me the page number.
The field VIS1 or VIS2 gives me the information whether I need to print or not. But if I put IMP1 AS ‘Value1’ VIS1, logically VIS1 appears like another field because it isn’t a variable.

I have also tried to define the variable VIS1 in the DEFINE but the field PAGE takes always the first value, that is, the value 1 and I don’t want that because PAGE has different values. Like that:

DEFINE SQLOUT
PAG/P20CS = PAGE; NOPRINT
-SET &VIS1 = IF (IMOD(PAG,2,'I2') NE 0) THEN ' ' ELSE 'NOPRINT';
END

Any ideas?

Thank you!!!

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


WebFocus 7.6.4 - Oracle 9
November 21, 2008, 09:27 AM
GinnyJakes
I'm not sure what you are trying to do. Is this example even close?
TABLE FILE CAR
PRINT SALES
COMPUTE PAG/P2CS = TABPAGENO; 
COMPUTE VIS/A7 = IF (IMOD(PAG,2,'I2') NE 0) THEN 'IMP1 ' ELSE 'IMP2'; BY COUNTRY PAGE-BREAK
BY CAR 
BY MODEL
BY BODYTYPE
ON TABLE SET ONLINE-FMT PDF
ON TABLE SET STYLE *
ORIENTATION=LANDSCAPE,$
ENDSTYLE
END



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 22, 2008, 04:28 AM
<JG>
Your approach is wrong, you cannot conditionally suppress a column with NOPRINT
Because NOPRINT can not be dynamic.

Make your data and heading dynamic and display your headings in a subhead



 
TABLE FILE CAR
PRINT 
     MODEL AS ''
     COMPUTE PAG/P2CS = TABPAGENO; NOPRINT
     COMPUTE VIS_DATA/A50 = IF ( IMOD(PAG, 2, 'I2') NE 0 ) THEN MODEL ELSE BODYTYPE;
 AS ''
     COMPUTE VIS_HEAD/A50 = IF ( IMOD(PAG, 2, 'I2') NE 0 ) THEN 'MODEL' ELSE 'BODYTYPE'; NOPRINT
 AS ''
BY CAR AS ''
     
ON CAR SUBHEAD
"CAR <+0> MODEL <VIS_HEAD"
ON CAR PAGE-BREAK
ON TABLE NOTOTAL
ON TABLE PCHOLD FORMAT PDF
ON TABLE SET STYLE *
     UNITS=IN,
     SQUEEZE=ON,
     ORIENTATION=LANDSCAPE,
$
TYPE=REPORT,
     GRID=OFF,
     FONT='TIMES NEW ROMAN',
     SIZE=10,
$
TYPE=SUBHEAD,
     BY=1,
     LINE=1,
     OBJECT=TEXT,
     ITEM=1,
     JUSTIFY=LEFT,
     WIDTH=1.08,
$
TYPE=SUBHEAD,
     BY=1,
     LINE=1,
     OBJECT=TEXT,
     ITEM=2,
     JUSTIFY=LEFT,
     WIDTH=2.10,
$
TYPE=SUBHEAD,
     BY=1,
     LINE=1,
     OBJECT=FIELD,
     ITEM=1,
     JUSTIFY=LEFT,
     WIDTH=3.625,
$
ENDSTYLE
END

 

November 23, 2008, 03:34 PM
Waz
I beleive you could do this with a coordinated compound report.

You would have two reports fitting the two layout requirements and turn coordination (MERGE) on


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!

November 24, 2008, 10:03 AM
Juanfi
Thank you JG!!!

I have done as you said and it works perfectly!!


WebFocus 7.6.4 - Oracle 9
November 24, 2008, 10:25 AM
nubi
Have i misunderstood? as i can make noprint dynamic..

 
-SET &CHOICE = 'N';
-SET &NOP = IF &CHOICE EQ 'Y' THEN 'NOPRINT' ELSE '';

TABLE FILE CAR 
PRINT CAR MODEL BODYTYPE 
BY COUNTRY '&NOP'
END
 


test by changing the value &CHOICE to 'Y' or 'N' and compare results...


Developer Studio 7.64
Win XP
Output: mostly HTML, also Excel and PDF

"Never attribute to malice that which can be adequately explained by stupidity." - Heinlein's Razor
November 24, 2008, 10:27 AM
nubi
ah i see DM is done before the TABLE Request so yes i see what you mean. The &Var can't be set until the table data has been processed...


Developer Studio 7.64
Win XP
Output: mostly HTML, also Excel and PDF

"Never attribute to malice that which can be adequately explained by stupidity." - Heinlein's Razor
November 24, 2008, 11:46 AM
Darin Lee
That is correct. Anything with the '-' (all Dialogue Manager commands) is executed in the order encountered and before any FOCUS code is run. That is the reason that you can't mix the two (i.e. -SET a variable equal to a field value.)


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