Уже второй раз на моей практике умудряются эту таблицу ушатать.
Делаем программу, планируем ежедневно.
*&---------------------------------------------------------------------*
*& Report ZPSB_BW_TVARVC_BACKUP
*&
*&---------------------------------------------------------------------*
*& Handmate TVARVC backup
*&
*&---------------------------------------------------------------------*
REPORT zpsb_bw_tvarvc_backup.
*&---------------------------------------------------------------------*
DATA:
l_sydate TYPE d,
lt_tvarvc TYPE TABLE OF tvarvc,
lo_struct_descr TYPE REF TO cl_abap_structdescr,
lt_struct_fields TYPE cl_abap_structdescr=>component_table,
l_string TYPE string,
lt_ztvarvc_backup TYPE TABLE OF ztvarvc_backup,
ls_ztvarvc_backup LIKE LINE OF lt_ztvarvc_backup.
FIELD-SYMBOLS:
<fs_struct_fields> LIKE LINE OF lt_struct_fields,
<comp> TYPE ANY,
<fs_tvarvc> LIKE LINE OF lt_tvarvc.
CONSTANTS:
l_nl(1) TYPE c VALUE cl_abap_char_utilities=>newline,
l_tab(1) TYPE c VALUE cl_abap_char_utilities=>horizontal_tab.
*&---------------------------------------------------------------------*
BREAK-POINT ID break.
*& История за последние полтора месяца
l_sydate = sy-datum - 45.
DELETE FROM ztvarvc_backup WHERE sy_date < l_sydate.
SELECT
*
FROM tvarvc
INTO TABLE lt_tvarvc.
*& Header
TRY.
lo_struct_descr ?= cl_abap_typedescr=>describe_by_name( 'TVARVC' ).
lt_struct_fields = lo_struct_descr->get_components( ).
LOOP AT lt_struct_fields ASSIGNING <fs_struct_fields>.
CONCATENATE l_string <fs_struct_fields>-name l_tab INTO l_string.
ENDLOOP.
CONCATENATE l_string l_nl INTO l_string.
CATCH cx_root.
ENDTRY.
*& Body
LOOP AT lt_tvarvc ASSIGNING <fs_tvarvc>.
IF lt_struct_fields IS NOT INITIAL.
LOOP AT lt_struct_fields ASSIGNING <fs_struct_fields>.
ASSIGN COMPONENT <fs_struct_fields>-name OF STRUCTURE <fs_tvarvc> TO <comp>.
CONCATENATE l_string <comp> l_tab INTO l_string.
ENDLOOP.
CONCATENATE l_string l_nl INTO l_string.
ENDIF.
ENDLOOP.
ls_ztvarvc_backup-sy_date = sy-datum.
ls_ztvarvc_backup-table_value = l_string.
MODIFY ztvarvc_backup FROM ls_ztvarvc_backup.
WRITE l_string.
*&---------------------------------------------------------------------*
*& Report ZPSB_BW_TVARVC_BACKUP
*&
*&---------------------------------------------------------------------*
*& Handmate TVARVC backup
*&
*&---------------------------------------------------------------------*
REPORT zpsb_bw_tvarvc_backup.
*&---------------------------------------------------------------------*
DATA:
l_sydate TYPE d,
lt_tvarvc TYPE TABLE OF tvarvc,
lo_struct_descr TYPE REF TO cl_abap_structdescr,
lt_struct_fields TYPE cl_abap_structdescr=>component_table,
l_string TYPE string,
lt_ztvarvc_backup TYPE TABLE OF ztvarvc_backup,
ls_ztvarvc_backup LIKE LINE OF lt_ztvarvc_backup.
FIELD-SYMBOLS:
<fs_struct_fields> LIKE LINE OF lt_struct_fields,
<comp> TYPE ANY,
<fs_tvarvc> LIKE LINE OF lt_tvarvc.
CONSTANTS:
l_nl(1) TYPE c VALUE cl_abap_char_utilities=>newline,
l_tab(1) TYPE c VALUE cl_abap_char_utilities=>horizontal_tab.
*&---------------------------------------------------------------------*
BREAK-POINT ID break.
*& История за последние полтора месяца
l_sydate = sy-datum - 45.
DELETE FROM ztvarvc_backup WHERE sy_date < l_sydate.
SELECT
*
FROM tvarvc
INTO TABLE lt_tvarvc.
*& Header
TRY.
lo_struct_descr ?= cl_abap_typedescr=>describe_by_name( 'TVARVC' ).
lt_struct_fields = lo_struct_descr->get_components( ).
LOOP AT lt_struct_fields ASSIGNING <fs_struct_fields>.
CONCATENATE l_string <fs_struct_fields>-name l_tab INTO l_string.
ENDLOOP.
CONCATENATE l_string l_nl INTO l_string.
CATCH cx_root.
ENDTRY.
*& Body
LOOP AT lt_tvarvc ASSIGNING <fs_tvarvc>.
IF lt_struct_fields IS NOT INITIAL.
LOOP AT lt_struct_fields ASSIGNING <fs_struct_fields>.
ASSIGN COMPONENT <fs_struct_fields>-name OF STRUCTURE <fs_tvarvc> TO <comp>.
CONCATENATE l_string <comp> l_tab INTO l_string.
ENDLOOP.
CONCATENATE l_string l_nl INTO l_string.
ENDIF.
ENDLOOP.
ls_ztvarvc_backup-sy_date = sy-datum.
ls_ztvarvc_backup-table_value = l_string.
MODIFY ztvarvc_backup FROM ls_ztvarvc_backup.
WRITE l_string.
*&---------------------------------------------------------------------*
Комментариев нет:
Отправить комментарий