SELECT * EXCEPT col1, col2, ...
DATA(dbtab) = 'scarr'.
DATA(except) = 'carrid, url'.
DATA(components) = CAST cl_abap_structdescr(
cl_abap_typedescr=>describe_by_name( to_upper( dbtab ) )
)->get_components( ).
SPLIT except AT `,` INTO TABLE DATA(columns).
LOOP AT columns ASSIGNING FIELD-SYMBOL(<column>).
DELETE components WHERE name = to_upper( condense( <column> ) ).
ENDLOOP.
DATA(token) =
REDUCE string( INIT s = ``
FOR <wa> IN components
NEXT s &&= COND #( WHEN s = `` THEN <wa>-name
ELSE `, ` && <wa>-name ) ).
DATA(target_type) =
cl_abap_tabledescr=>get(
p_line_type = cl_abap_structdescr=>get(
p_components = components )
p_table_kind = cl_abap_tabledescr=>tablekind_std ).
DATA target TYPE REF TO data.
CREATE DATA target TYPE HANDLE target_type.
SELECT (token)
FROM (dbtab)
INTO TABLE @target->*.
cl_demo_output=>display( target->* ).
DATA(sel_list) = NEW select_list( dbtab = 'scarr'
except = 'carrid, url' ).
DATA(token) = sel_list->get_token( ).
DATA(target) = sel_list->get_target( ).
SELECT (token)
FROM scarr
INTO TABLE @target->*.
cl_demo_output=>display( target->* ).
CLASS select_list DEFINITION.
PUBLIC SECTION.
METHODS:
constructor IMPORTING dbtab TYPE string
except TYPE string,
get_token RETURNING VALUE(token) TYPE string,
get_target RETURNING VALUE(target) TYPE REF TO data.
PRIVATE SECTION.
DATA
components TYPE cl_abap_structdescr=>component_table.
ENDCLASS.
CLASS select_list IMPLEMENTATION.
METHOD constructor.
components = CAST cl_abap_structdescr(
cl_abap_typedescr=>describe_by_name( to_upper( dbtab ) )
)->get_components( ).
SPLIT except AT `,` INTO TABLE DATA(columns).
LOOP AT columns ASSIGNING FIELD-SYMBOL(<column>).
DELETE components WHERE name = to_upper( condense( <column> ) ).
ENDLOOP.
ENDMETHOD.
METHOD get_token.
token =
REDUCE string( INIT s = ``
FOR <wa> IN components
NEXT s &&= COND #( WHEN s = `` THEN <wa>-name
ELSE `, ` && <wa>-name ) ).
ENDMETHOD.
METHOD get_target.
DATA(itab_type) =
cl_abap_tabledescr=>get(
p_line_type = cl_abap_structdescr=>get(
p_components = components )
p_table_kind = cl_abap_tabledescr=>tablekind_std ).
CREATE DATA target TYPE HANDLE itab_type.
ENDMETHOD.
ENDCLASS.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
5 | |
4 | |
4 | |
4 | |
2 | |
2 | |
2 | |
2 | |
2 | |
2 |