Hello,
I'm working on custom planning function type that implements IF_RSPLFA_SRVTYPE_IMP_EXEC_REF (planning on reference data).
The EXECUTE method of the implementing class has I_TH_REF_DATA TYPE HASHED TABLE as an 'importing' parameter. This table actually includes my reference data. The structure of the table is defined dynamically at runtime in accord with the structure of an aggregation level. It includes all characteristics and keyfigures that the aggregation level is comprised from.
To avoid full scan of the table I want to loop over it using some kind of 'partial' key that includes only limited set of characteristics. Product assistance suggests something like that:
DATA spfli_tab TYPE HASHED TABLE
OF spfli
WITH UNIQUE KEY primary_key
COMPONENTS carrid connid
WITH NON-UNIQUE SORTED KEY city_from_to
COMPONENTS cityfrom cityto
WITH NON-UNIQUE SORTED KEY city_to_from
COMPONENTS cityto cityfrom.
LOOP AT spfli_tab ASSIGNING <spfli> USING KEY city_from_to.
This, however. does not apply to my task, as the table I_TH_REF_DATA is defined somewhere inside planning engine and I have no control over its structure, keys included.
I know beforehand the structure of the aggregation level, and want to loop using a key that includes, let's say, characteristics 0FISCPER, 0CURRENCY, ZSCOPE and ZVERSION. I need something like
LOOP AT I_TH_REF_DATA ASSIGNING <fs_line> USING KEY COMPONENTS '0FISCPER' '0CURRENCY' 'ZSCOPE' 'ZVERSION'
However, it seems that ABAP syntax does not provide for that.
Please advise, how can I loop over a dynamic hashed table avoiding full table scan?
Thank you,
Val
Request clarification before answering.
If you want to create an index on a table, but you can't because this input table is typed generically, and you know the component names on which you want to define the key (you are sure that these components will exist forever), and you know that this table is standard or sorted, I'd suggest that you define statically a temporary internal table with a component being the table index corresponding to the line in the input table, initialize it from the input table, and use the order of this temporary table to access the lines of the input table.
Example:
TYPES : BEGIN OF ty_temp_table,
0FISCPER TYPE ...
0CURRENCY TYPE ...
ZSCOPE TYPE ...
ZVERSION TYPE ...
TABIX TYPE sytabix,
END OF ty_temp_table,
tt_temp_table TYPE SORTED TABLE OF ty_temp_table
WITH NON-UNIQUE KEY 0FISCPER, 0CURRENCY, ZSCOPE, ZVERSION.
temp_table = VALUE #(
FOR <i_th_line> IN <i_th_data> INDEX INTO i_th_line_tabix
( VALUE #( BASE CORRESPONDING #( <i_th_line> ) tabix = i_th_line_tabix ) ).
LOOP AT temp_table REFERENCE INTO DATA(temp_line)
WHERE 0FISCPER = ...
AND 0CURRENCY = ...
AND ZSCOPE = ...
AND ZVERSION = ...
<i_th_line> = <i_th_data>[ temp_line->tabix ].
...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Sandra,
I am not sure I follow this:
LOOP AT temp_table REFERENCE INTO DATA(temp_line)
WHERE 0FISCPER = ...
AND 0CURRENCY = ...
AND ZSCOPE = ...
AND ZVERSION = ...
Because I don't know the values of these characteristics beforehand. I just want to loop at source table of hashed type for all combinations of these four fields. Maybe I'm missing something in what you suggest here.
Thank you,
Val
Sandra,
Actually I described the algorithm that I need a bit earlier in the previous thread of this topic. mateuszadamus and michael.piesche, in turn, suggested solutions which I am going to explore in more details and (maybe) apply to my task.
Can we get back and talk the algorithm in more details after I'm done with the abovementioned research?
Thank you and best regards,
Val
My answer fits your algorithm, I don't understand what you don't understand. Can you clarify?
For part 3:
LOOP AT unique_combinations REFERENCE INTO DATA(combination).
LOOP AT temp_table REFERENCE INTO DATA(temp_line)
WHERE 0FISCPER = combination->0fiscper
AND 0CURRENCY = combination->0currency
AND ZSCOPE = ...
AND ZVERSION = ...
<i_th_line> = <i_th_data>[ temp_line->tabix ].
Thank you, Sandra, I'll take a note of that. This one definitely fits the scanario:
LOOP AT unique_combinations REFERENCE INTO DATA(combination).
LOOP AT temp_table REFERENCE INTO DATA(temp_line)
WHERE 0FISCPER = combination->0fiscper
AND 0CURRENCY = combination->0currency
Best regards,
Val
| User | Count |
|---|---|
| 5 | |
| 4 | |
| 4 | |
| 3 | |
| 2 | |
| 2 | |
| 2 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.