Differences in “For all entries” and “Inner Join”, how to use them for all entries in Sap, and how simple inner join is, I will explain to you with an example.
Example: To understand better I use a flight model, to fetch carrid, connid and fldate from sbook, and on the basis of sbook table I filer out and store them in sflight table.
EXAMPLE – FOR ALL ENTRIES
PROCESS AFTER INPUT. Data: gt_sbook type TABLE OF sbook, gt_sflight TYPE TABLE OF sflight. SELECT * FROM sbook INTO TABLE gt_sbook. IF sy-subrc = 0. SELECT * FROM sflight INTO TABLE gt_sflight FOR ALL ENTRIES IN gt_sbook WHERE carrid = gt_sbook-carrid. IF sy-subrc = 0. MESSAGE i000(yt029_msg). ENDIF. ENDIF.
EXAMPLE – INNER JOIN
To use inner join, you need to make a custom structure of required fields and make an internal table on the basis of the structure.
PROCESS AFTER INPUT. TYPES: BEGIN OF st_struct, carrid TYPE sbook-carrid, connid TYPE sbook-connid, fldate TYPE sbook-fldate, customid TYPE sbook-customid, seatsocc TYPE sflight-seatsocc, seatsocc_f TYPE sflight-seatsocc_f, seatsocc_b TYPE sflight-seatsocc_b, END OF st_struct. DATA: it_sbook TYPE TABLE OF st_struct, it_sflight TYPE TABLE OF sflight. SELECT l~carrid l~connid l~fldate l~customid s~seatsocc s~seatsocc_f s~seatsocc_b FROM sbook AS l INNER JOIN sflight AS s on l~carrid = s~carrid INTO TABLE it_sbook. IF it_sbook is INITIAL. MESSAGE 'data not found' TYPE 'S'. ENDIF.