Function Returns the attribute value in user format
Example myuservalue =
s10getuservalue( "kunnr" ).
Format data:
  myattrname type string,
  myunitattrname type string,
  myuservalue type string.

myuservalue =
  s10getuservalue(
    exporting
      attrname = myattrname
      unitattrname = myunitattrname ).
Parameters
Name Type Description
attrname string
Attribute name
unitattrname string
Unit or currency
uservalue string
Value in user format
Description The s10getuservalue() method is called by the S10 framework whenever the value of an attribute is displayed to the user. But the method can also be called directly, for example to insert values in user format in a message text or a generated document. The type of formatting is the same as for ABAP "Write", i.e. the user settings regarding decimal and date representation as well as a possible conversion exit are taken into account. The conversion exit can generate different outputs for different logon languages, for example, "Pce" is output for unit of measure "ST" for logon language French and "PC" for logon language English.

If necessary, a "build" method defined in the ABAP class for the attribute is called before the value is output.

If the name of the associated unit or currency attribute is stored in the ABAP class for the attribute to be displayed, the number of decimal places is selected appropriately for the output.

Example:

data
:
  
kwmeng     type vbap-kwmeng,
 
vrkme      type vbap-vrkme.

constants:
assign unit attribute
  unit_kwmeng type string value 'vrkme'.

If "vrkme" has the value "ST", i.e. piece, the output of "kwmeng" is without decimal places.

You can also provide the name of the attribute containing the unit as a parameter in the method call itself.

The attribute containing the unit is not always stored in the same database table as the quantity field. For example, the warehouse stock is stored in table "MARD" in the field "LABST", but the corresponding warehouse unit of measure is contained in table "MARA" in the field "MEINS" (base unit of measure).

If you now create a class for the database table "MARD", e.g. "db_mard" or generate it in the S10 Uitilities, the unit of measure is missing there. To get a correct output also for this case, you can proceed as follows:

You include the unit field as another attribute in the "db_mard" class and implement a "build" method that reads the unit from database table "MARA". The S10 framework will automatically call the build method of the corresponding unit of measure before displaying "LABST" whenever the material number has changed and the display will be correct according to the base unit of measure of the material:

* Class db_mard
    
data:
      
matnr type mard-matnr, Material
      werks type mard-werks" Plant
   
   lgort type mard-lgort" Storage Location
      labst 
type mard-labstUnrestricted
      
umlme type mard-umlme" Stock in transfer
      
insme type mard-insme" In Quality Insp.
     
retme type mard-retme" Returns
 

      meins 
type mara-meins. " Base unit

   constants:
assign unit attribute
      
unit_labst  type string value 'meins',
      
unit_umlme  type string value 'meins',
      
unit_insme  type string value 'meins',
      
unit_retme  type string value 'meins'.

 declare method and dependency
 
methods:
      build_mara_data

        
importing
          
matnr type mara-matnr
        
exporting
          meins 
type mara-meins.

 * implement method
 method build_mara_data.
    
select single meins from mara into meins
              
where matnr matnr.
 
endmethod.

 

Components S10 Framework