Focal Point
Adding a single column after all across columns

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

November 14, 2011, 09:27 AM
Wep5622
Adding a single column after all across columns
Is it possible to put a single column at the right-most end of the output of a series of ACROSS columns?

I'm generating a number of WHERE clauses from a data-file and OR-ing them together using ACROSS and COMPUTE, but I'm kind of stuck getting a semi-colon (Wink at the end of each line...

My code is similar to:
DEFINE FILE CAR
 SELITEM/A8 = DECODE COUNTRY('FRANCE' 'MODEL' 'ITALY' 'SEATS' ELSE '');
 SELVALS/A15 = DECODE COUNTRY('FRANCE' 'EQ ''504 4 DOOR''' 'ITALY' 'EQ 4' ELSE '');
 WHERELINE/A26 = IF SELITEM EQ '' OR SELVALS EQ '' THEN '' ELSE '('|SELITEM||' '|SELVALS||')';
END
TABLE FILE CAR
 SUM
    COMPUTE  CONDITION/A32 = IF WHERELINE EQ '' THEN ''
                  ELSE IF (LAST COUNTRY EQ COUNTRY)
                  THEN '   OR ' | TRIM('T', WHERELINE, 26, ' ', 1, 'A26')
                  ELSE 'WHERE ' | TRIM('T', WHERELINE, 26, ' ', 1, 'A26'); AS ''

 BY COUNTRY NOPRINT
 ACROSS CAR NOPRINT
WHERE COUNTRY EQ 'FRANCE' OR 'ITALY' OR 'SPAIN';
END


The result of this query, saved as FORMAT ALPHA, is to be -INCLUDE'd as the WHERE clause in another TABLE FILE query.
For that purpose, obviously, each line should end with a ';'. How do I do that?


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 :
November 14, 2011, 09:47 AM
<FreSte>
Wep,

You can add a COMPUTE'd field at the end like:

...
  BY COUNTRY NOPRINT
  ACROSS CAR NOPRINT
  COMPUTE SC/A1 = ';';
WHERE COUNTRY EQ 'FRANCE' OR 'ITALY' OR 'SPAIN';
END


-Fred
November 14, 2011, 11:03 AM
Wep5622
That field will repeat for each ACROSS value though. Without a way to detect that I'm at the last ACROSS value, that won't help.


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 :
November 14, 2011, 11:14 AM
njsden
Hmmm, as far as I know any COMPUTE field you add *after* the ACROSS clause will be appended at the end of the report right after the last ACROSS which seems to be what you wanted. Did you actually try FreSte's suggestion and it didn't work? If that's the case I'll have to revise my old assumptions Roll Eyes



Prod/Dev: WF Server 8008/Win 2008 - WF Client 8008/Win 2008 - Dev. Studio: 8008/Windows 7 - DBMS: Oracle 11g Rel 2
Test: Dev. Studio 8008 /Windows 7 (Local) Output:HTML, EXL2K.
November 14, 2011, 11:59 AM
dhagen
I don't think you need the across to do what you want. Try:
  DEFINE FILE CAR
 SELITEM/A8 = DECODE COUNTRY('FRANCE' 'MODEL' 'ITALY' 'SEATS' ELSE '');
 SELVALS/A15 = DECODE COUNTRY('FRANCE' 'EQ ''504 4 DOOR''' 'ITALY' 'EQ 4' ELSE '');
 WHERELINE/A26 = IF SELITEM EQ '' OR SELVALS EQ '' THEN '' ELSE '('|SELITEM||' '|SELVALS||')';
END
TABLE FILE CAR
 SUM 
   COMPUTE C_COUNTRY_CTR/I1 = CNT.CAR; NOPRINT
  BY COUNTRY NOPRINT
 SUM
   COMPUTE C_CAR_CTR/I5 = IF COUNTRY EQ LAST COUNTRY THEN LAST C_CAR_CTR + 1  ELSE 1; NOPRINT
    COMPUTE  CONDITION/A32 = IF WHERELINE EQ '' THEN ''
                  ELSE IF (LAST COUNTRY EQ COUNTRY)
                  THEN '   OR ' | TRIM('T', WHERELINE, 26, ' ', 1, 'A26')
                  ELSE 'WHERE ' | TRIM('T', WHERELINE, 26, ' ', 1, 'A26'); AS ''
   COMPUTE COMMA/A1 = IF C_CAR_CTR EQ C_COUNTRY_CTR THEN ';' ELSE ' '; AS ''
 BY COUNTRY NOPRINT
 BY CAR NOPRINT
WHERE COUNTRY EQ 'FRANCE' OR 'ITALY' OR 'SPAIN';
END



Output:
 
WHERE (MODEL EQ '504 4 DOOR') ; 
WHERE (SEATS EQ 4) 
OR (SEATS EQ 4) ; 



"There is no limit to what you can achieve ... if you don’t care who gets the credit." Roger Abbott
November 15, 2011, 04:20 AM
Wep5622
quote:
Originally posted by njsden:
Hmmm, as far as I know any COMPUTE field you add *after* the ACROSS clause will be appended at the end of the report right after the last ACROSS which seems to be what you wanted. Did you actually try FreSte's suggestion and it didn't work? If that's the case I'll have to revise my old assumptions Roll Eyes


Doh! I hadn't noticed that the COMPUTE was after the ACROSS and didn't know it would behave differently at that spot.

Thanks for pointing that out.


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 :
November 15, 2011, 09:03 AM
atturhari
Does it work for you?

DEFINE FILE CAR
SELITEM/A8 = DECODE COUNTRY('FRANCE' 'MODEL' 'ITALY' 'SEATS' ELSE '');
SELVALS/A15 = DECODE COUNTRY('FRANCE' 'EQ ''504 4 DOOR''' 'ITALY' 'EQ 4' ELSE '');
WHERELINE/A26 = IF SELITEM EQ '' OR SELVALS EQ '' THEN '' ELSE '('|SELITEM||' '|SELVALS||')';
SEMI_COLON/A1 = ';';
END
TABLE FILE CAR
SUM
COMPUTE CONDITION/A32 = IF WHERELINE EQ '' THEN ''
ELSE IF (LAST COUNTRY EQ COUNTRY)
THEN ' OR ' | TRIM('T', WHERELINE, 26, ' ', 1, 'A26')
ELSE 'WHERE ' | TRIM('T', WHERELINE, 26, ' ', 1, 'A26'); AS ''

BY COUNTRY NOPRINT
BY SEMI_COLON AS ''
ACROSS CAR NOPRINT
WHERE COUNTRY EQ 'FRANCE' OR 'ITALY' OR 'SPAIN';
ON TABLE SET NODATA ' '
ON TABLE SET STYLE *
TYPE=REPORT, COLUMN=SEMI_COLON, SEQUENCE=90,$
ENDSTYLE
END


WF 7.7.02 on Windows 7
Teradata
HTML,PDF,EXCEL,AHTML
November 15, 2011, 01:44 PM
Francis Mariani
As atturhari shows, you can use the SEQUENCE attribute in the style sheet to change the position of a column in a report.


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 15, 2011, 03:26 PM
<FreSte>
This SEQUENCE attribute is OK for HTML-output, but for writing to HOLD-files, it doesn't work.
Wep needs these HOLD-files with WHERE-statements for including in other fexes.
I also use this kind of dynamice WHERE-statements; very powerfull
November 21, 2011, 10:15 AM
GCohen
Its actually very easy. It depends on where you put the Compute. In this case put it after the ACROSS. The syntax is..
TABLE FILE CAR
SUM RETAIL_COST
BY COUNTRY
ACROSS BODYTYPE AND COMPUTE NEW= C1 + C3 ;
END

Note that the columns can be identified as C1,C2, etc


Release 7.6.9
Windows
HTML