I have a gateway service that needs to service users with different languages, and the best way I have found is to implement a method to fetch the language from request header.
But the downside is that I have to include this method call in every enitity implemented and therefore this is often called multiple times per request.
Is there a way to set the language as a global attribute in the gateway object modea and prehap redifine some base class method to set the language automatically in every request ?
METHOD get_language. DATA : lo_facade TYPE REF TO /iwbep/if_mgw_dp_int_facade, lt_client_headers TYPE tihttpnvp, lw_client_headers LIKE LINE OF lt_client_headers. TRY. lo_facade ?= /iwbep/if_mgw_conv_srv_runtime~get_dp_facade( ). lt_client_headers = lo_facade->get_request_header( ). CATCH /iwbep/cx_mgw_tech_exception. ENDTRY. LOOP AT lt_client_headers INTO lw_client_headers WHERE name = 'accept-language'. IF lw_client_headers-value CS 'en'. ov_language = 'E'. ELSEIF lw_client_headers-value CS 'pl'. ov_language = 'L'. ENDIF. ENDLOOP. SET LANGUAGE ov_language. sy-langu = ov_language. ENDMETHOD.