Dynamic String names
I want to dynamically name strings for the purpose of passing their value back to a jsp, but am not quit sure how to approach this.
for (int i = 0; i < products.size(); i++)
MyProducts temp = (MyProducts)products.get(i);
if (temp.getName().equals("DVD"))
String product + (i) = true;The product + (i) part is what I am trying to accomplish, and I know what I have in the code is not correct. I want to dynamically name a string (ex: product1 or product2) according to the variable iteration of the loop.
Would anyone have a clue how to accomplish this?
ty
its impossible to create such strings.
An alternative : use a map in which you put keys and values like the following :
Map map = new HashMap();
for (int i = 0; i < products.size(); i++)
MyProducts temp = (MyProducts)products.get(i);
if (temp.getName().equals("DVD"))
map.put("product"+i, "true");
Similar Messages
-
How to change recordset bahaviour to accept dynamic column names in the where clause
Hi
im using php-mysql and i make a recordset and i want to make the column names in the where clause to be dynamic like
"select id,name from mytable where $tablename-$myvar";
but when i do this my i break the recordset and it disappear
and when i use variables from advanced recordset it only dynamic for the value of the column not for the column name
and when i write the column name to dynamic as above by hand it truns a red exclamation mark on the server behaviour panel
so i think the only way is to change the recordset behaviour is it? if so How to make it accept dynamic column names?
thanks in advance.As bregent has already explained to you, customizing the recordset code will result in Dreamweaver no longer recognizing the server behavior. This isn't a problem, but it does mean that you need to lay out your dynamic text with the Bindings panel before making any changes. Once you have changed the recordset code, the Bindings panel will no longer recognize the recordset fields.
Using a variable to choose a column name is quite simple, but you need to take some security measures to ensure that the value passed through the query string isn't attempting SQL injection. An effective way of doing this is to create an array of acceptable column names, and check that the value matches.
// create array of acceptable values
$valid = array('column_name1', 'column_name2', 'column_name3');
// if the query string contains an acceptable column name, use it
if (isset($_GET['colname']) && in_array($_GET['colname'], $valid)) {
$col = $GET['colname'];
} else {
// set a default value if the submitted one was invalid
$col = 'column_name1'
You can then use $col directly in the SQL query. -
Hi,
I am following this blog to name the target file/directory dynamically at the runtime :
/people/sameer.shadab/blog/2005/09/23/an-interesting-usage-of-variable-substitution-in-xi
But I am getting this error in the CC monitoring :
Could not process due to error: com.sap.aii.adapter.file.configuration.DynamicConfigurationException: Error during variable substitution: com.sap.aii.adapter.file.varsubst.VariableDataSourceException: Unknown message header category 'interface_name ' for variable 'var1'.Hi,
Try following this weblog for dynamic file name.
/people/michal.krawczyk2/blog/2005/11/10/xi-the-same-filename-from-a-sender-to-a-receiver-file-adapter--sp14
Dynamic filename come under the Dynamic configuration in moni, for your messages.
This is the code used inside.
DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","FileName");
String ourSourceFileName = conf.get(key);
return ourSourceFileName;
That is why Dynamic configuration is coming in output.. It is a class to generate dynamic configuration file at runtime provided by SAP XI.
Hope this will help you.
regards
Aashish Sinha
PS : reward points if helpful -
Hi Master,
I written the UDF for Getting the Dynamic File name.
DynamicConfiguration conf = (DynamicConfiguration) container.getParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","FileName");
// Retrieve the filename
String FileName = conf.get(key);
This is working ok - but I want to return these values so I can be used in mapping.
when I try to add the statement return FileName; , the compiler then complains with the following error:
cannot return a value from method whose result type is void return FileName;
Please help me,
Thanks,
AnuThanks Nithiyanandam,
I am using the Same code. But i am getting the Syntax error:
Source code has syntax error: E:/usr/sap/DX1/DVEBMGS01/j2ee/cluster/server0/./temp/classpath_resolver/Mapaf708c00d6bb11dd83ee00101816a382/source/com/sap/xi/tf/_MM_I_FF_O_RFC_.java:13: cannot resolve symbol symbol : class variable location: class com.sap.xi.tf._MM_I_FF_O_RFC_ variable a; ^ 1 error
UDF Name: FileName
while creating the UDF, I select the first radio button(Value). not Context and Queue.
I written the below code.
DynamicConfiguration conf = (DynamicConfiguration) container
.getTransformationParameters()
.get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
DynamicConfigurationKey key = DynamicConfigurationKey.create(
"http://sap.com/xi/XI/System/File",
"FileName");
String FileName = conf.put(key, a);
return FileName;
Thanks,
ANU -
Xml file in dynamic file name in file receiver adapter
Hi,
I'm doing the dynamic file name in file receiver adapter. I have done as per instructed in /people/jayakrishnan.nair/blog/2005/06/20/dynamic-file-name-using-xi-30-sp12-part--i
All turned out okay. I have got the file name I require. Except that the file format is XML and I need to suppress the filename node occupied by the dynamic file name.
The content conversion mentioned in /people/sravya.talanki2/blog/2005/08/11/solution-to-the-problem-encountered-using-variable-substitution-with-xi-sp12, does not seem to solve my problem. As it is only for file format other than the XML one, because we only do the content conversion if we want to "convert" the format of the content from XML to the other format.
Does anybody have the solution to my problem? thanks in advanceThank you Raj for the direction
The way to do it is :
1. In ID, advanced tab, put a check on the adapter-specific message attributes - file name.
2. Put a "*" on the file name scheme
3. In IR, create a UDF to set up target file name :
DynamicConfiguration conf = (DynamicConfiguration) container
.getTransformationParameters()
.get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","FileName");
// set up file name for receiver adapter
String SourceFileName = conf.get(key);
conf.put(key, TargetFileName);
return " ";
4. Map the above UDF to the header level of the target structure.
Regards,
Idi -
File Adapter: Dynamic file name
Hello,
I would like to use a filename like this:
Name.<DOCNUM>.Direction.<Timestamp>
For DOCNUM I use variable substitution. Works fine.
For <Timestamp> I need a different format as the timestamp function
in file adapter create. So I try to set up my timestamp in mapping like
dynamic file name:
DynamicConfigurationKey key1 = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File", "Timestamp");
conf.put(key1, a);
Input a is date function which creates my desired timestamp format. In file adapter I try this:
Name.%DOCNUM%.Direction.%Timestamp%
or
Name.%DOCNUM%.Direction.Timestamp
or
Timestamp
all doesn't work for Timestamp.
So is there a possibility to configure a dynamic filename like this???
Is there a possibility to access dynamic configuration variables in dynamic filename except
the known for filename and directory??
thanks
chris
Edited by: Christian Riekenberg on Mar 10, 2009 4:02 PM
Edited by: Christian Riekenberg on Mar 10, 2009 4:05 PMyour file name needs to be
Name.<DOCNUM>.Direction.<Timestamp>
dont use variable substitution. use only dynamic configuration and set the file name
introduce a logic that will create the string
Name.<DOCNUM>.Direction.<Timestamp>
eg. String filename = "Name" + var_docnum + "Direction" + var_timestamp;
then use the dynamic conf code to set the file name and use adapter specific properties in you adapter to retrieve it.
Ref:
/people/michal.krawczyk2/blog/2005/11/10/xi-the-same-filename-from-a-sender-to-a-receiver-file-adapter--sp14
http://help.sap.com/saphelp_nw04/helpdata/en/43/03612cdecc6e76e10000000a422035/frameset.htm -
Dynamic file name(Context)
Hello All,
I am using Dynamic file name function in my message mapping. Below is the code that I am using inside UDF:
DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","FileName");
String fileName = conf.get(key);
return fileName;
Now the questions is as per my requirement, I need to generate multiple file names. Can some one help me how can change the above code for catering multiple returns
Thanks
Regards
MoorthyHello,
Now the questions is as per my requirement, I need to generate multiple file names. Can some one help me how can change the above code for catering multiple returns
If you are using multi-mapping (0..n), only one will be accessed. See link below from SAP Help
http://help.sap.com/saphelp_nw70/helpdata/EN/43/09b16006526e72e10000000a422035/frameset.htm
Or you can use variable substitution for filename generation (search in SDN).
Hope this helps,
Mark -
Dynamic file Name Generation-problem
Hi Friends..
in My Idoc to File..
i want to generate Dynamic File Name ..
i put the logic in Message mapping -java intialization section
Container container = null;
SimpleDateFormat simpledatFormat = new SimpleDateFormat("yyyyMMdd");
Date date = new Date();
String datewithYear = simpledatFormat.format(date);
SimpleDateFormat simpledatFormat1 = new SimpleDateFormat("HHmmss");
Date date1 = new Date();
String datewithMs = simpledatFormat1.format(date1);
DynamicConfiguration conf = ((DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION));
DynamicConfigurationKey key = DynamicConfigurationKey.create("http:/"+"/"+"sap.com"+"/"+"xi"+"/"+"XI"+"/"+"System"+"/"+"File" , "FileName");
String oldFileName=conf.get(key);
String valueNew;
if( oldFileName == null){
valueNew = "HRXML"+datewithYear+datewithMs+".xml";
else{
valueNew =oldFileName+datewithYear+datewithMs+".xml";
//set the new filename
conf.put(key, valueNew);
and i did in reciever File adaper adaper specific settings..
i am getting error sxmb_moni..
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
- <!-- Request Message Mapping
-->
- <SAP:Error xmlns:SAP="http://sap.com/xi/XI/Message/30" xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/" SOAP:mustUnderstand="1">
<SAP:Category>Application</SAP:Category>
<SAP:Code area="MAPPING">EXCEPTION_DURING_EXECUTE</SAP:Code>
<SAP:P1>com/sap/xi/tf/_ZHRMD5_to_HRMasterData_MM_</SAP:P1>
<SAP:P2>com.sap.aii.utilxi.misc.api.BaseRuntimeException</SAP:P2>
<SAP:P3>java.lang.NullPointerException</SAP:P3>
<SAP:P4 />
<SAP:AdditionalText />
<SAP:ApplicationFaultMessage namespace="" />
<SAP:Stack>com.sap.aii.utilxi.misc.api.BaseRuntimeException thrown during application mapping com/sap/xi/tf/_ZHRMD5_to_HRMasterData_MM_: java.lang.NullPointerException</SAP:Stack>
<SAP:Retry>M</SAP:Retry>
</SAP:Error>
if we remove the dynamic File configuration logic in message mapping ..i am getting the result..
please guide me..Container container = null;
DynamicConfiguration conf = ((DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION));
bound to get a NPE as your variable container is not getting intialized to a valid object ref here... -
Dynamic table name, how to query?
Hi!
There is a table name that is decided dynamically. the name is:
someNameYYY where YYY denotes the client number.
I get the client number by sy-mandt and concatenate it with someNameYYY to lc_table_name but then comes the problem:
I cannot do
SELECT *
FROM lc_table_name
because I get compiler error "lc_table_name" is not defined in ABAP dictionary.
How do I query a table with the name decided dynamically?
regards
BaranYou can have do something like this :
REPORT ZTABLE_DOWNLOAD .
tables :
dd02l, "SAP Tables
dd03l, "Table fields
dd04t. "R/3 DD: Data element texts
constants : c_activation_status(1) value 'A',
c_tabclass(6) type c value 'INTTAB',
c_language(2) type c value 'EN'.
type-pools : slis.
selection-screen begin of block b1 with frame title text-003.
*parameters :p_mandt like t001-mandt obligatory default '560'.
parameters :p_table like dd03l-tabname obligatory.
selection-screen end of block b1.
data:
table_desc(70) type c,
table_field like dd03l-fieldname,
total_rows type i,
t_rows(20) type c.
field-symbols:
<fs_line> type any,
<fs_field> type any.
at selection-screen.
*Check for the existence of the table
select single * from dd02l where tabname = p_table
and as4local = c_activation_status.
if sy-subrc ne 0.
*Table is not active in dictionary
message e999(zs) with 'Table is not active in dictionary'.
elseif dd02l-tabclass = c_tabclass.
*It is a structure not a table
message e999(zs) with 'This is a structure not a table'.
endif.
start-of-selection.
perform table_data_display.
end-of-selection.
form table_data_display.
data:
l_long_type type i,
lx_struct type ref to data,
lt_table type ref to data,
lcl_sdescr type ref to cl_abap_structdescr,
lx_lvc_cat type lvc_s_fcat,
lt_lvc_cat type lvc_t_fcat, "Field catalog
lx_fieldcat type slis_fieldcat_alv,
lt_fieldcat type slis_t_fieldcat_alv,
lx_layout type slis_layout_alv,
lt_sort type slis_t_sortinfo_alv, "Sort table
ls_sort type slis_sortinfo_alv.
field-symbols :
<fieldcat> type slis_fieldcat_alv,
<lt_table> type table,
<fs> type any,
<components> type abap_compdescr.
*Dynamic creation of a structure
create data lx_struct type (p_table).
assign lx_struct->* to <fs>.
*Get the field structure
lcl_sdescr ?= cl_abap_typedescr=>describe_by_data( <fs> ).
loop at lcl_sdescr->components assigning <components>.
*Do not display field "MANDT"
IF sy-tabix = 1 AND <components>-name = 'MANDT'.
CONTINUE. "next loop
ENDIF.
*Build fieldcatalog
lx_lvc_cat-fieldname = <components>-name.
lx_lvc_cat-ref_table = p_table.
append lx_lvc_cat to lt_lvc_cat.
lx_fieldcat-fieldname = <components>-name.
lx_fieldcat-ref_tabname = p_table.
append lx_fieldcat to lt_fieldcat.
endloop.
*Create an internal table
call method cl_alv_table_create=>create_dynamic_table
exporting it_fieldcatalog = lt_lvc_cat
importing ep_table = lt_table.
assign lt_table->* to <lt_table>.
*Read the data
select * from (p_table)
into corresponding fields of table <lt_table>
order by primary key.
loop at <lt_table> assigning <fs_line>.
assign component 'MANDT' of
structure <fs_line> to <fs_field>.
<fs_field> = p_mandt.
endloop.
if <lt_table>[] is initial.
*No table enties are existing
message e003(zdynamictable) with p_table.
exit.
else.
describe table <lt_table>[] lines total_rows.
t_rows = total_rows.
shift t_rows left deleting leading space.
endif.
*Specify the layout
lx_layout-zebra = 'X'.
lx_layout-colwidth_optimize = 'X'.
*Display the ALV List
select single ddtext into table_desc from dd02t
where tabname eq p_table and ddlanguage eq c_language.
check not table_desc is initial.
concatenate 'Entries from table:'
p_table '(' table_desc ')' '-:' t_rows 'Entries Found' into
table_desc
separated by space.
*Start - Download the data to excel sheet by validating the file path.
data:
*lv_filename type string,
lv_fname_validate like rlgrap-filename.
*CONCATENATE 'C:\ZTABLE_DWN\' P_TABLE '.Xls' INTO LV_FILENAME.
*CONCATENATE '
Pc-p31061\Harman\Tasks\ZTABLE_DWN\' P_TABLE '.xls' INTO
CONCATENATE 'C:\ZTABLE_DWN\' P_TABLE '.xls' INTO
LV_FNAME_VALIDATE.
call function 'WS_FILE_DELETE'
exporting
file = lv_fname_validate
IMPORTING
RETURN =
CALL FUNCTION 'WS_DOWNLOAD'
EXPORTING
BIN_FILESIZE = ' '
CODEPAGE = ' '
FILENAME = LV_FNAME_VALIDATE
FILETYPE = 'DAT'
IMPORTING
FILELENGTH =
TABLES
DATA_TAB = <lt_table>.
*call function 'GUI_DOWNLOAD'
exporting
BIN_FILESIZE =
filename = lv_fname_validate
filetype = 'ASC'
write_field_separator = 'X'
IMPORTING
FILELENGTH =
tables
data_tab = <lt_table>.
End of Download.
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_background_id = 'ALV_BACKGROUND'
i_grid_title = table_desc
is_layout = lx_layout
it_fieldcat = lt_fieldcat
tables
t_outtab = <lt_table>
exceptions
program_error = 1
others = 2
if sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
clear table_desc.
endform. " table_data_display -
Dynamic Variable Names in OpenScript
Is there a way to use dynamic variable names? What I mean by this is that the variable name in the file could be:
Name1, Name2, Name3, etc.
I may want to loop through these by saying something like:
For i = 0; i < iLoop; i++
String sFieldName = "{{ViewList.Name" + Integer.toString(i) + "}}";
JOptionPane.showMessageDialog(null, "sFieldName: " + "{{ViewList.{{sFieldName}}}}");
I don't want it to use the literal string of {{ViewList.Name1}}, but rather, I want to use the value from the DataBank for Name1. Thanks.
-JohnNishanth,
Thanks for your suggestion. Unfortunately, this is not a simple variable replacement. I want the name of the variable to be dynamic in nature. Imagine that I have 5 variables in the files named:
Name
FoodPref1
FoodPref2
FoodPref3
FoodPref4
I would like to loop through these and construct the variable name dynamically so it would be something similar to:
for i=1 to 4; i++
sFoodPrefVar = "FoodPref" + i;
getVariables().set("FoodPref",sFoodPrefVar);
JOptionPane.showMessageDialog(null, "Your Food Pref is: " + {{FoodPref}} + "\n");
This is pseudo code, but it would theoretically loop through the 4 food preferences. Thanks.
-John -
Dynamic table name in native SQL
Hi,
How can i use dynamic table name in native SQL?
My req is to select data from a external database table , but the table name will be only poulated during runtime.
How can i acheive this?
Regards,
Arun.It should work OK - see demo below.
Jonathan
report zsdn_jc_adbc_test.
start-of-selection.
perform demo_lookup.
form demo_lookup.
data:
l_error_msg type string,
ls_t001 type t001, "Company
ls_t003 type t003. "Doc types
perform dynamic_lookup
using
'T001'
changing
ls_t001
l_error_msg.
write: / l_error_msg.
perform dynamic_lookup
using
'T003'
changing
ls_t003
l_error_msg.
write: / l_error_msg.
endform.
form dynamic_lookup
using
i_tabname type tabname
changing
os_data type any
o_error_msg type string.
* Use ADBC to select data
data:
l_mandt_ref type ref to data,
l_result_ref type ref to data,
l_mandt type symandt,
l_tabname type tabname,
l_sql_statement type string,
lo_cx_root type ref to cx_root,
lo_cx_sql type ref to cx_sql_exception,
lo_connection type ref to cl_sql_connection,
lo_statement type ref to cl_sql_statement,
lo_result_set type ref to cl_sql_result_set.
clear: os_data, o_error_msg.
get reference of l_mandt into l_mandt_ref.
get reference of os_data into l_result_ref.
l_mandt = '222'. "i.e. select from client 222
l_tabname = i_tabname.
try.
lo_connection = cl_sql_connection=>get_connection( ).
lo_statement = lo_connection->create_statement( ).
* Set criteria for select:
lo_statement->set_param( l_mandt_ref ).
concatenate
'select * from' l_tabname
'where mandt = ?'
into l_sql_statement separated by space.
* Execute
call method lo_statement->execute_query
exporting
statement = l_sql_statement
hold_cursor = space
receiving
result_set = lo_result_set.
* Get the data from the resultset.
lo_result_set->set_param_struct( l_result_ref ).
while lo_result_set->next( ) > 0.
write: / os_data.
endwhile.
* Tidy up:
lo_result_set->close( ).
lo_connection->close( ).
catch cx_sql_exception into lo_cx_sql.
o_error_msg = lo_cx_sql->get_text( ).
catch cx_root into lo_cx_root.
o_error_msg = lo_cx_root->get_text( ).
endtry.
endform. -
Dynamic Table name in Inner Join in 4.6c
data: tab1(10) type c value 'MARA',
tab2(10) type c value 'MAKT'.
data: dbtab1(10) type c,
dbtab2(10) type c .
dbtab1 = tab1.
dbtab2 = tab2.
DATA: BEGIN OF itab occurs 0,
matnr TYPE mara-matnr,
maktx type makt-maktx,
END OF itab.
DATA: column_syntax TYPE string,
dbtab_syntax TYPE string.
PARAMETERS: p_matnr TYPE mara-matnr.
dbtab_syntax = '( (dbtab1) AS t1 '
&' INNER JOIN (dbtab2) AS t4 ON t1MATNR = t4MATNR )'.
SELECT matnr maktx
FROM (dbtab_syntax)
INTO TABLE itab WHERE t4~matnr = p_matnr.
Got the following error:
"A table name, specified in an SQL command, is unknown"
It seems not able to read dynamic table name in dbtab_syntax.
thanks
anya
Moderation Message: Duplicate Post.
Edited by: kishan P on Nov 29, 2010 11:17 AMHi,
Check this link.
[http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb39c4358411d1829f0000e829fbfe/frameset.htm]
[Re: accessing dynamic internal table's fields??;
hope it'll help u.
Regards,
Sneha.
Edited by: sneha kumari on Jun 18, 2009 1:57 PM -
Dynamic column name sql?
I need to do a select statement using dynamic column names. Can it be done WITHOUT building a string to execute the sql?
In other words, I want to use a variable name in the SELECT part of a statement.
ThanksProperly done, there shouldn't be a great difference in the performance of static and dynamic SQL. Of course, dynamic SQL is a whole lot more complicated to get right. It's also rather at odds with your requirement that column names get passed in dynamically-- if you don't know what columns you're going to select at compile time, you can't use static SQL.
That said, there are a handful of tricks around using Oracle's built-in XML processing functionality to simulate dynamic SQL. This is almost certainly less efficient than doing dynamic SQL in your case, and a whole lot more complicated, but it's technically not dynamic SQL.
The proper response, though, is almost certainly to either
1) figure out how to design the application so that column names need not be passed in at runtime or
2) use dynamic SQL.
If at all possible, option 1 is generally preferable. While there are situations where dynamic SQL is necessary, those tend to be rather rare.
Justin -
Call Type node not setting Call Type Dynamically By name.
I'm attempting to use the Call Type node to set a Call Type dynamically by name using the following logic:
concatenate("somestring_",userParseFromVXML("CT"),"_Q")
The userParseFromVXML is a custom function that works correctly and pulls my data out of FromExtVXML correctly. If I use a peripheral variable and use the same logic then set the Call Type node to set the call type dynamically by name using the peripheral variable it sets the call type correctly without any problems. I'm using UCCE 9.0.3 and I'm wondering if anyone else has run across this issue.I wish I'd known about the table function before myself.
This is what my experience is now after having tested these scenarios.
Scenario
Example
PASS/FAIL
String literal
concatenate("somestring_", "test", "_Q")
PASS
Peripheral Variable
concatenate("somestring_", Call.PeripheralVariable1, "_Q")
PASS
Custom Function
concatenate("somestring_", userParseFromVXML("CT"), "_Q")
Passing now (not sure what i must have been missing)
The custom function I'm using returns a string and when I created a new custom function returning a String literal it worked just fine. After doing my testing and swapping back to my original custom function I started seeing the call tagged with the correct Call Type, so I can only assume that I was missing something in the original concatenate string. The custom function I am using is as follows:
if((find(%1%,Call.user.microapp.FromExtVXML[0]))>0,before(";",after(concatenate(%1%,"="),Call.user.microapp.FromExtVXML[0])),if((find(%1%,Call.user.microapp.FromExtVXML[1]))>0,before(";",after(concatenate(%1%,"="),Call.user.microapp.FromExtVXML[1])),if((find(%1%,Call.user.microapp.FromExtVXML[2]))>0,before(";",after(concatenate(%1%,"="),Call.user.microapp.FromExtVXML[2])),if((find(%1%,Call.user.microapp.FromExtVXML[3]))>0,before(";",after(concatenate(%1%,"="),Call.user.microapp.FromExtVXML[3])),"Not Found")))) -
Access java variable by string name
Is there a way in java to set a variable by a string name like the $$ option in php?
What I'm trying to do is set a global String variable from within a loop of key-value pairs. I want to be able to set each variable dynamically without knowing the variable name.
Instead of doing this:
this.myVar = newValue;
I want to do something like:
this.{"variableName"} = newValue;
where the string inside the {""} is unknown and comes from data within the loop and one iteration may be "myVar".jhowley wrote:
Well, I kind of thought that wasn't possible and a Map was my backup plan anyway. Thanks for the info.its totally possible with Reflection (but you should use a Map).
read: [getField(String)|http://java.sun.com/javase/6/docs/api/java/lang/Class.html#getField(java.lang.String)]
import java.lang.reflect.*;
public class ReflectionDemo{
public static void main(String[] args){
new ReflectionDemo().start();
public void start(){
try{
Class c = this.getClass();
Field f = c.getDeclaredField("myField");
int i = f.getInt(this);
System.out.println(i);
} catch(Exception e){
e.printStackTrace();
int myField = 11;
}
Maybe you are looking for
-
ERROR WHILE RUNNING THE SESSION IN SM35
Hi all when ever m running this session in SM35 , M getting error as : "LEAVE TO TRANSACTION" MARA-BISMT is not allow in batch input REPORT YASEC_BDC_NIK_SESSION no standard page heading message
-
Hi I am using oracle BI Dashboard. i had configured my physical , business and presentation layers. when i click on the answers in the dashboard it also show me my new create presentation layer. even i can directly query my database using OBI but whe
-
What version of flash player should be installed on website?
Not very saavy with building site, looking for recommendations on what is the least problematic version of flash player. Site is www.legacygroupbuilders.com Thanks!
-
'Check covered levels OKS' process results in error during QA checkup
Hi, The following process in QA test, before submiting a service contract results in error. 'Check covered levels OKS' with the error message "Atleast one covered line is required". I'm not able to choose any product. How to set the covered level as
-
Wow... I keep finding bugs. I just restored my iPhone 4 since it was resetting every few min after the initial restore from my 3G's backup. Now however it seems Exchange and google or email links maybe are causing havoc on my device. If I enter the c