In SAP's pricing configuration, we often use reference structures and reference fields (condition tables and storage order). How are these fields used, with this curiosity, I read the sap source code (function sd_cond_access) and recorded my understanding for your reference.
Step 1 call the t682z_select sub-process to read from t682z and store the data in sequence to t682z_tab.
Perform t682z_select tables t682z_tab
Using t682i_ I
Changing subrc.
Splice the reference structure and reference fields into the field kommfield of the inner table.
Concatenate t682z_buf-qustr-'t682z_buf-qufna
Into t682z_buf-kommfield.
Step 2. In the child routine sel_kondtab, extract the corresponding Field Values of the reference structure based on the reference structure and field names in the storage order.
Assign table field (proto_fld_tab-kommfield) to <F>.
Proto_fld_tab-wert =.
Note: the value of the proto_fld_tab-kommfield, such as: KOMP-PRODH1
Step 3 splice query conditions in the child routine sel_kondtab (put in the Table in coding_tab)
* Buffered with wrong value-> replace value
Coding_template-value = proto_fld_tab-wert.
Replace all occurrences of ''' in proto_fld_tab-wert
With ''' in character mode.
Concatenate ''' proto_fld_tab-wert ''' into h_value.
Concatenate <t682z>-zifna '= 'h_value
Into coding_template-line
Separated ''.
Modify coding_template index sy-tabix transporting Value Line.
If first = yes.
First = No.
Coding_tab = coding_template-line.
Else.
Concatenate 'and' coding_template-line into coding_tab
Separated ''.
Endif.
Endif.
Append coding_tab.
Step 4 in the child routine sel_kondtab, query conditions are obtained based on splicing (placed in the coding_tab table) and read condition records are obtained.
Select * from (t681-kotab) appending table <cond_tab>
Up to 1 rows
Where kappl = se_kappl
And kschl = se_kschl
And (coding_tab ).
Note: The t681-kotab for the condition table name such as: a802; coding_tab content see
With this, we can easily understand the use of reference fields and reference structures.