Languages, Currency, and Units of Measure

Team-Fly

Another factor that is sometimes neglected in interface design, especially when it comes to Internet screen design, is that the screen can be viewed from around the world. If you are designing interfaces for a large multinational corporation, you need to allow for factors such as various login languages. Therefore, when you are writing your Java programs, you must get data element descriptions from SAP instead of coding the prompts yourself. One of the major advantages of an ERP system is that the data, including the metadata (the data about the data), is centralized, as you can see in Figure 17.2. This example shows the descriptions for the SAP data element EKGRP.

click to expand

Figure 17.2: Data element descriptions for purchase orders from the SAP data dictionary

Retrieving field prompts in the login language from SAP means that you have to maintain them in only one place. Unfortunately, SAP does not provide a standard BAPI for retrieving data element definitions. This step, however, is relatively easy, as the following example shows.

Function Module BAPI_Z_DATAELEMENT_GETDETAIL *"----------------------------------- *" *"local interface: *"       IMPORTING *"             VALUE(DATAELEMENT) LIKE  DD02L-FELDNAME *"       EXPORTING *"             VALUE(SHORT_DESC) LIKE  DD02L-TEXT *"             VALUE(MED_DESC) LIKE  DD02L-TEXT *"             VALUE(LONG_DESC) LIKE  DD02L-TEXT *"       TABLES *"              RETURN STRUCTURE  BAPIRET2 *"-----------------------------------

This BAPI will return the three descriptions (if they exist) for the current login language.

data: int_dd04T like structure dd04t occurs 10 with header line. call function ‘DD_DTEL_GET'     exporting          LANGU         = sy-langu         ROLL_NAME    = Data_element     tables         dd04t_tab_n      = int_dd04t.     read table int_dd04t index 1.     if sy-subrc ne 0.          return-msgno = ‘001'.         retrn-message = ‘Cannot find Data Element Descriptions'.         append return.     endif.     short_desc     = int_dd04t-scrtext_s.     med_desc       = int_dd04t-scrtext_m.     long_desc      = int_dd045-scrtext_l. ENDFUNCTION.

You can make this routine more generic by passing in the language you want the text returned in, but because you are likely to want the same language that you are using for the login to do this call, the language can be derived from the SAP system variables. Therefore, when developing BAPIs, keep the number of variables as low as possible. If you use the standard factories to generate the fields for the BAPI call, the amount of time the factory call takes is proportional to the number of variables.

Note 

Note that the naming convention for this BAPI is a little different from the SAP standard. According to that standard, a BAPI function module is labeled as BAPI_<OBJECT NAME>_<FUNCTION>. However, the standard does not show how to represent a customer-created BAPI for a standard SAP object (such as this one). Hence I threw the Z_ into the name so that people will realize that this item is a customer BAPI.

The preceding BAPI enables you to use MATNR in your Java code to represent material number and to display the prompts in the user's login language or on reports that your Java application produces. The same type of approach can be used for date format and currency or a preferred unit of measure. These features will not only enhance the overall user experience but also, over the long term, reduce the amount of code that you need to write or maintain.


Team-Fly


Java & BAPI Technology for SAP
Java & BAPI Technology for SAP
ISBN: 761523057
EAN: N/A
Year: 1998
Pages: 199

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net