Application Development Blog Posts
Learn and share on deeper, cross technology development topics such as integration and connectivity, automation, cloud extensibility, developing at scale, and security.
cancel
Showing results for 
Search instead for 
Did you mean: 
CreyJ
Participant
716

Hello,

here I want to share some knowledge/hints how an online language switch can be implemented.

  1. SET LOCALE LANGUAGE <SPRAS> changes the current language of the current internal session. see elp.sap.com/abapdocu_702/en/abapset_locale.htm.
  2. Transactions called by Function  TH_REMOTE_TRANSACTION seem to belong to that internal session, so they use that language
    1. Parameter DEST is not an RFC destination, but 'NONE' is accepted. If you want to execute the function on certain servers, you can use e.g. function  TH_SERVER_LIST  to get a list of servers (also by RFC).
    2. using transaction  ' ' starts just a session
    3. 'SESSION_MANAGER' is also a transaction.
  3. LEAVE PROGRAM  terminates a program.

So code snippet to switch language could look like this (usage on your own risk / only for evaluation):


form SWITCH using FUW_SPRAS

                                 FUW_TCODE..

   data: LW_TCODE type TSTC-TCODE.

   set locale language FUW_SPRAS.

   select single TCODE from TSTC into LW_TCODE
     where TCODE = FUW_TCODE.

   if not LW_TCODE is initial.
     call function 'AUTHORITY_CHECK_TCODE'
       exporting
         TCODE  = LW_TCODE
       exceptions
         OK     = 1
         NOT_OK = 2.
     if SY-SUBRC = 2.
       return.
     endif.
   endif.

   call function 'TH_REMOTE_TRANSACTION'
     exporting
       TCODE = LW_TCODE
       DEST  = 'NONE'.
   leave program.

endform.                    "SWITCH


-Jürgen-

Labels in this area