Code: Alles auswählen.
types: begin of type1
, felda type c
, feldb type c
, feldc type c
, end of type 1
.
types: begin of type2
, felda type c
, feldb type c
, feldc type c
, feldd type c
, end of type 2
.
data: lt_table1 type table of type1
, lt_table2 type table of type2
.
* Annahme: Beide Tabellen sind gefüllt
lt_table2 = value type2( base lt_table2 ( value #( for line in lt_table1 ( value #( base corresponding #( line ) feldd = 'X' ) ) ) ) ).
Code: Alles auswählen.
LT_TABLE2 = VALUE TT_TYPE2( BASE LT_TABLE2 ( LINES OF VALUE #( FOR LINE IN LT_TABLE1 ( VALUE #( BASE CORRESPONDING #( LINE ) FELDD = 'X' ) ) ) ) ).
Code: Alles auswählen.
REPORT ZTEST4.
TYPES: BEGIN OF TYPE1
, FELDA TYPE C
, FELDB TYPE C
, FELDC TYPE C
, END OF TYPE1
.
TYPES: BEGIN OF TYPE2
, FELDA TYPE C
, FELDB TYPE C
, FELDC TYPE C
, FELDD TYPE C
, END OF TYPE2
,
TT_TYPE2 TYPE STANDARD TABLE OF TYPE2 WITH EMPTY KEY.
DATA: LT_TABLE1 TYPE TABLE OF TYPE1
, LT_TABLE2 TYPE TABLE OF TYPE2
.
LT_TABLE1 = value #( ( felda = 'X'
feldb = 'Y'
feldc = 'Z' ) ).
LT_TABLE2 = value #( ( felda = 'A'
feldb = 'B'
feldc = 'C'
feldD = 'D' ) ).
LT_TABLE2 = VALUE TT_TYPE2( BASE LT_TABLE2 ( LINES OF VALUE #( FOR LINE IN LT_TABLE1 ( VALUE #( BASE CORRESPONDING #( LINE ) FELDD = 'X' ) ) ) ) ).
break-point.
Code: Alles auswählen.
lt_table2 = value #( base lt_table2 for line in lt_table1 ( value #( base corresponding #( line ) feldd = 'X' ) ) ).
Code: Alles auswählen.
TYPES:
BEGIN OF type1,
felda TYPE c LENGTH 1,
feldb TYPE c LENGTH 1,
feldc TYPE c LENGTH 1,
END OF type1.
TYPES:
BEGIN OF type2,
felda TYPE c LENGTH 1,
feldb TYPE c LENGTH 1,
feldc TYPE c LENGTH 1,
feldd TYPE c LENGTH 1,
END OF type2.
DATA lt_table1 TYPE TABLE OF type1.
DATA lt_table2 TYPE TABLE OF type2.
lt_table1 = VALUE #( felda = 'a'
feldb = 'b'
feldc = 'c'
( )
( )
( ) ).
lt_table2 = VALUE #( felda = 'A'
feldb = 'B'
feldc = 'C'
feldd = 'D'
( )
( )
( ) ).
lt_table2 = VALUE #( BASE lt_table2 FOR <line> IN lt_table1 ( VALUE #( BASE CORRESPONDING #( <line> ) feldd = 'X' ) ) ).
cl_demo_output=>display( lt_table2 ).