ABAP log

February 7, 2007

Language-specific logic in ABAP.

Filed under: ABAP, SAP — abaplog @ 8:06 pm

Writing code to support users all over the world is never easy, and SAP has, of course, its own specifics. You should process language-dependent data with care. You can get into a trouble if you assume that the data like material description is always available in your current language.

Have a look at this example of selecting production orders for materials together with their descriptions:

select afko~aufnr  makt~maktx from afko inner join makt
    on makt~matnr = afko-plnbez
  into table t_orders
  where afko-plnbez = material and
         makt~spras = sy-langu.

What if some material has a description only in a language other than current? You’ll miss some orders! If that can be possible on your system, it’s better to select production orders for the material first and then do a loop, selecting descriptions and assigning something like “Unknown” to those that do not have one.

A problem of similar kind can arise if you are using text constants for texts that are actually language dependent. Let’s say that your ABAP program is checking whether a production order is completed, assuming a presence of order status ‘TECO’. If you give this text to the status check function and don’t supply the language, you will get the wrong status information if your program is running in German (where ‘TECO’ is ‘TABG’). To solve the problem you can supply the right language or read the status directly from table JEST, providing language-independent status name like ‘Ixxxxxxx’ (see the contents of table TJ02T for possible values).

Another kind of problems with language-dependent data arise when your are doing updates with CALL TRANSACTION supplying BDC data in an internal table. The quantity fields or date and time are stored in your program variables in an internal form. To make your BDC work, you have to convert them to “output” representation that is specific to the user, with which your BDC will be running. For example, the difference can be on the order of date and month (European format vs USA), or decimal separator (comma or period?). The most simple way to get proper format is to declare a character variable and use WRITE … TO operation that will take care of current user’s formats.


Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Create a free website or blog at WordPress.com.

%d bloggers like this: