Page 1 of 1

field symbol

Posted: Mon Mar 26, 2018 2:51 pm
by Welcome
Hi.. Everyone..

How can i use field symbol ?
<FIELD> := 'FIni01'

who can tell me about <FILED> RDML Code???

Re: field symbol

Posted: Mon Mar 26, 2018 3:39 pm
by MarkDale
Could you explain a bit more about what you are trying to do.

Is 'Fini01' the name of a field that you want to update, or the value you want to update?

Normally if you want to update fields you would do something like:

Group_By Name(#SomeFields) Fields(#xEmployeeSurname #xEmployeeGivenName)

#xEmployeeSurname := 'MyValue'
Update Fields(#SomeFields) In_File(xEmployee) With_Key(#xEmployeeIdentification)


#xEmployeeSurname := 'MyValue'
Update Fields(#xEmployeeSurname #xEmployeeGivenName) In_File(xEmployee) With_Key(#xEmployeeIdentification)

You would not normally use '<FIELD>' in your code.

Re: field symbol

Posted: Mon Mar 26, 2018 4:03 pm
by Welcome
sorry mean..
<FIELD> is Dynamic field name..
<FIELD> name maybe IS 'A001' or 'A002' or 'B001' Or 'C001' .....
so... i want..

<FIELD> := (TEXT) => #A001 := 'TEXT' or #B001 := 'TEXT'


Re: field symbol

Posted: Mon Mar 26, 2018 6:02 pm
by MarkDale
I think there is no commonly used feature like that in RDML/RDMLX code.

If you are reading data using SELECT_SQL, the SQL instruction can be a string, so you can build up the string any way you want.
That would allow you to specify the field name at run time.

See ... free_p.htm

Or depending on what you want to do with your code, you might get what you want by calling a subroutine that receives the field name and the value, and maps it into the appropriate field using a CASE statement.

Code: Select all

subroutine CONVERT parms(#Name #Value)

CASE #Name
When = 'A001'
#A001 := #Value
When =  'A002'
#A002 := #Value

Others may have additional suggestions.

Re: field symbol

Posted: Tue Mar 27, 2018 11:04 am
by KevinW
/* function where you want to "dynamically" set a field to a value */
/* #FIELD contains the name of the field you want to set without leading # */
/* #VALUE contains the value you want to set it to */
/* The field you want to set the value for must be used in this function */
Exchange Fields(#FIELD #VALUE)
<do whatever with the field>

/* DYNAMIC function that sets the field to the value */

If you want to set a numeric value, use EXCHANGE_NUMERIC_VAR in the above code instead of EXCHANGE_ALPHA_VAR. If #FIELD & #VALUE are both defined as fields in the data dictionary then this will work without defining them in each function. Alternatively, use INCLUDE in both functions. This may not be optimal as far as performance is concerned.

As far as doing I/O is concerned, I don't know how to do that in RDML.

Re: field symbol

Posted: Wed Mar 28, 2018 12:59 am
by jyoung
Just thinking out loud here, but it looks like you are trying to dynamically build field / values and then update a table with those fields.

You might be able to do this with a variant and a keyed collection.

Code: Select all

define_com class(#PRIM_KCOL<#PRIM_VAR #STD_TEXT>) name(#MyFields)

#MyFields<'MyField1'> := 'My Value'
#MyFields<'MyField2'> := 205
The update command is not dynamic so you will have to build up a custom update SQL string. Should be doable by spinning through the collection and appending the field for each item. You will likely have to use the variant functions to determine types while building up the sql.

Then you could use the SQL free format to execute your update string, STD_NUM is just a dummy field as I think you have to have at least one.

Code: Select all

#wk_Sql := "my update string"

select_sql Fields(#STD_NUM) Using(#wk_Sql)
- Joe

Re: field symbol

Posted: Wed Mar 28, 2018 9:13 am
by KevinW
The other thing that occurs to me is that this is perhaps a code generation question, so that may mean creating and using a template to generate the requisite code.

It would also be useful to know what the actual problem is that needs an answer like dynamic field processing.