09-05-2008 9:15 PM
hi everyone,
I know how i can get components information from transparent tables or any structure in the data dictionary.
But, if i have just a internal table, how can i get components table?
E.g:
data:
types: BEGIN OF st_table,
matnr type matnr,
name1 type name1,
END OF st_table.
data: i_table TYPE TABLE OF st_table.
DATA: l_struc TYPE REF TO cl_abap_structdescr.
DATA: lt_comp TYPE cl_abap_structdescr=>component_table.
DATA: ls_comp LIKE LINE OF lt_comp.
l_struc ?= cl_abap_typedescr=>describe_by_name( itab-tabname ).
lt_comp = l_struc->get_components( ).
Does not work out
i've already try the following ones:
DESCRIBE_BY_DATA
DESCRIBE_BY_NAME
DESCRIBE_BY_OBJECT_REF
DESCRIBE_BY_DATA_REF
Any idea?
Alexandre
09-05-2008 10:12 PM
Check this, you get all the info you need in ls_components
type-pools abap.
types: begin of ty_est,
firstname type c,
second type i,
third type d,
end of ty_est.
DATA: ls_components TYPE ABAP_COMPDESCR_TAB,
wa_components like line of ls_components.
DATA: lo_strucdescr TYPE REF TO cl_abap_structdescr.
data: itab type table of ty_est with header line.
lo_strucdescr ?= cl_abap_typedescr=>describe_by_data( itab ).
ls_components = lo_strucdescr->components.
09-05-2008 9:24 PM
Try this:
REPORT Z_MP_TEST_STRUCT.
data: idfies type table of dfies with header line,
s_file TYPE string.
parameters: p_table type ddobjname.
parameters: filename(80) type c default 'D:\Documents and Settings\Desktop\download.xls'.
call function 'DDIF_FIELDINFO_GET'
exporting
tabname = p_table
tables
dfies_tab = idfies
exceptions
not_found = 1
internal_error = 2
others = 3.
s_file = filename.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
FILENAME = s_file
FILETYPE = 'DAT'
TABLES
DATA_TAB = idfies
EXCEPTIONS
FILE_WRITE_ERROR = 1
NO_BATCH = 2
GUI_REFUSE_FILETRANSFER = 3
INVALID_TYPE = 4
NO_AUTHORITY = 5
UNKNOWN_ERROR = 6
HEADER_NOT_ALLOWED = 7
SEPARATOR_NOT_ALLOWED = 8
FILESIZE_NOT_ALLOWED = 9
HEADER_TOO_LONG = 10
DP_ERROR_CREATE = 11
DP_ERROR_SEND = 12
DP_ERROR_WRITE = 13
UNKNOWN_DP_ERROR = 14
ACCESS_DENIED = 15
DP_OUT_OF_MEMORY = 16
DISK_FULL = 17
DP_TIMEOUT = 18
FILE_NOT_FOUND = 19
DATAPROVIDER_EXCEPTION = 20
CONTROL_FLUSH_ERROR = 21
OTHERS = 22.
09-05-2008 9:27 PM
Hi,
You can use the FM GET_COMPONENT_LIST..to get the list of components for an internal table.
THanks
Naren
09-05-2008 10:25 PM
Aparna Shekhar ,
It is a internal table. I can not use this first function. thanks.
Narendran,
This function return the same information that i've already got in the attributes section, i could not see the name of the field, just type. The information that i need are:
begin of abap_componentdescr,
name type string,
type type ref to cl_abap_datadescr,
as_include type abap_bool,
suffix type string,
end of abap_componentdescr,
the return parameter of the method GET_COMPONENTS.
thanks
Alexandre
09-05-2008 10:12 PM
Check this, you get all the info you need in ls_components
type-pools abap.
types: begin of ty_est,
firstname type c,
second type i,
third type d,
end of ty_est.
DATA: ls_components TYPE ABAP_COMPDESCR_TAB,
wa_components like line of ls_components.
DATA: lo_strucdescr TYPE REF TO cl_abap_structdescr.
data: itab type table of ty_est with header line.
lo_strucdescr ?= cl_abap_typedescr=>describe_by_data( itab ).
ls_components = lo_strucdescr->components.
09-05-2008 10:31 PM
Ramiro,
Wow man! You got it right!
Points are rewards for everyone.
thank you!