Created by Jerry Wang, last modified on Oct 01, 2016
The requirement is, you need to print out all relationship data in the system with relationship type STRSET:
You can use the following source code:
METHOD get_strset_info.
DATA: lt_strset TYPE STANDARD TABLE OF comm_il_strset,
lt_prod TYPE STANDARD TABLE OF comm_product.
SELECT * INTO TABLE lt_strset FROM comm_il_strset.
CHECK sy-subrc = 0.
SELECT * INTO TABLE lt_prod FROM comm_product FOR ALL ENTRIES IN lt_strset
WHERE product_guid = lt_strset-sourceguid OR product_guid = lt_strset-destinguid.
LOOP AT lt_strset ASSIGNING FIELD-SYMBOL(<strset>).
APPEND INITIAL LINE TO rt_result ASSIGNING FIELD-SYMBOL(<result>).
READ TABLE lt_prod ASSIGNING FIELD-SYMBOL(<parent>) WITH KEY
product_guid = <strset>-sourceguid.
IF sy-subrc = 0.
<result>-parent = <parent>-product_id.
ENDIF.
READ TABLE lt_prod ASSIGNING FIELD-SYMBOL(<child>) WITH KEY
product_guid = <strset>-destinguid.
IF sy-subrc = 0.
<result>-child = <child>-product_id.
ENDIF.
ENDLOOP.
ENDMETHOD.
An example of output:
要獲取更多Jerry的原創文章,請關注公衆號"汪子熙":