Created
January 31, 2014 06:08
-
-
Save weiserman/8727359 to your computer and use it in GitHub Desktop.
ABAP RTTS for describing a table
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| report ydemo1. | |
| DATA: | |
| gv_vendor type table of lfa1. | |
| DATA: | |
| gs_component TYPE abap_compdescr, | |
| go_typedescr TYPE REF TO cl_abap_typedescr, | |
| go_strucdescr TYPE REF TO cl_abap_structdescr, | |
| go_tabledescr TYPE REF TO cl_abap_tabledescr. | |
| START-OF-SELECTION. | |
| CALL METHOD cl_abap_typedescr=>describe_by_data | |
| EXPORTING | |
| p_data = gv_vendor " table type | |
| RECEIVING | |
| p_descr_ref = go_typedescr. " table type | |
| " Casting to table type instance | |
| go_tabledescr ?= go_typedescr. | |
| " Get table line type | |
| CALL METHOD go_tabledescr->get_table_line_type | |
| RECEIVING | |
| p_descr_ref = go_typedescr. | |
| " Casting to line type instance | |
| go_strucdescr ?= go_typedescr. | |
| " Components of range | |
| LOOP AT go_strucdescr->components INTO gs_component. | |
| AT FIRST. | |
| WRITE: /1 'Length', | |
| AT 15 'Decimals', | |
| AT 25 'Type', | |
| AT 35 'Name'. | |
| WRITE: / syst-uline. | |
| ENDAT. | |
| WRITE: /1 gs_component-length LEFT-JUSTIFIED, | |
| AT 15 gs_component-decimals LEFT-JUSTIFIED, | |
| AT 25 gs_component-type_kind, | |
| AT 35 gs_component-name. | |
| ENDLOOP. | |
| END-OF-SELECTION. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment