SAP Integration Suite avec ABAP Cloud : Intégration d

Catégorie
Integration
Publié
Auteur
Johannes

SAP Integration Suite est la plateforme d’intégration centrale sur SAP Business Technology Platform. Elle permet de connecter ABAP Cloud avec des services cloud, des systèmes on-premise et des applications tierces via des interfaces et protocoles standardisés.

Aperçu de SAP Integration Suite

SAP Integration Suite offre différentes capabilities pour différents scénarios d’intégration :

CapabilityDescriptionPertinence pour ABAP Cloud
Cloud IntegrationiPaaS pour l’intégration basée sur les messagesAppeler des iFlows depuis ABAP
API ManagementGateway API et gestion du cycle de viePublier des APIs ABAP
Event MeshIntégration basée sur les événementsRAP Business Events
Open ConnectorsAdaptateurs préconfigurésConnexion simplifiée
Integration AdvisorTraitement des messages B2B/EDIIntégration des partenaires commerciaux

Architecture : ABAP Cloud et Integration Suite

┌─────────────────────────────────────────────────────────────────────────┐
│ SAP Business Technology Platform │
├─────────────────────────────────────────────────────────────────────────┤
│ │
│ ┌──────────────────┐ ┌──────────────────────────────────────┐ │
│ │ ABAP Cloud │ │ SAP Integration Suite │ │
│ │ │ │ │ │
│ │ ┌────────────┐ │ HTTP │ ┌─────────────────────────────────┐ │ │
│ │ │ RAP BO │──┼──────┼─>│ Cloud Integration (iFlows) │ │ │
│ │ │ (Actions) │ │ │ │ │ │ │
│ │ └────────────┘ │ │ │ ┌─────┐ ┌─────┐ ┌─────┐ │ │ │
│ │ │ │ │ │Start│───>│ Map │───>│ End │ │ │ │
│ │ ┌────────────┐ │Events│ │ └─────┘ └─────┘ └─────┘ │ │ │
│ │ │ Business │──┼──────┼─>│ │ │ │
│ │ │ Events │ │ │ └─────────────────────────────────┘ │ │
│ │ └────────────┘ │ │ │ │
│ │ │ │ ┌─────────────────────────────────┐ │ │
│ │ ┌────────────┐ │ OData│ │ API Management │ │ │
│ │ │ OData │<─┼──────┼──│ (Gateway, Policies, Analytics) │ │ │
│ │ │ Services │ │ │ └─────────────────────────────────┘ │ │
│ │ └────────────┘ │ │ │ │
│ └──────────────────┘ └──────────────────────────────────────┘ │
│ │
└─────────────────────────────────────────────────────────────────────────┘
┌──────────────────────────────┐
│ Systèmes externes │
│ - SAP S/4HANA │
│ - Salesforce │
│ - SAP SuccessFactors │
│ - APIs tierces │
└──────────────────────────────┘

Scénario 1 : ABAP comme source (Outbound)

Dans ce scénario, ABAP Cloud appelle un iFlow dans Integration Suite pour transformer des données ou les envoyer vers des systèmes externes.

Communication Scenario pour Integration Suite

┌──────────────────────────────────────────────────────────────┐
│ Communication Scenario: Z_INT_SUITE_OUTBOUND │
├──────────────────────────────────────────────────────────────┤
│ Communication Type: Outbound │
│ │
│ Outbound Services: │
│ └── Z_INT_SUITE_IFLOW │
│ ├── Service Type: HTTP │
│ ├── Path: /cxf/http/* │
│ └── Authentication: OAuth 2.0 Client Credentials │
│ │
│ Supported Authentication Methods: │
│ ├── [x] OAuth 2.0 Client Credentials │
│ └── [x] Client Certificate │
└──────────────────────────────────────────────────────────────┘

Communication System pour Cloud Integration

┌──────────────────────────────────────────────────────────────┐
│ Communication System: CPI_TENANT │
├──────────────────────────────────────────────────────────────┤
│ General Data: │
│ ├── System ID: CPI │
│ ├── System Name: SAP Cloud Integration Tenant │
│ └── System Type: SAP Cloud Integration │
│ │
│ Technical Data: │
│ ├── Host: my-tenant.it-cpi001-rt.cfapps.eu10.hana.ondemand.com│
│ ├── Port: 443 │
│ └── Path Prefix: /cxf/http │
│ │
│ OAuth 2.0 Settings: │
│ ├── Token Endpoint: https://my-tenant.authentication.eu10.../token│
│ ├── Client ID: sb-integration-suite-client!t12345 │
│ └── Client Secret: ******** │
└──────────────────────────────────────────────────────────────┘

Appeler un iFlow depuis ABAP Cloud

CLASS zcl_integration_suite_client DEFINITION
PUBLIC FINAL
CREATE PUBLIC.
PUBLIC SECTION.
TYPES: BEGIN OF ty_order_message,
order_id TYPE c LENGTH 10,
customer_id TYPE c LENGTH 10,
total_amount TYPE decfloat34,
currency TYPE waers,
items TYPE STANDARD TABLE OF ty_order_item WITH EMPTY KEY,
END OF ty_order_message,
BEGIN OF ty_order_item,
product_id TYPE c LENGTH 18,
quantity TYPE i,
price TYPE decfloat34,
END OF ty_order_item,
BEGIN OF ty_iflow_response,
status TYPE c LENGTH 20,
message_id TYPE sysuuid_c32,
external_id TYPE string,
END OF ty_iflow_response.
METHODS send_order_to_iflow
IMPORTING
is_order TYPE ty_order_message
RETURNING
VALUE(rs_response) TYPE ty_iflow_response
RAISING
cx_http_dest_provider_error
cx_web_http_client_error.
ENDCLASS.
CLASS zcl_integration_suite_client IMPLEMENTATION.
METHOD send_order_to_iflow.
" Destination aus Communication Arrangement holen
DATA(lo_destination) = cl_http_destination_provider=>create_by_comm_arrangement(
comm_scenario = 'Z_INT_SUITE_OUTBOUND"
service_id = 'Z_INT_SUITE_IFLOW' ).
" HTTP Client erstellen
DATA(lo_client) = cl_web_http_client_manager=>create_by_http_destination(
i_destination = lo_destination ).
DATA(lo_request) = lo_client->get_http_request( ).
" iFlow-Endpunkt setzen (relativ zum Path Prefix)
lo_request->set_uri_path( '/orderProcessing' ).
" Header setzen
lo_request->set_header_field(
i_name = 'Content-Type"
i_value = 'application/json' ).
" Optionale Custom Header für iFlow-Routing
lo_request->set_header_field(
i_name = 'SAP_ApplicationID"
i_value = 'ABAP_CLOUD_ORDERS' ).
lo_request->set_header_field(
i_name = 'SAP_Sender"
i_value = 'ABAP_ENVIRONMENT' ).
" Order als JSON serialisieren
DATA(lv_json) = /ui2/cl_json=>serialize(
data = is_order
compress = abap_true
pretty_name = /ui2/cl_json=>pretty_mode-camel_case ).
lo_request->set_text( lv_json ).
" POST an iFlow senden
DATA(lo_response) = lo_client->execute( if_web_http_client=>post ).
DATA(lv_status) = lo_response->get_status( )-code.
DATA(lv_body) = lo_response->get_text( ).
lo_client->close( ).
" Response auswerten
IF lv_status >= 200 AND lv_status < 300.
" Erfolg - Response parsen
/ui2/cl_json=>deserialize(
EXPORTING json = lv_body
CHANGING data = rs_response ).
ELSE.
" Fehler
RAISE EXCEPTION TYPE cx_web_http_client_error
EXPORTING
status_code = lv_status.
ENDIF.
ENDMETHOD.
ENDCLASS.

RAP Action pour l’appel d’iFlow

" Behavior Definition
define behavior for ZI_SALESORDER alias SalesOrder
{
action sendToIntegrationSuite result [1] $self;
}
" Behavior Implementation
CLASS lhc_salesorder DEFINITION INHERITING FROM cl_abap_behavior_handler.
PRIVATE SECTION.
METHODS send_to_integration_suite FOR MODIFY
IMPORTING keys FOR ACTION SalesOrder~sendToIntegrationSuite RESULT result.
ENDCLASS.
CLASS lhc_salesorder IMPLEMENTATION.
METHOD send_to_integration_suite.
" Bestelldaten lesen
READ ENTITIES OF zi_salesorder IN LOCAL MODE
ENTITY SalesOrder
ALL FIELDS WITH CORRESPONDING #( keys )
RESULT DATA(lt_orders)
FAILED failed.
" Items lesen
READ ENTITIES OF zi_salesorder IN LOCAL MODE
ENTITY SalesOrder BY \_Items
ALL FIELDS WITH CORRESPONDING #( keys )
RESULT DATA(lt_items).
DATA(lo_client) = NEW zcl_integration_suite_client( ).
LOOP AT lt_orders INTO DATA(ls_order).
" Message aufbauen
DATA(ls_message) = VALUE zcl_integration_suite_client=>ty_order_message(
order_id = ls_order-OrderId
customer_id = ls_order-CustomerId
total_amount = ls_order-TotalAmount
currency = ls_order-Currency
items = VALUE #( FOR item IN lt_items
WHERE ( orderid = ls_order-orderid )
( product_id = item-ProductId
quantity = item-Quantity
price = item-Price ) ) ).
TRY.
" An Integration Suite senden
DATA(ls_response) = lo_client->send_order_to_iflow( ls_message ).
" Externe ID speichern
MODIFY ENTITIES OF zi_salesorder IN LOCAL MODE
ENTITY SalesOrder
UPDATE FIELDS ( ExternalId IntegrationStatus )
WITH VALUE #( (
%tky = ls_order-%tky
ExternalId = ls_response-external_id
IntegrationStatus = 'SENT' ) ).
APPEND VALUE #(
%tky = ls_order-%tky
%param = CORRESPONDING #( ls_order )
) TO result.
CATCH cx_http_dest_provider_error
cx_web_http_client_error INTO DATA(lx_error).
" Fehler melden
APPEND VALUE #(
%tky = ls_order-%tky
%msg = new_message_with_text( text = lx_error->get_text( ) )
) TO reported-salesorder.
MODIFY ENTITIES OF zi_salesorder IN LOCAL MODE
ENTITY SalesOrder
UPDATE FIELDS ( IntegrationStatus )
WITH VALUE #( (
%tky = ls_order-%tky
IntegrationStatus = 'ERROR' ) ).
ENDTRY.
ENDLOOP.
ENDMETHOD.
ENDCLASS.

Scénario 2 : ABAP comme cible (Inbound)

Dans ce scénario, Integration Suite appelle un service OData ou une API HTTP dans ABAP Cloud.

Exposer un service OData pour Integration Suite

@EndUserText.label: 'Produkt für Integration"
@AccessControl.authorizationCheck: #NOT_REQUIRED
define root view entity ZI_PRODUCT_INT
as select from zproduct
{
key product_id as ProductId,
product_name as ProductName,
category as Category,
price as Price,
currency as Currency,
stock as Stock,
@Semantics.systemDateTime.lastChangedAt: true
last_changed as LastChanged
}

Service Definition et Binding

@EndUserText.label: 'Product Integration Service"
define service Z_PRODUCT_INTEGRATION {
expose ZI_PRODUCT_INT as Products;
}

Communication Scenario pour Inbound

┌──────────────────────────────────────────────────────────────┐
│ Communication Scenario: Z_PRODUCT_INBOUND │
├──────────────────────────────────────────────────────────────┤
│ Communication Type: Inbound │
│ │
│ Inbound Services: │
│ └── Z_PRODUCT_INTEGRATION (OData V4) │
│ ├── Service URL: /sap/opu/odata4/sap/z_product_int/... │
│ └── Methods: GET, POST, PUT, PATCH, DELETE │
│ │
│ Supported Authentication Methods: │
│ ├── [x] OAuth 2.0 (SAML Bearer Assertion) │
│ ├── [x] Client Certificate │
│ └── [x] Basic Authentication │
└──────────────────────────────────────────────────────────────┘

Configuration iFlow pour l’appel ABAP

Dans Cloud Integration, un adaptateur HTTP est configuré :

┌──────────────────────────────────────────────────────────────┐
│ iFlow: Product Sync to ABAP Cloud │
├──────────────────────────────────────────────────────────────┤
│ │
│ ┌───────┐ ┌──────────┐ ┌─────────────┐ ┌───────┐ │
│ │ Start │───>│ Mapping │───>│ HTTP │───>│ End │ │
│ │ (SF) │ │ (XSLT) │ │ Receiver │ │ │ │
│ └───────┘ └──────────┘ └─────────────┘ └───────┘ │
│ │ │
│ ▼ │
│ HTTP Receiver Adapter: │
│ ├── Address: https://my-abap.abap.eu10.hana.ondemand.com │
│ ├── Proxy Type: Internet │
│ ├── Method: POST │
│ ├── Path: /sap/opu/odata4/sap/z_product_int/Products │
│ └── Authentication: OAuth2 Client Credentials │
│ ├── Token Endpoint: https://my-abap.authentication... │
│ ├── Client ID: integration-user │
│ └── Client Secret: (Secure Parameter) │
└──────────────────────────────────────────────────────────────┘

Traitement par lots avec Deep Insert

Pour les mises à jour en masse, Integration Suite peut envoyer des requêtes batch à ABAP :

" iFlow sendet OData $batch Request
" ABAP Cloud verarbeitet automatisch:
POST /sap/opu/odata4/sap/z_product_int/$batch
Content-Type: multipart/mixed; boundary=batch_123
--batch_123
Content-Type: application/http
POST Products HTTP/1.1
Content-Type: application/json
{"ProductId":"P001","ProductName":"Widget","Price":99.99,"Currency":"EUR"}
--batch_123
Content-Type: application/http
POST Products HTTP/1.1
Content-Type: application/json
{"ProductId":"P002","ProductName":"Gadget","Price":149.99,"Currency":"EUR"}
--batch_123--

Scénario 3 : Intégration basée sur les événements

Integration Suite Event Mesh connecte les RAP Business Events avec des systèmes externes.

Définir des RAP Business Events

managed implementation in class zbp_i_order unique;
strict ( 2 );
define behavior for ZI_ORDER alias Order
persistent table zorder
lock master
authorization master ( instance )
with additional save
{
create;
update;
delete;
" Business Events für Integration
event orderCreated parameter ZA_ORDER_CREATED_EVENT;
event orderCompleted parameter ZA_ORDER_COMPLETED_EVENT;
event orderCancelled parameter ZA_ORDER_CANCELLED_EVENT;
determination triggerOrderCreated on save { create; }
determination triggerOrderCompleted on save { field Status; }
}

Paramètres d’événement

@EndUserText.label: 'Order Created Event"
define abstract entity ZA_ORDER_CREATED_EVENT
{
OrderId : abap.char(10);
CustomerId : abap.char(10);
TotalAmount : abap.dec(15,2);
Currency : abap.cuky;
CreatedAt : timestampl;
CreatedBy : abap.uname;
}
@EndUserText.label: 'Order Completed Event"
define abstract entity ZA_ORDER_COMPLETED_EVENT
{
OrderId : abap.char(10);
CompletedAt : timestampl;
DeliveryDate : abap.dats;
TrackingNumber: abap.char(30);
}

Publication d’événements

CLASS lhc_order IMPLEMENTATION.
METHOD trigger_order_created.
READ ENTITIES OF zi_order IN LOCAL MODE
ENTITY Order
ALL FIELDS WITH CORRESPONDING #( keys )
RESULT DATA(lt_orders).
RAISE ENTITY EVENT zi_order~orderCreated
FROM VALUE #( FOR order IN lt_orders
( %key = order-%key
%param = VALUE #(
orderid = order-OrderId
customerid = order-CustomerId
totalamount = order-TotalAmount
currency = order-Currency
createdat = utclong_current( )
createdby = sy-uname ) ) ).
ENDMETHOD.
METHOD trigger_order_completed.
READ ENTITIES OF zi_order IN LOCAL MODE
ENTITY Order
ALL FIELDS WITH CORRESPONDING #( keys )
RESULT DATA(lt_orders).
" Nur für abgeschlossene Bestellungen
DATA(lt_completed) = VALUE #( FOR order IN lt_orders
WHERE ( status = 'COMPLETED' ) ( order ) ).
IF lt_completed IS NOT INITIAL.
RAISE ENTITY EVENT zi_order~orderCompleted
FROM VALUE #( FOR order IN lt_completed
( %key = order-%key
%param = VALUE #(
orderid = order-OrderId
completedat = utclong_current( )
deliverydate = order-DeliveryDate
trackingnumber = order-TrackingNumber ) ) ).
ENDIF.
ENDMETHOD.
ENDCLASS.

Configuration Event Mesh

┌──────────────────────────────────────────────────────────────┐
│ Enterprise Event Enablement │
├──────────────────────────────────────────────────────────────┤
│ Channel: Z_ORDER_EVENTS │
│ ├── Topic Space: default/sap.abapcloud/order │
│ └── Destination: EVENT_MESH_DESTINATION │
│ │
│ Topic Bindings: │
│ ├── ZI_ORDER.ORDERCREATED │
│ │ └── Topic: sap/abapcloud/order/created/v1 │
│ ├── ZI_ORDER.ORDERCOMPLETED │
│ │ └── Topic: sap/abapcloud/order/completed/v1 │
│ └── ZI_ORDER.ORDERCANCELLED │
│ └── Topic: sap/abapcloud/order/cancelled/v1 │
└──────────────────────────────────────────────────────────────┘

iFlow comme consommateur d’événements

┌──────────────────────────────────────────────────────────────┐
│ iFlow: Order Event Processing │
├──────────────────────────────────────────────────────────────┤
│ │
│ ┌─────────────┐ ┌──────────┐ ┌─────────────┐ │
│ │ AMQP │───>│ Router │───>│ HTTP │ │
│ │ Sender │ │ (Topic) │ │ Receiver │ │
│ └─────────────┘ └──────────┘ └─────────────┘ │
│ │ │ │ │
│ ▼ │ ▼ │
│ Event Mesh Queue │ External System │
│ queue:order-events │ (CRM, ERP, etc.) │
│ │ │
│ ├── sap/.../created ──> CRM │
│ ├── sap/.../completed ──> Billing │
│ └── sap/.../cancelled ──> Refund │
└──────────────────────────────────────────────────────────────┘

API Management pour les services ABAP

Enregistrer un service ABAP OData dans API Management

┌──────────────────────────────────────────────────────────────┐
│ API Management: Z_PRODUCT_API │
├──────────────────────────────────────────────────────────────┤
│ API Provider: │
│ ├── Name: ABAP Cloud Product Service │
│ ├── Type: SAP ABAP Environment │
│ ├── Host: my-abap.abap.eu10.hana.ondemand.com │
│ └── Service: Z_PRODUCT_INTEGRATION │
│ │
│ API Proxy: │
│ ├── Base Path: /products/v1 │
│ ├── Target Path: /sap/opu/odata4/sap/z_product_int │
│ └── Virtual Host: api.mycompany.com │
│ │
│ Policies: │
│ ├── Quota: 1000 calls/hour per API Key │
│ ├── Spike Arrest: 10 calls/second │
│ ├── OAuth2 Validation: Required │
│ └── Response Caching: 5 minutes (GET only) │
└──────────────────────────────────────────────────────────────┘

Appel d’API via API Management

Les consommateurs externes appellent l’API ABAP via l’API Gateway :

Terminal window
# API-Aufruf mit OAuth2 Token
curl -X GET "https://api.mycompany.com/products/v1/Products" \
-H "Authorization: Bearer ${ACCESS_TOKEN}" \
-H "APIKey: ${API_KEY}"

Exemple d’intégration complet

Scénario : Intégration Order-to-Cash

┌─────────────────────────────────────────────────────────────────────────┐
│ Order-to-Cash Integration Flow │
├─────────────────────────────────────────────────────────────────────────┤
│ │
│ 1. Commande créée dans ABAP Cloud │
│ │ │
│ ▼ │
│ 2. Business Event "orderCreated" déclenché │
│ │ │
│ ▼ │
│ 3. Event Mesh propage vers Integration Suite │
│ │ │
│ ├──────────────────────────┬──────────────────────────┐ │
│ ▼ ▼ ▼ │
│ 4a. Mise à jour CRM 4b. Fulfillment 4c. Analytics │
│ (Salesforce) (SAP EWM) (SAC) │
│ │ │ │ │
│ ▼ ▼ │ │
│ 5a. Opportunité 5b. Bon de livraison │ │
│ actualisée créé │ │
│ │ │ │
│ ▼ │ │
│ 6. Expédition effectuée │ │
│ │ │ │
│ ▼ │ │
│ 7. Event "shipped" │ │
│ │ │ │
│ ▼ │ │
│ 8. ABAP Cloud │ │
│ Mise à jour du statut │ │
│ │ │ │
│ ▼ │ │
│ 9. Event "completed"───────────┘ │
│ │
└─────────────────────────────────────────────────────────────────────────┘

iFlow pour le routage multi-cibles

" ABAP Cloud sendet Order-Event
" Integration Suite routet an multiple Targets
CLASS zcl_order_integration DEFINITION
PUBLIC FINAL
CREATE PUBLIC.
PUBLIC SECTION.
METHODS process_order_created
IMPORTING
is_event TYPE za_order_created_event.
ENDCLASS.
CLASS zcl_order_integration IMPLEMENTATION.
METHOD process_order_created.
" Direkter Aufruf eines iFlows für komplexe Orchestrierung
DATA(lo_destination) = cl_http_destination_provider=>create_by_comm_arrangement(
comm_scenario = 'Z_INT_SUITE_ORCHESTRATION' ).
DATA(lo_client) = cl_web_http_client_manager=>create_by_http_destination(
i_destination = lo_destination ).
DATA(lo_request) = lo_client->get_http_request( ).
" iFlow für Order-Orchestrierung
lo_request->set_uri_path( '/orderOrchestration' ).
lo_request->set_header_field(
i_name = 'Content-Type"
i_value = 'application/json' ).
" Event-Daten mit Routing-Info
DATA(ls_message) = VALUE ty_orchestration_message(
event_type = 'ORDER_CREATED"
event_data = is_event
routing = VALUE #(
( target = 'CRM' enabled = abap_true )
( target = 'FULFILLMENT' enabled = abap_true )
( target = 'ANALYTICS' enabled = abap_true ) ) ).
DATA(lv_json) = /ui2/cl_json=>serialize( data = ls_message ).
lo_request->set_text( lv_json ).
" Asynchroner Aufruf (Fire-and-Forget für Event-Propagierung)
TRY.
lo_client->execute( if_web_http_client=>post ).
CATCH cx_web_http_client_error.
" Fehler loggen für spätere Wiederholung
ENDTRY.
lo_client->close( ).
ENDMETHOD.
ENDCLASS.

Gestion des erreurs et surveillance

Logique de réessai pour les appels iFlow

CLASS zcl_integration_retry DEFINITION
PUBLIC FINAL
CREATE PUBLIC.
PUBLIC SECTION.
CONSTANTS: c_max_retries TYPE i VALUE 3,
c_retry_delay TYPE i VALUE 2000.
METHODS call_iflow_with_retry
IMPORTING
iv_path TYPE string
iv_payload TYPE string
RETURNING
VALUE(rv_response) TYPE string
RAISING
cx_web_http_client_error.
ENDCLASS.
CLASS zcl_integration_retry IMPLEMENTATION.
METHOD call_iflow_with_retry.
DATA: lv_retries TYPE i VALUE 0,
lv_delay TYPE i.
lv_delay = c_retry_delay.
WHILE lv_retries < c_max_retries.
TRY.
DATA(lo_destination) = cl_http_destination_provider=>create_by_comm_arrangement(
comm_scenario = 'Z_INT_SUITE_OUTBOUND' ).
DATA(lo_client) = cl_web_http_client_manager=>create_by_http_destination(
i_destination = lo_destination ).
DATA(lo_request) = lo_client->get_http_request( ).
lo_request->set_uri_path( iv_path ).
lo_request->set_header_field(
i_name = 'Content-Type"
i_value = 'application/json' ).
lo_request->set_text( iv_payload ).
DATA(lo_response) = lo_client->execute( if_web_http_client=>post ).
DATA(lv_status) = lo_response->get_status( )-code.
lo_client->close( ).
IF lv_status >= 200 AND lv_status < 300.
rv_response = lo_response->get_text( ).
RETURN.
ELSEIF lv_status >= 500.
" Server-Fehler: Retry
lv_retries = lv_retries + 1.
IF lv_retries < c_max_retries.
cl_abap_session_context=>sleep( lv_delay ).
lv_delay = lv_delay * 2. " Exponentielles Backoff
ENDIF.
ELSE.
" Client-Fehler: Kein Retry
RAISE EXCEPTION TYPE cx_web_http_client_error.
ENDIF.
CATCH cx_http_dest_provider_error INTO DATA(lx_dest).
RAISE EXCEPTION TYPE cx_web_http_client_error
EXPORTING previous = lx_dest.
ENDTRY.
ENDWHILE.
" Max Retries erreicht
RAISE EXCEPTION TYPE cx_web_http_client_error.
ENDMETHOD.
ENDCLASS.

Application Logging pour l’intégration

METHOD log_integration_call.
TRY.
DATA(lo_log) = cl_bali_log=>create_with_header(
header = cl_bali_header_setter=>create(
object = 'Z_INTEGRATION"
subobject = 'IFLOW_CALLS' ) ).
" Aufruf-Details loggen
lo_log->add_item( cl_bali_free_text_setter=>create(
severity = if_bali_constants=>c_severity_information
text = |iFlow Call: { iv_path } - Status: { iv_status }| ) ).
IF iv_status >= 400.
" Fehler-Details
lo_log->add_item( cl_bali_free_text_setter=>create(
severity = if_bali_constants=>c_severity_error
text = |Error Response: { iv_response }| ) ).
ENDIF.
" Log speichern
cl_bali_log_db=>get_instance( )->save_log( log = lo_log ).
CATCH cx_bali_runtime.
" Logging-Fehler ignorieren
ENDTRY.
ENDMETHOD.

Meilleures pratiques

ThèmeRecommandation
AuthentificationOAuth 2.0 Client Credentials pour service-to-service
Gestion des erreursRéessai pour les erreurs transitoires, Dead-Letter pour les permanentes
ÉvénementsImplémenter des consommateurs idempotents
PayloadEnvoyer uniquement les données nécessaires, pas les entités complètes
SurveillanceCombiner la surveillance Integration Suite et les logs ABAP
VersionnageVersions d’API pour les changements incompatibles
SécuritéCredentials dans Communication System, jamais dans le code
TestsTests iFlow locaux avant déploiement en production

Erreurs courantes et solutions

ErreurCauseSolution
HTTP 401Token expiréVérifier le token endpoint et les credentials
HTTP 403Permissions manquantesVérifier les rôles dans le système ABAP et BTP
HTTP 404iFlow non déployéActiver l’iFlow dans Cloud Integration
TimeoutiFlow trop lentAugmenter le timeout ou traiter de manière asynchrone
Connection refusedMauvais hôteVérifier l’hôte du Communication System
Certificate ErrorProblème TLSConfigurer le Trust Store

Sujets avancés