you can use below code
TYPES: BEGIN OF ty_po_guid_sc_guid,
po_guid TYPE swo_typeid,
sc_guid TYPE swo_typeid,
END OF ty_po_guid_sc_guid.
TYPES: BEGIN OF ty_sc_guid_sc_num,
sc_guid TYPE guid,
sc_num TYPE crmt_object_id_db,
END OF ty_sc_guid_sc_num.
DATA: lt_po_guid_sc_guid TYPE STANDARD TABLE OF ty_po_guid_sc_guid,
ls_po_guid_sc_guid TYPE ty_po_guid_sc_guid,
lt_sc_guid_sc_num TYPE STANDARD TABLE OF ty_sc_guid_sc_num,
ls_sc_guid_sc_num TYPE ty_sc_guid_sc_num.
*Get the SC guid related to PO guid
SELECT a~objkey AS po_guid c~objkey AS sc_guid INTO TABLE lt_po_guid_sc_guid
FROM srrelroles AS a
JOIN bbp_pdbinrel AS b ON a~roleid EQ b~role_b
JOIN srrelroles AS c ON b~role_a EQ c~roleid
FOR ALL ENTRIES IN lt_po_guid_sc_guid
WHERE a~objkey EQ lt_po_guid_sc_guid-po_guid.
LOOP AT lt_po_guid_sc_guid INTO ls_po_guid_sc_guid.
MOVE ls_po_guid_sc_guid-sc_guid TO ls_sc_guid_sc_num-sc_guid.
APPEND ls_sc_guid_sc_num TO lt_sc_guid_sc_num.
ENDLOOP.
IF lt_sc_guid_sc_num[] IS NOT INITIAL.
* Get the shopping cart number
SELECT a~guid AS sc_guid b~object_id AS sc_num INTO TABLE lt_sc_guid_sc_num
FROM crmd_orderadm_i AS a
JOIN crmd_orderadm_h AS b ON a~header EQ b~guid
FOR ALL ENTRIES IN lt_sc_guid_sc_num
WHERE a~guid = lt_sc_guid_sc_num-sc_guid
AND b~object_type = 'BUS2121'.
ENDIF.
<removed>
Please do not ask for points. Message was edited by: Zoltan Keller