Focal Point
[CLOSED] title of one field based on value of another field

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

January 28, 2019, 05:42 AM
AR
[CLOSED] title of one field based on value of another field
Hi

want to achieve something like below page.
https://www.informationbuilder...developers/PageBreak

but not through heading. is there any other way?
the requirement is
if SEATS field EQ 4 then
BY CAR AS 'Four Wheeler Car'

if SEATS field EQ 2 then
BY CAR AS 'Two Wheeler Car'

Note: consider that SEATS value will be single at a time and not known earlier. it can be anything.


Regards
Ashwini Rane

This message has been edited. Last edited by: FP Mod Chuck,


WebFOCUS 8
Windows, All Outputs
January 28, 2019, 06:56 AM
Wep5622
Sounds like a job for DEFINE and ACROSS.
SET ACROSSPRT = COMPRESS

DEFINE FILE CAR
   TITLE/A100 = DECODE SEATS(4 'Four Wheeler', 2 'Two Wheeler' ELSE 'Other');
END
TABLE FILE CAR
PRINT CAR MODEL
ACROSS TITLE
END



WebFOCUS 8.1.03, Windows 7-64/2008-64, IBM DB2/400, Oracle 11g & RDB, MS SQL-Server 2005, SAP, PostgreSQL 11, Output: HTML, PDF, Excel 2010
: Member of User Group Benelux :
January 29, 2019, 11:23 PM
AR
Thanks Wep5622

No. It should not be separated by across.
Its a normal BY or PRINT and title of the field should be based on the value receiving for other field.

Regards
Ashwini Rane


WebFOCUS 8
Windows, All Outputs
January 30, 2019, 04:01 AM
Wep5622
I don't see how you expect to have different column titles over the same columns without using ACROSS.

The example you linked doesn't do anything like what you describe. I suggest you provide an example of the output you are looking for.


WebFOCUS 8.1.03, Windows 7-64/2008-64, IBM DB2/400, Oracle 11g & RDB, MS SQL-Server 2005, SAP, PostgreSQL 11, Output: HTML, PDF, Excel 2010
: Member of User Group Benelux :
January 30, 2019, 04:43 AM
Addy
Hi,
If the value that decided what will be the column title is a variable then
-SET &COL_NAME = IF &variable EQ '2' THEN 'Two Wheeler' ELSE
- I F&variable EQ '4' THEN 'Four Wheeler' ELSE 'Others';

TABLE FILE CAR
PRINT CAR MODEL
BY SEAT AS '&COL_NAME.EVAL';

END

If it is a field then read the field value in a Variable and then use the above code.


WF 8.2.04
Windows/Unix
All Formats
In Focus since 2006
January 31, 2019, 08:32 AM
GamP
Expanding that a bit, you could make it a loop. Like this:
-SET &SEATS = 0;
-:LABEL
-SET &SEATS = &SEATS + 1;
-IF &SEATS EQ 9 THEN GOTO :ENDOFFEX;

-SET &COLTXT = DECODE &SEATS (1 'Just one passenger' 2 'Two-seater' 3 'Carries three' 4 'Four passengers' ELSE 'Famliy');

TABLE FILE CAR
PRINT CAR AS '&COLTXT'
MODEL BODYTYPE SEATS
WHERE SEATS EQ &SEATS;
END
-GOTO :LABEL
-:ENDOFFEX

Just my 2 cents ...


GamP

- Using AS 8.2.01 on Windows 10 - IE11.
in Focus since 1988
February 01, 2019, 12:44 AM
AR
Thanks GamP and Addy.

Thats what the problem is. Its not a variable but a field from mas and if taken in DEFINE then wont be able to use field for title as title can be customized at runtime by variable and not by field.

Regards
Ashwini Rane


WebFOCUS 8
Windows, All Outputs
February 04, 2019, 06:09 PM
Doug
quote:
I suggest you provide an example of the output you are looking for.

Yes, Please. Then we can assist you with this task.




   In FOCUS Since 1983 ~ from FOCUS to WebFOCUS.
   Current: WebFOCUS Administrator at FIS Worldpay | 8204, 8206
February 05, 2019, 04:38 AM
AR
Hi Doug

The example is same as the example given in page break link provided. Just dont want handling in header.

Regards
Ashwini Rane


WebFOCUS 8
Windows, All Outputs
February 05, 2019, 06:49 AM
Addy
Ashwini,
You can read the values of the filed in a variable and then set you variable that is used in title accordingly.

  
TABLE FILE CAR
PRINT
COUNTRY
WHERE RECORDLIMIT EQ 1
ON TABLE SAVE AS READ_VALUE
END
-*Considering there is only 1 value for country

-RUN
-READ READ_VALUE &COL_VALUE.A10.
-*Considering the filed format is A10
-RUN
-SET &COLTXT = DECODE &COL_VALUE (1 'Just one passenger' 2 'Two-seater' 3 'Carries three' 4 'Four passengers' ELSE 'Famliy');


TABLE FILE CAR
PRINT
CAR 
COUNTRY
BY SEAT AS '&COLTXT.EVAL'
END



WF 8.2.04
Windows/Unix
All Formats
In Focus since 2006
February 06, 2019, 03:50 AM
AR
quote:
WHERE RECORDLIMIT EQ 1


tried WHERE SEATS EQ 4 instead in filter
and still it went to else block and print Family.


WebFOCUS 8
Windows, All Outputs
February 06, 2019, 05:08 AM
Addy
Ashwini,
Did you understand the code or just copy pasted the code.
the decode statement is working on the value from SEAT column.
I have copid that from what GamP wrote.

Did you change your Decode statement to consider country value instead of SEAT?

When you apply SEAT where conditoin you get 4 different values, as per your original post you have only 1 value at any point.

I gave you a code sample for you to understand what GamP and I are trying to explain.


WF 8.2.04
Windows/Unix
All Formats
In Focus since 2006
February 18, 2019, 10:31 PM
AR
Hey,
Thanks GamP. the solution you provided worked with my example as well.


WebFOCUS 8
Windows, All Outputs