Multi-language messages in SAP

The title of this post says it all.  It is known that usually international companies can afford to implement SAP and that part of the correspondence that they will have will be in several languages. So here is a simple procedure that can be used when a message to customers from different countries should be sent.

Step 1 -> Open the transaction s010 for Standard text creation

Step 2 ->  In the field add descriptive

TEXT NAME – (in this case – Z_CUST_MSG)

TEXD ID – ST

LANGUAGE – any.

Step 3 ->  Write the content of the message in the text editor and save it.

Step 4 ->  Repeat Steps 1-3 for all the languages that you would like to use.

Step 4 -> Using the text via ABAP code.

* t_lines to hold the text
  data: t_lines type table of tline with header line.
* CUSTOMER COMMUNICATION LANGUAGE
  select spras
    into cust_lang
    from kna1
    where kunnr = p_kunnr.
  endselect.
* GET THE TEXT FOR THE BODY OF THE MESSAGE
  CALL FUNCTION 'READ_TEXT'
    EXPORTING
      CLIENT   = SY-MANDT
      ID       = 'ST'
      LANGUAGE = cust_lang
      NAME     = 'Z_CUST_MSG'
      OBJECT   = 'TEXT'
    TABLES
      LINES    = t_lines.
  IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
* IF THERE IS NO TRANSLATION OF THE LANGUAGE ASK USER
  ENDIF.
  DATA: counter type i.
 counter = 0.
 loop at t_lines.
 if counter = 0.
* in this case the first line of the text is used as a subject text for the message
      REPLACE ALL OCCURRENCES OF '/' IN t_lines WITH ''.
      modify t_lines.
      msg_sub = t_lines.
      counter = counter + 1.
    else.
      REPLACE ALL OCCURRENCES OF '/' IN t_lines WITH ''.
      modify t_lines.
      concatenate msg_body t_lines CL_ABAP_CHAR_UTILITIES=>NEWLINE into msg_body.
      counter = counter + 1.
    endif.
  endloop.
Advertisements