2023 Feb 21 8:48 AM
So I am using cl_salv_table=>factory alv to display some data in an internal table to a user.
At the selection screen the user has the option to fill in a language parameter.
So for example if a user is logged with EN language, but fills DE for the parameter, I'd want to display the information from the alv in German - That includes the name of the columns and all the content in the fields.
Is this possible? Thank you.
2023 Feb 21 9:16 AM
You can use SET LOCALE LANGUAGE command before the SALV factory method call.
Here are details in the ABAP help docu:
https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/index.htm?file=abapset_locale.htm
Do not forget to change language back after the SALV display 🙂
EDIT: I have to mention that according to programming guidelines: "Set the statement SET LOCALE LANGUAGE in exceptional cases only, and reverse any text environment switches in good time." ! Maybe someone knows better way to switch ALV output language.
2023 Feb 21 11:33 AM
Not sure if it's a "better way", but it's a less intrusive one: play with the field catalog. If the selected language differs from the system's one, retrieve the field catalog and find a way to re-populate the texts with the selected language (I'm pretty sure there are DDIC functions to retrieve them).