Skip to Content
-1
Jun 08 at 09:55 PM

LOOP AT a table with with another table to get all matched ID's listed

243 Views

Hi Gurus,

I have an issue with my code. I am trying to LOOP AT the contents of one table up against the contents of another table and retrieve all the matching results into a variable that I can further evaluate, this is the code:

METHOD get_owner_property_validation2.
TYPES: BEGIN OF lty_team,
team_mbr(20) TYPE c,
END OF lty_team,

BEGIN OF ty_string,
str(25) TYPE c,
END OF ty_string.

DATA: lt_teams TYPE STANDARD TABLE OF uj_team_id,
lt_teams_mbr TYPE STANDARD TABLE OF lty_team,
ls_teams_mbr TYPE lty_team,
lt_leading_teams TYPE STANDARD TABLE OF uj_team_id,
ls_leading_teams TYPE uj_team_id,
lv_uj_user_id TYPE uj_user_id,
lo_user_dao TYPE REF TO cl_uje_user_dao,
lo_dim_reader TYPE REF TO cl_uja_dim,
dyn_table TYPE REF TO data,
lt_dim_data TYPE REF TO data,
ls_mbr TYPE uj_attr_name,
lt_attr_list TYPE uja_t_attr_name,
lv_member TYPE ujw_owner_mgr,
it_string TYPE TABLE OF ty_string,
wa_string TYPE ty_string.

FIELD-SYMBOLS: <fs_t_txt_data> TYPE STANDARD TABLE,
<fs_s_txt_data> TYPE any,
<lv_val> TYPE any.

TRY.
CREATE OBJECT lo_dim_reader
EXPORTING
i_appset_id = i_appset_id
i_dimension = i_dimension.
CATCH cx_uja_admin_error .
ENDTRY.

ls_mbr = i_member.
APPEND ls_mbr TO lt_attr_list.

TRY.
CALL METHOD lo_dim_reader->if_uja_dim_data~read_mbr_data
EXPORTING
it_attr_list = lt_attr_list
IMPORTING
er_data = lt_dim_data.
CATCH cx_uja_admin_error.
ENDTRY.

TRY.
CALL METHOD lo_dim_reader->if_uja_dim_data~read_mbr_data
EXPORTING
it_attr_list = lt_attr_list
IMPORTING
er_data = lt_dim_data.
CATCH cx_uja_admin_error.
ENDTRY.

ASSIGN lt_dim_data->* TO <fs_t_txt_data>.

LOOP AT <fs_t_txt_data> ASSIGNING <fs_s_txt_data>.
ASSIGN COMPONENT 'ID' OF STRUCTURE <fs_s_txt_data> TO <lv_val>.
IF <lv_val> IS ASSIGNED.
IF <lv_val> = i_id.
UNASSIGN <lv_val>.
ASSIGN COMPONENT i_member OF STRUCTURE <fs_s_txt_data> TO <lv_val>.
lv_member = <lv_val>.

REPLACE ALL OCCURRENCES OF '[' IN lv_member WITH ''.
REPLACE ALL OCCURRENCES OF ']' IN lv_member WITH ''.

REFRESH it_string.
SPLIT lv_member AT ',' INTO TABLE it_string.

lv_uj_user_id = sy-uname.

CREATE OBJECT lo_user_dao
EXPORTING
i_appset_id = i_appset_id.

TRY.
CALL METHOD lo_user_dao->get_user_team_list
EXPORTING
i_user_id = lv_uj_user_id
IMPORTING
et_teams = lt_teams
et_leading_teams = lt_leading_teams.
CATCH cx_uje_exception .
ENDTRY.

IF lt_teams[] IS NOT INITIAL.
lt_teams_mbr[] = lt_teams[].
LOOP AT it_string INTO wa_string .
READ TABLE lt_teams_mbr INTO ls_teams_mbr WITH KEY team_mbr = wa_string-str.
IF sy-subrc = 0.
e_validation = abap_true.
E_VALIDATION_TEAM = wa_string-str.
EXIT.
ENDIF.
ENDLOOP.
ENDIF.
ENDIF.
ENDIF.
ENDLOOP.
ENDMETHOD.

I need to loop through it_string and find all the records that match the records contained within lt_teams_mbr and then store those results in a separate structure where I can read the each one of the records apply an extra set of conditions to get a final result.

Any help will be greatly appreciated. Thanks in advance.