How do I connect to a Repository using the Function Module-Based MDM4A?
This is the exact same logic as our earlier class-based example, just now implemented using the Function Groups.
DATA log_object_name TYPE mdm_log_object_name.
DATA language TYPE mdm_cdt_language_code.
log_object_name = 'LOCAL_MDM'.
language-language = 'eng'.
language-country = 'US'. language-region = 'USA'.
CALL FUNCTION 'MDM_ACCESSOR_CONNECT'
EXPORTING
is_repository_language = language
iv_log_object_name = log_object_name
EXCEPTIONS
ex_api_usage_error = 1
* ....
OTHERS = 6.
IF sy-subrc NE 0.
WRITE: / 'Error during connect: ', sy-subrc.
EXIT.
ENDIF.
****Do Something
CALL FUNCTION 'MDM_ACCESSOR_DISCONNECT'
EXPORTING
iv_log_object_name = log_object_name
EXCEPTIONS
ex_api_usage_error = 1
* ....
OTHERS = 6.
IF sy-subrc NE 0.
EXIT.
ENDIF.
One of the key differences is that now we have to pass the configuration key (the MDM Logical Object Name) into every function module call. Also the exception handling must be repeated and checked after each function module call. The functions don't throw exception classes, therefore TRY...CATCH blocks must be replaced with checks of SY-SUBRC.