Aug 28, 2025

What is the Difference between Statement RETURN and EXIT in SAP ABAP?

Both RETURN and EXIT are control flow statements, but they serve different purposes and behave differently depending on the context. Here's a clear breakdown:

🔁 RETURN Statement

Purpose:
Used to exit a procedure—like a function module, method, or form—immediately and return control to the calling program.

Where it's used:

  • Function modules
  • Methods
  • Subroutines (FORM routines)

Behavior:

  • Ends the current procedure and returns to the caller.
  • No further code in the procedure is executed after RETURN.

Example:

FORM my_form. 

  IF sy-subrc <> 0. 

    RETURN. 

  ENDIF. " More code here won't run if RETURN is triggered 

ENDFORM.


🚪 EXIT Statement

Purpose:
Used to exit a loop or control structure like DO, WHILE, or LOOP.

Where it's used:

  • Inside loops (LOOP, DO, WHILE)
  • Not valid in procedures like methods or function modules (outside loops)

Behavior:

  • Immediately exits the current loop, but the rest of the surrounding code continues.
  • Does not exit the entire procedure.

Example:

LOOP AT it_table INTO wa_table. 

  IF wa_table-flag = 'X'. 

    EXIT. " Exits the LOOP, not the FORM 

  ENDIF. 

ENDLOOP.


🧠 Summary Table




Let me know if you want to see how CHECK fits into this trio—it’s another control statement that behaves a bit differently again.

Oct 23, 2024

Steps to Create Table Maintenance in SAP FIORI

 

Step 1: Create an OData Service

  1. Open SEGW (Gateway Service Builder):

    • T-code: SEGW.
    • Create a new project for your table maintenance (e.g., Z_TABLE_MAINTENANCE).
  2. Create Entity Type:

    • In the Data Model section, right-click on Entity Types and choose Create.
    • Define the Entity Type based on your SAP table (e.g., MARA).
  3. Create Entity Set:

    • Right-click on Entity Sets and create an entity set that corresponds to the table (e.g., MaterialSet for MARA).
    • Map the entity type to the entity set.
  4. Generate Runtime Objects:

    • Once your data model is complete, right-click on the project and choose Generate Runtime Objects.
  5. Implement CRUD Operations in DPC_EXT:

    • Navigate to SE80 or SE24 to access the DPC_EXT class (Data Provider Class Extension).
    • Implement the CRUD methods like CREATE_ENTITY, UPDATE_ENTITY, DELETE_ENTITY, and GET_ENTITYSET to handle the operations for your SAP table.
  6. Register and Activate the OData Service:

    • Go to T-code /IWFND/MAINT_SERVICE to register and activate your OData service.
    • Test the service by accessing /sap/opu/odata/sap/<SERVICE_NAME>/ to verify that the service is working as expected.

Step 2: Create a Fiori Elements App (List Report App)

  1. Set up SAP Web IDE or Business Application Studio:

    • Open SAP Web IDE or SAP Business Application Studio (BAS) to create your app.
  2. Create a New Project:

    • From the welcome screen, select New Project from Template.
    • Choose SAP Fiori Elements – List Report Application template.
  3. Provide OData Service Information:

    • Select the system and service you created in SEGW (e.g., Z_TABLE_MAINTENANCE_SRV).
    • Select the Entity Set created for your table (e.g., MaterialSet for MARA).
  4. Configure the List Report and Object Page:

    • Define your list report settings like filters and table columns.
    • Configure the Object Page for detail views.

Step 3: Enable Editing (CRUD Operations)

  1. Edit the manifest.json:
    • Ensure that the app allows editing by setting the necessary flags in the manifest.json.
"sap.ui.generic.app": {
    "pages": {
        "ListReport|MaterialSet": {
            "entitySet": "MaterialSet",
            "component": {
                "name": "sap.suite.ui.generic.template.ListReport",
                "settings": {
                    "editable": true,
                    "defaultCreateEnabled": true,
                    "defaultDeleteEnabled": true,
                    "defaultUpdateEnabled": true
                }
            }
        },
        "ObjectPage|MaterialSet": {
            "entitySet": "MaterialSet",
            "component": {
                "name": "sap.suite.ui.generic.template.ObjectPage",
                "settings": {
                    "editableHeaderContent": true
                }
            }
        }
    }
}

  1. Configure the CDS View (if used):
    • If you are using a CDS view, ensure that you annotate the fields appropriately for editing using annotations like @UI.fieldGroup for forms and @UI.lineItem for table display.

Step 4: Deploy to SAP Fiori Launchpad

  1. Deploy the Fiori App to the ABAP Repository:

    • In SAP Web IDE or BAS, right-click on the project and select Deploy > Deploy to ABAP Repository.
    • Provide your SAP system details and select the package and transport request.
  2. Configure the Fiori Launchpad:

    • Access the Fiori Launchpad Designer using the T-code /UI2/FLPD_CUST.
    • Create a new Catalog and Group.
    • Define a new Tile for the app in the catalog.
    • Set up Target Mapping to link the tile to your deployed Fiori app by entering the Semantic Object and Action.
  3. Assign the Tile to a Role:

    • Use PFCG to create a new role or update an existing role.
    • Assign the catalog or tile to the user roles that will have access to the app.

Step 5: Assign Roles and Access in Fiori Launchpad

  1. Assign Roles to Users:
    • In PFCG, add the catalog or group to the role and assign the role to the relevant users.
    • Users assigned with the role will see the app tile in the Fiori Launchpad.

Step 6: Test and Use the App

  1. Test CRUD Operations:
    • Access the Fiori Launchpad as the user.
    • Click on the app tile and test the CRUD operations (Create, Update, Delete) for the SAP table.
    • Verify that you can maintain the SAP table's data directly from the Fiori UI.

By following these detailed steps, you will be able to create a Fiori app that allows users to maintain (Create, Update, Delete) data in an existing SAP table through the SAP Fiori Launchpad without using SE11 or SE80 directly.