Hi Eitan,
as you have seen for yourself RTTC is not very handy in ABAP. The code becomes quite confusing for more complex use cases - just imagine to create an internal table that stores a more complex structure (> 10 elements) and everything has to be created via RTTC ...
I'm not using RTTC very often but there is however one use case where I find it particularly useful and beneficially to employ:
Imagine getting a structured record description in a text file like
01 CUSTOMER_ID CHAR 10
02 CUST_NAME CHAR 40
03 CUST_ADDR CHAR 80
04 CUST_ACTIVE NUM
05 DATA_CREATE DAT
06 DATA_CHANGE DAT
along with the real data - in that case you can parse the record description and create a suitable structure via RTTC to process the actual data for instance from a CSV file.
And the good news is that the code will work for every CSV file that comes with such a record description - extremely flexible!
But again - there are only a few circumstances where the (considerable) effort is justified and even then it makes sense to encapsulate some of the steps to create tables and structures via RTTC in a class hierarchy to make the code more expressive and easier to maintain.
Example:
DATA:
lo_container TYPE REF TO zcl_abap_rttc_container,
lo_structure TYPE REF TO zcl_abap_struct_component.
lo_container = zcl_abap_rttc_container_factory=>create( ).
lo_structure = lo_container->create_structure( 'LINE_STRUCT' ).
lo_structure->add_element( 'MATERIAL', 'MATNR', 'material number' ).
lo_structure->add_element( 'MATTEXT', 'MAKTX', 'material short text' ).
Regards,
Chris
PS: If you consider yourself new to ABAP because you're using it since 2006 then I'm an absolute rookie (using ABAP since 2010)