null

Skip to end of banner
Go to start of banner

Defining Text Providers

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Version History

Version 1 Next »

A functionality of the OBJ module is to provide descriptions/texts for specific field values, these might be for example units of measure, code numbers, like factory code, descriptions of choices in fields, or document numbers for which a descriptive text can be provided. This functionality is used by the AFW framework, for example, to provide descriptive texts to AFW application users.

The texts for various fields of Business Objects is made available by a Text Provider. This is an ABAP program (ABAP Class) that evaluates Customizing and DDIC information to determine if text description can be provided for a specific field. Based on that information reads database tables and services requests of applications for text description of specific field values.

The OBJ module provides a way to assign and extend this functionality to data fields for which a text description is not yet available or to change the provided text for fields which already have a value description.

The functionality of the Text Provider is implemented by the class /PCH/CL_OBJ_VALUETEXT_PROVIDER. It evaluates the various ways to read the text for a field value, and takes into account the defined Text Classes from customizing tables /PCH/OBJ_VTEXT_P and /PCH/OBJ_VTEXT_C. For some fields the text provider can automatically provide text, other fields require a custom Text Class to be implemented.

Defining a Text Class

A text class is an ABAP class that implements the /PCH/IF_OBJ_VALUETEXT class-interface, and has a working GET_TEXT method-implementation. It is called by the Text Provider to retrieve a text description for a specific field value. A GET_TEXT method implementation is usually a database selection on the relevant database table with the provided key value.

The GET_TEXT method has the following parameters:

  • IV_TABLE
    Is the relevant DDIC Table or Structure name.

  • IV_FIELD
    Is the relevant field in the table for which we are retrieving text.

  • IV_DATA_ELEMENT
    Is the data type/data element as defined for the field in DDIC

  • IV_LANUAGE
    Is the desired language of the text that should be retrieved/when text descriptions in multiple languages are available.

  • IR_STRUCTURE_DATA
    Corresponds to the IV_TABLE parameter. If it is provided to the GET_TEXT method, then it is a structure containing the IV_FIELD field, and other fields. It is used in cases when multiple key fields comprise a foreign key that required to read another table for the text description.

  • RV_TEXT
    This is the result field of the GET_TEXT method, and should be filled with text that corresponds to the value passed in IV_VALUE parameter.

An example implementation of a Text Class is the class /PCH/CL_OBJ_VALUETEXT_FLAG. The method GET_TEXT of the class returns a simple Yes/No when passed a customary ABAP bool value.

  METHOD /pch/if_obj_valuetext~get_text.
    IF iv_language CA 'DEF'.
      " Use translated text for German, English and French
      rv_text = COND #( WHEN iv_value = abap_true THEN 'Ja'(001) ELSE 'Nein'(002) ).
    ELSE.
      " Revert to reading DD07T for other langugages
      SELECT SINGLE ddtext
              INTO rv_text
             FROM dd07t
        WHERE domname = 'XFELD'
          AND ddlanguage = iv_language
          AND as4local = 'A'
          AND domvalue_l = iv_value.
    ENDIF.
  ENDMETHOD.

Registering the Text Class

Defining a Text Class like /PCH/CL_OBJ_VALUETEXT_FLAG in itself is not enough. The Text Provider needs to know that such a class is available, and should be called to provide text for boolean fields.

Registering a Text Class involves entering the class name into a customizing table. The relevant customizing tables can be found in SAP’s Implementation Guide (Transaction SPRO):

Some Text Class implementations are provided as default and are already registered in customizing table /PCH/OBJ_VTEXT_P. These entries should not be maintained in customer systems.

Customer-specific Text Class implementations need to be registered into customizing Table /PCH/OBJ_VTEXT_C. Entries in the /PCH/OBJ_VTEXT_C table take precedence over entries from the P table.

There are two ways to register Text Classes:

  1. Registering for a specific table field. The table and field names are entered into the customizing table, along with the class name.

  2. Registering for a data type/DDIC Data Element. The name of the Data Element is entered in the Table Name field, and the Field Name should be left empty.

The registration of Text Classes can be done for public ABAP classes or for local ABAP classes (that are publicly instantiable). For public classes specifying the name of the class suffices, for local classes the special format for specifying types has to be followed.

  • No labels