Technology Blog Posts by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
SachinArtani
Active Participant
4,142

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.

Setting the Stage

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:

SachinArtani_0-1739011988303.png

SachinArtani_1-1739011988306.png

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.

SachinArtani_2-1739012073416.png

Did I make a mistake in the logic?

The syntax is copied directly from the I_BankTP documentation. So, what went wrong?

Understanding the Error

To diagnose the issue, we can use a tool called - ABAP Cross Trace in the ABAP Development Tools (ADT).

  1. Open the ABAP Cross Trace Tool: Navigate to Window > Show View > Others in the Eclipse navigation bar.

  2. Create a New Trace: Start a new trace for the logged-in user.

    SachinArtani_0-1739012362271.png
  3. Configure the Trace Settings: Adjust the settings as needed or keep the default values. Click OK to activate the trace.

    SachinArtani_0-1739012566960.png
  4. Activate the Trace: Once activated, the trace will appear in the cross trace list.

    SachinArtani_1-1739012619576.png
  5. 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.

    SachinArtani_2-1739012642850.png
  6. Deactivate the Trace: After the exception occurs, return to the trace and deactivate it.

    SachinArtani_3-1739012665654.png
  7. 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.

    SachinArtani_4-1739012683137.png
  8. 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.

    SachinArtani_5-1739012709376.png
  9. 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.

    1. SachinArtani_6-1739012765476.png
  10. 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.

    SachinArtani_7-1739012847251.png
  11. 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.

    SachinArtani_8-1739012876297.png
  12. 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.

    SachinArtani_9-1739012935255.png
  13. 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!

 

4 Comments
Deep46
Explorer

This trick is going to come in so handy!

ThorstenHoefer
Active Contributor
0 Kudos

Hi Sachin,

is it possible to use the control structure like:

UPDATE FROM VALUE #(
        ( %cid_ref = 'cid3'
          data_field1_root = 'iii'
          %control-data_field1_root = if_abap_behv=>mk-on
          data_field2_root = 'jjj'
          %control-data_field2_root = if_abap_behv=>mk-on )
         )
SachinArtani
Active Participant
0 Kudos

@ThorstenHoefer this does not look relevant to the post, but yes, you can fill control structure like that.

Aditi_Singhal21
Explorer

Awesome Sachin !! understood 🙂

Labels in this area