abap backend implementation of asynchronous services
TRANSCRIPT
Service enabling of SAP Business Suite - ImplementationZDSESA
ABAP backend implementation of asynchronous services
Communication Layer
Proxy Framework
XML Payload
ABAP Payload
Application Service-Enabling Layer
Restartable Service Implementation
ABAP Payload
Application Layer
BAPIAPIMethod
FEH Layer
Appl. Message Persistency
RError & Conflict Handler
Resolution Stratetgy
Determination
Post Processing
Office
SXMB_MONI Runtime
MonitoringUser Interface
ABAP Parameters
XML Message Persistency
R
Proxy Implementation
WS Runtime Local XI Runtime
© SAP 2007 / Page 2
1. Integration Repository1.1. ….
2. Proxy Generation
3. Proxy implementation of Inbound Services3.1. Basic Aspects of Enterprise Service Implementation
3.1.1 Transformation, Data Mapping, Conversion3.1.2 Extensibility – BAdI Concept3.1.3 Error and Exception Handling3.1.4 Synchronous Communication
3.1.5 Asynchronous Communication3.2. Data Changing Enterprise Services3.3. ….
Agenda
© SAP 2007 / Page 3
Objectives
You understand the basic programming model of asynchronous services and the impact of uni- and bi-directional communication on the backend implementation.
You understand, how to implement DB updates for asynchronous services.
You aware of the difference between errors and exceptions and you understand the Forward Error Handling (FEH) solution for asynchronous services.
You are aware of the tools available to test asynchronous services in a single service test.
© SAP 2007 / Page 4
Sequence: Asynchronous Communication Option 1
Mediation via Integration Server required – but do not presuppose so! Business logic is performed inside inbound proxy (i.e. a direct BAPI call) Outbound proxy is called from inbound proxy implementation
uni-directional
bi-directional
© SAP 2007 / Page 5
Sequence: Asynchronous Communication Option 2
Mediation via Integration Server required – but do not presuppose so! Business logic is at least in part ‘forwarded’ to application (asynchronous) Outbound proxy is called in separate LUW by application
© SAP 2007 / Page 6
Move out of proxy into separate service implementation class
Asynchronous services – Basic Programming Model (single service)
METHOD execute_asynchronous RAISING CX_<StandardMessageFault>.
“ Switch of Extended XML Handling if switched on in CONSTRUCTOR
SET UPDATE TASK LOCAL.
CALL METHOD import_conversion … CALL BADI inbound_processing …
CALL FUNCTION … “business logic using BAPI, API, method …
“ if an error occurred in the inbound mapping or the business logicCall method <FEH register> “Register FEHCall method … “FEH processingCL_PROXY_FAULT=>RAISE …
“ if response is sent immediately (outbound service call) CALL METHOD export_conversion … *) CALL BADI outbound_processing …
“ Can you implement logical receiver determination? “ CALL function outbound proxy (in UPDATE TASK )
create object lo_proxy…..lo_proxy-> execute_asynchronous ( output ).
ENDMETHOD.
Atomic transaction; database updates local,COMMIT by framework
Conversion service-appropriate ABAP internal language
Handover erroneousdata to FEH
*) maybe to be included in the call function …. In update task
© SAP 2007 / Page 7
Asynchronous Services – Database Updates
Database Updates Never invoke COMMIT WORK or ROLLBACK WORK nor any encapsulation (such as BAPI_TRANSACTION_COMMIT) NW will react with an runtime error in future!
The XI / WS-RM runtime is responsible to COMMIT or ROLLBACK (CL_PROXY_FAULT=>RAISE(error_messages) ) database updates: this is related to the Processing Status in the XI monitoring (TX SXMB_MONI)
COMMIT: message successfully completed ROLLBACK: Application errors occurred!
SET UPDATE TASK LOCAL Always use this statement at the start of a proxy implementation for data changing services Confirmation message and data changes must share the same LUW Confirmation
consistent with system state Confirmation message should be sent in the update task
CheckMan
© SAP 2007 / Page 8
Asynchronous Services – Exceptions vs. Errors
Errors (FEH: Forward Error Handling)
Error and conflict situations classified at design time
Rule-based resolution strategy: Automatically by retry manually by business expert?
Returned to consumer only if request really can’t be fulfilled – as Log element in response
Errors (FEH: Forward Error Handling)
Error and conflict situations classified at design time
Rule-based resolution strategy: Automatically by retry manually by business expert?
Returned to consumer only if request really can’t be fulfilled – as Log element in response
Exceptions Fault Messages – but not
returned to consumer
Logged & monitored technical expert triggers resolution
Use RAISE operation of class CL_PROXY_FAULT
Exceptions Fault Messages – but not
returned to consumer
Logged & monitored technical expert triggers resolution
Use RAISE operation of class CL_PROXY_FAULT
© SAP 2007 / Page 9
Asynchronous Services – Error and Exception Handling
Sender and receiver processfully decoupled Sender process may end before receiver starts Different LUWs, no two phase commit, no cross-system rollback
& locks No immediate resolution by sender possible
Errors detected by receiverto be handled independently from sender process
Error forward resolution necessaryIf possible error forward recovery
Out Out
© SAP 2007 / Page 10
Suitable Error & Conflict Recovery Strategies
Different strategies to attempt error recovery possible
Suitable strategy depends on Kind of error / conflict
Categorization of errors & conflictsat design-time
Exact service & customer environment
Configurable determinationof recovery strategy
Automatic Manual Reject & delegate
© SAP 2007 / Page 11
Asynchronous Service Execution –With Forward Error Handling
FEHLocal IEIntegration ServerService Consumer Service-enabledBusiness Logic
Service ImplementationInbound Service Proxy
<XML> Request</ XML>
Extended XML handling on
Error duringExecution
Rollback
Business Logic
Send RequestXML à ABAPTransformation Extended XML
handling off
ExecutionSuccessful
Pass input &error info to FEH
Register
Register FEH
Raise Exception
Start Reovery Process
Commit
Translate to API input paramsValidate params
Call pre-processing BAdI
Execute Business Logic
Input Parameters
Translate to ResponseCall post-processing BAdI
Result Parameters
Call Business Logic
Technical errors Fault
Messages
Scope of FEH
© SAP 2007 / Page 12
FEH
Outbound Service Proxy
Service-enabledBusiness Logic
Service Implementation
Assemble Response
Response
Register outbound call
ExecutionSuccessful
Determine Strategy
Start Resolution Process
Commit
Translate to API input paramsValidate params
Call pre-processing BAdI
Execute Business Logic
Input Parameters
Translate to ResponseCall post-processing BAdI
Result Parameters
Call Business Logic
Retry
Manual completion/ Fail
Error during execution
Error occured in mapping
Error occuredin API
Sketch: Forward Error Handling Process
Different re-entry points conceivable
Service implementation not called by XI or WS runtime
callback operations IF_ECH_ACTION:
RETRY, FINISH, FAIL
© SAP 2007 / Page 13
FEH Integration:Effort for Application Development
Separate service processing steps from inbound proxy class Required for automatic or manual re-execution
No XI or WS-RM runtime active
Call FEH, implement ®ister call-back interface (IF_ECH_ACTION) Ensure FEH is called at run-time if errors or conflicts are detected Call-back by FEH on retry requires implementation of defined interface
Application Service-Enabling Layer
Restartable Service Implementation
ABAP Payload
FEH Layer
Appl. Error Persistency
RError & Conflict Handler
Resolution Stratetgy
Determination
Post Processing
Office
Proxy Implementation
© SAP 2007 / Page 14
FEH Integration:Effort for Application Development (cont’d)
Categorization of errors & conflicts Assignment of messages to error symptom codes
Meta-data maintenance for FEH components Registration of service & call-back implementation
in ECH and PPO Configuration of retry-periodicity Optional: default configuration of resolution strategy
Application Service-Enabling Layer
Restartable Service Implementation
ABAP Payload
FEH Layer
Appl. Error Persistency
RError & Conflict Handler
Resolution Stratetgy
Determination
Post Processing
Office
Proxy Implementation
© SAP 2007 / Page 15
Asynchronous (inbound) Services – Single Service Tests
HTML client
Link
ABAP test report
available with SAP BS FND 7.01
HTML and ABAP client to be used for developer test (/SICF provides information regarding technical settings for the HTML client)
synchronous service execution using local IE full functionality of the local IE (including FEH) available test environment of SPROXY
Asynchronous outbound services must be reviewed in XI monitoring, if the message was correctly constructed
Wiki: test guideline