Focal Point Banner


As of December 1, 2020, Focal Point is retired and repurposed as a reference repository. We value the wealth of knowledge that's been shared here over the years. You'll continue to have access to this treasure trove of knowledge, for search purposes only.

Join the TIBCO Community
TIBCO Community is a collaborative space for users to share knowledge and support one another in making the best use of TIBCO products and services. There are several TIBCO WebFOCUS resources in the community.

  • From the Home page, select Predict: WebFOCUS to view articles, questions, and trending articles.
  • Select Products from the top navigation bar, scroll, and then select the TIBCO WebFOCUS product page to view product overview, articles, and discussions.
  • Request access to the private WebFOCUS User Group (login required) to network with fellow members.

Former myibi community members should have received an email on 8/3/22 to activate their user accounts to join the community. Check your Spam folder for the email. Please get in touch with us at community@tibco.com for further assistance. Reference the community FAQ to learn more about the community.


Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [SOLVED] Array as Field

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[SOLVED] Array as Field
 Login/Join
 
Member
posted
Hi,
I have a requirement to calculate grand totals. I am able to generate the grand totals but it is in the form of amper variable array. How can I declare an Array variable to a field?
-SET &ECHO = ALL;
TABLE FILE CAR
SUM
CNT.CAR/I5
AVE.DEALER_COST/D12.2
BY COUNTRY/A10
ON TABLE HOLD AS CAR_CNT FORMAT ALPHA
END
-RUN

-SET &LIMIT1 = &LINES;
-SET &I=1;
-REPEAT ENDLOOP_BEN &LIMIT1 TIMES
-READ CAR_CNT NOCLOSE &country.A10 &carcnt.A5 &temp.A7 &car_cost.A12
-SET &country.&I=&country;
-TYPE &country.&I
-SET &carcnt.&I=&carcnt;
-TYPE &carcnt.&I
-SET &car_cost.&I=&car_cost;
-TYPE &car_cost.&I
-SET &I=&I+1;
-ENDLOOP_BEN

TABLE FILE CAR
PRINT
CAR NOPRINT
ON TABLE PCHOLD FORMAT PDF
HEADING
"Grand Totals:"
" "
"Average Cost for Subscribers:"
" "
-BENCONTAGE1_C
"<+0><5 Country<+0><20 Average Cost "
" "
-SET &I=1;
-REPEAT ENDLOOP_BEN1_C &LIMIT1 TIMES
"<+0><5 <+0>&country.&I<+0><20 &car_cost.&I<+0>"
-SET &I = &I+1;
-ENDLOOP_BEN1_C
" "
"Count of Cars:"
" "
-BENCONTAGE1_C
"<+0><5 Country<+0><20 Count "
" "
-SET &I=1;
-REPEAT ENDLOOP_BEN2_C &LIMIT1 TIMES
"<+0><5 <+0>&country.&I<+0><20 &carcnt.&I<+0>"
-SET &I = &I+1;
-ENDLOOP_BEN2_C
END

In the above eg. I am taking count on cars and avg on dealer cost. I am displaying it as a part of heading in the PDF report. But suppose the number of heading lines exceeds the page, then it creates a problem, it starts displaying the calculated fields on the next page without any header space.
Instead of displaying these array variables in heading I want to display it as an part of data, so the problem will be resolved.
How can I assign array variable values as an field?
Please Help

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


Supriya
WF 7.7.02/8.0
 
Posts: 18 | Registered: November 16, 2011Report This Post
Gold member
posted Hide Post
Well this is one way if you must use parameter arrays (Output does not have any of the headings you have)

-SET &ECHO = ALL;
TABLE FILE CAR
SUM 
CNT.CAR/I5
AVE.DEALER_COST/D12.2
BY COUNTRY/A10 
ON TABLE HOLD AS CAR_CNT FORMAT ALPHA
END 
-RUN

-SET &LIMIT1 = &LINES;
-SET &I=1;
-REPEAT ENDLOOP_BEN &LIMIT1 TIMES
-READ CAR_CNT NOCLOSE &country.A10 &carcnt.A5 &temp.A7 &car_cost.A12
-SET &country.&I=&country;
-TYPE &country.&I
-SET &carcnt.&I=&carcnt;
-TYPE &carcnt.&I
-SET &car_cost.&I=&car_cost;
-TYPE &car_cost.&I
-SET &I=&I+1;
-ENDLOOP_BEN

DEFINE FILE CAR

-SET &TEMP=;
CAR_COST/D12.2=
-REPEAT :LOOP_DEF_COST FOR &I FROM 1 TO &LIMIT1
-SET &TEMP=IF &I.EVAL EQ 1 THEN 'IF COUNTRY EQ ''' | &country.&I | ''' THEN ' | &car_cost.&I ELSE 'ELSE IF COUNTRY EQ ''' | &country.&I | ''' THEN ' | &car_cost.&I;
&TEMP
-:LOOP_DEF_COST
ELSE 0;

CAR_CNT/I5=
-REPEAT :LOOP_DEF_CNT FOR &I FROM 1 TO &LIMIT1
-SET &TEMP=IF &I.EVAL EQ 1 THEN 'IF COUNTRY EQ ''' | &country.&I | ''' THEN ' | &carcnt.&I ELSE 'ELSE IF COUNTRY EQ ''' | &country.&I | ''' THEN ' | &carcnt.&I;
&TEMP
-:LOOP_DEF_CNT
ELSE 0;

END

TABLE FILE CAR
PRINT
CAR_COST
CAR_CNT
BY COUNTRY
BY CAR
END


However in the example above you can do the exact same thing using a multi verb request without using any parameters or arrays

TABLE FILE CAR
SUM 
CNT.CAR/I5 AS 'CAR_CNT'
AVE.DEALER_COST/D12.2 AS 'CAR_COST'
BY COUNTRY/A10 

PRINT
CAR
BY COUNTRY
END


WF: 8201, OS: Windows, Output: HTML, PDF, Excel
 
Posts: 78 | Registered: November 08, 2010Report This Post
Member
posted Hide Post
Thanks Crymsyn

But it doesn't solve my problem, as my calculation needs to have Heading like Grand Totals and all.
Is there any other solution?


Supriya
WF 7.7.02/8.0
 
Posts: 18 | Registered: November 16, 2011Report This Post
Expert
posted Hide Post
There is always a solution, it is just a case of finding it!

Try this -
FILEDEF OUTPUT DISK OUTPUT.FTM (APPEND
-RUN

DEFINE FILE CAR
  DATATYPE1/A10 = 'Cost';
  DATATYPE2/A10 = 'Count';
END

TABLE FILE CAR
  SUM CNT.CAR/D12.2 AS VALUE
   BY DATATYPE2
   BY COUNTRY
ON TABLE SET ASNAMES ON
ON TABLE SET HOLDLIST PRINTONLY
ON TABLE HOLD AS OUTPUT FORMAT ALPHA
END 
-RUN

TABLE FILE CAR
  SUM AVE.DEALER_COST/D12.2 AS VALUE
   BY DATATYPE1
   BY COUNTRY
ON TABLE SET ASNAMES ON
ON TABLE SET HOLDLIST PRINTONLY
ON TABLE HOLD AS OUTPUT FORMAT ALPHA
END 
-RUN

TABLE FILE OUTPUT
  SUM COMPUTE CFORMAT/A8 = DECODE DATATYPE1 ('Cost' 'D12.2' 'Count' 'I5' ELSE 'D5'); NOPRINT
      VALUE/CFORMAT AS ''
   BY DATATYPE1 NOPRINT SKIP-LINE
   BY COUNTRY AS ''
HEADING
"Grand Totals: </1"
ON DATATYPE1 SUBHEAD
"Count of Cars: </1"
"Country<+0>Count"
WHEN DATATYPE EQ 'Count'
ON DATATYPE1 SUBHEAD
"Average Cost for Subscribers: </1"
"Country<+0>Average Cost"
WHEN DATATYPE EQ 'Cost'
ON DATATYPE1 SUBFOOT
" "
ON TABLE SET PAGE NOLEAD
ON TABLE PCHOLD FORMAT PDF
ON TABLE SET STYLE *
TYPE=REPORT, HEADALIGN=BODY, $
TYPE=SUBHEAD, LINE=3, ITEM=2, JUSTIFY=RIGHT, $
ENDSTYLE
END


Or use the "new" compound reporting syntax.

T

This message has been edited. Last edited by: Tony A,



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 
 
Posts: 5694 | Location: United Kingdom | Registered: April 08, 2004Report This Post
Member
posted Hide Post
Thanks Tony

I got the solution of my problem through Compound Report (PDF NOBREAK).
I have around 5 calculation hold files which I am displaying back-to-back through PDF NOBREAK.
I have a logo which has to be displayed on the report top left. With NOBREAK if the report calculation goes to next page the logo isnt there and the data comes just attached to the top.I want the company logo to be on every page.
How would I come to know exactly where it goes to the next page?


Supriya
WF 7.7.02/8.0
 
Posts: 18 | Registered: November 16, 2011Report This Post
  Powered by Social Strata  

Read-Only Read-Only Topic

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [SOLVED] Array as Field

Copyright © 1996-2020 Information Builders