You can build a new internal table with only selected entries and fields like this: *&---------------------------------------------------------------------* *& Report ZREP_LCLCLASS *&---------------------------------------------------------------------* *& Demonstrates modern ABAP syntax: REDUCE, FILTER, FOR expressions *&---------------------------------------------------------------------* REPORT zrep_lclclass. *---------------------------- * Example 1: REDUCE Operator *---------------------------- TYPES: BEGIN OF ty_order, id TYPE i, amount TYPE i, END OF ty_order. DATA: lt_orders TYPE STANDARD TABLE OF ty_order WITH EMPTY KEY, lv_total TYPE i. lt_orders = VALUE #( ( id = 1 amount = 100 ) ( id = 2 amount = 250 ) ( id = 3 amount = 150 ) ). lv_total = REDUCE i( INIT sum = 0 FOR order IN lt_orders NEXT sum = sum + order-amount ). WRITE: / '--- REDUCE Example ---', / 'Total Amount:', lv_total. *---------------------------- * Example 2: FILTER Operator *---------------------------- TYPES: BEGIN OF ty_user, name TYPE string, status TYPE string, END OF ty_user. DATA: lt_users TYPE STANDARD TABLE OF ty_user WITH EMPTY KEY, lt_active_users TYPE STANDARD TABLE OF ty_user WITH EMPTY KEY. lt_users = VALUE #( ( name = 'Alice' status = 'ACTIVE' ) ( name = 'Bob' status = 'INACTIVE' ) ( name = 'Charlie' status = 'ACTIVE' ) ). lt_active_users = FILTER #( lt_users WHERE status = 'ACTIVE' ). WRITE: / '--- FILTER Example ---'. LOOP AT lt_active_users INTO DATA(user). WRITE: / user-name, user-status. ENDLOOP. *------------------------------------------------------ * Example 3: FOR Expression - Extract Specific Fields *------------------------------------------------------ DATA: lt_names TYPE STANDARD TABLE OF string WITH EMPTY KEY. lt_names = VALUE string_table( FOR user IN lt_users WHERE ( status = 'ACTIVE' ) ( user-name ) ). WRITE: / '--- FOR Expression Example ---'. LOOP AT lt_names INTO DATA(name). WRITE: / name. ENDLOOP. This creates a new string table containing only the names of users whose status = 'ACTIVE'—short, clean, and readable. Output: — ...
SAP EWM Help Latest Questions
A Listbox in SAP refers to a dropdown list UI element that allows users to select one value from a predefined set of values. *&---------------------------------------------------------------------* *& Report ZREP_LCLCLASS *& *&---------------------------------------------------------------------* *& *& *&---------------------------------------------------------------------* REPORT zrep_lclclass. PARAMETERS: p_color AS LISTBOX VISIBLE LENGTH 20 USER-COMMAND uc. INITIALIZATION. DATA: lt_list TYPE vrm_values, ls_list TYPE vrm_value. ls_list-key = 'R'. ls_list-text = 'Red'. APPEND ls_list TO lt_list. ls_list-key = 'G'. ls_list-text = 'Green'. APPEND ls_list TO lt_list. ls_list-key = 'B'. ls_list-text = 'Blue'. APPEND ls_list TO lt_list. CALL FUNCTION 'VRM_SET_VALUES' EXPORTING id = 'P_COLOR' values = lt_list. Output: execute the Code.
In OData (Open Data Protocol), an entity is a representation of a data record that typically maps to a row in a database table. Key Concepts: Entity = Object or Record For example, a Customer, Order, or Product can each be ...
SEGW (Service Gateway Builder) is a transaction code used to create ODATA services in SAP NetWeaver Gateway. It lets you define models, entities, and implement CRUD operations using a UI-based interface. Steps to Create an ODATA Project in SEGW Step 1: Open ...
The SET PARAMETER ID and GET PARAMETER ID statements are used with SAP memory to pass data between two separate transactions, each running in its own session. When you use SET PARAMETER ID to assign a value to a field, opening ...
A final class is declared using the keyword FINAL in its definition. It’s used when you want to prevent further inheritance of the class, ensuring its behavior cannot be modified through subclassing. Why Use a Final Class?
It is a file (with .behavior extension) that specifies the business behavior of an entity (CDS view), and it controls: Which operations are allowed Which fields are modifiable Which validations or determinations are triggered Custom logic, like actions Key Purposes of Behavior Definition Function Description Enable CRUD operations Define ...
Aspect DDIC View (ABAP Dictionary View) CDS View (Core Data Services View) Definition Tool Created using SE11 (Graphical interface) Created using ADT (Eclipse) with SQL-like DDL syntax Technology Base Classic SAP NetWeaver Modern SAP HANA / S/4HANA Definition Style GUI-based definition (drag-and-drop style) Text-based, code-centric with annotations Join Support Basic joins (Inner, Outer) Advanced ...