2012 Aug 15 11:28 AM
Hi,
I have a field symbols as a work area declared as of type ANY.
E.g
<fs> TYPE ANY.
Also I have an internal table declared as of TYPE STANDARD TABLE OF char32.
How can I MOVE/APPEND the contents of that work area ( <fs> ) to the internal table.
Please advise !
Stefan
2012 Aug 17 12:57 AM
please use below code you will get what you want.
FIELD-SYMBOLS <fs_line> type any.
data ls_tab type ref to data.
data it_tab type standard TABLE OF char32 with header line.
create data ls_tab like line of it_tab.
ASSIGN ls_tab->* to <fs_line>.
<fs_line> = 'fs'.
append <fs_line> to it_tab.
loop at it_tab.
write it_tab.
endloop.
i also want to tell u something.
1. you should create line type of your internal table.
create data ls_tab like line of it_tab.
2.assign it to 1 field symbol. then you can operate this work area.
ASSIGN ls_tab->* to <fs_line>.
2012 Aug 15 11:45 AM
First you need to assign the field-symbol to an exiting variable with: ASSIGN field TO <fs>
Then you can move the field symbol value into a table line variable: char32 = <fs>
Then you can append the table line into your table: INSERT char32 into table char32_table
Regards Jack
2012 Aug 15 12:52 PM
Hi Jack,
Thank you for your reply. Let me clarify.
The following is a part of my code.
DATA: lt_string TYPE STANDARD TABLE OF char32.
FIELD-SYMBOLS: <t_itab> TYPE ANY TABLE,
<fs_err_tab>,
<fld> ,
<fs_string> TYPE STANDARD TABLE.
ASSIGN <fs_stepid> TO <t_itab>.
<fs_stepid> has been declared as global field symbols and everytime it contains different table records.
Then I have...
LOOP AT <t_itab> ASSIGNING <fs_err_tab>.
* here I want to move/append <fs_err_tab> TO lt_string
ENDLOOP.
The system returns short dump, because of the different types.
Please advise !
Stefan
2012 Aug 15 1:42 PM
Hi Stefan,
since lt_string is a standard table, you have the choice
If you work with "APPEND <fs_err_tab> TO lt_string.", your program should work as expected, with no dump, as long as the first 32 places of <fs_err_tab> can be moved to the target field which is of type CHAR32, i.e. as long as these 32 places belong to components of type CHAR, NUMC or similar.
I tested it in my system (SAP_BASIS 702), with several types for <fs_err_tab> (and for the data object to which "<fs_err_tab> type any" is assigned at run time, but this makes no difference):
It worked with all these types. But it doesn't work with types like this one:
types: begin of ty_line,
c type c,
f type f,
end of ty_line.
The second option, "INSERT ... INTO TABLE ...", is much more restrictive. When working with "INSERT <fs_err_tab> into table lt_string.", you will get an error unless the type of <fs_err_tab> is a precise match of the line type of lt_string.
INSERT ... INTO TABLE is the better option for a robust programmer, since it protects your program against the unexpected. In order to use it, you will need an auxiliary variable (not field-symbol) of type char32 and have to fill it yourself in the loop. You can't avoid the MOVE anyway, APPEND would perform it implicitly. So don't worry.
Regards,
Rüdiger
Remark: In your code, I see the obsolete statement "field-symbols with no explicit type"
FIELD-SYMBOLS <FS_ERR_TAB>.
gives the field-symbol the generic type ANY - contrary to all other declarations in ABAP which default to CHAR1. To make it even weirder: In this case, the field-symbol will by default be assigned to the constant SPACE, even if no ASSIGN statement has been performed.
2012 Aug 15 2:35 PM
Hi Rüdiger,
Unfortunately the statement APPEND <FS_ERR_TAB> TO LT_STRING returns the following error as a short dump:
You attempted to move one data object to another.
This is not possible here because the conversion of a data object
of type "ZRSP_PROPOSAL" to type "C" is not supported.
Basically ZRSP_PROPOSAL is our <FS_ERR_TAB>.
Your thoughts ?
Stefan
2012 Aug 15 2:53 PM
My thoughts?
Regards,
Rüdiger
2012 Aug 16 2:25 PM
Hi Rüdiger,
I have tried your last suggestion, but it doesn't work.
The compilier returns: The type of lv_prop cannot be converted to the type of lv_char32.
Please advise !
Regards,
Stefan
2012 Aug 16 3:52 PM
What type of field is lv_prop? It appears to be a type that cant be converted to characters. Since lv_char32 is a character type field, there needs to be logic to convert lv_prop to characters. First thing I would try is the WRITE lv_prop INTO lv_char32 statement. It converts lv_prop to characters in external format.
2012 Aug 16 4:04 PM
Stefan,
so the simple "MOVE" test shows, your problem has nothing to do with field-symbols at all. It's about moving something into type c which can't be moved to type c.
Until now, you make a secret of the root cause of your problem: The type of zrsp_proposal. I have explained you in detail the conditions, when it is possible to move something to a type c field - and when not.
Now it's up to you to apply these conditions to your problem. We can't help you further, unless you are willing to unveil the components of zrsp_proposal.
Regards,
Rüdiger
2012 Aug 16 2:43 PM
2012 Aug 17 12:57 AM
please use below code you will get what you want.
FIELD-SYMBOLS <fs_line> type any.
data ls_tab type ref to data.
data it_tab type standard TABLE OF char32 with header line.
create data ls_tab like line of it_tab.
ASSIGN ls_tab->* to <fs_line>.
<fs_line> = 'fs'.
append <fs_line> to it_tab.
loop at it_tab.
write it_tab.
endloop.
i also want to tell u something.
1. you should create line type of your internal table.
create data ls_tab like line of it_tab.
2.assign it to 1 field symbol. then you can operate this work area.
ASSIGN ls_tab->* to <fs_line>.
2012 Aug 17 7:35 AM
This proposal will only shift the problem to the MOVE statement: The line
<fs_line> = 'fs'.
will very likely result in the same error he got all the time.
He doesn't have a field-symbol problem, he has a move problem. Not everything can be moved into a type C field.
My guess: The leading part of his source structure contains a counter field of type integer (since it's the data structure of an error log).
2012 Aug 17 10:06 AM
Guys,
Everytime the structure/table will be different. Let me clarify the scenario.
I have screen showing the errors of DB tables update. On that screen I have a hotspot against evry single table. When the user clicks on that hotspot the system opens an additional screen where I have custom control ( text edit box ) where I have to display the records which hasn't been inserted because of some problems. That's why the table passed to the PBO of the second screen could be different every time. I am able to pass dynamically the table name and it's contents, but I am not able to pass it to the import parameter of the function module:
CALL METHOD
text_editor->
set_textstream
that should display so called 'wrong table records'.
And that's my code ( again )
ASSIGN <fs_stepid> TO <t_itab>.
* <t_itab> is declared as TYPE ANY TABLE
* <fs_stepid> is declared in the Global definitions as TYPE STANDARD TABLE. It passes the table contents from the first screen to the second screen.
So I have the following code:
LOOP AT <t_itab> ASSINING <fs_err_tab>." <fs_err_tab> is of type any
APPEND <fs_err_tab> TO lt_text_stream. "lt_text_stream TYPE STANDARD TABLE OF char32.
CONCATENATE LINES OF lt_text_stream INTO lv_string.
CALL METHOD text_edit->set_textstream
EXPORTING
text = lv_string.
ENDLOOP.
2012 Aug 17 10:21 AM
Hi
before appending the record you need to move it to string
LOOP AT <t_itab> ASSINING <fs_err_tab>." <fs_err_tab>.
DO.
CLEAR: X, Y, W, L_CHAR32.
ASSIGN COMPONENT SY-INDEX OF STRUCTURE <FS_ERR_TAB> TO <FS_ERR_FIELD>.
IF SY-SUBRC <> 0. EXIT. ENDIF.
DESCRIBE FIELD <FS_ERR_FIRLD> LENGTH Y IN CHARACTER MODE
W = X + Y.
IF W > 32. EXIT. ENDIF,
MOVE <FS_ERR_FIELD> TO L_CHAR32+X(Y).
X = X + Y.
W = X.
ENDDO.
APPEND L_CHAR32 TO IT_TEXTSTREAM.
ENDLOOP.
Max
2012 Aug 17 11:46 AM
2024 Jun 13 7:30 AM - edited 2024 Jun 13 7:31 AM
Above solution did not work for me since I just need to move from field symbol to deep structure.
Specify the type with the corresponding:
FIELD-SYMBOLS : <lfs_any> TYPE any & IM_DATA_CONTAINER TYPE REF TO DATA
ASSIGN im_data_container->* TO <lfs_any>.
IF <lfs_any> IS ASSIGNED. ex_form_data = CORRESPONDING YLC_SD_ORDER_CONFIRMATION( DEEP EXACT <lfs_any> ).