Fonction SAP CBIH_LB11_QTY_GET_STOCK_TOTAL - EHS: User Exit - Determine Warehouse Stock for Material

Paramètre Reférence Type Long. Valeur par déf. Facultatif Description
I_BEGIN_DATE SYST-DATUM D 8 SY-DATUM X Start date of selection (optional)
I_END_DATE SYST-DATUM D 8 SY-DATUM X End date of selection (optional)
I_LIMIT_TYPE CCIHC_LT01-LTTYPE C 3 Reference value category/method category
I_QUANTITY_TYPE CCIHC_QT01-EPQUANTTYPE C 3 Exposure amount category
I_VALIDATION_DATE SYST-DATUM D 8 SY-DATUM X Key date for selection (optional)

Paramètre Reférence Type Long. Description
E_ERROR_STRUC RCGEXTERROR u 608 Error structure, filled in case of error
E_FLG_NO_VALUES ESP1_BOOLEAN 0 Indicator: True ('X'), no values calculated

Paramètre Reférence Long. Facultatif Description
E_EXPOSURE_HEADER_TAB CCIHS_ERHIOT 1750 Risk assessment headers (output)
E_QUANTITY_TAB CCIHS_ERQTIOT 1144 Exposure amounts (output)
I_EXPOSURE_HEADER_TAB CCIHS_ERHIOT 1750 Risk assessment headers (input)
I_QUANTITY_TAB CCIHS_ERQTIOT 1144 X Exposure amounts (input, optional)

Exception Description
INTERNAL_ERROR Internal program error
PARAMETER_ERROR Input parameter error

Use
This function module enables you to calculate the warehouse stock ofmaterials orreal substances to which amaterial is assigned.

Input
In the interface, an amount category and ameasured value/reference value category arepassed to the module. As an option, a start date and end date for theselection period and a key date can be passed. If these are not filledat the interface, the current system date is used.
A table of risk assessment header records for which the calculation isto be carried out is also passed. If it exists, a table of existingamount records is passed.

Output
If no new data could be calculated on the basis of the values passed,the E_FLG_NO_VALUES indicator is set to "X" (= true).
The newly calculated amount records with the stock data for theindividual materials or real substances are returned in theE_QUANTITY_TAB table. Here, each amount record is assigned a headerrecord of the risk assessment in the E_EXPOSURE_HEADER_TAB table.
If an error occurs in processing that does not lead to an exceptionhandling being triggered, error information is returned to the callingprogram via the E_ERROR_STRUC structure.

Functionality
Processing is done in the following steps:
Input check
First the input parameters are checked. If the passed amount category,the measured value/reference value category, or the table for the riskassessment header records are empty, further processing is canceled. Thepassed data is also transferred to a local work table.
Check for material or real substance
A check is run on the passedagent type. The agent typemust be a material or a real substance because executing a materialstock determination only makes sense for these. If the agent type is nota material or a real substance, processing is ended without errors andno data is returned.
Determine material assignment
If the passed agent type is a real substance, for all passedspecifications contained inthe risk assessment header records, the material assignments aredetermined within the specification database and updated in the worktable.
If it is a material, only the local work table is updated.
Entries in the work table for which no material exists - either directlyor via an assignment - are deleted. If the work table is then empty,processing is ended without errors.
Determine work area assignment and integration objects
To determine the stock data for the material, both the assignment of theagent to the work area and the assignment of a storage location to thework area are used.
The work area is assigned directly via the risk assessment header.
The assignment of the storage location to the work area is made usingthe data integration function in the work area.
The assignment data is transferred to the work table, entries with noassignment are deleted. If the work table is empty, further processingis ended without error messages.
Determine RFC destination
The module is prepared for a link to the material data via RemoteFunction Call (RFC). Forthis purpose, a check is made for each plant via an environmentparameter whether a link has been set up via RFC. This means it ispossible in principle to set up one Plant Maintenance system for eachplant.
Important: Distribution via RFC is not used in this modulebecause no released module with RFC capability for reading materialstocks was available at the time.
Read material stock data
Once all required data has been entered in the work table, the materialstocks can be read.
Prepare output
Output is now prepared by writing the calculated data to the amounttable for export. The following is important here:
The link to its header record must be entered in the new amount record.To do this, the RECN of the relevant header record is transferred to theamount record as RECNROOT.
A check must be made whether the unit of the calculated material stockhas the same dimension asis set for the amount category (see SpecifyMeasurement Items).
If an amount record already exists for thismeasurement item, afollow-on record can be created. Here, a check is run to determinewhether the start of validity of the existing record is not equal to thecurrent key date and whether the end of validity is the 12/31/9999("high date"). Only if this is the case is a record split permitted andthe SPLITTFLG indicator of the exported amount record can be set to true("X").
Export calculated data
The final step checks whether the export table for amounts containsentries. If it does, the export indicator E_FLG_NO_VALUES is set tofalse (" ").

Prerequisites
So that the function module can be used it must be active in the systemand be assigned to at least onemeasurement item inCustomizing for Industrial Hygiene and Safety in the IMG activitySpecify Measurement Items. When you edit the activity
, also make sure that the dimension of the amount category matches thedimension in inventory management, and that the units ofmeasurement for inventory management are contained in thedimension for the amount category.

Notes
If the function module was assigned as described in Customizing, it canbe called from the Industrial Hygiene and Safety menu usingAgents -> Amount Determination. Before determination is started,you must specify the amount category and the measured value/referencevalue category.

Further_sources_of_inf
INCLUDE EHS_CBIH_UE_READ_QUANTITIES OBJECT DOKU ID TX

398842Quantity determination via user exits incorrect
679397Error in the amount determination