2005 Nov 26 4:44 AM
hi
i have an internal table itab with fields
f1(20) type c,
f2 type p,
f3 type p decimals 2,
f4 like mseg-matnr,
f5 like makt-maktx.
can i know the structure and dat type of the firleds at run time of an internal table..... like what we get thru FM <b>DDIF_FIELDINFO_GET</b>
Abhishek suppal
2005 Nov 26 5:18 AM
hi, except the CL_ABAP_XXXX class, you can also try this way:
DATA:BEGIN OF IT_TEST OCCURS 0,
F1(20) TYPE C,
F2 TYPE P,
F3 TYPE P DECIMALS 2,
F4 LIKE MSEG-MATNR,
F5 LIKE MAKT-MAKTX,
END OF IT_TEST.
DATA: IT_RSTRUCINFO TYPE STANDARD TABLE OF RSTRUCINFO.
CALL FUNCTION 'GET_COMPONENT_LIST'
EXPORTING
PROGRAM = 'XXXX' " your application name
FIELDNAME = 'IT_TEST'
TABLES
COMPONENTS = IT_RSTRUCINFO.
The internal table definition info will be restored in IT_RSTRUCINFO.
Hope it will be helpful
thanks
2005 Nov 26 4:52 AM
Hi Abhishek,
1. This can be done using Class/Object.
2. The required class (SE24) is
CL_ABAP_structDESCR.
3. Sample Program : (Just copy and paste)
REPORT typedescr_test.
*------- Variables
data : det type ref to CL_ABAP_structDESCR.
data : wa like line of det->components.
*------ Internal Table
DATA : BEGIN OF ITAB OCCURS 0,
MANDT TYPE T001-MANDT, "--- type
PERNR LIKE P0001-PERNR, " --- like
MATNR TYPE MARA-MATNR, "--- type
EBELN LIKE EKKO-EBELN, "--- like
END OF ITAB.
*----
Start of selection
START-OF-SELECTION.
det ?= cl_abap_typedescr=>describe_by_DATA( ITAB ).
loop at det->components into wa.
write 😕 wa-name , wa-type_kind , wa-length.
endloop.
*----
Number Of columns
describe table det->components.
write /: sy-tfill.
*----
hope the above helps.
Regards,
Amit M.
2005 Nov 26 4:53 AM
Abhishek,
You can use the methods of the class CL_ABAP_DATADESCR. The method is GET_DATA_TYPE_KIND.
Regards,
Ravi
Note : Please reward points if the posts are helpful.
2005 Nov 26 5:18 AM
hi, except the CL_ABAP_XXXX class, you can also try this way:
DATA:BEGIN OF IT_TEST OCCURS 0,
F1(20) TYPE C,
F2 TYPE P,
F3 TYPE P DECIMALS 2,
F4 LIKE MSEG-MATNR,
F5 LIKE MAKT-MAKTX,
END OF IT_TEST.
DATA: IT_RSTRUCINFO TYPE STANDARD TABLE OF RSTRUCINFO.
CALL FUNCTION 'GET_COMPONENT_LIST'
EXPORTING
PROGRAM = 'XXXX' " your application name
FIELDNAME = 'IT_TEST'
TABLES
COMPONENTS = IT_RSTRUCINFO.
The internal table definition info will be restored in IT_RSTRUCINFO.
Hope it will be helpful
thanks
2005 Nov 26 8:25 AM
2005 Nov 26 6:34 AM
Abhishek,
Simple way is to use DESCRIBE statement.
This will solve your problem.
Regards,
Amey