11-18-2005 8:27 AM
Hi,
I'm trying to do a function that receives the name of a table (not the table) and then list its content. How can I assign the table to a field symbol. I think in something like this:
perform compara using 'kna1'.
FORM compara USING tabl.
FIELD-SYMBOLS: <table> TYPE ANY.
ASSIGN (tabl) TO <table>.
WRITE <table>-kunnr.
ENDFORM.
But it doesn't work, something like "the data object <table> has no structure and therefore no component called KUNNR"
In fact the real purpose of the function is to receive a structure of the same type of the table and a the header of the table, compare its fields and then return if all fields have the same value.
11-18-2005 8:47 AM
Hi,
change the code as
perform compara using 'kna1'.
FORM compara USING tabl.
FIELD-SYMBOLS: <table> TYPE ANY.
*<b>ASSIGN (tabl) TO <table>.</b>
<b> Assign tabl to <table>.</b>
WRITE <table>-kunnr.
ENDFORM.
Refer to example prog in ABAPDOCU
REPORT demo_field_symbols_assign_comp .
DATA: BEGIN OF line,
col1 TYPE i VALUE '11',
col2 TYPE i VALUE '22',
col3 TYPE i VALUE '33',
END OF line.
DATA comp(5) TYPE c VALUE 'COL3'.
FIELD-SYMBOLS: <f1> TYPE ANY, <f2> TYPE ANY, <f3> TYPE ANY.
ASSIGN line TO <f1>.
Regards,
Sailaja.
11-18-2005 8:47 AM
Hi,
change the code as
perform compara using 'kna1'.
FORM compara USING tabl.
FIELD-SYMBOLS: <table> TYPE ANY.
*<b>ASSIGN (tabl) TO <table>.</b>
<b> Assign tabl to <table>.</b>
WRITE <table>-kunnr.
ENDFORM.
Refer to example prog in ABAPDOCU
REPORT demo_field_symbols_assign_comp .
DATA: BEGIN OF line,
col1 TYPE i VALUE '11',
col2 TYPE i VALUE '22',
col3 TYPE i VALUE '33',
END OF line.
DATA comp(5) TYPE c VALUE 'COL3'.
FIELD-SYMBOLS: <f1> TYPE ANY, <f2> TYPE ANY, <f3> TYPE ANY.
ASSIGN line TO <f1>.
Regards,
Sailaja.
11-18-2005 8:55 AM
Hi,
perform compara tables itab.
form compara tables itab type table.
field-symbols: <fs> type any,
<fs1> type any.
loop at itab assigning <fs>.
do.
ASSIGN COMPONENT sy-index OF STRUCTURE <fs> TO <fs1>.
write <fs1>.
if sy-subrc ne 0.
exit.
endif.
enddo.
new-line.
endloop.
endform.
Kindly reward points if it helps.
11-18-2005 8:57 AM
Hi
You can't indicate the field name, because the system can know the structure only at run time, so you get the sintax error. you should dymanically indicate the the field:
perform compara using 'kna1'.
FORM compara USING tabl.
FIELD-SYMBOLS: <table> TYPE ANY,
<field> TYPE ANY.
ASSIGN (tabl) TO <table>.
ASSIGN COMPONENT 'KUNNR' OF STRUCTURE <TABLE> TO <FIELD>.
WRITE <FIELD>.
ENDFORM.
12-03-2008 11:41 AM
IF i want to change the (not to write) ' kuner ' and update the table
how t do it any help pls.....
12-03-2008 11:47 AM
Hi,
For changing the field, you assign the new value to <FIELD>
i.e instead of Write <FIELD> use,
<FIELD> = 'New Value'.
Field symbol accesses the memory directly. So changes made to field symbol will automatically reflect in the assigned field's value.
Note: Create new thread whenever you ask new queries. I responded without seeing the initiator name of the thread. Please take care of this!
Thanks,
Lakshmi
Edited by: Santhanalakshmi V on Dec 3, 2008 5:19 PM