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.

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.

SAP EWM Help Latest Questions

  • 0
  • 0
DPM125

Join VS For all Entries

Joins

combine rows from two or more tables based on a related column, usually a key field. ABAP supports various join types (INNER JOIN, LEFT OUTER JOIN, etc.) mostly used inside Open SQL queries.

How to Use Joins:

SELECT a~vbeln, a~erdat, b~posnr, b~matnr
  FROM vbak AS a
  INNER JOIN vbap AS b ON a~vbeln = b~vbeln
  INTO TABLE @DATA(result).

  • Here, sales order header (vbak) is joined with sales order items (vbap) on the sales order number (vbeln).
  • Result is fetched in one go, improving performance by reducing database calls.

FOR ALL ENTRIES

is a clause in ABAP that allows you to select records from a table where a field matches any entry in an internal table, acting like an “IN” condition.

How to Use FOR ALL ENTRIES:

DATA: lt_vbak TYPE TABLE OF vbak,
      lt_vbap TYPE TABLE OF vbap.

” First select sales orders into internal table
SELECT vbeln erdat vkorg kunnr FROM vbak
  INTO TABLE lt_vbak
  WHERE vkorg = ‘1000’.

” Use FOR ALL ENTRIES to select matching items
IF lt_vbak IS NOT INITIAL.
  SELECT vbeln posnr matnr FROM vbap
    INTO TABLE lt_vbap
    FOR ALL ENTRIES IN lt_vbak
    WHERE vbeln = lt_vbak-vbeln.
ENDIF.

  • The first SELECT fetches sales orders for a sales org.
  • The second SELECT fetches all items related to these orders.
  • This reduces database hits compared to looping with multiple selects.

Related Questions

Leave an answer

Leave an answer