Focal Point Banner
Community Center Education Summit Technical Support User Groups
Let's Get Social!

Facebook Twitter LinkedIn YouTube
Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [CLOSED] Dynamic variable assignment
Go
New
Search
Notify
Tools
Reply
  
[CLOSED] Dynamic variable assignment
 Login/Join
 
Member
posted
Hi,
I need to assign variables dynamically as below. I will get the variable Name and Variable value in 2 different parameters and need to assign the value accordingly.

Code
========

-SET &VAR_NAME ='Fruit';
-SET &VAR_VALUE ='Apple';
-TYPE &Fruit

Expected Output
================
Apple

Please let me know how to achieve it.

Thanks

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


WebFOCUS 8

Windows, All Outputs
 
Posts: 16 | Registered: March 28, 2018Reply With QuoteReport This Post
Guru
posted Hide Post
quote:
-SET &VAR_NAME ='Fruit';
-SET &VAR_VALUE ='Apple';
-TYPE &Fruit


NOTE: Turn off prompting on your procedure and you will not need the DEFAULTH command.

 -DEFAULTH &Fruit = '_FOC_NULL'
-SET &VAR_NAME ='Fruit';
-SET &VAR_VALUE ='Apple';
-SET &VAR_NAME.EVAL = &VAR_VALUE;
-TYPE &Fruit 


WebFOCUS Administrator @ Worldpay FIS
PROD/DEV/TEST: 8204, SANDBOX: 8206 soon - BIP, Reportcaster, Resource Manager, EUM, HyperStage soon, DB: HIVE,Oracle,MSSQL
 
Posts: 291 | Location: Greater Cincinnati  | Registered: May 11, 2005Reply With QuoteReport This Post
Virtuoso
posted Hide Post
-SET &VAR_NAME = 'Fruit';
-SET &VAR_VALUE_.&VAR_NAME = 'Apple';
-TYPE &VAR_VALUE_Fruit


Autoprompt will want to know about &VAR_VALUE_Fruit though...


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 :
 
Posts: 1654 | Location: Enschede, Netherlands | Registered: August 12, 2010Reply With QuoteReport This Post
Member
posted Hide Post
quote:
Originally posted by Don Garland:
quote:
-SET &VAR_NAME ='Fruit';
-SET &VAR_VALUE ='Apple';
-TYPE &Fruit


NOTE: Turn off prompting on your procedure and you will not need the DEFAULTH command.

 -DEFAULTH &Fruit = '_FOC_NULL'
-SET &VAR_NAME ='Fruit';
-SET &VAR_VALUE ='Apple';
-SET &VAR_NAME.EVAL = &VAR_VALUE;
-TYPE &Fruit 


Hi Don ,
I duno the parameter name at all since thats dynamic then how do I set the below
-DEFAULTH &Fruit = '_FOC_NULL'


WebFOCUS 8

Windows, All Outputs
 
Posts: 16 | Registered: March 28, 2018Reply With QuoteReport This Post
Virtuoso
posted Hide Post
SridharLakshmipathy

It is confusing as to where this parameter name is being set dynamically. Is it in a html form or where does this happen. Parameter names should not be set dynamically, the values they contain can be but not the actual parameter name itself.


Thank you for using Focal Point!

Chuck Wolff - Focal Point Moderator
WebFOCUS 7x and 8x, Windows, Linux All output Formats
 
Posts: 1749 | Location: Customer Support | Registered: April 12, 2005Reply With QuoteReport This Post
Member
posted Hide Post
quote:
Originally posted by FP Mod Chuck:
SridharLakshmipathy

It is confusing as to where this parameter name is being set dynamically. Is it in a html form or where does this happen. Parameter names should not be set dynamically, the values they contain can be but not the actual parameter name itself.


FP Mod Chuck,
If you look at my example , you can see &VAR_NAME ='Fruit' i.e. the parameter name is Fruit which will come in VAR_NAME variable.


WebFOCUS 8

Windows, All Outputs
 
Posts: 16 | Registered: March 28, 2018Reply With QuoteReport This Post
Master
posted Hide Post
Hi,

or this:
-SET &ECHO = ALL;

-SET &VAR_NAME = 'fruit'; 
-SET &VAR_VALUE_.&VAR_NAME = 'apple'; 

-TYPE &VAR_VALUE_fruit


but here also. You need to turn of auto-prompt.

The real question is : Why do you need this? It will be almost impossible to write code for variables with variable names.

What are you trying to achieve?


_____________________
WF: 8.0.0.9 > going 8.2.0.5
 
Posts: 669 | Location: Veghel, The Netherlands | Registered: February 16, 2010Reply With QuoteReport This Post
Member
posted Hide Post
quote:
Originally posted by Dave:
Hi,

or this:
-SET &ECHO = ALL;

-SET &VAR_NAME = 'fruit'; 
-SET &VAR_VALUE_.&VAR_NAME = 'apple'; 

-TYPE &VAR_VALUE_fruit


but here also. You need to turn of auto-prompt.

The real question is : Why do you need this? It will be almost impossible to write code for variables with variable names.

What are you trying to achieve?


Hi Dave,
Thank you, but I need to do without auto prompting.
Below is the example of what I want to achieve. I will get the dynamic request parameters from java like below. so I need to read variable values from the request params only.

1) /ibi_apps/WFservlet?IBIF_ex=general&IBIAPP_app=baseapp&VAR_NAME=Fruit&VAR_VALUE=Apple&Application=1

2) /ibi_apps/WFservlet?IBIF_ex=general&IBIAPP_app=baseapp&VAR_NAME=Animal&VAR_VALUE=Tiger&Application=2

3) /ibi_apps/WFservlet?IBIF_ex=general&IBIAPP_app=baseapp&VAR_NAME=Bird&VAR_VALUE=pigeon&Application=3


general.fex
################
-IF &Application EQ '1' THEN APP1 ELSE APP2;
-APP1
-INCLUDE APP1
-GOTO ENDAPP
-APP2
-IF &Application EQ '3' THEN APP3;
-INCLUDE APP2
-GOTO ENDAPP
-APP3
-INCLUDE APP3
-ENDAPP

APP1.fex
##########
-TYPE &Fruit

APP2.fex
##########
-TYPE &Animal

APP3.fex
##########
-TYPE &Bird

Thanks


WebFOCUS 8

Windows, All Outputs
 
Posts: 16 | Registered: March 28, 2018Reply With QuoteReport This Post
Virtuoso
posted Hide Post
As far as I can see you don't need different variable's name.

Each Appx.fex can use the same variable's name, only the assigned value is important.
It doesn't matter that a variable named &MY_VAR contains either a fruit's name, an animal's name or a bird's name. You're making your request too complicated for nothing.
If you need to know the content "type" then have one variable to receive the type (VAR_TYPE : fruit, animal, bird) and one for the kind (VAR_VALUE : apple, tiger, pigeon).


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: 2282 | Location: Montreal Area, Qc, CA | Registered: September 25, 2013Reply With QuoteReport This Post
Guru
posted Hide Post
It looks like you need to determine the "category" of &VAR_NAME before you launch a procedure? Why is that? Not knowing why you want to do this, but here is what I would to with your traffic control logic.

general.fex
################

-GOTO &VAR_NAME


-APP1
-INCLUDE APP1
-GOTO ENDAPP

-APP2
-INCLUDE APP2
-GOTO ENDAPP

-APP3
-INCLUDE APP3

-ENDAPP


WebFOCUS Administrator @ Worldpay FIS
PROD/DEV/TEST: 8204, SANDBOX: 8206 soon - BIP, Reportcaster, Resource Manager, EUM, HyperStage soon, DB: HIVE,Oracle,MSSQL
 
Posts: 291 | Location: Greater Cincinnati  | Registered: May 11, 2005Reply With QuoteReport This Post
Member
posted Hide Post
quote:
Originally posted by MartinY:
As far as I can see you don't need different variable's name.

Each Appx.fex can use the same variable's name, only the assigned value is important.
It doesn't matter that a variable named &MY_VAR contains either a fruit's name, an animal's name or a bird's name. You're making your request too complicated for nothing.
If you need to know the content "type" then have one variable to receive the type (VAR_TYPE : fruit, animal, bird) and one for the kind (VAR_VALUE : apple, tiger, pigeon).


Hi Martin,
I agree but the APP1, APP2 and APP3 applications already built and we have more than 1000 lines of code. I dont want to revisit the 1000 lines of code again to have unique variable name..

Thanks,


WebFOCUS 8

Windows, All Outputs
 
Posts: 16 | Registered: March 28, 2018Reply With QuoteReport This Post
Member
posted Hide Post
quote:
Originally posted by Don Garland:
It looks like you need to determine the "category" of &VAR_NAME before you launch a procedure? Why is that? Not knowing why you want to do this, but here is what I would to with your traffic control logic.

general.fex
################

-GOTO &VAR_NAME


-APP1
-INCLUDE APP1
-GOTO ENDAPP

-APP2
-INCLUDE APP2
-GOTO ENDAPP

-APP3
-INCLUDE APP3

-ENDAPP


Hi Don,
We are not only routing the fex traffic based on the category, we need to assign the variable values dynamically


WebFOCUS 8

Windows, All Outputs
 
Posts: 16 | Registered: March 28, 2018Reply With QuoteReport This Post
Platinum Member
posted Hide Post
Maybe this will work for you. I tested the following code in WebFOCUS 8.2.x

-DEFAULTH &VAR_NAME  = 'Fruit';
-DEFAULTH &VAR_VALUE = 'Apple';

-SET &.&VAR_NAME = &VAR_VALUE;

-? &Fruit

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


WF 8.2.06
Win10 / IE11
AHTML EXL2K PDF
 
Posts: 147 | Registered: October 19, 2010Reply With QuoteReport This Post
Guru
posted Hide Post
quote:
Hi Don,
We are not only routing the fex traffic based on the category, we need to assign the variable values dynamically


Right, but isn't it true, that once you've determined the category (app name) then you know what variable names must exist to make that work?


WebFOCUS Administrator @ Worldpay FIS
PROD/DEV/TEST: 8204, SANDBOX: 8206 soon - BIP, Reportcaster, Resource Manager, EUM, HyperStage soon, DB: HIVE,Oracle,MSSQL
 
Posts: 291 | Location: Greater Cincinnati  | Registered: May 11, 2005Reply With QuoteReport This Post
Member
posted Hide Post
quote:
Originally posted by Don Garland:
quote:
Hi Don,
We are not only routing the fex traffic based on the category, we need to assign the variable values dynamically


Right, but isn't it true, that once you've determined the category (app name) then you know what variable names must exist to make that work?


Hi Don,
Yes, we shall be able to identify the category and list of variables used in it . if so we need use -SET DEFAULTH for all variables used in all apps .


WebFOCUS 8

Windows, All Outputs
 
Posts: 16 | Registered: March 28, 2018Reply With QuoteReport This Post
Guru
posted Hide Post
quote:
-SET DEFAULTH for all variables used in all apps .



There are couple of ways to approach the DEFAULT(H) issue.

1. Right click on the procedures and set the Prompt for Parameters to 'NO'.

2. If you need default values for your parameters, then create an include file that has all of the variable names and their defaults and add that to the top of your procedures. You can set defaults for all the variables you want, even if you don't use them and it's a great way to keep track of all the variables that you create.


WebFOCUS Administrator @ Worldpay FIS
PROD/DEV/TEST: 8204, SANDBOX: 8206 soon - BIP, Reportcaster, Resource Manager, EUM, HyperStage soon, DB: HIVE,Oracle,MSSQL
 
Posts: 291 | Location: Greater Cincinnati  | Registered: May 11, 2005Reply With QuoteReport This Post
Virtuoso
posted Hide Post
In each APPx.fex you can add the following.
So you keep the var's name as they are in each fex but with no need to have dynamic var name assignation

-* APP1.fex
-SET &Fruit = &VAR_VALUE;
-TYPE &Fruit

-* APP2.fex
-SET &Animal = &VAR_VALUE;
-TYPE &Animal

-* APP3.fex
-SET &Bird = &VAR_VALUE;
-TYPE &Bird


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: 2282 | Location: Montreal Area, Qc, CA | Registered: September 25, 2013Reply With QuoteReport This Post
  Powered by Social Strata  
 

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [CLOSED] Dynamic variable assignment

Copyright © 1996-2018 Information Builders, leaders in enterprise business intelligence.