Implementing Entity Sets for Items

Sep 28, 2024

Lecture Notes on Implementing Entity Set and Entity Type for Items

Introduction

  • Discussion on implementing and testing item entity sets and types.
  • Previous implementation discussed was for header entity set.

Error Handling

  • Initial attempt to access item results in an error: "method is not implemented."
  • Identified methods to implement for handling multiple and single entries.

Backend Implementation Steps

  1. Access Backend System

    • Navigate to the method section and check inherited methods.
    • Look for item entity set get entities method.
  2. Method Redefinition

    • Right-click on the method and select "Redefine."
    • Activate the method after redefining.
  3. Code Implementation

    • Remove commented lines of code.
    • Execute the SQL command:
      SELECT * FROM VBRP INTO TABLE ET  
      
      • Limit results to 13 records.
    • Perform syntax check and activate the code.
  4. Testing in Frontend

    • Test the implementation in the frontend.
    • Verify that data is now available (previous error resolved):
      • Displays item details including billing number and item number.
  5. Data Format Testing

    • Test JSON format output using URL query:
      • Append ?format=json to the request URL.
  6. Count Functionality

    • Count of entries should return 13 (hard coded).
    • Test functionality to read a single entry using primary key.
  7. Backend Implementation for Single Entry

    • Navigate back to backend, redefine get entity method.
    • Generate code and remove unnecessary sections.
    • Read key from the table:
      READ TABLE ITKEY_TAB INTO LS_KEY_TAB  
      
    • Assign values to local variables for processing.
  8. Select Logic

    • Check if primary key values are not initial.
    • Execute SQL command for single entry:
      SELECT SINGLE * FROM VBRP INTO ET  
      WHERE VBELN = LV_VBELN AND POSNR = LV_POSNR  
      
    • Perform syntax check and activate the method.

Frontend Testing for Single Entry

  • Execute the corrected single entry request.
  • Verify successful retrieval of one entry (details of VBELN and item).

Conclusion

  • Key Points:
    • Multiple selects require redefining get entity set method.
    • Single entity retrieval requires redefining get entity method.
  • Completion of steps 7 and 8 for item entity type and set implementation.