FIELD-SYMBOLS: <lfs_vkorg> TYPE vkorg.
CONSTANTS: lc_curr_vkorg TYPE objectname VALUE '(SAPMV13H)KOMGH-VKORG'.
... Do something ...
ASSIGN (lc_curr_vkorg) TO <lfs_vkorg>.
IF <lfs_vkorg> IS ASSIGNED.
IF <lfs_vkorg> IS NOT INITIAL.
... Do something ...
ENDIF.
ENDIF.
PARAMETERS: p_tab TYPE tabname.
DATA: lo_structure TYPE REF TO cl_abap_structdescr,
lr_data TYPE REF TO data.
lo_structure ?= cl_abap_structdescr=>describe_by_name( p_name = p_tab ).
CREATE DATA lr_data TYPE HANDLE lo_structure.
ASSIGN lr_data->* TO FIELD-SYMBOL(<lfs_structure>).
IF <lfs_structure> IS ASSIGNED.
" Do something
ENDIF.
PARAMETERS: p_cnt TYPE i.
TYPES: BEGIN OF ty_material_price,
matnr TYPE matnr,
waers TYPE waers,
END OF ty_material_price.
DATA: go_struc TYPE REF TO cl_abap_structdescr,
go_new_struc TYPE REF TO cl_abap_structdescr,
gr_structure TYPE REF TO data,
go_tabdata TYPE REF TO data,
go_descr TYPE REF TO cl_abap_datadescr,
gv_price TYPE STPRS,
gs_mat_price TYPE ty_material_price.
go_struc ?= cl_abap_structdescr=>describe_by_data( gs_mat_price ).
DATA(components) = go_struc->get_components( ).
DO p_cnt TIMES.
go_descr ?= cl_abap_typedescr=>describe_by_data( gv_price ).
APPEND INITIAL LINE TO components
ASSIGNING FIELD-SYMBOL(<component>).
<component> = VALUE #( name = |STPRS{ sy-index }| type = go_descr ).
ENDDO.
TRY.
DATA(new_struc) = cl_abap_structdescr=>create( p_components = components ). " Structure Type Object
CREATE DATA gr_structure TYPE HANDLE new_struc.
ASSIGN gr_structure->* TO FIELD-SYMBOL(<new_structure>).
IF <new_structure> IS ASSIGNED.
" Do something
ENDIF.
CATCH cx_sy_struct_creation. " Exception when creating a structure description
ENDTRY.
PARAMETERS: p_tab TYPE tabname.
DATA: lo_structure TYPE REF TO cl_abap_structdescr,
lo_table TYPE REF TO cl_abap_tabledescr,
lr_data TYPE REF TO data,
lr_table_data TYPE REF TO data.
FIELD-SYMBOLS: <lfs_table> TYPE STANDARD TABLE.
lo_structure ?= cl_abap_structdescr=>describe_by_name( p_name = p_tab ).
CREATE DATA lr_data TYPE HANDLE lo_structure.
lo_table ?= cl_abap_tabledescr=>create(
p_line_type = lo_structure " Line Type
* p_table_kind = tablekind_std " Table Category (STANDARD, SORTED, HASHED)
* p_unique = abap_false " Uniqueness of the Key
* p_key = " Key table
* p_key_kind = keydefkind_default " Key category
).
CREATE DATA lr_table_data TYPE HANDLE lo_table.
ASSIGN lr_data->* TO FIELD-SYMBOL(<lfs_structure>).
ASSIGN lr_table_data->* TO FIELD-SYMBOL(<lfs_table_data>).
IF <lfs_table_data> IS ASSIGNED.
" Do something
ENDIF.
PARAMETERS: p_cnt TYPE i.
TYPES: BEGIN OF ty_material_price,
matnr TYPE matnr,
waers TYPE waers,
END OF ty_material_price.
DATA: go_struc TYPE REF TO cl_abap_structdescr,
go_new_struc TYPE REF TO cl_abap_structdescr,
gr_structure TYPE REF TO data,
gr_table TYPE REF TO data,
go_descr TYPE REF TO cl_abap_datadescr,
gv_price TYPE STPRS,
gs_mat_price TYPE ty_material_price.
FIELD-SYMBOLS: <new_table> TYPE STANDARD TABLE.
go_struc ?= cl_abap_structdescr=>describe_by_data( gs_mat_price ).
DATA(components) = go_struc->get_components( ).
DO p_cnt TIMES.
go_descr ?= cl_abap_typedescr=>describe_by_data( gv_price ).
APPEND INITIAL LINE TO components
ASSIGNING FIELD-SYMBOL(<component>).
<component> = VALUE #( name = |STPRS{ sy-index }| type = go_descr ).
ENDDO.
TRY.
DATA(new_struc) = cl_abap_structdescr=>create( p_components = components ). " Structure Type Object
CREATE DATA gr_structure TYPE HANDLE new_struc.
ASSIGN gr_structure->* TO FIELD-SYMBOL(<new_structure>).
IF <new_structure> IS ASSIGNED.
" Do something
ENDIF.
DATA(new_table) = cl_abap_tabledescr=>create( p_line_type = new_struc ).
CREATE DATA gr_table TYPE HANDLE new_table.
ASSIGN gr_table->* TO <new_table>.
IF <new_table> IS ASSIGNED.
" Do something
ENDIF.
CATCH cx_sy_table_creation. " Exception when Creating a Table Type
CATCH cx_sy_struct_creation. " Exception when creating a structure description
ENDTRY.
CREATE DATA gr_structure TYPE HANDLE new_struc.
ASSIGN gr_structure->* TO FIELD-SYMBOL(<new_structure>).
IF <new_structure> IS ASSIGNED.
gv_field = |STPRS{ p_cnt }|.
"Option 1
ASSIGN <new_structure>-(gv_field) TO FIELD-SYMBOL(<stprs2>).
IF <stprs2> IS ASSIGNED.
<stprs2> = 10.
ENDIF.
"Option 2
ASSIGN COMPONENT gv_field OF STRUCTURE <new_structure> TO FIELD-SYMBOL(<stprs>).
IF <stprs> IS ASSIGNED.
<stprs> = 20.
" Do something
BREAK-POINT.
ENDIF.
UNASSIGN <stprs>.
" Do something
ENDIF.
PARAMETERS: p_tab TYPE tabname,
p_matnr TYPE matnr.
TYPES: BEGIN OF ty_list,
name TYPE tabname,
r_str TYPE REF TO data,
r_tbl TYPE REF TO data,
END OF ty_list.
DATA: lt_list TYPE STANDARD TABLE OF ty_list.
DATA: lo_structure TYPE REF TO cl_abap_structdescr,
lo_table TYPE REF TO cl_abap_tabledescr,
lt_fields TYPE STANDARD TABLE OF fieldname,
lt_CONDTAB TYPE STANDARD TABLE OF hrcond,
lt_where TYPE STANDARD TABLE OF string,
lr_data TYPE REF TO data,
lr_table_data TYPE REF TO data.
FIELD-SYMBOLS: <lfs_table> TYPE STANDARD TABLE.
lo_structure ?= cl_abap_structdescr=>describe_by_name( p_name = p_tab ).
CREATE DATA lr_data TYPE HANDLE lo_structure.
lo_table ?= cl_abap_tabledescr=>create(
p_line_type = lo_structure " Line Type
* p_table_kind = tablekind_std " Table Category (STANDARD, SORTED, HASHED)
* p_unique = abap_false " Uniqueness of the Key
* p_key = " Key table
* p_key_kind = keydefkind_default " Key category
).
CREATE DATA lr_table_data TYPE HANDLE lo_table.
ASSIGN lr_data->* TO FIELD-SYMBOL(<lfs_structure>).
ASSIGN lr_table_data->* TO FIELD-SYMBOL(<lfs_table_data>).
lt_condtab = VALUE #( ( field = 'MATNR' opera = 'EQ' low = p_matnr ) ).
IF <lfs_table_data> IS ASSIGNED.
IF p_tab EQ 'MARA'.
lt_fields = VALUE #( ( 'MATNR' ) ).
CALL FUNCTION 'RH_DYNAMIC_WHERE_BUILD'
EXPORTING
dbtable = p_Tab
TABLES
condtab = lt_condtab
where_clause = lt_where
EXCEPTIONS
empty_condtab = 1
no_db_field = 2
unknown_db = 3
wrong_condition = 4
OTHERS = 5.
SELECT (lt_fields)
FROM (p_tab)
WHERE (lt_where)
INTO CORRESPONDING FIELDS OF TABLE @<lfs_table_data>.
" Do something
ENDIF.
ENDIF.
TYPES: BEGIN OF ty_list,
name TYPE tabname,
r_str TYPE REF TO data,
r_tbl TYPE REF TO data,
END OF ty_list.
DATA: lt_list TYPE STANDARD TABLE OF ty_list.
PARAMETERS: p_tab TYPE tabname.
CLASS lcl_main DEFINITION.
PUBLIC SECTION.
CLASS-METHODS: set_data CHANGING o_tbl TYPE REF TO data.
ENDCLASS.
TYPES: BEGIN OF ty_list,
name TYPE tabname,
r_str TYPE REF TO data,
r_tbl TYPE REF TO data,
END OF ty_list.
DATA: lt_list TYPE STANDARD TABLE OF ty_list.
DATA: lo_structure TYPE REF TO cl_abap_structdescr,
lo_table TYPE REF TO cl_abap_tabledescr,
lr_data TYPE REF TO data,
lr_table_data TYPE REF TO data.
FIELD-SYMBOLS: <lfs_table> TYPE STANDARD TABLE.
lo_structure ?= cl_abap_structdescr=>describe_by_name( p_name = p_tab ).
CREATE DATA lr_data TYPE HANDLE lo_structure.
lo_table ?= cl_abap_tabledescr=>create(
p_line_type = lo_structure " Line Type
* p_table_kind = tablekind_std " Table Category (STANDARD, SORTED, HASHED)
* p_unique = abap_false " Uniqueness of the Key
* p_key = " Key table
* p_key_kind = keydefkind_default " Key category
).
CREATE DATA lr_table_data TYPE HANDLE lo_table.
ASSIGN lr_data->* TO FIELD-SYMBOL(<lfs_structure>).
ASSIGN lr_table_data->* TO FIELD-SYMBOL(<lfs_table_data>).
IF <lfs_table_data> IS ASSIGNED.
lcl_main=>set_data(
CHANGING
o_tbl = lr_table_data
).
ENDIF.
CLASS lcl_main IMPLEMENTATION.
METHOD set_data.
FIELD-SYMBOLS: <lfs_data> TYPE STANDARD TABLE.
ASSIGN o_tbl->* TO <lfs_data>.
IF <lfs_data> IS ASSIGNED.
" Do something
ENDIF.
ENDMETHOD.
ENDCLASS.
DATA: lo_adapter TYPE REF TO zif_adapter,
ls_data TYPE ty_data.
IF ms_adapter-s_adapter-call_class IS NOT INITIAL.
TRY.
CREATE OBJECT lo_adapter TYPE (ms_adapter-s_adapter-call_class).
IF lo_adapter IS BOUND.
lo_adapter->send( CHANGING is_data = ls_data ).
ENDIF.
CATCH cx_sy_dyn_call_illegal_method.
CATCH cx_sy_create_object_error.
ENDTRY.
ENDIF.
" Class #1. Send via Email
CLASS zcl_email definition
public
final
create public .
PUBLIC SECTION.
INTERFACES: zif_adapter.
PROTECTED SECTION.
PRIVATE SECTION.
ENDCLASS.
CLASS lcl_main IMPLEMENTATION.
METHOD zif_adapter~send.
" Send via email
ENDMETHOD.
ENDCLASS.
" Class #2. Send via FTP
CLASS zcl_ftp definition
public
final
create public .
PUBLIC SECTION.
INTERFACES: zif_adapter.
PROTECTED SECTION.
PRIVATE SECTION.
ENDCLASS.
CLASS lcl_main IMPLEMENTATION.
METHOD zif_adapter~send.
" Send to ftp server
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 |
---|---|
4 | |
4 | |
3 | |
2 | |
2 | |
2 | |
2 | |
1 | |
1 | |
1 |