Hello,

Sign up to join our community!

Welcome Back,

Please sign in to your account!

Forgot Password,

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

You must login to ask a question.

You must login to send a message.

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Welcome To Himer

Ask questions and get real answers from real people. Whether you’re looking for crossword answers, practical advice or you’ve just come for a chat, get answers to your questions. To get started all you need to do is register.

Our Statistics

  • Questions 92
  • Answers 3
  • Best Answers 0
  • Users 3

SAP EWM Help Latest Questions

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: — ...

This replaces the need for LOOP AT, IF, and APPEND all in one line—powerful and readable. *&---------------------------------------------------------------------* *& Report  ZREP_LCLCLASS *& *&---------------------------------------------------------------------* *& *& *&---------------------------------------------------------------------* REPORT zrep_lclclass. 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_names TYPE STANDARD TABLE OF string WITH EMPTY KEY. lt_users = VALUE #(   ( name = 'Alice'   status = 'ACTIVE' )   ( name = 'Bob'     status = 'INACTIVE' )   ( name = 'Charlie' status = 'ACTIVE' ) ). lt_names = VALUE string_table(   FOR user IN lt_users   WHERE ( status = 'ACTIVE' )   ( user-name ) ). LOOP AT lt_names INTO DATA(name).   WRITE: / name. ENDLOOP. Output: Alice Charlie

It returns a filtered internal table based on a condition—no need for loops or APPEND. *&---------------------------------------------------------------------* *& Report  ZREP_LCLCLASS *& *&---------------------------------------------------------------------* *& *& *&---------------------------------------------------------------------* REPORT zrep_lclclass. 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' ). LOOP AT lt_active_users INTO DATA(user).   WRITE: / user-name, user-status. ENDLOOP.   Output :  Alice ACTIVE Charlie ACTIVE

REDUCE is used to aggregate values like totals, counts, etc., in a clean, functional style. *&---------------------------------------------------------------------* *& Report  ZREP_LCLCLASS *& *&---------------------------------------------------------------------* *& *& *&---------------------------------------------------------------------* REPORT zrep_lclclass. 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: / 'Total Amount:', lv_total. Output: Total Amount: 500

A macro is a text replacement technique defined using DEFINE … END-OF-DEFINITION. It’s similar to a preprocessor directive and is expanded at runtime. When to use: · For short code blocks with similar patterns (e.g., logging or repetitive output). · Used mainly in ...

Recent Posts on sapewmhelp.com

SAP EWM Help Latest Articles

Create TU in SAP Extended Warehouse Management – EWM

TRY.          lo_tu_cntrl->create_new_bo_tu( EXPORTING is_bo_tu_new = ls_new_tu_head                                         IMPORTING eo_bo_tu     = eo_bo_tu ). IF eo_bo_tu IS BOUND.             es_tu_act_num = eo_bo_tu->get_num( ).             APPEND es_tu_act_num TO lt_inkeys.          ENDIF.             lo_tu_cntrl->save( ). *--Commit work             COMMIT WORK AND WAIT.             tu_num = es_tu_act_num-tu_num.             "Log something in case of success           CATCH /scwm/cx_sr_error INTO lo_tu_exception.             ROLLBACK WORK. *--Log something in case of error

How can you extract specific fields from an internal table using FOR … WHERE inside a VALUE expression?

This creates a new string table containing only the names of users whose status = ‘ACTIVE’—short, clean, and readable. — REDUCE Example —Total Amount: 500 Output: — FILTER Example —Alice ACTIVECharlie ACTIVE — FOR Expression Example —AliceCharlie

Explore Our Blog