Several custom utility classes are available in S/4HANA. These utility classes are reusable and reduce the need to "reinvent the wheel" for basic, reoccurring needs in custom ABAP code. There are to be used to avoid unnecessary code duplication and slightly different implementation approaches.


All utility classes sit in package /SYQ/UTILITY and have the release contract C1 set to be able to be used in the ABAP Cloud standard.

Amount in Words

This utility class simplifies the conversion of amounts into their written form in words including the currency, based on passed language key.

Class Name/SYQ/CL_AMOUNT_IN_WORDS
Method NameDescriptionParameters
GET_AMOUNT_IN_WORDSConverts an amount into words in different languages

i_currency

i_amount

i_language

e_in_words

GET_AMOUNT_IN_WORDS_RUConverts an amount into words in Russian

i_currency

i_amount

i_language

e_in_words

Application Logging

This utility class unifies the way we use the application log and has all needed functionality to create log entries.

Class Name/SYQ/CL_APPLOG_UTILITY
Method NameDescriptionParameters
GET_INSTANCECreate an instance of the Application Logging Utility Class


CREATE_LOG_OBJECTCreate a log object using header descriptors

i_object

i_subobject

i_external_id

ADD_FREE_TEXTAdd a free text value to Log

i_severity (Default: Default Severity)

i_text

ADD_MESSAGES_FROM_BAPI_RETURNAdd message table from BAPI Return

i_messages

ADD_MESSAGE_FROM_BAPI_RETURNAdd a single message in the format of BAPI Return

i_message

ADD_MESSAGE_FROM_SYSTAdd message based on SY value (ie. SY-MSGID, SY-MSGNO, etc)


ADD_MESSAGE_FROM_BEHAVIORAdd new message from RAP Behavior messages

i_behavior_message

SAVESave log object to DB


GET_HANDLEGet the handle ID of the created log object

r_handle

GET_LOG_OBJECTGet the previous instance of the log object using handle

i_handle

READ_LOG_FROM_DBRead the log results from DB using filter values

i_object

i_subobject

i_external_id

i_user

i_start_time

i_end_time

r_logs


New message class /SYQ/APP_LOG added to maintain error messages while creation

New exception class /SYQ/CX_APPLOG_UTILITY created to handle errors in standard BAL processing

In terms of usage, the most common and straightforward processing would be: (a)

  1. Get instance of the object
  2. Create new log object
  3. Add new text (executed one or more times depending on the number of messages)
  4. Save


Conversions

This utility class has the required logic to convert to and from strings, xstrings, and binaries.

Class Name/SYQ/CL_CONVERSION_UTILITY
Method NameDescriptionParameters




Sending of emails

This utility class unifies the email sending process in case it is part of a requirement.

Class Name/SYQ/CL_EMAIL_UTILITY
Method NameDescriptionParameters
CREATE_INSTANCECreates a new instance of the Email Utility
SEND_EMAILSends email 

i_sender

i_recipients

i_subject

i_body_html (Optional)

i_attachments (Optional)


Enterprise Structure Constants

This utility class provides a unified access to enterprise structure constants.

Class Name/SYQ/CL_CONSTANT_UTILITY
Method NameDescriptionParameters




Dynamic Logo for form outputs

This utility class provides the logic to determine and retrieve the required logo to be output on a form and removes the need to maintain it in each form build.

Class Name/SYQ/CL_DYNAMIC_LOGO_UTILITY
Method NameDescriptionParameters
GET_COMPANY_LOGO_FROM_BUKRSRetrieve the company logo path and binary

i_bukrs

e_logo_path

GET_FILE_FROM_MIMERetrieve logo binary from MIME repository

i_mime_path

e_logo_binary


Logos are maintained in the MIME Repository, transaction code SO2_MIME_REPOSITORY. Folder is under SAP->PUBLIC→SYENSQO. Default logo file is called Default_Logo.png. It is only needed to add additional and different logos than the default.

Table /SYQ/T_LOGO_PATH contains the logo location path per company code. Company code 0000 is set up for the default logo.


Launchpad Notifications

This utility class provides a simplified and unified approach to trigger custom launchpad notifications. Functionality provided is the sending of notifications with or without navigation targets.

Class Name/SYQ/CL_NOTIF_PROVIDER
Method NameDescriptionParameters
CREATE_NOTIFICATIONCreates a launchpad notification

i_type_key

i_recipient

i_parameter

i_nav_parameters


Message class /SYQ/NOTIFICATION to be updated to add a new notification text with parameters.

Table /SYQ/T_NOTIF_CNF to be updated with the Notification type and created message ids.

Table /SYQ/T_NOTIF_NAV to be updated  with navigation target, if required, having the semantic object and action.


Switch framework

This utility class provides the logic to switch on or off certain functionality in custom code in each system separately. Each enhancement requires the switch to be implemented to be able to quickly deactivate it in case of an issue. it is also useful to implement endless loops to allow background task debugging when active.

Class Name/SYQ/CL_SWITCH_FRAMEWORK
Method NameDescriptionParameters
CHECK_SWITCHReturns a boolean based on a check in  the switch table

i_enhancement_id

i_enhancement_step

r_check_value


Table /SYQ/T_SWITCHES to be updated with the switch definition and activation indicator. Table to be maintained in each system/client where and when needed.