Focal Point
[SOLVED] How to add multiple data from a field to a Header

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

March 27, 2013, 08:42 AM
kitten
[SOLVED] How to add multiple data from a field to a Header
Please forgive me if I'm not asking this question appropriatly. I really don't know how to word it. I've tried to recreate the scenario using the Car File. See below:
TABLE FILE CAR
PRINT
CAR.BODY.BODYTYPE
CAR.BODY.SEATS
CAR.BODY.DEALER_COST
CAR.BODY.RETAIL_COST
CAR.BODY.SALES
CAR.SPECS.LENGTH
CAR.SPECS.WIDTH
CAR.SPECS.HEIGHT
CAR.SPECS.WEIGHT
CAR.SPECS.WHEELBASE
CAR.SPECS.FUEL_CAP
BY CAR.ORIGIN.COUNTRY NOPRINT
BY CAR.COMP.CAR NOPRINT
BY CAR.CARREC.MODEL NOPRINT
ON CAR.CARREC.MODEL PAGE-BREAK
HEADING
"DATE: &DATEMDYY"
"CAR FILE"
"Country:"Model: "Other Model(s): "
END

What I'm trying to do is populate the 'Other Model:' in the header with the other models of a given Car. For example,the ALFA ROMEO, on the page that list the MODEL as 'Model: 2000 4 DOOR BERLINA' I'd like the OTHER MODEL to read 'Other Model(s): 2000 GT VELOCE, 2000 SPIDER VELOCE'.

Can someone please tell me how to approach this.

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


WebFOCUS 7.6.2, MS Windows Server/______, Excel, PDF, HTML
March 27, 2013, 10:25 AM
Tony A
One slightly convoluted method of achieving what (I think) you want -

TABLE FILE CAR
PRINT COMPUTE OTH_MODEL/A200V = IF COUNTRY NE LAST COUNTRY THEN MODEL
                           ELSE IF CAR     NE LAST CAR     THEN MODEL
                           ELSE LAST OTH_MODEL || (', '|MODEL);
      COMPUTE KEY/A40 = COUNTRY || CAR;
   BY COUNTRY  
   BY CAR      
ON TABLE HOLD AS TEMPCAR1
END
-RUN
TABLE FILE TEMPCAR1
  SUM LST.OTH_MODEL
   BY KEY
ON TABLE HOLD AS TEMPCAR2 FORMAT FOCUS INDEX KEY
END
-RUN
JOIN CLEAR *
JOIN KEY WITH CAR IN CAR TO KEY IN TEMPCAR2 AS J1
DEFINE FILE CAR
  KEY/A40 WITH CAR = COUNTRY || CAR;
END
TABLE FILE CAR
PRINT BODYTYPE
      SEATS
      DEALER_COST
      RETAIL_COST
      SALES
      LENGTH
      WIDTH
      HEIGHT
      WEIGHT
      WHEELBASE
      FUEL_CAP
   BY COUNTRY  NOPRINT
   BY CAR      NOPRINT
   BY MODEL    NOPRINT
ON CAR PAGE-BREAK
HEADING
"DATE: &DATEMDYY"
"CAR FILE"
"Country: <COUNTRY Car: <CAR Other Model(s): <OTH_MODEL"
ON TABLE SET PAGE NOLEAD
ON TABLE SET STYLE *
  TYPE=HEADING, LINE=3, ITEM=2, COLOR=BLUE, $
  TYPE=HEADING, LINE=3, ITEM=4, COLOR=BLUE, $
  TYPE=HEADING, LINE=3, ITEM=6, COLOR=BLUE, $
ENDSTYLE
END

T



In FOCUS
since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2  
WebFOCUS App Studio 8.2.06 standalone on Windows 10 
March 27, 2013, 10:59 AM
kitten
Not convoluted at all...I made some changes to get closer to what I wanted there's just one problem...run the code below and it will be a little clearer... Is there any way to not repeat the Model on a page in the Other Model list on the same page.

TABLE FILE CAR
PRINT COMPUTE OTH_MODEL/A200V = IF COUNTRY NE LAST COUNTRY THEN MODEL
ELSE IF CAR NE LAST CAR THEN MODEL
ELSE LAST OTH_MODEL || (', '|MODEL);
COMPUTE KEY/A40 = COUNTRY || CAR;
BY COUNTRY
BY CAR
BY MODEL
ON TABLE HOLD AS TEMPCAR1
END
-RUN
TABLE FILE TEMPCAR1
SUM LST.OTH_MODEL
BY KEY
ON TABLE HOLD AS TEMPCAR2 FORMAT FOCUS INDEX KEY
END
-RUN
JOIN CLEAR *
JOIN KEY WITH CAR IN CAR TO KEY IN TEMPCAR2 AS J1
DEFINE FILE CAR
KEY/A40 WITH CAR = COUNTRY || CAR;
END
TABLE FILE CAR
PRINT BODYTYPE
SEATS
DEALER_COST
RETAIL_COST
SALES
LENGTH
WIDTH
HEIGHT
WEIGHT
WHEELBASE
FUEL_CAP
BY COUNTRY NOPRINT
BY CAR NOPRINT
BY MODEL NOPRINT
ON CAR.CARREC.MODEL PAGE-BREAK
HEADING
"DATE: &DATEMDYY"
"CAR FILE"
"Country: "Model: "Other Model(s): ON TABLE SET PAGE-NUM NOLEAD
ON TABLE NOTOTAL
ON TABLE PCHOLD FORMAT HTML
ON TABLE SET HTMLCSS ON
ON TABLE SET STYLE *
INCLUDE = endeflt,
$
TYPE=REPORT,
GRAPHCOLOR='GREEN',
$
TYPE=HEADING,
LINE=1,
JUSTIFY=LEFT,
$
TYPE=HEADING,
LINE=2,
JUSTIFY=LEFT,
$
TYPE=HEADING,
LINE=3,
JUSTIFY=LEFT,
$
TYPE=HEADING,
LINE=4,
JUSTIFY=LEFT,
$
TYPE=HEADING,
LINE=5,
JUSTIFY=LEFT,
$
TYPE=REPORT,
OBJECT=MENU,
COLOR='WHITE',
HOVER-COLOR=RGB(66 70 73),
BACKCOLOR=RGB(102 102 102),
HOVER-BACKCOLOR=RGB(218 225 232),
BORDER-COLOR='WHITE',
$
TYPE=REPORT,
OBJECT=STATUS-AREA,
COLOR='WHITE',
BACKCOLOR=RGB(102 102 102),
$
TYPE=REPORT,
OBJECT=CURRENT-ROW,
HOVER-BACKCOLOR=RGB(218 225 232),
BACKCOLOR=RGB(200 200 200),
$
TYPE=REPORT,
OBJECT=CALC-AREA,
COLOR='WHITE',
BACKCOLOR=RGB(102 102 102),
$
ENDSTYLE
END


WebFOCUS 7.6.2, MS Windows Server/______, Excel, PDF, HTML
March 27, 2013, 11:27 AM
Francis Mariani
Please put the code between
[code]
your code here
[/code]
tags, otherwise we cannot properly copy/paste the code.


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
March 27, 2013, 11:45 AM
Francis Mariani
This snippet may get you a tiny bit closer:

TABLE FILE TEMPCAR1
SUM
COMPUTE OTH_MODEL1/A200V = STRREP (200, OTH_MODEL, 24, MODEL, 0, '', 200, 'A200V'); NOPRINT
LST.OTH_MODEL1 AS OTH_MODEL
BY KEY
ON TABLE HOLD AS TEMPCAR2 FORMAT FOCUS INDEX KEY
END
-RUN


But I see a problem: the output of the second TABLE FILE gives you one row per KEY, which is COUNTRY | CAR. You need the key to include MODEL, since MODEL is in your report and in the heading you want to display all the models except the model that is the sort field value...


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
March 29, 2013, 08:28 AM
kitten
Thanks guys. Your post really helped. I got it to work. Issue solved.


WebFOCUS 7.6.2, MS Windows Server/______, Excel, PDF, HTML