Focal Point
Question on another twist for Across

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

July 10, 2008, 10:12 AM
Joel
Question on another twist for Across
I'm trying to create a report that looks like this:

CAR Dealer Cost Retail Cost
England France Italy England France Italy
Alpha Romeo
Jaguar
Peugeot

The code that I have below is putting the country on top of the costs.

TABLE FILE CAR
SUM
DEALER_COST
RETAIL_COST
BY CAR
ACROSS COUNTRY
ON TABLE NOTOTAL
END

Is this even possible?


7.6.6
Windows 2003 Server, Sybase IQ, DB2, SQL Server and Oracle Databases
Excel, HTML and PDF
July 10, 2008, 10:22 AM
Danny-SRL
Joel,
From your example it is hard to understand what you want to achieve.
You have twice across "England France Italy"
Under CAR you have "Alpha Romeo", "Jaguar", "Peugeot".
Could you be a bit more precise?


Daniel
In Focus since 1982
wf 8.202M/Win10/IIS/SSA - WrapApp Front End for WF

July 10, 2008, 10:39 AM
Joel
I don't know if this will show up correctly on this forum.

The output of the above code shows like this:

ENGLAND FRANCE ITALY
CAR DEALER_COST RETAIL_COST DEALER_COST RETAIL_COST DEALER_COST RETAIL_COST
ALFA ROMEO . . . . 16,235 19,565
JAGUAR 18,621 22,369 . . . .
JENSEN 14,940 17,850 . . . .
MASERATI . . . . 25,000 31,500
PEUGEOT . . 4,631 5,610 . .
TRIUMPH 4,292 5,100 . . . .


This is the output that I'd like to achieve:

CAR DEALER_COST RETAIL_COST
ENGLAND FRANCE ITALY ENGLAND FRANCE ITALY
ALFA ROMEO . . 16,235 . . 19,565
JAGUAR 18,621 . . 22,369 . .
JENSEN 14,940 . . 17,850 . .
MASERATI . . 25,000 . . 31,500
PEUGEOT . 4,631 . . 5,610 .
TRIUMPH 4,292 . . 5,100 . .


7.6.6
Windows 2003 Server, Sybase IQ, DB2, SQL Server and Oracle Databases
Excel, HTML and PDF
July 10, 2008, 10:49 AM
Danny-SRL
Like this?
CAR        DEALER_COST                      RETAIL_COST
           ENGLAND    FRANCE     ITALY      ENGLAND    FRANCE     ITALY
ALFA ROMEO          .          .     16,235          .          .     19,565
JAGUAR         18,621          .          .     22,369          .          .
JENSEN         14,940          .          .     17,850          .          .
MASERATI            .          .     25,000           .         .     31,500
PEUGEOT             .      4,631          .           .     5,610          .




Daniel
In Focus since 1982
wf 8.202M/Win10/IIS/SSA - WrapApp Front End for WF

July 10, 2008, 10:58 AM
Joel
Yes Danny. That's the format I want to achieve.


7.6.6
Windows 2003 Server, Sybase IQ, DB2, SQL Server and Oracle Databases
Excel, HTML and PDF
July 10, 2008, 11:04 AM
Danny-SRL
Joel,

Here you are:
  
-* File Joel1.fex
DEFINE FILE CAR
DC/A12='DEALER_COST';
RC/A12='RETAIL_COST';
END
TABLE FILE CAR
SUM DC DEALER_COST RC RETAIL_COST
BY COUNTRY
BY CAR
WHERE COUNTRY EQ 'ENGLAND' OR 'FRANCE' OR 'ITALY';
ON TABLE SAVE AS JOEL
END
-RUN
FILEDEF JOELM DISK JOEL.MAS
-RUN
-WRITE JOELM FILENAME=JOEL    , SUFFIX=FIX
-WRITE JOELM SEGMENT=JOEL, SEGTYPE=S0
-WRITE JOELM FIELDNAME=COUNTRY, ALIAS=E01, USAGE=A10, ACTUAL=A10, $
-WRITE JOELM FIELDNAME=CAR, ALIAS=E02, USAGE=A16, ACTUAL=A16, $
-WRITE JOELM SEGMENT=CST, PARENT=JOEL,  OCCURS=VARIABLE
-WRITE JOELM FIELDNAME=CODE, ALIAS=E03, USAGE=A12, ACTUAL=A12, $
-WRITE JOELM FIELDNAME=COST, ALIAS=E04, USAGE=D7, ACTUAL=A07, $
-RUN
TABLE FILE JOEL
SUM COST
BY CAR
ACROSS CODE AS ''
ACROSS COUNTRY AS ''
END



Daniel
In Focus since 1982
wf 8.202M/Win10/IIS/SSA - WrapApp Front End for WF

July 10, 2008, 11:07 AM
j.gross
You can avoid the Dialog Manager manipulation, by use of the McGuyver technique, as discussed in recent posts. The crux is to transform the Dealer Code and Retail Code captions from field-names into ACROSS sort values.

Essentially the technique uses a join to double the set of reportable records, and establishes a single DEFINEd numeric variable to hold values of DEALER_COST or RETAIL_COST, depending on a sort-key variable with "Dealer Code" and "Retail Code" as its values. Your report request will
SUM [the defined numeric field]
BY Car
ACROSS [the new key field] AS ''
ACROSS Country AS ''


- Jack Gross
WF through 8.1.05
July 10, 2008, 11:36 AM
Anonymouse
Jack stole my thunder, but here's the code I came up with:
JOIN BLANK WITH DEALER_COST IN CAR TO BLANK IN FSEQ

DEFINE FILE CAR
BLANK / A1 = ' ';
COST_TYPE/A11 = IF COUNTER EQ 1 THEN 'DEALER_COST' ELSE 'RETAIL_COST';
COST_AMOUNT/D7 = IF COUNTER EQ 1 THEN DEALER_COST ELSE RETAIL_COST;
END

TABLE FILE CAR
PRINT COST_AMOUNT
BY COUNTRY
BY CAR
BY COST_TYPE
WHERE COUNTER LE 2
ON TABLE HOLD
END

TABLE FILE HOLD
SUM COST_AMOUNT
BY CAR
ACROSS COST_TYPE
ACROSS COUNTRY
END


Jeff
WebFOCUS 8.0.09, Unix-Win-z/OS
FOCUS 7.3.1 on z/OS
July 10, 2008, 11:59 AM
Joel
Thanks Jack and Jeff. I will give this a shot!


7.6.6
Windows 2003 Server, Sybase IQ, DB2, SQL Server and Oracle Databases
Excel, HTML and PDF
July 10, 2008, 01:02 PM
j.gross
It's important to include a WITH anchor in the define of BLANK, corresponding to the anchor point of the JOIN.

I have my own utility fex to set up the McGuyver file:
  
-* File MakeSeq.fex
-DEFAULTH &FILE=FSEQ, &KEY=BLANK, &COUNTER=COUNTER, &FIRST=1, &LAST=100
 EX -LINES 7
 EDAPUT MASTER, &FILE, CV, MEM
  FILE=&FILE, SUFFIX=FOC, $
    SEGNAME=FSEQ1, SEGTYPE=S1, $
      FIELD=&KEY, , A1, ACCEPT=' ', INDEX=I, $
    SEGNAME=FSEQ2, SEGTYPE=S1, PARENT=FSEQ1, $
      FIELD=&COUNTER, , I4, $
 END
 CREATE FILE &FILE
 MODIFY FILE &FILE
  FREEFORM &KEY &COUNTER
  MATCH &KEY &COUNTER
    ON NOMATCH INCLUDE
    ON MATCH REJECT
 DATA
-REPEAT SEQ.LOOP FOR &I FROM &FIRST TO &LAST ;
 ' ', &I, $
-SEQ.LOOP
 END                     

The parameters allow the caller to tailor the range of Counter values stored in the focus file (and the filename and fieldnames as well).
The END line after the EX -LINES block is for clarity; it's harmless, and saves the day if the count is 1 over Wink

For the present case:

EX SESSION/CAR5

-* File CAR5.fex
EX BASEAPP/MAKESEQ FIRST=1,LAST=2,FILE=FOCSEQ,KEY=NADA

JOIN CLEAR *
JOIN NADA WITH DEALER_COST IN CAR TO NADA IN FOCSEQ

DEFINE FILE CAR
  NADA/A1 WITH DEALER_COST =;
  FIELD/A12 WITH COUNTER =
    DECODE COUNTER (
      1 'Dealer Cost'
      2 'Retail Cost'
    ELSE ' ');
  Value/D12.2 WITH COUNTER =
    IF COUNTER EQ 1 THEN DEALER_COST ELSE
    IF COUNTER EQ 2 THEN RETAIL_COST ELSE 0;
  Country/A10 =LCWORD(10,COUNTRY,'A10');
  Car/A16     =LCWORD(16,CAR,'A16');
END

TABLE FILE CAR
  SUM Value AS ''
  BY Car AS ''
  ACROSS COUNTER NOPRINT
  ACROSS FIELD AS ''
  ACROSS Country AS ''
  WHERE CAR IN ('ALFA ROMEO' 'JAGUAR' 'PEUGEOT');
END



- Jack Gross
WF through 8.1.05
July 10, 2008, 04:10 PM
Danny-SRL
Joel,

You can choose between 2 techniques.
Jack & Jeff propose the McGuyver
Mine is called "Alternate Master".

It is good to be acquainted with both.


Daniel
In Focus since 1982
wf 8.202M/Win10/IIS/SSA - WrapApp Front End for WF