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] Keep a variable as macro variable

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[SOLVED] Keep a variable as macro variable
 Login/Join
 
Member
posted
Hi,

To begin i would lik eto apologize for my bad English, i try to do my best but sorry for the erros :-).

So, what i want to do don't seem to be difficult, but i didnt have a big formation on focus so to me it's a big problem.

I would like to keep value on a variable i have in a table to use it as a macro variable on the rest of my code.

This is an exemple :

TABLE FILE mytable
PRINT VAR1 VAR2 VAR3
END

How may i keep the value of VAR1 in a macro variable (&mavar) to use it on an other table.

i tried with a define like that :

DEFINE FILE mytable
-SET &MAVAR = VAR1;
END

TABLE FILE mytable
..END

But infortunately, &mavar returne 'VAR1' instead of the value of VAR1.

I hope i am enough clear

Thks a lot for your help!

Cedric

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


WebFocus 8.2, Windows
 
Posts: 13 | Registered: August 09, 2019Report This Post
Virtuoso
posted Hide Post
  
-SET &VAR1='COUNTRY';
TABLE FILE CAR
PRINT CAR
BY &VAR1
END


https://infocenter.information...%2Fsource%2Fdm64.htm


WebFOCUS 8206, Unix, Windows
 
Posts: 1853 | Location: New York City | Registered: December 30, 2015Report This Post
Virtuoso
posted Hide Post
TABLE FILE myTable
PRINT VAR1 VAR2 VAR3
-* Assuming that myTable only has one record, no need to perform a filter (WHERE) otherwise multiple lines will be returned
WHERE myTable.myFld EQ cond;
ON TABLE HOLD AS TMP
END
-RUN

-READFILE TMP
-RUN
-* TO AVOID VARIABLE'S PROMPTING
-DEFAULTH &VAR1 = ''
-DEFAULTH &VAR2 = ''
-DEFAULTH &VAR3 = ''

TABLE FILE oTable
PRINT ABC
BY XYZ
WHERE oTable.tstFld1 EQ &VAR1;
WHERE oTable.tstFld2 EQ &VAR2;
WHERE oTable.tstFld3 EQ &VAR3;
END
-RUN


WF versions : Prod 8.2.04M gen 33, Dev 8.2.04M gen 33, OS : Windows, DB : MSSQL, Outputs : HTML, Excel, PDF
In Focus since 2007
 
Posts: 2409 | Location: Montreal Area, Qc, CA | Registered: September 25, 2013Report This Post
Virtuoso
posted Hide Post
Kykyn

First of all welcome to Focal Point. It is a great place to get answers to your development questions.

If you want these variables to be available to other reports run in the same user session then you will need to use global variarbles with 2 &&'s

-SET &&VAR1 = 'COUNTRY'


Thank you for using Focal Point!

Chuck Wolff - Focal Point Moderator
WebFOCUS 7x and 8x, Windows, Linux All output Formats
 
Posts: 2127 | Location: Customer Support | Registered: April 12, 2005Report This Post
Member
posted Hide Post
HI,

Thanks a lot for your answers.
But, unfortunately, i think i didnt have explained correctly my problem :-)

So, to begin i have a table in which one i count the number of lines :

TABLE FILE STEP1
SUM CNT.MYVAR
END

I would like to keep the value of my count in a dialogue manager variable, in order to use it later in my code.
For example, we say there is 10 lines in my table STEP1
I need this value to make a loop on an other table.
As there is 10 lines in STEP1, i need to do a 10 times loop...

I hope this time my explanations are clear :-)

Thks
Ced


WebFocus 8.2, Windows
 
Posts: 13 | Registered: August 09, 2019Report This Post
Member
posted Hide Post
Finally, after having looking it for a while in the forum, i found what i wanted!!

http://forums.informationbuild...327037906#7327037906

Thks a lot!!


WebFocus 8.2, Windows
 
Posts: 13 | Registered: August 09, 2019Report This Post
Member
posted Hide Post
So, Unfortunately, my last answer make me to come back with an other question...

In the beginning of my code i have kept then number of distinct variable (nb of towns)

TABLE FILE TOWNS
SUM
CNT.DST.TOWNS
ON TABLE SAVE
END
-RUN
-READ SAVE &CNT_TOWNS.I9.
-TYPE &CNT_TOWNS

==> i have 5 towns so the value of &CNT_TOWS is 5


And now, i work with another table, which contains the name of roads.
theres are 10 lines in this table with 10 distinct values.

For each of these 10 distinct values, i would having on my final table, 5 lines (&CNT_TOWNS) with the same value (name of road). So i will have finally 50 lines in my table.

I m sure ma ask is not very clear so this is an exemple :

&COD_FED_CNT = 5

Table ROAD
NAME_OF_ROAD
Name1
Name2
Name3
Name4
Name5
Name6
Name7
Name8
Name9
Name10

Table ROAD2 (5 Lines per distinct road)
NAME_OF_ROAD2
Name1
Name1
Name1
Name1
Name1
...
Name10
Name10
Name10
Name10
Name10


I tried to do that with a loop, but i dont know how to write in my table at each loop.

If i do that :

DEFINE FILE ROAD

-SET &CPT=1;
-MALOOP

NAME_OF_ROAD2/A30 = NAME_OF_ROAD;

-SET &CPT=&CPT+1;
-IF (&CPT GT &CNT_TOWNS) THEN GOTO FINLOOP;
-GOTO MALOOP
-FINLOOP

END

TABLE FILE ROAD
PRINT
NAME_OF_ROAD2
END


==> I have only 10 lines because the data are written only at the end of the loop.

thks a lot for your help


WebFocus 8.2, Windows
 
Posts: 13 | Registered: August 09, 2019Report This Post
Virtuoso
posted Hide Post
Yes, it's not clear what you are attempting to perform.

What are you trying to perform :
- have each Road with their Town ?
- repeat each Road's name as many time you have Town ? So, as you stated : you have 5 Towns and 10 Roads so you want 5 X 10 = 50 lines in output.

Can you just JOIN the two tables together ?
If no commun field exist between the two tables, you can JOIN them using a Dummy field such as below

-*-* TMP1 includes up to 5 Countries
TABLE FILE CAR
BY TOTAL COMPUTE DUMMY /I1 = 1;
BY COUNTRY
WHERE RECORDLIMIT EQ 5;
ON TABLE HOLD AS TMP1
END

-*-* TMP2 includes up to 10 Cars
TABLE FILE CAR
BY TOTAL COMPUTE DUMMY /I1 = 1;
BY CAR
WHERE RECORDLIMIT EQ 10;
ON TABLE HOLD AS TMP2
END

-*-* Since TMP1 and TMP2 have no commun field, we use a DUMMY one to create a JOIN and produce cartesian result
JOIN   DUMMY IN TMP1 TAG T1
TO ALL DUMMY IN TMP2 TAG T21 AS J1
END

TABLE FILE TMP1
BY CAR
BY COUNTRY
END
-RUN



As a note : always use the code tag when posting sample code and/or data
It's the last icon on the ribbon that looks like the below
</>


WF versions : Prod 8.2.04M gen 33, Dev 8.2.04M gen 33, OS : Windows, DB : MSSQL, Outputs : HTML, Excel, PDF
In Focus since 2007
 
Posts: 2409 | Location: Montreal Area, Qc, CA | Registered: September 25, 2013Report This Post
Member
posted Hide Post
Yes it was the second choice.

Finally, i did it with a concatenation.

One more time, thks all for your help


WebFocus 8.2, Windows
 
Posts: 13 | Registered: August 09, 2019Report 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] Keep a variable as macro variable

Copyright © 1996-2020 Information Builders