Functions for Data Transformation
Very often you need to read a characteristic's attribute during a data transformation process, e.g. in an update rule. Rather than accessing the characteristic's attribute table (e.g. the view /BI0/MMATERIAL) directly with a SELECT statement, it is better to use the function module RSAU_READ_MASTER_DATA. It has been designed exactly for this scope. Taking advantage of it, you can avoid writing explicit data access code in the Data Transformation Layer routines.
Here are four examples which illustrate how to use this function in four different scanarios.
Read a single attribute value for a single characteristic value
You need to get the value of an attribute (e.g. 0SOLD_TO) corresponding to a characteristic value (e.g. 0SOLD_TO = 'CUST_CODE'). In this case you need to export to the function the name of the involved characteristic (parameter I_IOBJNM), its value (parameter I_CHAVL), and the name of the attribute (parameter I_ATTRNM). Notice that the parameter I_CHAVL expects a RSGENERAL-CHAVL data format. The function returns the attribute value in the parameter E_ATTRVAL.
Notice that even for a custom attribute, the simple attribute name needs to be exported (e.g. ZATTR), and not the field name as it appears in the attribute table (e.g. /BIC/ZATTR). Remember also that the name of both the characteristic and the attribute must be upper case (i.e. is case sensitive). Lastly, the import parameter I_DATE may be used to specify the key date when a time-dependent characteristic is involved. The output attribute value will fulfil the temporal condition that the key date is in the validity time interval of the characteristic.
Read all attributes of a single characteristic value
You need to get the value of several (or all) attributes for a given characteristic value (e.g. 0MATERIAL = 'MAT_CODE'). Again, you need to export the name of the involved characteristic (parameter I_IOBJNM) and its value (parameter I_CHAVL). The attribute names are not needed, since all the attributes will be fetched. In fact their value will be returned in the E_STRUCTURE structure. This structure has to have the same structure of the attribute view of the involved charateristic (e.g. /BI0/MMATERIAL). Notice that you have to use the M-view structure and not the P-table structure, as only the former is valid when time-dependent attributes are defined for the characteristic.
Read all attributes for many characteristic values
You need to read the attributes of a set of values of a characteristic (e.g. 0SALESORG). You need to fill an internal table of type rsd_t_chavl with the characteristic values and pass them with the I_T_CHAVL import parameter. The attribute values for the characteristic values passed in I_T_CHAVL are returned in the E_TABLE table. As in the point above, this table has to have the same structure as the attribute view of the involved charateristic (e.g. /BI0/MMATERIAL).
Read all attribute for all the characteristic values
You need to read all the values of a characteristic (e.g. 0SALESORG). Since you are interested in all the values, you do not input a characteristic value, but just the characteristic name (parameter I_IOBJNM). To actually fetch the values, you need to set the boolean parameter I_FLG_WHOLE_TABLE. All the contents of the attribute view are pushed into an internal table, which has to have its same structure.
Similarly to the above cases, it is often advisable not to access the hierarchy tables directly to get hierarchy data. You can use the function module RSNDI_SHIE_STRUCTURE_GET instead. You pass the internal hierarchy ID in the input parameter I_S_HIEKEY. The internal hierarchy ID identifies the hierarchy uniquely. You can get this ID opening the detail window from the hierarchy maintenace screen:
The return code of the function call is passed back in the E_SUBRC parameter. The contents of the hierarchy table (e.g. /BI0/HMATERIAL) are returned in an internal table with structure RSHIERSTRUCT (parameter E_T_HIERSTRUCT). Optional output messages are put in an internal table with structure RSNDI_S_MESSAGE (parameter E_T_MESSAGE).
The GUID or the hierarchy ID for the hierarchy given can be found from the table RSHIEDIR which has the hierarchy header information.
Since BW 3.x the similar function module RSNDI_SHIE_STRUCTURE_GET3 is defined as well, which has a more flexible interface.