on 07-11-2023 1:29 PM
Hello Experts,
I have an internal table which is of Dynamic Type created as below:
METHOD BUILD_LOG:
FIELD-SYMBOLS: <lt_tabinput> TYPE ANY TABLE.
ASSIGN (iv_tabname) TO <lt_tabinput>. "iv_taname is importing param of method.
ENDMETHOD.
above makes <lt_tabinput> like GT_GENERAL (which is global table in class)
and looks like:
I want to create a string line which goes like:
FLGDEFAULT_ADR12#URI_ADDR#URI_TYPE#TELNR_LONG#COUNTRY_ADR2#R3_USER#DFT_RECEIV
I tried utilising DDIF_FIELDINFO_GET but entered into a runtime error because I think this internal table doesn't relate to any repository object?
Need some advice to achieve this or I'll have to rewrite lots of logic.
Regards,
Shailesh
Did you try to use some RTS class such as CL_ABAP_TABLEDESCR or CL_ABAP_STRUCTDESCR and not DDIC FM to get information on table / structure?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Raymond.giuseppi
Thanks, I was looking into this but many methods and superclass methods intimidated me with no documentation in class.
on a side node, could you pls clarify below for me?:
why is there a ?= for this, normal ways don't work? what's so special about '?=' ?
if I use = instead of ?=, I get warning message as "The result type of the functional method cannot be converted into the type of LO_TABLEDESCR".
"My Way and it works
DATA(lt_type) = cl_abap_tabledescr=>describe_by_data( <lt_tabinput> ).
"Code in where used list and this works too:
DATA lo_tabledescr TYPE REF TO cl_abap_tabledescr.
lo_tabledescr ?= cl_abap_tabledescr=>describe_by_data( <lt_tabinput> ).
"Gives Error: The result type of the functional method cannot be converted into the type of LO_TABLEDESCR.
DATA blo_tabledescr TYPE REF TO cl_abap_tabledescr.
blo_tabledescr = cl_abap_tabledescr=>describe_by_data( <lt_tabinput> ).
Check class & methods definitions;
Basically CL_ABAP_TABLEDESCR->DESCRIBE_BY_DATA returns a 'generic' CL_ABAP_TYPEDESCR type data.
So the ?= downcast (also widening cast) operator assign the specific sub-class variable to a more general superclass variable (like truck class to vehicle class in Abap course)
lv_string = REDUCE #(
INIT lv_tabinput = ``
FOR <ls_component> IN
CAST cl_abap_structdescr(
CAST cl_abap_tabledescr(
cl_abap_tabledescr=>describe_by_data( <lt_tabinput> ) )->get_table_line_type( )
)->get_components( )
INDEX INTO lv_index
NEXT lv_tabinput &&= COND #( WHEN lv_index GT 1 THEN `#` ) && <ls_component>-name ).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
76 | |
9 | |
8 | |
6 | |
6 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.