Skip to Content
0
Apr 06, 2020 at 03:52 PM

Display info from 4 tables

116 Views

Hi All, I'm still trying to learn ABAP by myself - I'm trying to create a program in which I could search for a value in a table it gives me the values after checks in other three tables as I do in SE16N.

Currently, I do the following steps in SE16N.

1º SE16N: Table AGR_1251 and fulfill as following: AGR_1251-OBJECT = S_TCODE; AGR_1251-FIELD = TCD; AGR_1251-LOW = transactions (more than 1) which I want to find users that have access to all of them. Here I want to get the "AGR_1251-AGR_NAME" results.

2º SE16N: Table AGR_1016 with the results of previously searched and fulfill as following: AGR_1016-AGR_NAME = (results of the first search). Here I want to get the information AGR_1016-PROFILE.

3º SE16N: Table UST04 with the results found in step 2 and I fulfill as following: UST04-PROFILE = (results of the second search). Here I want to get the information UST04-BNAME.

4º SE16N: Table USR02 with the results of step 3 and I fulfill as following: USR02-BNAME = (results of the third search) and USR02-CLASS = TEST.

The objective is to find generic tests users who have access to multiples transactions as in SUIM is possible to check one by one and sometimes I need these users which access to more than 5 or 6 transactions would take a lot of time.

I've started but with my knowledge, the far I can get I'll share below, I know it will demand a lot of time, but if someone could help would help me a lot.

REPORT ZUSERTEST.

TABLES: USR02, UST04, AGR_1016, AGR_1251.

DATA: T_USR02 TYPE TABLE OF USR02.
DATA: T_UST04 TYPE TABLE OF UST04.
DATA: T_AGR_1016 TYPE TABLE OF AGR_1016.
DATA: T_AGR_1251 TYPE TABLE OF AGR_1251.

DATA: W_AREA1251 TYPE AGR_1251.
DATA: W_AREA1016 TYPE AGR_1016.
DATA: W_AREAUST04 TYPE UST04.
DATA: W_AREAUSR02 TYPE USR02.

SELECT-OPTIONS: S_TCODE FOR AGR_1251-LOW.

START-OF-SELECTION.
SELECT *
INTO TABLE T_AGR_1251 FROM AGR_1251 WHERE LOW = S_TCODE.
IF sy-subrc EQ 0.
SORT T_AGR_1251 BY AGR_NAME.
DELETE ADJACENT DUPLICATES FROM T_AGR_1251 COMPARING AGR_NAME.
ENDIF.

SELECT *
INTO TABLE T_AGR_1016 FROM AGR_1016 FOR ALL ENTRIES IN T_AGR_1251 WHERE AGR_NAME EQ T_AGR_1251-AGR_NAME.
IF sy-subrc EQ 0.
SORT T_AGR_1016 BY PROFILE.
DELETE ADJACENT DUPLICATES FROM T_AGR_1016 COMPARING PROFILE.
ENDIF.

SELECT *
INTO TABLE T_UST04 FROM UST04 FOR ALL ENTRIES IN T_AGR_1016 WHERE PROFILE EQ T_AGR_1016-PROFILE.
IF sy-subrc EQ 0.
SORT T_UST04 BY BNAME.
delete ADJACENT DUPLICATES FROM T_UST04 COMPARING BNAME.
ENDIF.

SELECT *
INTO TABLE T_USR02 FROM USR02 FOR ALL ENTRIES IN T_UST04 WHERE BNAME EQ T_UST04-BNAME AND USR02-CLASS EQ TEST.
IF sy-subrc EQ 0.
SORT T_USR02 BY BNAME.
ENDIF.