Campos repetidos en dos tablas...
posted under
MODULE POOL - FUNCIONES
by Antonio Lopez
Continuando con mis posts con programas simples pero útiles, ahora les
traigo un que recibe dos tablas y devuelve todos los campos que
comparten ambas tablas (Comparando los dominios y no los nombres claro
está...)
traigo un que recibe dos tablas y devuelve todos los campos que
comparten ambas tablas (Comparando los dominios y no los nombres claro
está...)
REPORT ydummy_atg NO STANDARD PAGE HEADING.
TYPES: BEGIN OF ty_repeated,
fieldname TYPE dd03p-fieldname,
ddtext TYPE dd03p-ddtext,
END OF ty_repeated.
DATA: dd03p_table1 TYPE STANDARD TABLE OF dd03p,
dd03p_table2 TYPE STANDARD TABLE OF dd03p,
t_repeated TYPE STANDARD TABLE OF ty_repeated
WITH HEADER LINE.
DATA: long_1 TYPE i,
long_2 TYPE i,
w_title TYPE string.
FIELD-SYMBOLS: <fs_dd03p> LIKE LINE OF dd03p_table1,
<fs_dd03p_aux> LIKE LINE OF dd03p_table1,
<fs_repeated> LIKE LINE OF t_repeated.
SELECTION-SCREEN BEGIN OF BLOCK test.
PARAMETERS:
p_tab_1 TYPE dd17s-sqltab,
p_tab_2 TYPE dd17s-sqltab.
SELECTION-SCREEN END OF BLOCK test.
START-OF-SELECTION.
CONCATENATE p_tab_1 p_tab_2 INTO
w_title SEPARATED BY '-'.
sy-title = w_title.
CALL FUNCTION 'DDIF_TABL_GET'
EXPORTING
name = p_tab_1
state = 'A'
langu = sy-langu
TABLES
dd03p_tab = dd03p_table1
EXCEPTIONS
illegal_input = 1
OTHERS = 2.
DELETE dd03p_table1 WHERE rollname EQ space.
CALL FUNCTION 'DDIF_TABL_GET'
EXPORTING
name = p_tab_2
state = 'A'
langu = sy-langu
TABLES
dd03p_tab = dd03p_table2
EXCEPTIONS
illegal_input = 1
OTHERS = 2.
DELETE dd03p_table2 WHERE rollname EQ space.
DESCRIBE TABLE dd03p_table1 LINES long_1.
DESCRIBE TABLE dd03p_table2 LINES long_2.
IF long_1 GT long_2.
LOOP AT dd03p_table1 ASSIGNING <fs_dd03p>.
READ TABLE dd03p_table2 ASSIGNING <fs_dd03p_aux>
WITH KEY rollname = <fs_dd03p>-rollname.
IF sy-subrc EQ 0.
MOVE <fs_dd03p_aux>-fieldname TO t_repeated-fieldname.
MOVE <fs_dd03p_aux>-ddtext TO t_repeated-ddtext.
APPEND t_repeated.
ENDIF.
ENDLOOP.
ELSE.
LOOP AT dd03p_table2 ASSIGNING <fs_dd03p>.
READ TABLE dd03p_table1 ASSIGNING <fs_dd03p_aux>
WITH KEY rollname = <fs_dd03p>-rollname.
IF sy-subrc EQ 0.
MOVE <fs_dd03p_aux>-fieldname TO t_repeated-fieldname.
MOVE <fs_dd03p_aux>-ddtext TO t_repeated-ddtext.
APPEND t_repeated.
ENDIF.
ENDLOOP.
ENDIF.
LOOP AT t_repeated ASSIGNING <fs_repeated>.
WRITE:/ <fs_repeated>-fieldname,<fs_repeated>-ddtext.
ENDLOOP.
Comment Form under post in blogger/blogspot