Do Runtime Type Services (RTTS) use database to get data descriptions?


Do Runtime Type Services (RTTS) use database to get data descriptions?



Question



Do methods like describe_by_data, get_ddic_field_list, get_components (of cl_abap_typedescr and similar), retrieve data from database or does it get generated on application server?


describe_by_data


get_ddic_field_list


get_components


cl_abap_typedescr



I looked at those classes and all of the some methods (that populate cache, presumably) appear to pull data in non-standard ways (METHOD ... BY KERNEL MODULE ...) and others pull data from cache. I am wondering how it gets pulled if it is not cached.


METHOD ... BY KERNEL MODULE ...



Google didn't give me any concrete info on this topic either.



Some context, in case details become relevant



I've been looking into implementing dynamic select clauses generation for some generic classes (to replace asterisk for column-based processing in S/4HANA and hopefully reduce the strain on DB).



Since most of those classes retrieve data into dictionary type structures, I figured I could use type descriptions of Runtime Type Services (RTTS), to get the field lists and dynamically generate the select clause based on target structure.



In most cases I can work around performance loss (if there is any) by implementing static variables (and only processing it once per session), but I've ran into similar cases where static variables were not an option (processing is made on unknown types) and I had to abandon the idea because I wasn't sure how it would impact the peak performance if those methods were called, let's say 30 times per session.



Edit (just a piece of code, to avoid further confusion that leads to condescending comments with no substance):


lo_struct ?= cl_abap_structdescr=>describe_by_data( header ).
ct_components = lo_struct->get_components( ).
"Loop through ct_components appending names to lv_select_clause

lv_select_clause = get_header_fields( is_target_structure = header ).
select single (lv_select_clause)
from rbkp
where gjahr = @iv_gjahr
and belnr = @iv_belnr
into corresponding fields of @header.





Thank you for your input. I am sorry if I wasn't clear enough, but what I am doing IS a dynamic select, but one that uses RTTS to dynamically form the field/column list (based on target structure) of a select clause. Would you mind clarifying what made you say I am rewriting RTTS?
– Zero
Jul 2 at 13:50





Well, clearly defined problem is half of a solution. If you want to form a target structure dynamically to select DB data into it, it's perfectly possible with RTTS (dunno for what do you need RTTS implementation details). Just rewrite your question and describe your task in detail and give your snippets/works/progress up to now.
– Suncatcher
Jul 2 at 15:00






It is even more interesting if You would create the binding/joining clause also dynamically. In Your case it simply looks like You want to select SOME particular fields from ONE table. I did this several times.When it comes to the detail, wether or not the rtts is retrieving the ddic-definition from the db itself, BUT You are unsure, get the desired fields of the tables DD02L or DD03L. But In most cases You can trust the RTTS, get the components, create a target struc, then a table, then use the comptab to create the select-clause-string. Have a look into structdescr->GET_DDIC_FIELD_LIST.
– icbytes
Jul 2 at 16:45





I have considered dynamic joined selects, but seem to be more a lot of trouble and I wanted to find out is whether or not it RTTS method speed was something to worry about. With that said, one idea I've got is using describe_by_name (instead of describe_by_data', passing table of structure names (instead of structures themselves) and building based on matches between DB table names and names in target strucutres. For overlapping fields (where table must be specified in select) mandatory manual mapping in 3rd table. It's complex but ultimately achieves the goal.
– Zero
Jul 3 at 5:05


describe_by_name




1 Answer
1



I can't be sure for the latest ABAP versions, but that ABAP Dictionary stuff (AKA "DDIC" for Data Dictionary) originates from the database tables DDNTT and DDNTF (also called "nametab", and its elements are called the "database runtime objects") which are filled during activation of DDIC objects (tables and so on, those tables are DD02L, DD03L, as said by @icbytes, and so on).



When they are queried, they are also transferred and persisted in every application server memory. This memory is called the nametab buffer. The newest data are replacing the oldest data when the buffer is full.



No idea about the performance, but no doubt that it can be neglicted compared to the SELECT you do right after.



One more thing, about RTTS, always use the GET_* methods rather than the CREATE_* ones because they are faster (they behave slightly differently, but generally only experienced developers may need to use the latter ones).



If you want, you can add another layer of memory, but I guess it's not worth doing it (more developer time spent + more memory consumed versus no big performance improvement).






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

api-platform.com Unable to generate an IRI for the item of type

How to set up datasource with Spring for HikariCP?

Display dokan vendor name on Woocommerce single product pages