abap-system-fields
An ABAP Cloud class that wraps SY system fields and calendar-date functions behind an injectable instance, so code that reads them stays stable under unit tests.
An instance created with zcl_syst=>create( ) stands in for SY: the README's example creates it in the constructor and assigns it to an attribute of the class, so that a unit test stays stable, and says SY can be overridden this way. Its table of methods gives user_id for sy-uname, system_date for sy-datum, return_code for sy-subrc and table_index for sy-tabix, and others for cl_abap_context_info=>get_user_alias, GET TIME STAMP or utclong_current( ). The date methods read I_CalendarDate and return the quarter, the week number, the weekday and the first or last day of a week or month. The README presents all of it as ABAP Cloud enabled, decoupled from coding and testable through the injector pattern.
Facts
Where it sits
Who is behind it
In the atlas: maintains 7, contributes to 8@Xexermaintainer
What it declares
Every artifact
- Type
- Package
- Origin
- Independently maintained
As a package
- Where it runs
- does not say
- Distributed through
- does not say
Connections
Whether code can run in ABAP Cloud, and what to do when it cannot
Download
README
quoted from Xexer/abap-system-fields under MIT, readABAP System Fields
Introduction
ABAP Cloud enabled system fields and date functions.
- Decoupled from coding
- ABAP Cloud best practices
- Testable (Injector Pattern)
Fields and Functions
Via this article you can get more informations to the actual structure and functions.
| Method | Function |
|---|---|
| user_id | sy-uname |
| user_alias | cl_abap_context_info=>get_user_alias |
| system_date | sy-datum |
| system_time | sy-uzeit |
| timestamp | GET TIME STAMP |
| timestamp_long | GET TIME STAMP |
| utclong | utclong_current( ) |
| user_date | sy-datlo |
| user_time | sy-timlo |
| time_zone | sy-zonlo |
| language | sy-langu |
| language_iso | - |
| system_information | sy-mandt, sy-sysid, sy-cprog, sy-saprl |
| index | sy-index |
| table_index | sy-tabix |
| database_count | sy-dbcnt |
| return_code | sy-subrc |
| letter_upper | sy-abcde |
| letter_lower | - |
| weekday | sy-fdayw |
| message | sy-msgid, sy-msgno, sy-msgty, sy-msgv1, ... |
| message_bapiret2 | sy-msgid, sy-msgno, sy-msgty, sy-msgv1, ... |
| message_bali | sy-msgid, sy-msgno, sy-msgty, sy-msgv1, ... |
Date Functions
In the newest classes we utilize I_CalendarDate to give easy and fast access to date functions. You will find methods for often used calculation methods.
| Method | Description |
|---|---|
| get_raw_date | Return full data set from I_CalendarDate |
| get_quarter | Return the quarter |
| get_week | Number of the week |
| get_weekday | Weekday as integer (constants available) |
| get_first_day_of_week | First day of the week |
| get_first_day_of_month | First day of the month |
| get_last_day_of_week | Last day of the week |
| get_last_day_of_month | Last day of the month |
| get_calendar_day_of_the_year | Return the number of the day in the actual year |
Example
Start in the constructor to create the instance and assign it to an attribute of the class, so your Unit Test should stay stable. We can override the "SY" with this method.
sy = zcl_syst=>create( ).
Using as SY-SUBRC in a function:
AUTHORITY-CHECK OBJECT 'S_APPL_LOG'
ID 'ACTVT' FIELD '02'.
RETURN xsdbool( sy->return_code( ) = 0 ).
Using as SY-UNAME in a IF statement:
IF sy->user_id( ) = 'TECHUSER'.
RETURN abap_true.
ELSE.
RETURN abap_false.
ENDIF.
Creating a timestamp inline:
DATA(actual_time) = sy->timestamp_long( ).
Retrieve information about the weekday:
DATA(today) = sy->date_functions( ).
DATA(weekday) = today->get_weekday( ).
DATA(weekday_new) = sy->date_functions( )->get_weekday( ).Others providing
Compare all 11 on the ABAP Cloud readiness page →- abap-cloud-guiabap-cloud-guiA report-style programming model for abap2UI5: one class produces a selection screen with a WRITE list or an ALV grid, running as a UI5 app on ABAP Cloud as well as on NetWeaver 7.02.independent, abapReport-style programming model for abap2UI5 on ABAP Cloud
- codepagecodepageA polyfill class, ZCL_ABAP_CODEPAGE, that converts strings to binary and back behind one interface, where Clean Core blocks CL_ABAP_CODEPAGE and older systems lack CL_ABAP_CONV_CODEPAGE.independent, abapPolyfill for CL_ABAP_CODEPAGE under Clean Core
- Modernization Agents for SAP on AWSModernization Agents for SAP on AWSAWS's suite of agents for SAP modernisation work: custom ABAP converted for S/4HANA, PI/PO interfaces moved to Integration Suite, BW objects moved to SAP Datasphere, deployed into a customer's own AWS account and reached only after registration.partner, abapAWS agents for ABAP, PI/PO and BW modernisation work
- ROSAROSAAnswers whether an SAP object is released for ABAP Cloud, and what to use instead when it is not — served from SAP's own Cloudification Repository over MCP and over plain REST.independent, abapMCP server answering whether SAP objects are released for ABAP Cloud
- Cloudification RepositoryCloudification RepositorySAP's list of released APIs for SAP Cloud ERP, with the successors of the objects that are not released — the content the ABAP test cockpit's cloud readiness and clean core checks are pointed at.sap official, abapSAP's list of released APIs for SAP Cloud ERP with successors
- code pal for ABAP — Cloud Editioncode pal for ABAP — Cloud EditionThe same Clean ABAP check set for ABAP Cloud, where the legacy edition cannot run.sap official, abapClean ABAP check set for ABAP Cloud
- Clean-Core.ioClean-Core.ioA free hosted workspace that reads one piece of custom ABAP, redraws its business process as BPMN with a line anchor on every element, grades the SAP objects it uses Level A–D and ends in a keep, rebuild, move-to-standard or retire decision.independent, abapHosted workspace redrawing custom ABAP as BPMN and grading it
- Clean Core MeasurementClean Core MeasurementAn ABAP application for a central ATC system that imports Clean Core check results and reports them per system as Level A to D KPIs, technical debt scores and documented assignments.independent, abapReports Clean Core ATC results per system as Level A to D KPIs
- ABAP Select ConverterABAP Select ConverterConverts a classic Open SQL SELECT against dictionary tables to the equivalent statement against released Core Data Services entities and their fields.independent, abapConverts classic Open SQL SELECTs to released CDS entities
- Cloudification Repository ViewerCloudification Repository ViewerA browser form over the Cloudification Repository, the list SAP publishes of which standard objects are released for ABAP Cloud and what replaces the ones that are not.independent, abapBrowser form over SAP's Cloudification Repository for ABAP Cloud
Details
Sources
Sources are graph entities: the same page may back several entries, and an unreachable source flags every row that rests on it.
Compatibility and provenance
abaplint
Flavors
“ABAP Cloud enabled system fields and date functions.” — Xexer/abap-system-fields — README, Introduction
History in the atlas
- First seen.
For your agent
- Ref
artifact:xexer-abap-system-fields- JSON
- /artifacts/xexer-abap-system-fields.json
- MCP
- Connecting an agent