‎2011 Apr 11 9:23 AM
Hello Everybody!
I had a similar question previously about calling a column name based on a string placing a variable inbetween ( ) when using SQL queries.
However, I'm trying to call the name of a variable and component based on a string. When I try doing:
var1 = var2-(varColumn)I get a dump saying var2 has no component named ''.
I've also tried to do the entire variable name, like:
column_name = '-c1'.
variable_name='whatever'.
CONCATENATE variable_name column_name INTO total_name.
var1 = (total_name).
This doesn't compile, and if I activate and try to run the program anyway I get an error over an non-exsistant variable.
My searches across google and here aren't really producing great results. Is doing it this way even possible?
Thanks for the help!
‎2011 Apr 11 11:24 AM
You need to use field symbols like this;
1. First declare the field symbol
FIELD-SYMBOLS <fs> like var2-col2.
*2 Now dynamically assign the column
ASSIGN COMPONENT 'COL2' OF STRUCTURE var2 to <fs>.
*<fs> now has the value var2-col2
‎2011 Apr 11 9:54 AM
Hello Bryan,
Are you trying to SELECT data using "dynamic" columns? Did you check the F1 help or the online documentation? [http://help.sap.com/abapdocu_702/en/abapselect_clause_cols.htm#!ABAP_ALTERNATIVE_3@3@]
BR,
Suhas
‎2011 Apr 11 9:59 AM
Hey Suhas,
No, I've already gotten that one figured out.
UPDATE (table_name)
SET (column_name)
WHERE LETTER = row.
I have a structure and a lengthy CASE block, for example:
CASE column.
WHEN 1.
char = lc_board_s-c1.
WHEN 2.
char = lc_board_s-c2.
...
WHEN 10.
char = lc_board_s-c10.
ENDCASE.
The SQL has query has been executed by this point. I just want to be able to call the component of the structure variably, so I can reduce the block to (psuedocoding).
character = structure-(variable_component_name).
‎2011 Apr 11 11:23 AM
‎2011 Apr 11 11:39 AM
Hello Bryan,
Is this what you're looking for:
FIELD-SYMBOLS <val> TYPE ANY.
WHILE sy-subrc = 0.
ASSIGN COMPONENT sy-index OF STRUCTURE wa TO <val>.
CHECK <val> IS ASSIGNED.
WRITE: / <val>.
UNASSIGN <val>.
ENDWHILE.BR,
Suhas
‎2011 Apr 11 11:24 AM
You need to use field symbols like this;
1. First declare the field symbol
FIELD-SYMBOLS <fs> like var2-col2.
*2 Now dynamically assign the column
ASSIGN COMPONENT 'COL2' OF STRUCTURE var2 to <fs>.
*<fs> now has the value var2-col2
‎2011 Apr 11 12:00 PM
Thanks everybody! That's exactly what I was looking for. I was trying to search google and the forums here but wasn't sure what the proper term was for it.
Thanks!