来源资料待手动核验
ABAP Form Translator
ABAP Cloud-ready tool for SAP form translations.
项目简介
ABAP Cloud-ready tool for SAP form translations.
ABAP Cloud-ready tool for SAP form translations.
ABAP Cloud-ready tool for SAP form translations.
Open Source Contribution: This project is community-driven and Open Source! 🚀
If you spot a bug or have an idea for a cool enhancement, your contributions are more than welcome. Feel free to open an Issue or submit a Pull Request.
A lightweight, dynamic runtime translation tool for SAP forms.
It decouples text management from form development, allowing functional consultants or users to maintain labels via a simple database table (RAP Application), bypassing the complex standard SE63 workflow.
This project is licensed under the MIT License.
The repository was created by George Drakos.
IF sy-langu = 'D'. text = 'Kunde'. ENDIF.ZCL_FORM_TRANSLATION=>clear_buffer( )
to pick up changes immediately.Part of the test suite runs outside the ABAP system, transpiled to JavaScript with abaplint, so every push is verified without an SAP system:
npm ci
npm run lint
npm test
This covers ZCL_FORM_TRANSLATION (RTTI mapping, language fallback, buffer)
and ZCL_FORM_TRANS_RULES (validation rules). 30 unit tests, backed by an
in-memory SQLite database so the SELECT and CL_OSQL_TEST_ENVIRONMENT
behave as they do in the system.
DATA: BEGIN OF labels,
title TYPE string,
footer_note TYPE string,
customer_lbl TYPE string,
END OF labels.
" 1.Initialize (Optional defaults)
labels-title = 'Invoice'.
" 2.Translate dynamically based on Language and DB Configuration
DATA(translator) = CAST zif_form_translation( NEW zcl_form_translation( ) ).
translator->translate_form(
EXPORTING formname = 'ZINVOICE_FORM' " Key in ZABAP_FORM_TRANS
langu = cl_abap_context_info=>get_user_language_abap_format( )
CHANGING form_elements = labels ). " The structure to be translated
" 3. The labels structure now contains the translated texts from ZABAP_FORM_TRANS
" Pass this structure to your Smartform / Adobe Form interface.
translate_form maps the fields of ZABAP_FORM_TRANS onto the components of your
structure by field name (via RTTI). Signature:
| Parameter | Direction | Type | Default | Meaning |
|---|---|---|---|---|
formname | importing | zabap_form_trans_name | – | Key in ZABAP_FORM_TRANS. An empty value returns without changes. |
langu | importing | zabap_form_trans_langu | logon language | Target language. If empty, the current user language is used. |
enable_fallback | importing | abap_boolean | abap_true | When on, fields that have no text in the target language fall back to the default language (E). |
form_elements | changing | any | – | Flat structure whose components are filled with the translated texts. |
clear_buffer (static) invalidates the in-memory translation buffer. Call it after
maintaining translations inside a long-living session (mass print / batch / job
server) so hot-swapped texts take effect immediately.
Note: only flat structures are supported. Nested structures and internal tables are not translated.
ZABAP_FORM_TRANSMaintain the texts through the RAP/Fiori app (ZUI_FORM_TRANS_BIN) in this table:
| Field | Type | Key | Description |
|---|---|---|---|
FORM | ZABAP_FORM_TRANS_NAME (CHAR 30) | ✔ | Form key passed as formname. |
FIELDNAME | ZABAP_FORM_TRANS_FIELD (CHAR 30) | ✔ | Component name in your structure. |
LANGU | ZABAP_FORM_TRANS_LANGU (LANG) | ✔ | Language of the text. |
DESCR | ZABAP_FORM_TRANS_DESCR (CHAR 50) | Translated text. | |
LENGTH | ZABAP_FORM_TRANS_MAXLEN (INT2, domain range 0–9999) | Max length; text longer than this is truncated at print time. 0 means no length limit. |
Select one or more rows in the list, press Copy Language and pick the target language. Each selected row is duplicated into that language as a draft, keeping its description and max length.
Rejected with a message: