‎2010 Sep 07 10:20 AM
Hi,
I'm trying to use a BAdI (BADI_EAM_RIQMEL20_FCODE_CUS1) which has an input parameter called IT_SELECTED_OBJECTS which declaration is TYPE ANY TABLE, the question is simple how can I do a "loop at IT_SELECTED_OBJECTS".
I tried the following code:
Input parameters of method EXECUTE_FUNCTION_CODE
IV_FUNCTION_CODE TYPE SYUCOMM OPTIONAL Funktionscode, der PAI ausgelöst hat
IV_ACTIVITY_TYPE TYPE AKTYP DEFAULT 'A' Aktivitätstyp in der Transaktion
IT_SELECTED_OBJECTS TYPE ANY TABLE Selektierte ObjekteMethod Code
DATA: T_OBJ type ZCAU_T_1206_MAPA,
wa_obj type ZCAU_1206_MAPA,
w_dref TYPE REF TO data.
* wa_selected_objets like line of IT_SELECTED_OBJECTS.
FIELD-SYMBOLS: <t_itab> TYPE ANY.
CREATE DATA w_dref like IT_SELECTED_OBJECTS.
ASSIGN w_dref TO <t_itab>.
loop at it_selected_objects assigning <t_itab>.
wa_obj-tipo = 'AVISO'.
wa_obj-numero = <t_itab>-qmnum.
wa_obj-clase = <t_itab>-qmmart.
wa_obj-calle = <t_itab>-street.
wa_obj-ciudad = <t_itab>-city1.
wa_obj-codigo_postal = <t_itab>-post_code1.
append wa_obj to t_obj.
endloop.The compiler throws the following error:
The data object "" has no structure and therefore no component
called "QMNUM".
Any help??
Thanks.
Juan.
Edited by: Sistemes Emaya on Sep 7, 2010 11:23 AM
‎2010 Sep 07 10:32 AM
The answer is simple too. <t_itab> has static type ANY but dynamic type as like line of IT_SELECTED_OBJECTS .
Therefore statically syntax checker doesn't recognize any components of <t_itab> but dynamically it does (components of your table). So the acces to these components mustn't also be static but must be dynamic
"GMNUM statically unknow
wa_obj-numero = <t_itab>-qmnum.
"...but dynamically known
field-symbols <comp> type any.
assign component 'GMNUM' of structure <t_itab> to <comp>. "<comp> if our field now
wa_obj-numero = <comp>.
Regards
Marcin
‎2010 Sep 07 10:32 AM
The answer is simple too. <t_itab> has static type ANY but dynamic type as like line of IT_SELECTED_OBJECTS .
Therefore statically syntax checker doesn't recognize any components of <t_itab> but dynamically it does (components of your table). So the acces to these components mustn't also be static but must be dynamic
"GMNUM statically unknow
wa_obj-numero = <t_itab>-qmnum.
"...but dynamically known
field-symbols <comp> type any.
assign component 'GMNUM' of structure <t_itab> to <comp>. "<comp> if our field now
wa_obj-numero = <comp>.
Regards
Marcin
‎2010 Sep 07 10:47 AM
‎2010 Sep 07 10:47 AM
Hello Juan,
No need to create data reference w_dref you can directly use the generic field-symbol directly.
FIELD-SYMBOLS:
<fieldval> TYPE ANY,
<t_itab> TYPE ANY.
loop at it_selected_objects assigning <t_itab>.
" Why & how to use ASSIGN COMPONENT has been elaborated by Marcin
endloop.BR,
Suhas
‎2010 Sep 07 10:48 AM
‎2020 Feb 18 2:07 PM
Hello friend from the internet!
Maybe you are trying to find this?
DATA t_table TYPE "****" .
PERFORM loop_any_table USING t_table.
FORM loop_any_table USING my_table TYPE TABLE.
LOOP AT my_table ASSIGNING FIELD-SYMBOL(<l_line>).
BREAK-POINT.
ENDLOOP.
ENDFORM