ABAP - BOPF Determination
What about derived data that does not stand in the database? We want to pursue this question in today's article.
With data collection, you can read additional data at runtime when accessing BOPF. We had already presented this transient data with the data model and today we would like to show you an example of how the data can simply be read.
Create a determination
The determination is created on the respective node. For this, transaction BOBX must be called again. On the corresponding node, you now create a determination.
For this, the individual fields are filled, whereby the name of the processing class can be generated again via "Extras -> Propose Repository Names". As a category you choose Transient, because we want to read additional data for this node.
The next step is to set, when the determination should be made. For transient data in most cases the determination is sufficient for "load".
The evaluation timepoint is right here after loading the data from the database so that the data is complete. There are no dependencies for this node and determination.
The implementation of the logic takes place in a separate class which implements the interface /BOBF/IF_FRW_DETERMINATION. In method EXECUTE, you receive all selected nodes, in this case only the table with keys. The implementation example is explained in the following code example:
DATA: lt_head TYPE ztest_t_contract. io_read->retrieve( EXPORTING iv_node = is_ctx-node_key it_key = it_key iv_fill_data = abap_true IMPORTING et_data = lt_head ). LOOP AT lt_head REFERENCE INTO DATA(lr_head). SELECT SINGLE name1 FROM lfa1 WHERE lifnr = @lr_head->creditor INTO @lr_head->creditor_name. IF sy-subrc = 0. io_modify->update( EXPORTING iv_node = is_ctx-node_key iv_key = lr_head->key iv_root_key = lr_head->root_key is_data = lr_head ). ENDIF. ENDLOOP.
Using the Retrieve method, you can read the corresponding data for the keys, using the combination table type that accepts the data. Then a loop about the header data by reference, reading the custom properties from the supplier's master record and updating the data with the update method, passing in the new data as a reference. The loop by reference has already solved this problem.
When reading the node, the data is automatically read at the right time and the structure is enriched. The easiest way to check that is to try the test transaction BOBT. If you look at the sample data now, the field CREDITOR_NAME will be filled.
Not all data must always be persisted in the data model on the tables. With the example shown, you'll get an insight into how easily additional dependent data can be loaded. During implementation, you should make sure that the data determination is called with each read access, which can slow down the individual accesses a lot.