Beyond ABAPdesigned by@Tejoram97
Beyond ABAP / ABAP on BTP / ABAP for Cloud Development

ABAP for Cloud Development

ABAP on BTP · SAP BTP ·

Open the interactive lesson →
  1. What ABAP for Cloud Development is
  2. The rules and how they are enforced
  3. What is not allowed and what replaces it
  4. Syntax side by side for everyday tasks
  5. Data access in ABAP Cloud
  6. Released APIs
  7. The XCO library
  8. Getting started step by step
  9. Converting classic code to ABAP Cloud: a worked example
  10. Common mistakes, tips and a one-page cheat sheet
  11. Interview questions

A complete guide to the ABAP language version ABAP for Cloud Development: what it is, its rules, the syntax differences from classic Standard ABAP side by side, the released APIs and the XCO library that replace classic techniques, how to get started and how to convert classic code. Modern 7.4/7.5 syntax is on ABAP on HANA › 03, clean core levels on Clean Core › 01, the SAP Business AI Platform, ABAP environment on ABAP on BTP › 01 and RAP in the RAP section; this page points there instead of repeating them.

Part 1 – What ABAP for Cloud Development is

What you learn on this page

Part

Topic

You can then …

1

The three ABAP language versions, ABAP Cloud, where it is mandatory

explain the difference between a language version and a development model

2

The rules and how they are enforced

say what is a syntax error, a warning or an ATC finding

3

What is not allowed and what replaces it

map every classic technique to its cloud replacement

4

Everyday tasks side by side

write date, user, GUID, log, mail, job, HTTP code the cloud way

5

Data access in ABAP Cloud

replace SELECT on VBAK/KNA1 by released CDS views and EML

6–7

Released APIs, release contracts, the XCO library

find a released API and its successor

8–9

Getting started, converting a classic report

set up a cloud package and fix ATC findings

10–11

Mistakes, cheat sheet, interview questions

answer clean core / ABAP Cloud questions

Why it exists

In ECC every custom program could read any SAP table, call any function module and change SAP code. That freedom is why upgrades are expensive: SAP changes a table or an FM, and thousands of custom objects break. ABAP for Cloud Development removes that risk at the source: your code may use only a small, modern part of the language and only SAP objects that SAP has released with a stability promise. If it compiles, it survives the next upgrade.

The three ABAP language versions

Every ABAP repository object (class, interface, CDS view, behavior definition, …) has an attribute ABAP Language Version. It decides which statements the compiler accepts and which other objects the code may use. There are three versions:

Language version

Language scope

Objects you may use

Tools

Standard ABAP

Unrestricted – the full language that runs in Unicode systems (classic ABAP)

Any repository object

ADT and SAP GUI

ABAP for Cloud Development

Restricted – a small, modern set of statements; almost no obsolete statements; client isolation

Released APIs (release contract C1, "use in cloud development") and objects of the same software component

ADT only

ABAP for Key Users

Restricted further – code written inside key user apps, method bodies only, with its own short statement list

Only what the key user app offers

Fiori key user apps

The three ABAP language versions as nested scopes: Standard ABAP (full scope, any object, ADT and SAP GUI) contains ABAP for Cloud Development (restricted scope, released APIs only, ADT only), which contains ABAP for Key Users. On the right: where ABAP for Cloud Development is mandatory or optional, and ABAP Cloud as the development model

ABAP Cloud = the development model

ABAP Cloud is SAP's name for the programming model for cloud-ready, upgrade-stable code. It is more than the language version. SAP's cheat sheet lists four parts:

  • Language version ABAP for Cloud Development (the restricted language).
  • Released APIs – SAP objects only if they are released; most SAP tables are replaced by released CDS views, and libraries such as XCO provide ready-made functions.
  • Tools – ABAP Development Tools for Eclipse (ADT) only; no SE80, SE24, SE38.
  • RAP – the ABAP RESTful Application Programming Model is the transactional model; Fiori elements is the UI. RAP itself is taught in the RAP section.
    • Interview tip: "ABAP Cloud is the model, ABAP for Cloud Development is the language version. On S/4HANA 2022+ on-premise I can choose it per package, so new extensions are level A while old classic code keeps running."
    • Common mistake: saying "ABAP Cloud only runs on BTP". It is mandatory there and in Public Edition, and available on-premise / Private Edition from 2022.
    • Modern syntax (inline declarations, constructor operators, string templates, FOR, REDUCE, GROUP BY) all works in ABAP Cloud and is not repeated here → ABAP on HANA › 03 · ABAP New Syntax 7.4 / 7.5+.
    • Interview tip: "Unreleased API = syntax error, deprecated API = warning with successor, everything else the ATC reports. Dynamic access is checked at runtime, so I validate dynamic names with cl_abap_dyn_prg."
    • Common mistake: thinking an object in your own package is "unreleased" and therefore blocked. Objects of the same software component may always be used; the release check applies across software components and to SAP objects.
    • Interview tip: group your answer – "no classic UI (lists, dynpros, transactions), no direct SAP data (tables, unreleased FMs), no system-level access (files, native SQL, client handling), no obsolete statements – and for each there is a released replacement."
    • Common mistake: "ABAP Cloud has no authorization checks." AUTHORITY-CHECK exists; the object name must be a literal, and most read checks move into CDS access control.

The opposite is classic ABAP: Standard ABAP, any tool, any object. It is still supported in S/4HANA (on-premise and Private Edition), but SAP positions it for existing solutions.

Where it is mandatory and where optional

Product

ABAP for Cloud Development

How you get it

SAP Business AI Platform, ABAP environment ("Steampunk")

Mandatory for all your code

Every software component you create is cloud; details → ABAP on BTP › 01 · ABAP on BTP – ABAP Cloud**

S/4HANA Cloud Public Edition – developer extensibility

Mandatory

Development in ADT on the same system ("embedded Steampunk")

S/4HANA Cloud Private Edition and S/4HANA on-premise, release 2022 and later

Optional – next to classic ABAP

Set the language version per object, or as the default of a package / software component; classic objects keep Standard ABAP

ECC, S/4HANA 2021 and older

Not available (Standard ABAP only)

Write cloud-ready code by convention and check it with ATC (cloud readiness)

In ADT you see the version on the Properties tab → General → ABAP Language Version. In a system that supports classic ABAP you can change it there with Edit… – the object then gets the cloud syntax rules and usually shows errors until you refactor it.

How it relates to clean core level A

The Clean Core page (Clean Core › 01 · Clean Core) grades extensions from level A (fully clean) to D. Code in ABAP for Cloud Development that uses only released APIs is level A by construction – the compiler enforces what level A means. Classic code that happens to use only released APIs can also be clean, but nothing stops the next developer from adding SELECT FROM vbak; in ABAP Cloud that line does not compile.

Part 2 – The rules and how they are enforced

The four rules

Rule

What it means in practice

Example

1 · Restricted language scope

Only statements of ABAP for Cloud Development; classic UI, list, report, file and low-level database statements are not part of it

WRITE, MOVE, DESCRIBE TABLE, USING CLIENT → syntax error

2 · Released APIs only

SAP objects only if released for use in cloud development (contract C1); objects of your own software component are always allowed

SELECT FROM vbak → error; SELECT FROM I_SalesOrder → fine

3 · ADT only

Classes, CDS, RAP, service bindings are edited in Eclipse; there is no SAP GUI access in the SAP Business AI Platform, ABAP environment and Public Edition

no SE38, SE80, SE11 – ADT editors instead

4 · No SAP GUI artefacts

No executable programs (reports), dynpros, selection screens, classic lists, transactions; UIs are Fiori, test output goes to the ADT console

REPORT, CALL SCREEN, PARAMETERS → not possible

Two more rules are built into the language: client isolation (ABAP SQL always reads the current client; USING CLIENT is not available; AMDP must be client-safe) and stable typing – when you call a released API, type your variables with the API's own types, otherwise a warning tells you the code may break if SAP extends the type.

Who enforces the rules

Three guards: the syntax check rejects statements outside the restricted scope and unreleased SAP objects (object cannot be activated), deprecated APIs give a warning with a successor, and ATC runs a cloud check variant on demand or at transport release and can block the transport. In Standard ABAP only the ATC reports cloud problems; dynamic names fail only at runtime

Guard

When

What it checks

Result

Syntax check (compiler)

While typing, on activation

Statement allowed in ABAP for Cloud Development?

Syntax error – object cannot be activated

API state (part of the syntax check)

While typing, on activation

Used SAP object released for cloud development? Deprecated?

Not released → error; deprecated → warning naming the successor

ATC (ABAP Test Cockpit)

On demand, in CI, at transport release

Cloud check variant; on classic code a cloud-readiness variant

Finding (error / warning / info); errors can block the transport release

Runtime

When the code runs

Dynamic names (SELECT FROM (lv_table), dynamic calls)

Runtime error if the dynamic target is not allowed

What happens when you break a rule

CLASS zcl_so_rules_demo DEFINITION PUBLIC FINAL CREATE PUBLIC.
PUBLIC SECTION.
INTERFACES if_oo_adt_classrun.
ENDCLASS.

CLASS zcl_so_rules_demo IMPLEMENTATION.
METHOD if_oo_adt_classrun~main.
SELECT SalesOrder FROM I_SalesOrder             " released CDS view: fine
INTO TABLE @DATA(orders) UP TO 5 ROWS.

SELECT vbeln FROM vbak                          " SAP table, not released: syntax error
INTO TABLE @DATA(old_orders).

DATA(today) = sy-datum.                         " should not be used: flagged by the checks
WRITE 'Done'.                                   " classic list statement: syntax error

DATA(tab) = 'VBAK'.
SELECT * FROM (tab) INTO TABLE @DATA(dyn).      " compiles, fails at runtime
ENDMETHOD.
ENDCLASS.

The same class with language version Standard ABAP activates and runs. Only an ATC run with the cloud-readiness check variant would list the problems. That is the key difference: in ABAP for Cloud Development the compiler is the gatekeeper, in classic ABAP only the ATC is.

Part 3 – What is not allowed and what replaces it

This Part is the core of the page: for each classic technique, why it is gone and what you use instead. The picture is the one-page summary; the tables give the details.

Classic technique to ABAP Cloud replacement: output, input screens, calling programs, SAP data, database access, files, reuse code, system fields, locks, memory and LUW, old statements – each with the classic statement or object on the left and the cloud replacement on the right

User interface, programs and output

Classic (Standard ABAP)

ABAP for Cloud Development

Note

REPORT, WRITE, ULINE, classic lists

Class implementing if_oo_adt_classrun; output with out->write( ) in the ADT console (F9)

The console is for developers and tests, not for end users

ALV (cl_salv_table, REUSE_ALV_*)

Fiori elements list report on a CDS view (+ RAP for changes)

cl_salv_table is not released; in ABAP Cloud it is a syntax error

PARAMETERS, SELECT-OPTIONS, selection screens

Fiori filter bar (@UI.selectionField), CDS parameters, action parameters (abstract entity)

Selection screens are dynpros – none in ABAP Cloud

Dynpros, CALL SCREEN, module pools, GUI status

Fiori elements or freestyle UI5 app on an OData service from RAP

"Dynpros cannot be created in ABAP Cloud" (SAP cheat sheet)

CALL TRANSACTION, LEAVE TO TRANSACTION

Call a class method, use EML on a released RAP BO, or navigate between Fiori apps (intent-based navigation)

There are no transactions to call

SUBMIT report [AND RETURN]

Call the logic as a class method; run it in the background as an application job

There are no executable programs to submit

MESSAGE e001(zmsg) shown on the screen

Exceptions with message texts (IF_T100_DYN_MSG); RAP reported; MESSAGE … INTO DATA(text)

Only the INTO variant is possible – there is no screen

BREAK-POINT, BREAK user

ADT breakpoints (double-click left of the line number)

BREAK-POINT is shown as invalid in SAP's demo class

Data and database access

Classic (Standard ABAP)

ABAP for Cloud Development

Note

SELECT … FROM vbak / kna1 / mara

SELECT … FROM I_SalesOrder / I_Customer / I_Product

SAP tables are "not to be released"; the Cloudification Repository names the successor (Part 5)

EXEC SQL … ENDEXEC, ADBC (cl_sql_statement)

ABAP SQL; for HANA-specific logic AMDP that is read-only, SQLScript and client-safe

Low-level database access is not in the restricted scope; cl_sql_statement is not released

USING CLIENT, CLIENT SPECIFIED

Not possible – implicit client handling only

Client isolation: you only ever see the current client

OPEN DATASET, TRANSFER, READ DATASET (application server files)

File upload/download in the Fiori app (RAP large-object fields), XCO_CP_XLSX for Excel content, HTTP to an external store

No access to the server file system in the cloud

GUI_UPLOAD, GUI_DOWNLOAD, cl_gui_frontend_services

Same as above – the browser does the file dialog

No SAP GUI frontend

CALL FUNCTION 'ENQUEUE_EZSO'

cl_abap_lock_object_factory=>get_instance( iv_name = 'EZSO' ) → enqueue( ) / dequeue( ); in RAP the lock master does it

The lock object itself is still created in ADT

CALL FUNCTION … IN UPDATE TASK, PERFORM … ON COMMIT, IN BACKGROUND TASK

RAP save sequence; bgPF (cl_bgmc_process_factory) for asynchronous work

SAP: "the bundling techniques are not available"; local update is the default

Reuse code: function modules and classes

Classic (Standard ABAP)

ABAP for Cloud Development

Note

Any SAP function module (GUID_CREATE, NUMBER_GET_NEXT, BAL_LOG_CREATE, SO_NEW_DOCUMENT_ATT_SEND_API1, JOB_OPEN)

Released successor classes: cl_system_uuid, cl_numberrange_runtime, cl_bali_log, cl_bcs_mail_message, cl_apj_rt_api

All successors as listed in SAP's Cloudification Repository; code in Part 4

BAPI_SALESORDER_CREATEFROMDAT2

EML on the released RAP BO I_SalesOrderTP

The Cloudification Repository names I_SalesOrderTP as successor

Unreleased SAP classes (cl_http_client, cl_ixml, cl_bcs)

cl_web_http_client_manager, cl_ixml_core, cl_bcs_mail_message

Use F2 in ADT on the class: the API state shows Released / Deprecated

Writing your own function modules

Technically possible, but write classes

SAP: function modules "are not recommended for new implementations" in ABAP for Cloud Development

FORM / PERFORM (subroutines)

Methods

Subroutines are obsolete and not usable in ABAP Cloud

System fields

SAP's released-classes cheat sheet lists the sy components that are usable in ABAP for Cloud Development. Date and time fields are not in the list because they are system-specific values that make no sense in a cloud system with users in many time zones.

Classic (Standard ABAP)

ABAP for Cloud Development

Note

sy-index, sy-tabix, sy-dbcnt, sy-fdpos, sy-subrc

Same – allowed

Loop and statement results

sy-langu, sy-batch, sy-mandt, sy-sysid, sy-uname

Same – allowed

sy-uname is fine; for the user's name text use cl_abap_context_info

sy-msgid, sy-msgty, sy-msgno, sy-msgv1 … sy-msgv4

Same – allowed

Filled by MESSAGE … INTO

sy-datum, sy-uzeit

cl_abap_context_info=>get_system_date( ) / get_system_time( ) (UTC), utclong_current( )

Do not use; the cheat sheet example flags them

sy-datlo, sy-timlo, sy-zonlo

xco_cp=>sy->date( xco_cp_time=>time_zone->user ), cl_abap_context_info=>get_user_time_zone( )

User-local date and time come from XCO

sy-repid, sy-tcode, sy-ucomm, sy-dynnr, list fields

No equivalent needed

They belong to programs, transactions and screens, which do not exist

Memory, authorizations, dynamic programming

Classic (Standard ABAP)

ABAP for Cloud Development

Note

EXPORT … TO MEMORY ID, IMPORT … FROM MEMORY ID (ABAP memory)

Pass data as parameters or keep it in class attributes; persistent state in a table or RAP draft

ABAP memory belongs to the program chain of SUBMIT / CALL TRANSACTION, which ABAP Cloud does not have; SAP's cheat sheets use these statements only in classic-ABAP examples

SET PARAMETER ID / GET PARAMETER ID (SAP memory)

Fiori user defaults, app parameters

SPA/GPA parameters are SAP GUI user memory

EXPORT … TO DATA BUFFER / IMPORT … FROM DATA BUFFER

Same – allowed

SAP's cloud cheat sheet uses it for data clusters in an xstring

AUTHORITY-CHECK OBJECT lv_object …

AUTHORITY-CHECK OBJECT 'V_VBAK_VKO' ID … FIELD … with a literal object name

Released auth objects (e.g. V_VBAK_VKO) or your own; checks only the current user (the other-user addition is Standard ABAP only)

Hand-written auth checks before every SELECT

CDS access control (DEFINE ROLE with aspect pfcg_auth) and RAP authorization

Implicit checks on read; SAP's released views bring their own roles

SELECT FROM (lv_tab) on any table

Dynamic names allowed, but only for allowed targets

Unreleased target → runtime error; validate input with cl_abap_dyn_prg

ASSIGN (lv_name) TO <fs> with a variable holding a data object name

Put the data in a structure and use ASSIGN struct-(lv_comp) TO <fs>

Named dynamic ASSIGN gives a syntax warning

RTTI get_ddic_field_list( ), READ REPORT, INSERT REPORT, GENERATE SUBROUTINE POOL

XCO library (xco_cp_abap_dictionary, XCO generation APIs)

Some RTTI methods are not supported; source code is read and generated with XCO

Obsolete statements

ABAP for Cloud Development allows almost no obsolete language elements. SAP's demo class shows these:

Classic (Standard ABAP)

ABAP for Cloud Development

Note

MOVE a TO b.

b = a.

Invalid statement

DESCRIBE TABLE itab LINES n.

n = lines( itab ).

Invalid statement (DESCRIBE is Standard ABAP only)

GET REFERENCE OF a INTO r.

r = REF #( a ).

Deprecated – warning

CALL FUNCTION … EXCEPTIONS … for non-class exceptions

Class-based exceptions, TRY … CATCH

Warning in ABAP for Cloud Development

Header lines, TABLES, OCCURS, RANGES

Explicit work areas, TYPE TABLE OF, TYPE RANGE OF

Obsolete – see 03 · ABAP New Syntax 7.4 / 7.5+ for the modern forms

Part 4 – Syntax side by side for everyday tasks

Each block shows the classic way first and the ABAP Cloud way second. All cloud class names are released in SAP's Cloudification Repository and taken from SAP's "Released ABAP Classes" cheat sheet; method signatures can differ between releases, so press F2 in ADT for the class documentation.

Sixteen everyday tasks, each with the classic call crossed out and the released ABAP Cloud API below it: today/now, current user, GUID, random number, number range, application log, e-mail, JSON, background job, asynchronous run, parallel processing, HTTP call, lock, unit conversion, messages and test output

Hello World: a console class

A class that implements if_oo_adt_classrun is the ABAP Cloud replacement for a test report. Run it with F9 in ADT; out->write( ) prints values, structures and internal tables to the console.

" Classic
REPORT zso_open_orders.
SELECT vbeln, kunnr, netwr FROM vbak INTO TABLE @DATA(lt_vbak) UP TO 10 ROWS.
LOOP AT lt_vbak INTO DATA(ls_vbak).
WRITE: / ls_vbak-vbeln, ls_vbak-kunnr, ls_vbak-netwr.
ENDLOOP.

" ABAP Cloud
CLASS zcl_so_open_orders DEFINITION PUBLIC FINAL CREATE PUBLIC.
PUBLIC SECTION.
INTERFACES if_oo_adt_classrun.
ENDCLASS.

CLASS zcl_so_open_orders IMPLEMENTATION.
METHOD if_oo_adt_classrun~main.
SELECT SalesOrder, SoldToParty, TotalNetAmount, TransactionCurrency
FROM I_SalesOrder
INTO TABLE @DATA(orders)
UP TO 10 ROWS.
out->write( data = orders name = `Open sales orders` ).
ENDMETHOD.
ENDCLASS.
  • Field names of I_SalesOrder follow SAP's CDS naming (CamelCase, English) – open the view in ADT (F3) to see the exact fields of your release.
  • Alternatives for console output: inherit from cl_demo_classrun or cl_xco_cp_adt_simple_classrun (both released); cl_demo_output_cloud exists for demos.

Date, time and time stamps

" Classic
DATA(lv_date) = sy-datum.
DATA(lv_time) = sy-uzeit.
GET TIME STAMP FIELD DATA(lv_ts).

" ABAP Cloud
DATA(sys_date) = cl_abap_context_info=>get_system_date( ).   " UTC date, e.g. 20240101
DATA(sys_time) = cl_abap_context_info=>get_system_time( ).   " UTC time
DATA(now)      = utclong_current( ).                         " utclong time stamp (UTC)
GET TIME STAMP FIELD DATA(ts).                               " still allowed (timestamp type)

" User's local date and time with XCO (strings)
DATA(user_date) = xco_cp=>sy->date( xco_cp_time=>time_zone->user
)->as( xco_cp_time=>format->iso_8601_extended )->value.  " 2025-01-25
DATA(user_time) = xco_cp=>sy->time( xco_cp_time=>time_zone->user
)->as( xco_cp_time=>format->iso_8601_extended )->value.  " 09:23:40

" Calculations
DATA(tomorrow) = utclong_add( val = now days = 1 ).
cl_abap_utclong=>diff( EXPORTING high = tomorrow low = now
IMPORTING days = DATA(days) hours = DATA(hours) ).
  • For database fields SAP recommends the DDIC types datn, timn and utclong over the old dats / tims. cl_abap_tstmp (add, subtract, convert timestamp ↔ utclong) is released too.

Current user

" Classic
DATA(lv_user) = sy-uname.
SELECT SINGLE persnumber FROM usr21 WHERE bname = @sy-uname INTO @DATA(lv_pers).  " then ADRP ...

" ABAP Cloud
DATA(user_id) = sy-uname.                                      " allowed
DATA(alias)   = cl_abap_context_info=>get_user_alias( ).       " e.g. XY0000001234
TRY.
DATA(full_name) = cl_abap_context_info=>get_user_formatted_name( ).   " e.g. John Doe
CATCH cx_abap_context_info_error.
ENDTRY.
DATA(user_xco) = xco_cp=>sy->user( )->name.

Messages and exceptions

There is no screen to show a message, so messages become exception texts (or RAP reported entries). Create a message class in ADT, then an exception class that inherits from cx_static_check and implements IF_T100_DYN_MSG (SAP's recommended interface; it includes IF_T100_MESSAGE).

" Classic
MESSAGE e001(zso_msg) WITH lv_vbeln.          " error dialog in SAP GUI

" ABAP Cloud – exception class (created in ADT, constructor generated)
CLASS zcx_so_error DEFINITION PUBLIC INHERITING FROM cx_static_check FINAL CREATE PUBLIC.
PUBLIC SECTION.
INTERFACES if_t100_dyn_msg.
METHODS constructor IMPORTING textid   LIKE if_t100_message=>t100key OPTIONAL
previous LIKE previous OPTIONAL.
ENDCLASS.

" Raising it with a message of message class ZSO_MSG
RAISE EXCEPTION TYPE zcx_so_error MESSAGE e001(zso_msg) WITH so_id.

" Catching it
TRY.
check_order( so_id ).
CATCH zcx_so_error INTO DATA(error).
out->write( error->get_text( ) ).
ENDTRY.

" Message text into a variable (fills sy-msgid, sy-msgno, sy-msgv1 ...)
MESSAGE e001(zso_msg) WITH so_id INTO DATA(msg_text).
  • Constructor body: ADT generates it when you choose the exception superclass in the class wizard; do not hand-write it.

Random numbers and GUIDs

" Classic
CALL FUNCTION 'QF05_RANDOM_INTEGER' ...
CALL FUNCTION 'GUID_CREATE' IMPORTING ev_guid_16 = lv_guid.

" ABAP Cloud
DATA(dice) = cl_abap_random_int=>create( seed = cl_abap_random=>seed( )
min  = 1
max  = 6 )->get_next( ).
TRY.
DATA(uuid_x16) = cl_system_uuid=>create_uuid_x16_static( ).    " raw 16
DATA(uuid_c36) = cl_system_uuid=>create_uuid_c36_static( ).    " 429A229A-8802-1EDF-...
CATCH cx_uuid_error.
ENDTRY.
DATA(uuid_xco) = xco_cp=>uuid( )->value.                           " XCO alternative
  • cl_abap_random_float and cl_abap_prob_distribution are released as well.

String templates, conversion exits and formatting

Conversion-exit function modules such as CONVERSION_EXIT_ALPHA_INPUT are not released. String template options do the same job and work in both language versions.

" Classic
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT' EXPORTING input = lv_kunnr IMPORTING output = lv_kunnr.
WRITE lv_date TO lv_text DD/MM/YYYY.

" ABAP Cloud
DATA(customer_in)  = |{ '1234' ALPHA = IN WIDTH = 10 }|.                " 0000001234
DATA(customer_out) = |{ '0000001234' ALPHA = OUT }|.                   " 1234
DATA(date_iso)     = |{ cl_abap_context_info=>get_system_date( ) DATE = ISO }|.   " 2024-01-01
DATA(date_user)    = |{ cl_abap_context_info=>get_system_date( ) DATE = USER }|.  " user format
DATA(ts_iso)       = |{ utclong_current( ) TIMESTAMP = ISO }|.
DATA(amount_txt)   = |{ 12345678 CURRENCY = 'EUR' }|.                  " decimals of the currency
  • Date and time to and from external formats in code: cl_abap_datfm and cl_abap_timefm (released).

Units and currencies

" Classic
CALL FUNCTION 'UNIT_CONVERSION_SIMPLE' EXPORTING input = lv_qty unit_in = 'KG' unit_out = 'G' ...

" ABAP Cloud
DATA qty_out TYPE decfloat34.
cl_uom_conversion=>create( )->unit_conversion_simple(
EXPORTING  input                = CONV decfloat34( '1' )
round_sign           = 'X'
unit_in              = 'KG'
unit_out             = 'G'
IMPORTING  output               = qty_out
EXCEPTIONS conversion_not_found = 1
OTHERS               = 2 ).
  • Unit and currency master data: released views I_UnitOfMeasure and I_Currency.
  • Currency conversion: cl_exchange_rates is listed as released in the Cloudification Repository for SAP Cloud ERP, the SAP Business AI Platform, ABAP environment and S/4HANA Cloud Private Edition; open the class in ADT for its conversion methods and their parameters.

JSON

" XCO (released)
DATA(json) = xco_cp_json=>data->from_abap( orders )->to_string( ).
xco_cp_json=>data->from_string( json )->write_to( REF #( orders ) ).

" /UI2/CL_JSON (also released for cloud development)
DATA(json2) = /ui2/cl_json=>serialize( data = orders ).
/ui2/cl_json=>deserialize( EXPORTING json = json2 CHANGING data = orders ).
  • Both classes appear in SAP's released-classes cheat sheet and as "released" in the Cloudification Repository. XCO also offers a JSON builder and name transformations (pascal_case_to_underscore).

E-mail

" Classic
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1' ...        " or cl_bcs (not released)

" ABAP Cloud
TRY.
DATA(mail) = cl_bcs_mail_message=>create_instance( ).
mail->set_sender( '[email protected]' ).
mail->add_recipient( '[email protected]' ).
mail->set_subject( |Sales order { so_id } needs approval| ).
mail->set_main( cl_bcs_mail_textpart=>create_instance(
iv_content      = '<p>Please approve the order.</p>'
iv_content_type = 'text/html' ) ).
mail->send( IMPORTING et_status = DATA(status) ).      " or send_async( )
CATCH cx_bcs_mail INTO DATA(mail_error).
ENDTRY.
  • Sending needs an e-mail configuration (SAP Help "Emailing"); attachments with cl_bcs_mail_textpart / cl_bcs_mail_binarypart.

Application log

" Classic
CALL FUNCTION 'BAL_LOG_CREATE' ...   CALL FUNCTION 'BAL_LOG_MSG_ADD' ...   CALL FUNCTION 'BAL_DB_SAVE' ...

" ABAP Cloud (log object ZSO_LOG / subobject APPROVAL created in ADT)
TRY.
DATA(log) = cl_bali_log=>create( ).
log->set_header( header = cl_bali_header_setter=>create( object      = 'ZSO_LOG'
subobject   = 'APPROVAL'
external_id = CONV #( so_id ) ) ).
log->add_item( item = cl_bali_free_text_setter=>create(
severity = if_bali_constants=>c_severity_status
text     = |Order { so_id } approved| ) ).
cl_bali_log_db=>get_instance( )->save_log( log = log ).
CATCH cx_bali_runtime INTO DATA(log_error).
ENDTRY.
  • Exceptions go in with cl_bali_exception_setter; XCO_CP_BAL is the XCO alternative.

Number ranges

" Classic
CALL FUNCTION 'NUMBER_GET_NEXT' EXPORTING nr_range_nr = '01' object = 'ZSO_NR' IMPORTING number = lv_no.

" ABAP Cloud (number range object created in ADT)
TRY.
cl_numberrange_runtime=>number_get( EXPORTING nr_range_nr       = '01'
object            = 'ZSO_NR'
IMPORTING number            = DATA(number)
returncode        = DATA(rc)
returned_quantity = DATA(qty) ).
CATCH cx_nr_object_not_found cx_number_ranges INTO DATA(nr_error).
ENDTRY.
  • Intervals: cl_numberrange_intervals; object attributes: cl_numberrange_objects. In a RAP BO the number is drawn in adjust_numbers (late numbering) → RAP section.

Background processing: application jobs and bgPF

There are no reports, so SUBMIT … VIA JOB is replaced by application jobs (scheduled, repeatable, visible in the Fiori app *Application Jobs*) and the Background Processing Framework (bgPF) for "run this asynchronously after commit".

" Classic
CALL FUNCTION 'JOB_OPEN' ...  SUBMIT zso_reminder VIA JOB lv_job NUMBER lv_cnt AND RETURN.
CALL FUNCTION 'JOB_CLOSE' ...

" ABAP Cloud – application job: the class run by the job
CLASS zcl_so_reminder_job DEFINITION PUBLIC FINAL CREATE PUBLIC.
PUBLIC SECTION.
INTERFACES if_apj_rt_run.                     " execute( ) is called by the job
ENDCLASS.
" Then: job catalog entry + job template (ADT or cl_apj_dt_create_content),
"       schedule in the Fiori app or with cl_apj_rt_api=>schedule_job( ... ).

" ABAP Cloud – bgPF: run an operation asynchronously
CLASS zcl_so_async_mail DEFINITION PUBLIC FINAL CREATE PUBLIC.
PUBLIC SECTION.
INTERFACES if_bgmc_op_single_tx_uncontr.      " execute( ) runs in the background
ENDCLASS.

TRY.
DATA(process) = cl_bgmc_process_factory=>get_default( )->create( ).
process->set_name( `Approval mail` ).
process->set_operation_tx_uncontrolled( NEW zcl_so_async_mail( ) ).
process->save_for_execution( ).
COMMIT WORK.                                  " not needed inside RAP – the framework commits
CATCH cx_bgmc INTO DATA(bg_error).
ROLLBACK WORK.
ENDTRY.
  • Application job interfaces: SAP's current cheat sheet uses if_apj_rt_run. Older code and tutorials use the pair if_apj_dt_exec_object (design time, parameters) + if_apj_rt_exec_object (run time); the Cloudification Repository lists all three as released (SAP Cloud ERP, SAP Business AI Platform, ABAP environment, Private Edition).
  • bgPF with transactional control: implement if_bgmc_op_single and call set_operation( ); switch to the save phase with cl_abap_tx=>save( ) before writing to the database.

Parallel processing

" Classic
CALL FUNCTION 'Z_PROCESS_PACKAGE' STARTING NEW TASK lv_task DESTINATION IN GROUP DEFAULT ...

" ABAP Cloud – each instance implements if_abap_parallel~do
DATA(parallel) = NEW cl_abap_parallel( ).
parallel->run_inst( EXPORTING p_in_tab  = VALUE #( ( NEW zcl_so_package( 1 ) )
( NEW zcl_so_package( 2 ) ) )
IMPORTING p_out_tab = DATA(results) ).
LOOP AT results INTO DATA(result).
DATA(done) = CAST zcl_so_package( result-inst ).    " read the processed instance
ENDLOOP.

HTTP calls

" Classic
cl_http_client=>create_by_destination( EXPORTING destination = 'Z_CARRIER' IMPORTING client = lo_client ).

" ABAP Cloud
TRY.
DATA(destination) = cl_http_destination_provider=>create_by_url(
i_url = `https://api.example.com/tracking` ).
DATA(client)   = cl_web_http_client_manager=>create_by_http_destination( i_destination = destination ).
DATA(response) = client->execute( if_web_http_client=>get ).
DATA(status)   = response->get_status( ).            " status-code = 200
DATA(body)     = response->get_text( ).
CATCH cx_root INTO DATA(http_error).                  " narrow this in real code
ENDTRY.
  • create_by_url is only for public services and tests. Productive calls use a destination from a communication arrangement – cl_http_destination_provider=>create_by_comm_arrangement( comm_scenario = … service_id = … ) – or a BTP destination (create_by_cloud_destination). Set-up → ABAP on BTP › 01 · ABAP on BTP – ABAP Cloud.
  • Base64 and URL helpers: cl_web_http_utility (successor of the unreleased cl_http_utility).
    • Interview tip: name three successors without thinking – GUID_CREATE → cl_system_uuid, NUMBER_GET_NEXT → cl_numberrange_runtime, BAL_LOG_CREATE → cl_bali_log – and say where you look up the rest: the Cloudification Repository or the ADT error message.
    • Common mistake: using sy-datum in cloud code "because it still compiles somewhere". It is flagged; and in the cloud the system time zone is UTC, so the date can be wrong for the user.

Locks

" Classic
CALL FUNCTION 'ENQUEUE_EZSO_HDR' EXPORTING so_id = lv_id EXCEPTIONS foreign_lock = 1 OTHERS = 2.

" ABAP Cloud (lock object EZSO_HDR created in ADT)
TRY.
DATA(lock) = cl_abap_lock_object_factory=>get_instance( iv_name = 'EZSO_HDR' ).
lock->enqueue( it_parameter = VALUE #( ( name = 'SO_ID' value = REF #( so_id ) ) ) ).
" ... change the data ...
lock->dequeue( it_parameter = VALUE #( ( name = 'SO_ID' value = REF #( so_id ) ) ) ).
CATCH cx_abap_lock_failure cx_abap_foreign_lock INTO DATA(lock_error).
ENDTRY.

Part 5 – Data access in ABAP Cloud

Why you cannot read VBAK any more

A SAP table is an implementation detail: SAP may split it, add a field or move data elsewhere (as happened with the FI tables when S/4HANA introduced ACDOCA). A released CDS view is a contract: SAP keeps its name, fields and meaning stable across upgrades. In the Cloudification Repository the classic tables have the state notToBeReleased with a named successor.

What ABAP Cloud code may read and write: own tables and own CDS views with ABAP SQL and EML, SAP released CDS views read-only with ABAP SQL, SAP released RAP BOs like I_SalesOrderTP with READ ENTITIES and MODIFY ENTITIES, and SAP tables like VBAK never; successors from the Cloudification Repository

Classic (Standard ABAP)

ABAP for Cloud Development

Note

VBAK (sales document header)

I_SalesOrder (sales orders) or I_SalesDocument

Cloudification Repository: successor of VBAK is I_SalesDocument; I_SalesOrder is released too

VBAP (items)

I_SalesOrderItem or I_SalesDocumentItem

Repository successor: I_SalesDocumentItem

KNA1 (customer)

I_Customer

Repository successor: I_Customer

BUT000 (business partner)

I_BusinessPartner

Repository successor: I_BusinessPartner

MARA (material)

I_Product (+ I_ProductSales, I_ProductStorage_2, …)

Several successors, one per view of the material

T001 (company code)

I_CompanyCode

Repository successor: I_CompanyCode

TADIR (object directory)

I_CustABAPObjDirectoryEntry

Repository successor

ABAP SQL on your own tables and released views

" Classic
SELECT k~vbeln, k~kunnr, n~name1
FROM vbak AS k INNER JOIN kna1 AS n ON n~kunnr = k~kunnr
WHERE k~erdat >= @lv_from
INTO TABLE @DATA(lt_orders).

" ABAP Cloud – released views; your own table zsales_hdr is allowed as it is
SELECT so~SalesOrder, so~SoldToParty, cust~CustomerName
FROM I_SalesOrder AS so
INNER JOIN I_Customer AS cust ON cust~Customer = so~SoldToParty
WHERE so~CreationDate >= @from_date
INTO TABLE @DATA(orders).

SELECT FROM zsales_hdr
FIELDS so_id, customer_id, status
WHERE status = 'N'
INTO TABLE @DATA(own_orders).
  • Use the association instead of a manual join where the view offers one (for example a _Customer or _Item association) – check the view's associations in ADT.
  • Released views often carry CDS access control: ABAP SQL returns only the rows the user is authorized for. A background job sees what its job user may see.
  • Client handling is always implicit; USING CLIENT and CLIENT SPECIFIED are not available.

CDS view entities for your own data model

@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'Open sales orders with customer name'
define view entity ZI_SO_OpenOrder
as select from I_SalesOrder
association [1..1] to I_Customer as _Customer on $projection.SoldToParty = _Customer.Customer
{
key SalesOrder,
SoldToParty,
TotalNetAmount,
TransactionCurrency,
_Customer
}
  • Build your own views on released views (and on your own tables) – CDS details → ABAP on HANA › 05 · CDS Views; the RAP data model → RAP section.
  • To extend an SAP view with fields, SAP must release it for extension (contract C0) – Part 6.

Writing SAP data: EML on released RAP BOs

Changing SAP business data never happens with SQL. Classic code called a BAPI; ABAP Cloud uses EML on the released RAP business object, for sales orders I_SalesOrderTP, which the Cloudification Repository names as successor of BAPI_SALESORDER_CREATEFROMDAT2.

" Classic
CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2' ... TABLES return = lt_return.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.

" ABAP Cloud – outline; field names and required fields: see the BDEF of I_SalesOrderTP
MODIFY ENTITIES OF I_SalesOrderTP
ENTITY SalesOrder
CREATE FIELDS ( SalesOrderType SalesOrganization DistributionChannel
OrganizationDivision SoldToParty )
WITH VALUE #( ( %cid = 'SO1' ... ) )
MAPPED DATA(mapped) FAILED DATA(failed) REPORTED DATA(reported).
COMMIT ENTITIES RESPONSE OF I_SalesOrderTP FAILED DATA(commit_failed).
  • Entity aliases, fields and child entities differ by release – open the behavior definition I_SalesOrderTP in ADT before writing the call.
  • Full EML (READ / MODIFY / COMMIT ENTITIES, responses, local mode) → RAP › 08 · EML; calling SAP's BO from your app → RAP › 11 · Files, Custom Entities & Integration.
    • Interview tip: "Read: released CDS views with ABAP SQL. Write: EML on released RAP BOs. Own data: my own tables through my own RAP BO. SAP tables: never."
    • Common mistake: building a Z-view as select from vbak to "wrap" the table. In ABAP for Cloud Development the view does not activate either – the data source must be released.

Part 6 – Released APIs

Why this matters. In ABAP for Cloud Development your code may use only SAP objects that are released. A released object carries a release contract: SAP promises to keep it stable across upgrades. Everything else (tables such as VBAK, most function modules, internal classes) can change at any upgrade, so the syntax check simply does not accept it. Released APIs are the reason ABAP Cloud code survives upgrades without rework.

Release contracts C0 to C4 and the API states of an SAP object

6.1 The release contracts

Contract

What SAP promises

Who uses it

Example

C0 – Extend

Stable extension points: you may add fields or behavior at the places SAP marked as extensible

Developer extensibility (extend a released CDS view, BDEF or DDIC structure)

Extending I_SalesOrderTP (RAP › Extensibility)

C1 – Use system-internally

Stable for use inside the same system by ABAP code. Two visibilities: Use in Cloud Development and Use in Key User Apps

Your ABAP Cloud classes, CDS views, behavior pools; key user tools

I_SalesOrder, I_Customer, CL_ABAP_RANDOM_INT

C2 – Use as remote API

Stable for external callers (OData or SOAP services)

BTP apps, integration flows, third-party systems

Released APIs on api.sap.com

C3 – Manage configuration content

Stable persistence for configuration content that is exported, imported and edited with dedicated APIs and editors

Business configuration

SAP configuration tables (API State tab in ADT)

C4 – Use in AMDP

May be used inside ABAP-managed database procedures

AMDP developers (rare)

Tables and views read in an AMDP (API State tab)

  • C1 is the one you need for coding. "Released for ABAP Cloud" means C1 with the visibility Use in Cloud Development switched on. C0 is asked about for extensions, C2 for integration.
  • A release contract is set per object in ADT (*Properties* → *API State*). The same object can have several contracts, e.g. C0 and C1 on a CDS view.
  • Your own objects can be released too: that is how a wrapper class becomes usable from ABAP Cloud code (6.4).

6.2 API state: released, deprecated, decommissioned (remote APIs) – "not to be released" is a Cloudification Repository state

State

Meaning

What you do

Released

Contract active, stable

Use it

Deprecated

Still released, but SAP has named a successor and wants you to move

Keep running, plan the switch; new code uses the successor

Not to be released (Cloudification Repository)

SAP will never release it; the Cloudification Repository often names a successor object or concept

Use the successor; never wrap it in public cloud

Real successor entries from SAP's Cloudification Repository (file objectReleaseInfoLatest.json, SAP Cloud ERP):

Classic (Standard ABAP)

ABAP for Cloud Development

Note

Table VBAK

CDS view I_SalesDocument

Formal successor; I_SalesOrder (also released) shows sales orders only

Table VBAP

CDS view I_SalesDocumentItem

I_SalesOrderItem for order items only

Table KNA1

CDS view I_Customer

One successor

Table MARA

I_Product, I_ProductSales, I_ProductStorage_2 …

Several successors, one per data area

Table TADIR

CDS view I_CustABAPObjDirectoryEntry

Repository directory

Class CL_BCS

Class CL_BCS_MAIL_MESSAGE

E-mail

FM NUMBER_GET_NEXT

Class CL_NUMBERRANGE_RUNTIME

Number ranges

FM GUID_CREATE

Class CL_SYSTEM_UUID

UUIDs

FM BAL_LOG_CREATE

Class CL_BALI_LOG

Application log

Class CL_HTTP_CLIENT

Concept Communication Targets (CL_WEB_HTTP_CLIENT_MANAGER + CL_HTTP_DESTINATION_PROVIDER)

Successor is a concept, not one object

FM BAPI_SALESORDER_CREATEFROMDAT2

Released RAP BO I_SalesOrderTP (EML)

RAP › 11 · Files, Custom Entities & Integration, Part 7

  • Interview tip: "The successor of VBAK is I_SalesDocument, because VBAK holds every sales document (orders, quotations, contracts). For an order-only report I read I_SalesOrder." This shows you have actually looked at the repository.

6.3 How to find released objects

Four ways to find a released API and what to do when none exists

Where

How

Best for

ADT *Project Explorer* → Released Objects

Tree of everything released for ABAP Cloud; classes are in the *Source Code Library* folder

Browsing: "is there a class for …?"

ADT object → *Properties* → API State

Open the object (Ctrl+Shift+A), check contract and visibility

Checking one object you already know

Cloudification Repository (github.com/SAP/abap-atc-cr-cv-s4hc) and its viewer (sap.github.io/abap-atc-cr-cv-s4hc)

JSON/CSV list of released, deprecated and not-to-be-released objects with successors

"What replaces table X / FM Y?"

SAP Business Accelerator Hub (api.sap.com)

Products S/4HANA Cloud Public Edition, Private Edition and S/4HANA; developer extensibility content

Released CDS views, BO interfaces, remote APIs

CDS views in code

I_APIsForCloudDevelopment, I_APIsWithCloudDevSuccessor

Lists inside your own system and release

ATC check Usage of Released APIs (Cloudification Repository)

Runs over existing classic code and lists every unreleased object with its successor

Cloud readiness of old code (Part 9)

" All classes released for ABAP for Cloud Development in this system
SELECT ReleasedObjectType, ReleasedObjectName, ReleaseState
FROM i_apisforclouddevelopment
WHERE ReleaseState       = 'RELEASED'
AND ReleasedObjectType = 'CLAS'
ORDER BY ReleasedObjectName
INTO TABLE @DATA(released_classes).

" Which object replaces table VBAK?
SELECT SINGLE * FROM I_APIsWithCloudDevSuccessor
WHERE PredecessorObjectName = 'VBAK'
INTO @DATA(successor_vbak).

" API state of a DDIC table read with XCO (works for released and own objects)
DATA(table) = xco_cp_abap_repository=>object->tabl->database_table->for( 'ZSALES_HDR' ).
DATA(release_state) = table->get_api_state( )->get_release_state( )->value.
  • View and field names as in SAP's released-classes cheat sheet (ReleasedObjectType, ReleasedObjectName, ReleaseState; PredecessorObjectType, PredecessorObjectName). Code completion (Ctrl+Space) lists the fields of your system.

6.4 What to do when no released API exists

  • 1. Search again. A released CDS view, a BO interface (I_…TP), an XCO module or a released class often covers it under another name. Look up the successor in the Cloudification Repository or with I_APIsWithCloudDevSuccessor.
  • 2. Ask SAP to release it through SAP Customer Influence (campaigns for SAP Cloud ERP and SAP Cloud ERP Private). SAP Note 3126893 describes the process.
  • 3. Private cloud / on-premise only: build a wrapper. In a separate package with language version Standard ABAP, write a small class that calls the classic object, and release it with C1 and Use in Cloud Development. Your ABAP Cloud code calls only the wrapper.
    • Wrap a classic API (clean core level B), e.g. a BAPI. The Cloudification Repository viewer lists them: filter *classic API* and label *transactional-consistent*. SAP's generator for RFC/BAPI wrappers is the sample repo SAP-samples/tier2-rfc-proxy.
    • Full pattern with code: Clean Core › 01 · Clean Core, Part 11.
  • 4. Public cloud (SAP Business AI Platform, ABAP environment, S/4HANA Cloud Public Edition): no Standard ABAP, so no wrapper. Use key user tools, a side-by-side app on BTP calling C2 remote APIs, or change the design.
" Releasing your own wrapper class for ABAP Cloud programmatically (ADT API State tab does the same)
TRY.
DATA(api_state) = cl_abap_api_state=>create_instance(
api_key = VALUE #( object_type = 'CLAS' object_name = 'ZCL_WRAP_SO_BLOCK' ) ).
api_state->release( use_in_cloud_development = abap_true
use_in_key_user_apps     = abap_false
request                  = 'TRKORR_HERE' ).    " your transport request
DATA(is_released) = api_state->is_released( use_in_cloud_development = abap_true
use_in_key_user_apps     = abap_false ).
CATCH cx_abap_api_state INTO DATA(error).
DATA(text) = error->get_text( ).
ENDTRY.
  • Common mistake: wrapping an object that has a released successor. ATC and reviewers will reject it; the wrapper is the last resort, not a shortcut.

Part 7 – The XCO library

XCO (Extension Components library) is SAP's general-purpose library for ABAP Cloud. Its released classes have CP in the name (XCO_CP, XCO_CP_TIME, XCO_CP_JSON …). Standard ABAP has similar classes without CP (e.g. XCO_ABAP_REPOSITORY); this page covers the released CP edition. Where classic ABAP used system fields, function modules or utility classes, XCO often gives one consistent, object-oriented API.

The XCO modules and how an XCO call chain reads

7.1 How XCO code reads

  • Every call returns an object, so calls are chained: xco_cp=>sy->date( )->as( format )->value.
  • The chain ends with ->value (or a getter) to get plain ABAP data. Forgetting it is the most common error: you get an object reference instead of a date.
  • Explore with Ctrl+Space after ->: the ADT code completion is the best documentation.
  • Repository-information APIs see only released and your own objects in ABAP Cloud.

7.2 The modules at a glance

Area

XCO entry point

Classic equivalent

System fields, user, language

xco_cp=>sy->date( ), ->time( ), ->moment( ), ->user( ), ->language( )

sy-datum, sy-uzeit, sy-uname, sy-langu

Strings

xco_cp=>string( … ), xco_cp=>strings( … )

SPLIT, CONCATENATE, TRANSLATE

Date and time

xco_cp_time (time zones, formats, moment( ))

CONVERT TIME STAMP, date FMs

UUIDs

xco_cp=>uuid( ), xco_cp_uuid=>format

GUID_CREATE

JSON

xco_cp_json=>data

CALL TRANSFORMATION id, /UI2/CL_JSON

Excel (XLSX)

xco_cp_xlsx, xco_cp_xlsx_selection

abap2xlsx, OLE, GUI_DOWNLOAD

Repository objects

xco_cp_abap_repository, xco_cp_abap_dictionary, xco_cp_cds

Reading TADIR, DD02L, DD03L

Generating objects

xco_cp_generation

INSERT REPORT, generated code

Transports

xco_cp_cts

TR_* function modules

Application log

xco_cp_bal (or class CL_BALI_LOG)

BAL_LOG_* function modules

Tenant, call stack

xco_cp=>current->tenant( ), xco_cp=>current->call_stack

sy-mandt, SYSTEM_CALLSTACK

7.3 System fields, date and time

Classic (Standard ABAP)

ABAP for Cloud Development

Note

sy-datum

xco_cp=>sy->date( xco_cp_time=>time_zone->user ) or cl_abap_context_info=>get_system_date( )

sy-datum should not be used; the context-info date is UTC

sy-uzeit

xco_cp=>sy->time( xco_cp_time=>time_zone->user ) or cl_abap_context_info=>get_system_time( )

Same rule; choose user time zone or UTC deliberately

sy-uname

sy-uname (allowed) or xco_cp=>sy->user( )->name

Full name: cl_abap_context_info=>get_user_formatted_name( )

sy-langu

sy-langu (allowed) or xco_cp=>sy->language( )

XCO adds the name and ISO 639 code

Date arithmetic lv_date + 30

Still allowed; or ->add( iv_day = 30 ) on an XCO date

XCO handles month and year steps

" Current date, time and time stamp in the user's time zone, ISO format
DATA(today_iso) = xco_cp=>sy->date( xco_cp_time=>time_zone->user
)->as( xco_cp_time=>format->iso_8601_extended )->value.    " 2026-11-21
DATA(now_iso)   = xco_cp=>sy->time( xco_cp_time=>time_zone->user
)->as( xco_cp_time=>format->iso_8601_extended )->value.    " 09:23:40
DATA(moment)    = xco_cp=>sy->moment( xco_cp_time=>time_zone->utc
)->as( xco_cp_time=>format->abap )->value.                 " 20261121092340
DATA(unix_ts)   = xco_cp=>sy->unix_timestamp( )->value.

" Parts and arithmetic
DATA(year)      = xco_cp=>sy->date( )->year.
DATA(in_30days) = xco_cp=>sy->date( )->add( iv_day = 30
)->as( xco_cp_time=>format->iso_8601_extended )->value.

" User and language
DATA(user)      = xco_cp=>sy->user( )->name.
DATA(lang_name) = xco_cp=>sy->language( )->get_name( ).                        " English
  • Allowed sy fields (SAP's released-classes cheat sheet): sy-index, sy-tabix, sy-dbcnt, sy-fdpos, sy-subrc, sy-langu, sy-batch, sy-mandt, sy-sysid, sy-uname and the sy-msg* fields. Others, such as sy-datum, should not be used.

7.4 Strings

DATA(str) = xco_cp=>string( `abcdefghijklmnopqrstuvwxyz` ).
DATA(sub) = str->from( 2 )->to( 6 )->value.                         " bcdefg

DATA(parts)  = xco_cp=>string( `Hello.World.ABAP` )->split( `.` )->value.          " string table
DATA(joined) = xco_cp=>strings( VALUE string_table( ( `a` ) ( `b` ) ) )->join( `, ` )->value.
DATA(upper)  = xco_cp=>string( `abap` )->to_upper_case( )->value.                  " ABAP

IF xco_cp=>string( `ZSALES_HDR` )->starts_with( `Z` ).
" customer object
ENDIF.

Built-in string functions and string templates (ABAP on HANA › 03) work in ABAP Cloud too; XCO is an option, not a must.

7.5 JSON

TYPES: BEGIN OF ty_order,
sales_order TYPE c LENGTH 10,
customer    TYPE c LENGTH 10,
net_amount  TYPE p LENGTH 15 DECIMALS 2,
END OF ty_order.
DATA(order) = VALUE ty_order( sales_order = '0000004711' customer = '0010100001' net_amount = '1200.50' ).

" ABAP -> JSON: {"SALES_ORDER":"0000004711","CUSTOMER":"0010100001",...}
DATA(json) = xco_cp_json=>data->from_abap( order )->to_string( ).

" JSON -> ABAP
DATA order_back TYPE ty_order.
xco_cp_json=>data->from_string( json )->write_to( REF #( order_back ) ).

" JSON with Pascal-case names (SalesOrder) -> ABAP names with underscores (SALES_ORDER)
xco_cp_json=>data->from_string( `{"SalesOrder":"0000004712"}` )->apply( VALUE #(
( xco_cp_json=>transformation->pascal_case_to_underscore ) ) )->write_to( REF #( order_back ) ).
  • /UI2/CL_JSON is also listed as released in the Cloudification Repository – for SAP Cloud ERP, the SAP Business AI Platform, ABAP environment and S/4HANA Cloud Private Edition – and in SAP's released-classes cheat sheet.

7.6 Excel (XLSX)

" Read: XLSX file content (xstring, e.g. from an upload) into an internal table
DATA(sheet) = xco_cp_xlsx=>document->for_file_content( file_content
)->read_access( )->get_workbook( )->worksheet->at_position( 1 ).
DATA(all_cells) = xco_cp_xlsx_selection=>pattern_builder->simple_from_to( )->get_pattern( ).
sheet->select( all_cells )->row_stream( )->operation->write_to( REF #( orders ) )->execute( ).

" Write: internal table into a new XLSX file
DATA(new_file) = xco_cp_xlsx=>document->empty( )->write_access( ).
new_file->get_workbook( )->worksheet->at_position( 1
)->select( all_cells )->row_stream( )->operation->write_from( REF #( orders ) )->execute( ).
DATA(xlsx_content) = new_file->get_file_content( ).                " xstring for download or mail

A full upload scenario with a RAP action is in RAP › 11 · Files, Custom Entities & Integration, Part 2.

7.7 UUIDs

DATA(uuid_x16) = xco_cp=>uuid( )->value.                                   " type sysuuid_x16
DATA(uuid_c36) = xco_cp=>uuid( )->as( xco_cp_uuid=>format->c36 )->value.   " 429A229A-8802-…
" Classic class, also released:
DATA(uuid_x16_b) = cl_system_uuid=>create_uuid_x16_static( ).             " raises cx_uuid_error

7.8 Repository objects and generation

" All own classes whose name starts with ZCL_SO
DATA(name_filter) = xco_cp_abap_repository=>object_name->get_filter(
xco_cp_abap_sql=>constraint->contains_pattern( 'ZCL_SO%' ) ).
DATA(classes) = xco_cp_abap_repository=>objects->clas->where( VALUE #( ( name_filter ) )
)->in( xco_cp_abap=>repository )->get( ).
LOOP AT classes INTO DATA(class).
DATA(package) = class->get_package( )->name.
ENDLOOP.

" Generation (development system only): create a domain with fixed values
DATA(put) = xco_cp_generation=>environment->dev_system( transport      " request ID, e.g. from xco_cp_cts
)->create_put_operation( ).
DATA(domain) = put->for-doma->add_object( 'ZSO_STATUS' )->set_package( 'ZSO_DEMO'
)->create_form_specification( ).
domain->set_short_description( 'Sales order status' ).
domain->set_format( xco_cp_abap_dictionary=>built_in_type->char( 1 ) ).
domain->fixed_values->add_fixed_value( 'N' )->set_description( 'New' ).
domain->fixed_values->add_fixed_value( 'A' )->set_description( 'Approved' ).
TRY.
put->execute( ).
CATCH cx_xco_gen_put_exception.
ENDTRY.
  • Generation APIs are what ADT wizards and code generators use. In projects they are rare; know that they exist and that they need a development system and a transport.
  • Interview tip: "XCO is SAP's released utility library for ABAP Cloud: system fields, time, strings, JSON, Excel, repository information and generation, all in one fluent API."

Part 8 – Getting started step by step

The fastest way to learn ABAP Cloud is to write a small console class, debug it, test it and run ATC on it. The steps are the same in every system; only the way you get a system differs.

Six steps from system access to an ATC-clean ABAP Cloud class

8.1 Get a system

Option

What you get

Note

SAP Business AI Platform, ABAP environment Trial

Free shared system, ABAP Cloud only

Tutorial "Create an SAP Business AI Platform, ABAP environment Trial User" on developers.sap.com; SAP's RAP workshops use it

SAP Business AI Platform, ABAP environment (customer)

Own system, ABAP Cloud only

Setup: ABAP on BTP › 01, Part 3

S/4HANA Cloud Public Edition

Developer extensibility, ABAP Cloud only

Needs a developer tenant and business role

S/4HANA 2022+ private cloud or on-premise

Both language versions in one system

Create a software component / package for ABAP Cloud, or set the language version per object (Part 1)

8.2 Create the package and the first class

  • Install Eclipse with the ABAP Development Tools (tutorial "Install ADT" on developers.sap.com).
  • *File* → *New* → ABAP Cloud Project (BTP / public cloud) or ABAP Project (S/4HANA).
  • Right-click the parent package → *New* → *ABAP Package*: ZSO_DEMO, with a transport request.
  • Right-click ZSO_DEMO → *New* → *ABAP Class*: ZCL_SO_OPEN_ORDERS, interface IF_OO_ADT_CLASSRUN.
  • In a classic S/4HANA system: class *Properties* → *General* → *ABAP Language Version* → *Edit…* → ABAP for Cloud Development (unless the package already enforces it).
  • Activate (Ctrl+F3), run as console application (F9). The output appears in the *Console* view.
CLASS zcl_so_open_orders DEFINITION PUBLIC FINAL CREATE PUBLIC.
PUBLIC SECTION.
INTERFACES if_oo_adt_classrun.
METHODS age_in_days
IMPORTING created_on    TYPE d
today         TYPE d
RETURNING VALUE(result) TYPE i.
ENDCLASS.

CLASS zcl_so_open_orders IMPLEMENTATION.
METHOD if_oo_adt_classrun~main.
DATA(today) = cl_abap_context_info=>get_system_date( ).
out->write( |Hello { sy-uname }, today (UTC) is { today DATE = ISO }| ).
out->write( data = age_in_days( created_on = '20261101' today = today ) name = `Age in days` ).
ENDMETHOD.

METHOD age_in_days.
result = today - created_on.
ENDMETHOD.
ENDCLASS.

8.3 Debugging

  • Set a breakpoint by double-clicking the ruler left of the line number; ADT breakpoints replace the BREAK-POINT statement.
  • Run with F9: the debugger perspective opens at the breakpoint. Step with F5 (into), F6 (over), F7 (return), continue with F8.
  • Console classes, RAP handlers called from the Fiori preview and application jobs are all debugged the same way (for RAP see RAP › Quality, Part 2).

8.4 ABAP Unit

Add a test class in the *Test Classes* tab of the class (type test, Ctrl+Space, choose the template), then run it with Ctrl+Shift+F10; Ctrl+Shift+F11 shows coverage.

CLASS ltc_open_orders DEFINITION FINAL FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
PRIVATE SECTION.
METHODS age_is_counted_in_days FOR TESTING.
ENDCLASS.

CLASS ltc_open_orders IMPLEMENTATION.
METHOD age_is_counted_in_days.
DATA(cut) = NEW zcl_so_open_orders( ).
cl_abap_unit_assert=>assert_equals( act = cut->age_in_days( created_on = '20261101'
today      = '20261121' )
exp = 20 ).
ENDMETHOD.
ENDCLASS.
  • Released test doubles for database and CDS access: CL_OSQL_TEST_ENVIRONMENT, CL_CDS_TEST_ENVIRONMENT; for RAP BOs CL_BOTD_TXBUFDBL_BO_TEST_ENV and CL_BOTD_MOCKEMLAPI_BO_TEST_ENV; general doubles CL_ABAP_TESTDOUBLE.
  • Passing today as a parameter instead of reading the date inside the method is what makes the method testable.

8.5 ATC: the check variants

Check variant

Use it for

Note

ABAP_CLOUD_DEVELOPMENT_DEFAULT

Code written in ABAP for Cloud Development

Default quality checks for ABAP Cloud code; often the transport-release check

ABAP_CLOUD_READINESS

Classic Standard ABAP code you want to move to ABAP Cloud

Reports every statement and object that blocks the switch (Part 9)

Own variant with Usage of Released APIs (Cloudification Repository)

ECC or S/4HANA systems that analyse custom code

Check attribute = URL of the JSON file, e.g. objectReleaseInfoLatest.json or the …PCE… file for private cloud

  • Run: right-click in the editor → *Run As* → ABAP Test Cockpit With… → enter the variant (type * and *Browse* to see all variants in your system). Plain *ABAP Test Cockpit* (Ctrl+Shift+F2) uses the system default variant.
  • Results appear in the *ATC Problems* view; double-click a finding for the explanation.
  • ATC can also be started from code with the released class CL_SATC_API (e.g. in a pipeline).
  • Common mistake: activating code with warnings and skipping ATC. In most landscapes the transport release runs ATC and blocks on priority 1 findings, so you find out at the worst moment.

Part 9 – Converting classic code to ABAP Cloud: a worked example

A typical small classic report (as it runs on S/4HANA on-premise – in ECC the status GBSTK was read from VBUK, not VBAK): open sales orders of one sales organization with customer name, amount and age, and the user's full name in the header. We run the readiness check, read the findings and convert the report step by step. For a full report with selection screen, ALV and background job, see Clean Core › 02 · Clean-Core Report.

Conversion flow from a classic report to an ABAP Cloud class

9.1 The classic report

REPORT z_so_open_orders.

PARAMETERS p_vkorg TYPE vkorg OBLIGATORY.

DATA ls_address TYPE bapiaddr3.
DATA lt_return  TYPE STANDARD TABLE OF bapiret2.

SELECT vbak~vbeln, vbak~erdat, vbak~netwr, vbak~waerk, kna1~name1
FROM vbak
INNER JOIN kna1 ON kna1~kunnr = vbak~kunnr
WHERE vbak~vkorg = @p_vkorg
AND vbak~vbtyp = 'C'                                   " sales order
AND vbak~gbstk <> 'C'                                  " not completely processed (S/4HANA: GBSTK on VBAK · ECC: on VBUK)
INTO TABLE @DATA(lt_orders).

CALL FUNCTION 'BAPI_USER_GET_DETAIL'
EXPORTING
username = sy-uname
IMPORTING
address  = ls_address
TABLES
return   = lt_return.

WRITE: / 'Open orders of', p_vkorg, 'run by', ls_address-fullname, 'on', sy-datum.
ULINE.
LOOP AT lt_orders INTO DATA(ls_order).
DATA(lv_age) = sy-datum - ls_order-erdat.
WRITE: / ls_order-vbeln, ls_order-name1, ls_order-netwr CURRENCY ls_order-waerk, ls_order-waerk, lv_age.
ENDLOOP.

9.2 Step 1 – Run ATC with ABAP_CLOUD_READINESS

*Run As* → *ABAP Test Cockpit With…* → ABAP_CLOUD_READINESS. The findings group into a few categories (the exact message texts depend on the release):

Classic (Standard ABAP)

ABAP for Cloud Development

Note

REPORT (executable program)

Global class with IF_OO_ADT_CLASSRUN, or a Fiori elements app

Executable programs are not allowed

PARAMETERS p_vkorg

Method parameter; in a Fiori app a filter field (@UI.selectionField)

Selection screens are dynpro technology

SELECT … FROM vbak / kna1

I_SalesOrder + I_Customer

Not released; repository successors I_SalesDocument / I_Customer

TYPE vkorg, bapiaddr3

Type from the released view: i_salesorder-salesorganization

Unreleased DDIC types are errors too

CALL FUNCTION 'BAPI_USER_GET_DETAIL'

cl_abap_context_info=>get_user_formatted_name( )

The BAPI is a classic API (level B), not released

sy-datum

cl_abap_context_info=>get_system_date( ) (UTC) or XCO user date

sy-datum should not be used

WRITE, ULINE

out->write( ) for developers; a Fiori list for users

List statements are not allowed

  • For many findings ADT shows the successor or offers a quick fix (Ctrl+1 on the finding or in the editor); which quick fixes exist depends on your release. Structural changes (report → class, selection screen → parameters or filter bar) are always manual.

9.3 Step 2 – Rewrite as an ABAP Cloud class

CLASS zcl_so_open_orders DEFINITION PUBLIC FINAL CREATE PUBLIC.
PUBLIC SECTION.
INTERFACES if_oo_adt_classrun.
TYPES: BEGIN OF ty_order,
sales_order TYPE i_salesorder-salesorder,
customer    TYPE i_customer-customername,
net_amount  TYPE i_salesorder-totalnetamount,
currency    TYPE i_salesorder-transactioncurrency,
age_in_days TYPE i,
END OF ty_order,
tt_order TYPE STANDARD TABLE OF ty_order WITH EMPTY KEY.
METHODS get_open_orders
IMPORTING sales_org     TYPE i_salesorder-salesorganization
today         TYPE d
RETURNING VALUE(result) TYPE tt_order.
METHODS age_in_days
IMPORTING created_on    TYPE d
today         TYPE d
RETURNING VALUE(result) TYPE i.
ENDCLASS.

CLASS zcl_so_open_orders IMPLEMENTATION.
METHOD if_oo_adt_classrun~main.
DATA user_name TYPE string.
DATA(today) = cl_abap_context_info=>get_system_date( ).               " was sy-datum
TRY.
user_name = cl_abap_context_info=>get_user_formatted_name( ).     " was BAPI_USER_GET_DETAIL
CATCH cx_abap_context_info_error.
user_name = cl_abap_context_info=>get_user_alias( ).
ENDTRY.
out->write( |Open orders of 1010, run by { user_name } on { today DATE = ISO }| ).   " was WRITE
out->write( get_open_orders( sales_org = '1010' today = today ) ).
ENDMETHOD.

METHOD get_open_orders.
SELECT so~SalesOrder, cu~CustomerName, so~TotalNetAmount, so~TransactionCurrency, so~CreationDate
FROM i_salesorder AS so                                             " was VBAK
INNER JOIN i_customer AS cu ON cu~Customer = so~SoldToParty         " was KNA1
WHERE so~SalesOrganization       =  @sales_org
AND so~OverallSDProcessStatus <> 'C'                              " was GBSTK
INTO TABLE @DATA(orders).

result = VALUE #( FOR o IN orders ( sales_order = o-SalesOrder
customer    = o-CustomerName
net_amount  = o-TotalNetAmount
currency    = o-TransactionCurrency
age_in_days = age_in_days( created_on = o-CreationDate
today      = today ) ) ).
ENDMETHOD.

METHOD age_in_days.
result = today - created_on.
ENDMETHOD.
ENDCLASS.
  • Element names as used on Clean Core › 02 (Clean-Core Report) for I_SalesOrder; confirm them with Ctrl+Space in your release. I_SalesOrder already returns sales orders only, so the vbtyp = 'C' filter disappears.
  • Released views come with access controls: in a Fiori app the user sees only the orders SAP's authorization allows, unlike the classic SELECT on VBAK, which checked nothing.
  • The date is UTC. If the user's local date matters (e.g. late evening in America), use xco_cp=>sy->date( xco_cp_time=>time_zone->user ).

9.4 Step 3 – Give users a real UI

The console class is a developer tool. For end users the same selection becomes a CDS view entity on I_SalesOrder with @UI annotations, a service definition and an OData V4 UI binding: a Fiori elements list report with filter bar, variants and Excel export, and no ABAP at all. The complete code is on Clean Core › 02 · Clean-Core Report, Part 2. If the list needs ABAP logic (e.g. the age), use a virtual element or a custom entity (Clean Core › 02, Part 3).

9.5 Step 4 – Replace BAPIs that change data

  • If the report also created sales orders with BAPI_SALESORDER_CREATEFROMDAT2, the Cloudification Repository names the released RAP BO I_SalesOrderTP as successor: create the order with EML. Code: RAP › 11 · Files, Custom Entities & Integration, Part 7.
  • BAPI_SALESORDER_CHANGE is a classic API (level B) without a released successor in the repository file (it is classified classicAPI, remote-enabled): change the order with EML MODIFY ENTITIES OF I_SalesOrderTP … UPDATE on the fields its BDEF allows, or use a wrapper on private cloud / on-premise (6.4).

9.6 Step 5 – Switch the language version and re-check

  • *Properties* → *General* → *ABAP Language Version* → ABAP for Cloud Development. Now the syntax check itself enforces the rules: anything unreleased is an error, no longer just an ATC finding.
  • Run ATC with ABAP_CLOUD_DEVELOPMENT_DEFAULT, fix the rest, add the unit test from 8.4, transport.
  • Interview tip: "I start with ATC ABAP_CLOUD_READINESS, fix released-API findings with the Cloudification Repository successors, move UI to Fiori elements, replace BAPIs with released BOs or wrappers, then switch the language version and re-run ATC."

Part 10 – Common mistakes, tips and a one-page cheat sheet

10.1 Common mistakes

  • Searching for the table instead of the view. "VBAK is not released" is not a dead end: look up the successor (I_SalesDocument, I_SalesOrder) in the Cloudification Repository or with I_APIsWithCloudDevSuccessor.
  • Using sy-datum / sy-uzeit out of habit. Use cl_abap_context_info (UTC) or XCO with an explicit time zone, and decide which one the business needs.
  • Forgetting ->value at the end of an XCO chain, then wondering why a date variable is an object reference.
  • Typing with unreleased data elements copied from old code (vkorg, bapiret2). Type against the released view element or a released data element.
  • Copying a wrapper idea into public cloud. Wrappers need Standard ABAP; SAP Business AI Platform, ABAP environment and S/4HANA Cloud Public Edition have none.
  • Building a console class as the user's report. Console output is for developers; users get Fiori.
  • Running only the syntax check. ATC finds what the syntax check does not (deprecated APIs, performance, security); run it before every transport.
  • Expecting a deprecated API to break. It still works; but new code must use the successor.

10.2 Tips

  • Learn the naming of released views: I_ interface views (C1), I_…TP transactional BO interfaces, C_ consumption views (usually not for reuse), R_ restricted reuse views.
  • Keep the Cloudification Repository viewer bookmarked; it answers "what replaces X?" in seconds.
  • Use Ctrl+Space after -> in XCO and in released classes instead of searching the web.
  • Make methods testable: pass dates, users and other context as parameters.
  • Read SAP's own examples: SAP-samples/abap-cheat-sheets (19 ABAP for Cloud Development, 22 Released ABAP Classes) and the RAP100 workshop.

10.3 Cheat sheet: I want to …

I want to …

Classic (Standard ABAP)

ABAP for Cloud Development

Note

Run code and see output

SE38 report, WRITE, F8

Class with IF_OO_ADT_CLASSRUN, out->write( ), F9

Developers only

Show a list to users

ALV (CL_SALV_TABLE)

CDS view + service + Fiori elements

Clean Core › 02

Get today's date

sy-datum

cl_abap_context_info=>get_system_date( ), xco_cp=>sy->date( … )

UTC vs user time zone

Get the current time

sy-uzeit

cl_abap_context_info=>get_system_time( ), xco_cp=>sy->time( … )

Get the user's full name

BAPI_USER_GET_DETAIL

cl_abap_context_info=>get_user_formatted_name( )

sy-uname stays allowed

Read customers

SELECT FROM kna1

SELECT FROM i_customer

Repository successor

Read sales documents

SELECT FROM vbak

i_salesdocument, i_salesorder

Create a sales order

BAPI_SALESORDER_CREATEFROMDAT2

EML on I_SalesOrderTP

RAP › 11

Send an e-mail

CL_BCS

CL_BCS_MAIL_MESSAGE

Write a log

BAL_LOG_CREATE …

CL_BALI_LOG (or XCO_CP_BAL)

Get a number

NUMBER_GET_NEXT

cl_numberrange_runtime=>number_get( )

Create a GUID

GUID_CREATE

cl_system_uuid=>create_uuid_x16_static( ), xco_cp=>uuid( )

Lock an object

ENQUEUE_… function module

CL_ABAP_LOCK_OBJECT_FACTORY

RAP locks itself

Run in background

SM36 job, SUBMIT … VIA JOB

Application job (CL_APJ_RT_API), bgPF (CL_BGMC_PROCESS_FACTORY)

Clean Core › 02, Part 4

Run in parallel

CALL FUNCTION … STARTING NEW TASK

CL_ABAP_PARALLEL

Call an HTTP service

CL_HTTP_CLIENT

CL_WEB_HTTP_CLIENT_MANAGER + CL_HTTP_DESTINATION_PROVIDER

Communication targets

Convert to / from JSON

CALL TRANSFORMATION id

xco_cp_json

/UI2/CL_JSON (released)

Read or write Excel

abap2xlsx, OLE

xco_cp_xlsx

Count table lines

DESCRIBE TABLE … LINES

lines( itab )

DESCRIBE TABLE invalid

Assign / get a reference

MOVE a TO b, GET REFERENCE OF

b = a, REF #( )

Obsolete forms flagged

Find what replaces X

Where-used, experience

Cloudification Repository, I_APIsWithCloudDevSuccessor

Check old code

Code Inspector / ATC

ATC ABAP_CLOUD_READINESS

Check ABAP Cloud code

ATC default variant

ATC ABAP_CLOUD_DEVELOPMENT_DEFAULT

Release my own API

–

ADT *API State* tab, CL_ABAP_API_STATE

Wrapper pattern

Part 11 – Interview questions

Q1. What is ABAP for Cloud Development, and how is it different from ABAP Cloud?

ABAP for Cloud Development is an ABAP language version: a restricted language scope plus access only to released APIs, checked by the syntax check. ABAP Cloud is the development model built on it: this language version, released APIs, ADT as the only tool, RAP for transactional apps and CDS for the data model. Standard ABAP is the unrestricted language version used by classic code.

Q2. Explain release contracts C0, C1 and C2.

A release contract is SAP's stability promise for an object. C0 keeps extension points stable, so you can extend the object (fields, behavior). C1 keeps it stable for system-internal use, with the visibilities *Use in Cloud Development* and *Use in Key User Apps*; that is what ABAP Cloud code needs. C2 keeps a remote API (OData/SOAP) stable for external callers. C3 covers configuration content, C4 use in AMDP. You see them in ADT under *Properties* → *API State*.

Q3. How do you find out whether an SAP object is released, and what replaces it if not?

In ADT: the *Released Objects* tree and the *API State* tab. For successors: the Cloudification Repository on GitHub and its viewer, the view I_APIsWithCloudDevSuccessor, and api.sap.com. For existing code, ATC with ABAP_CLOUD_READINESS or the check *Usage of Released APIs* lists every unreleased object with its successor. Example: VBAK → I_SalesDocument, KNA1 → I_Customer.

Q4. What does "deprecated" mean for a released API?

It is still released and still works, but SAP has named a successor and will not develop the old one further. Existing code keeps running; new code uses the successor, and old code is moved in a planned way. ATC reports the use of deprecated APIs.

Q5. You need SAP functionality that has no released API. What do you do?

First search again: released views, BO interfaces (I_…TP), XCO, released classes. Then request the release through SAP Customer Influence. On S/4HANA private cloud or on-premise, build a wrapper in a Standard ABAP package around a classic API and release it with C1 for cloud development (clean core level B), so the ABAP Cloud code calls only the wrapper. In public cloud there is no Standard ABAP, so the options are key user tools, side-by-side on BTP with remote APIs, or another design.

Q6. What is XCO? Give three examples.

The Extension Components library, SAP's released general-purpose library for ABAP Cloud (classes XCO_CP*). Examples: xco_cp=>sy->date( xco_cp_time=>time_zone->user ) for the user's date, xco_cp_json=>data->from_abap( … )->to_string( ) for JSON, xco_cp_xlsx to read and write Excel, xco_cp_abap_repository for repository information and xco_cp_generation to generate objects.

Q7. Why should you not use sy-datum in ABAP Cloud, and what do you use instead?

sy-datum is the application server's local date, which has no meaning for a cloud system that serves users in many time zones; SAP lists it among the sy fields that should not be used. Use cl_abap_context_info=>get_system_date( ) for the UTC date or xco_cp=>sy->date( xco_cp_time=>time_zone->user ) for the user's date. Fields such as sy-subrc, sy-tabix and sy-uname stay allowed.

Q8. Which ATC check variants do you use and when?

ABAP_CLOUD_READINESS on classic code to see what blocks a move to ABAP Cloud; ABAP_CLOUD_DEVELOPMENT_DEFAULT on code written in ABAP for Cloud Development. In ECC or S/4HANA systems an own variant with the check *Usage of Released APIs (Cloudification Repository)*, pointed at SAP's JSON file on GitHub, analyses custom code against the current list of released APIs.

Q9. How do you run and debug code without SE38?

A global class implementing IF_OO_ADT_CLASSRUN runs with F9 in ADT and writes to the console with out->write( ). Breakpoints are set in the ADT ruler, and the Eclipse debugger opens on F9. Tests are ABAP Unit classes run with Ctrl+Shift+F10. For end users the output is a Fiori app, not a console.

Q10. Scenario: a classic report reads VBAK and KNA1, prints with WRITE and calls BAPI_USER_GET_DETAIL. Walk through the conversion.

Run ATC ABAP_CLOUD_READINESS. Replace the report with a class (IF_OO_ADT_CLASSRUN) or, for users, a CDS view on I_SalesOrder with a Fiori elements list. Replace VBAK/KNA1 with I_SalesOrder and I_Customer, sy-datum with cl_abap_context_info=>get_system_date( ), the BAPI with get_user_formatted_name( ), WRITE with out->write( ). Type fields from the released views. Switch the language version to ABAP for Cloud Development, run ABAP_CLOUD_DEVELOPMENT_DEFAULT, add a unit test, transport.

Q11. Scenario: a custom program creates sales orders with BAPI_SALESORDER_CREATEFROMDAT2. The customer moves to S/4HANA Cloud Public Edition. What changes?

The BAPI is not released, and public cloud has no Standard ABAP for a wrapper. The Cloudification Repository names the released RAP BO I_SalesOrderTP as successor, so the program becomes ABAP Cloud code that creates the order with EML (MODIFY ENTITIES OF i_salesordertp … COMMIT ENTITIES), with the BO's own validations and late numbering (CONVERT KEY to get the final number). If the call comes from outside, the released remote API (C2) is used instead.

Q12. Scenario: your team lead asks whether a utility class written last year can be used from new ABAP Cloud code in the same S/4HANA 2023 system. How do you decide?

Check its language version and dependencies. If it is Standard ABAP and uses only released APIs, switch it to ABAP for Cloud Development and re-run ATC. If it must stay Standard ABAP because it calls unreleased objects, treat it as a wrapper: check that it wraps classic APIs only (level B), give it a clean interface, release it with C1 *Use in Cloud Development* in ADT or with CL_ABAP_API_STATE, and document it so it can be replaced when SAP releases a successor.

🏠 Start Here · ◀ 01 · ABAP Environment · 03 · Interview Questions ▶ · Sections: CORE ABAP | OOPS ABAP | ABAP on HANA | Clean Core | RAP | ABAP Points | SAP Fiori | SAPUI5 | Mobile Development (MDK) | BTP Foundations | BTP Development | CAP | SAP Build | ABAP on BTP | Integration Suite | SAP Business AI | SAP BASIS | Security | SAP SDLC

Functional: FICO ABAP | TRM ABAP | VIM | SAP BIS | SD ABAP | MM ABAP | PP ABAP | QM ABAP | PM ABAP | PS ABAP | EWM | TM ABAP | GTM ABAP | EHS ABAP | HR ABAP | BW | SAP Datasphere | SAP Business Data Cloud | SAP MDG | SAP Analytics Cloud | SAP Ariba | SAP CX | SAP IBP