During SAP RAP application development, it’s common to encounter the error “An exception was raised.” However, figuring out the root cause of this error can often take days. This issue might occur when performing actions like clicking a button, opening an object page, saving a record, or during any random event execution.
To demonstrate how to identify and fix such errors, let’s take an example from a custom application I was working on. It’s a simple, unmanaged RAP application designed to create and update bank records in the standard table BNKA using the provided interface I_BankTP.
Below is how the list page and object page of the application look:
The update method in the application has the following logic:
* Changed record from transaction buffer
DATA(ls_bank) = entities[ 1 ].
* Update the bank data
MODIFY ENTITIES OF i_banktp PRIVILEGED ENTITY bank
UPDATE FIELDS (
longbankname
longbankbranch
)
WITH VALUE #( (
%key-bankcountry = ls_bank-BankCountry
%key-bankinternalid = ls_bank-BankInternalID
longbankname = ls_bank-BankName
longbankbranch = ls_bank-BankBranch
) )
FAILED DATA(failed_bank) REPORTED DATA(reported_bank) MAPPED DATA(updated_mapped).
The logic simply takes whatever is passed in the importing parameter entities of the update method and uses it in the EML statement to update the bank record. When I change the Bank Name, the application works perfectly. However, when I try to update only the Bank Branch field, it throws an error.
Did I make a mistake in the logic?
The syntax is copied directly from the I_BankTP documentation. So, what went wrong?
To diagnose the issue, we can use a tool called - ABAP Cross Trace in the ABAP Development Tools (ADT).
Open the ABAP Cross Trace Tool: Navigate to Window > Show View > Others in the Eclipse navigation bar.
Create a New Trace: Start a new trace for the logged-in user.
Configure the Trace Settings: Adjust the settings as needed or keep the default values. Click OK to activate the trace.
Activate the Trace: Once activated, the trace will appear in the cross trace list.
Execute the Event: Go back to the application and perform the action that triggers the exception. In this case, click the Save button on the object page.
Deactivate the Trace: After the exception occurs, return to the trace and deactivate it.
Review Trace Results: Once deactivated, a new tab called Trace Results will appear beside the Trace Configurations tab. Double-click on the trace result to open it.
Identify the Failure Point: Expand the trace details to locate where the execution failed for the first time. In this example, the failure occurred in the process Check Before Save.
Find the Error Message: Expand the process to locate the subprocess containing the error messages. You should find Failed messages. In my case, we have 1 failed message.
Double-click on FAILED:1, REPORTED:2 to open the contents of FAILED and REPORTED. Check the REPORTED table for the error message ID and number.
Analyze the Error: Upon checking the message class, we found the error. When editing a record and changing only the Bank Branch, the Bank Name field remains blank if it’s not updated.
Root Cause: I debugged the code and validated the case. The application attempts to modify the bank records using the standard interface I_BANKTP with a blank Bank Name, which triggers the exception.
Fix the Logic: To resolve this, modify the update method logic to ensure Bank Name is always populated:
* Changed record from transaction buffer
DATA(ls_bank) = entities[ 1 ].
* Fetch existing data
SELECT SINGLE * FROM zsac_r_bank
WHERE BankCountry = @LS_bank-BankCountry
AND BankInternalID = @LS_bank-BankInternalID
INTO @DATA(ls_existing_bank).
* Update the bank data
MODIFY ENTITIES OF i_banktp PRIVILEGED ENTITY bank
UPDATE FIELDS (
longbankname
longbankbranch
)
WITH VALUE #( (
%key-bankcountry = ls_bank-BankCountry
%key-bankinternalid = ls_bank-BankInternalID
longbankname = COND #( WHEN ls_bank-BankName IS INITIAL
THEN ls_existing_bank-BankName ELSE ls_bank-BankName )
longbankbranch = ls_bank-BankBranch
) )
FAILED DATA(failed_bank) REPORTED DATA(reported_bank) MAPPED DATA(updated_mapped).
Test the Fix: After making the changes, the application works as expected. This exercise was a great learning experience in using the ABAP Cross Trace tool to diagnose and resolve exceptions.
That's it folks!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Subject | Kudos |
---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
User | Count |
---|---|
10 | |
5 | |
4 | |
4 | |
4 | |
3 | |
3 | |
3 | |
3 | |
2 |