class ZSIH_LOG_PRO definition
public
final
create public .
*"* public components of class ZSIH_LOG_PRO
*"* do not include other source files here!!!
public section.
types:
BEGIN OF ty_tab.
INCLUDE TYPE zsih_log.
* TYPES:rowcolor(4) TYPE c.
* TYPES:cellcolor TYPE lvc_t_scol.
TYPES:excp(1) TYPE c.
TYPES:END OF ty_tab .
data:
ALV_TAB type table of TY_TAB .
methods CONSTRUCTOR
importing
value(TYPE) type C optional
value(TEST) type C optional
value(REM) type ADMI_TEXT optional .
methods ARCHIVE
importing
!IM_PROG type ZTRANGE
!IM_TOD type ZTRANGE
!IM_DATE type ZTRANGE
!IM_USR type ZTRANGE
!IM_TYP type ZTRANGE
!IM_DAY type BAPI_JBD_DTE_STITEL optional
returning
value(SUBR) like SY-SUBRC .
methods DEL_FILE .
methods RIC_ARCH .
class-methods INSERT_LOG
importing
!IM_TLOG type ZTLOG
!IM_PROG type PROGNAME
returning
value(RET) like SY-SUBRC .
methods DISPLAY_LOG
importing
!IM_PROG type ZTRANGE optional
!IM_TOD type ZTRANGE optional
!IM_DATE type ZTRANGE optional
!IM_USR type ZTRANGE optional
!IM_TYP type ZTRANGE optional
changing
!IM_CONTAINER type ref to CL_GUI_CUSTOM_CONTAINER .*"* protected components of class ZSIH_LOG_PRO
*"* do not include other source files here!!!
protected section.*"* private components of class ZSIH_LOG_PRO
*"* do not include other source files here!!!
private section.
data ARCH_OBJECT type OBJCT_TR01 .
data ARCH_TYP type C .
data ARCH_TEST type C .
data ARCH_REM type ADMI_TEXT .
data ARCHIVE_HANDLE type INT4 .
data ARCHIVE_NAME type ARKEY .
data TB_LOG type ZT_SIHLOG .
data ARCHIVE_FLAGS type ARC_BUFFER-FLAGS .
data ALV_LAYOUT type LVC_S_LAYO .
data ALV_FIELDCAT type LVC_T_FCAT .
data REF_ALV type ref to CL_GUI_ALV_GRID .
data REF_DTL type ref to CL_GUI_ALV_GRID .
data DET_LAY type LVC_S_LAYO .
data DET_FIELD type LVC_T_FCAT .
data REF_SPLIT type ref to CL_GUI_EASY_SPLITTER_CONTAINER .
data ALV_CON type ref to CL_GUI_CONTAINER .
data DET_CON type ref to CL_GUI_CONTAINER .
data SPLIT_CON type ref to CL_GUI_CUSTOM_CONTAINER .
data SPLIT_FLAG type C .
methods OPEN_OBJ .
methods SELECT_DATA
importing
!IM_PROG type ZTRANGE optional
!IM_TOD type ZTRANGE optional
!IM_DATE type ZTRANGE optional
!IM_USR type ZTRANGE optional
!IM_TYP type ZTRANGE optional
returning
value(SUBR) like SY-SUBRC .
methods ARCH_OBJ .
methods ARCH_STATUS .
methods PREPARE_LAYOUT
importing
value(DETAIL_FLAG) type C optional .
methods PREPARE_FIELDCAT
importing
value(DETAIL_FLAG) type C optional .
methods SHOW_ALV
importing
!CONTAINER type ref to CL_GUI_CONTAINER .
methods HANDLE_DOUBLE_CLICK
for event DOUBLE_CLICK of CL_GUI_ALV_GRID
importing
!E_ROW .
methods SHOW_DETAIL
importing
!IM_CON type ref to CL_GUI_CONTAINER
!E_ROW type LVC_S_ROW .*"* local class implementation for public class
*"* use this source file for the implementation part of
*"* local helper classes*"* use this source file for any type declarations (class
*"* definitions, interfaces or data types) you need for method
*"* implementation or private method's signature*"* use this source file for any macro definitions you need
*"* in the implementation part of the classmethod ARCHIVE.
* Local data definition
data: wa type zsih_log.
* Open Object
call METHOD me->open_obj.
* Getting data
subr = SELECT_DATA( im_prog = im_prog
im_tod = im_tod im_date = im_date im_usr = im_usr im_typ = im_typ ).
check subr = 0.
* Archive processing
call method me->ARCH_OBJ.
endmethod.method ARCH_OBJ.
* Local data definition
data: wa type zsih_log.
* Open archive
CALL FUNCTION 'ARCHIVE_OPEN_FOR_WRITE'
EXPORTING
call_delete_job_in_test_mode = space
* create_archive_file = v_wriprd
object = 'ZSIH_LOG'
IMPORTING
archive_handle = archive_handle.
loop at tb_log into wa.
* Create new archive
CALL FUNCTION 'ARCHIVE_NEW_OBJECT'
EXPORTING archive_handle = archive_handle.
* Put record to archive
CALL FUNCTION 'ARCHIVE_PUT_RECORD'
EXPORTING
archive_handle = archive_handle
record_flags = ARCHIVE_FLAGS
record_structure = 'ZSIH_LOG'
record = WA.
* Save archive object
CALL FUNCTION 'ARCHIVE_SAVE_OBJECT'
EXPORTING archive_handle = archive_handle.
endloop.
* Update status
CALL FUNCTION 'ARCHIVE_WRITE_STATISTICS'
EXPORTING
archive_handle = archive_handle.
* Close file
CALL FUNCTION 'ARCHIVE_CLOSE_FILE'
EXPORTING
archive_handle = archive_handle.
endmethod.method ARCH_STATUS.
* Write archive status
CALL FUNCTION 'ARCHIVE_WRITE_STATISTICS'
EXPORTING
archive_handle = archive_handle
EXCEPTIONS
internal_error = 1
OTHERS = 2
.
* Close archive file
CALL FUNCTION 'ARCHIVE_CLOSE_FILE'
EXPORTING
archive_handle = archive_handle.
endmethod.method CONSTRUCTOR.
me->arch_typ = type.
me->arch_test = test.
me->arch_object = 'ZSIH_LOG'.
me->arch_rem = rem.
endmethod.method DEL_FILE.
* Local data definition
DATA: str_name type RKZ_DBNA,
str_wa(10092) TYPE c,
str_flags type CHAR08,
cnt_commit TYPE i,
max_commit TYPE i,
cnt_log TYPE i.
data: wa type zsih_log.
* Archive open for deletion
CALL FUNCTION 'ARCHIVE_OPEN_FOR_DELETE'
EXPORTING object = arch_object
test_mode = arch_test
IMPORTING archive_handle = archive_handle
EXCEPTIONS no_files_available = 01.
IF sy-subrc <> 0.
MESSAGE e003(zsih_msg_bc).
ENDIF.
* Get archive information
CALL FUNCTION 'ARCHIVE_GET_INFORMATION'
EXPORTING archive_handle = archive_handle
IMPORTING archive_name = archive_name.
* Get customize data
CALL FUNCTION 'ARCHIVE_GET_CUSTOMIZING_DATA'
EXPORTING object = arch_object
IMPORTING commit_count_for_delete_prg = max_commit.
DO.
CALL FUNCTION 'ARCHIVE_GET_NEXT_OBJECT'
EXPORTING archive_handle = archive_handle
EXCEPTIONS end_of_file = 01.
IF sy-subrc <> 0.
EXIT.
ENDIF.
DO.
CALL FUNCTION 'ARCHIVE_GET_NEXT_RECORD'
EXPORTING archive_handle = archive_handle
IMPORTING record_structure = str_name
record_flags = str_flags
record = str_wa
EXCEPTIONS end_of_object = 01.
IF sy-subrc <> 0.
EXIT.
ENDIF.
add 1 to cnt_log.
add 1 to cnt_commit.
class CL_ABAP_CONTAINER_UTILITIES definition load.
call method cl_abap_container_utilities=>read_container_c
exporting IM_CONTAINER = str_wa
importing EX_VALUE = wa
exceptions ILLEGAL_PARAMETER_TYPE = 1
others = 2.
IF str_flags = archive_flags.
call method cl_abap_container_utilities=>read_container_c
exporting IM_CONTAINER = str_wa
importing EX_VALUE = wa
exceptions ILLEGAL_PARAMETER_TYPE = 1
others = 2.
IF arch_test IS INITIAL.
delete zsih_log from wa.
endif.
endif.
enddo.
* Check if not test run
IF arch_test IS INITIAL.
CALL FUNCTION 'ARCHIVE_DELETE_OBJECT_DATA'
EXPORTING archive_handle = archive_handle.
ENDIF.
enddo.
* Close archive file
CALL FUNCTION 'ARCHIVE_CLOSE_FILE'
EXPORTING
archive_handle = archive_handle.
endmethod.method DISPLAY_LOG.
* local data definition
data: wa type ty_tab.
data: log type ref to ty_tab.
* Selection data
SELECT_DATA( im_prog = im_prog
im_tod = im_tod im_date = im_date im_usr = im_usr im_typ = im_typ ).
check tb_log[] is not INITIAL.
loop at tb_log into wa.
* Edit data
append wa to alv_tab.
endloop.
* Edit the record
loop at alv_tab REFERENCE INTO log.
case log->ZTYPE.
when 'E'.
log->excp = 1.
when 'S'.
log->excp = 3.
when 'W'.
log->excp = 2.
ENDCASE.
endloop.
* Prepare layout
call method prepare_layout.
* Prepare fieldcat
call method prepare_fieldcat.
* Show data
call method show_alv EXPORTING container = im_container.
* Get original split container
split_con = im_container.
endmethod.method HANDLE_DOUBLE_CLICK.
if split_flag is INITIAL.
* Free over all alv object
call method ref_alv->free.
* Create splitter
CREATE OBJECT ref_split EXPORTING
parent = split_con orientation = 0 SASH_POSITION = 80.
* Get the separated control
alv_con = ref_split->top_left_container.
det_con = ref_split->bottom_right_container.
* Show data
call method show_alv EXPORTING container = alv_con.
* Add detail alv layout and fieldcat
call method prepare_layout EXPORTING detail_flag = 'X'.
call method prepare_fieldcat EXPORTING detail_flag = 'X'.
* Show detail
call method show_detail EXPORTING im_con = det_con e_row = e_row.
CALL METHOD cl_gui_cfw=>flush
EXCEPTIONS cntl_system_error = 1
cntl_error = 2.
IF sy-subrc <> 0.
* error handling
ENDIF.
split_flag = 'X'.
else.
if ref_dtl is not INITIAL.
call method ref_dtl->free.
endif.
* Show detail
call method show_detail EXPORTING im_con = det_con e_row = e_row.
endif.
endmethod.method INSERT_LOG.
* Lock log table
CALL FUNCTION 'ENQUEUE_EZSIH_LOG'
EXPORTING
MODE_ZSIH_LOG = 'X'
MANDT = SY-MANDT
ZPROGRAM = im_prog
EXCEPTIONS
FOREIGN_LOCK = 1
SYSTEM_FAILURE = 2
OTHERS = 3
.
if sy-subrc <> 0.
ret = 1. " Lock failed
endif.
check ret = 0.
* Check log record
if im_tlog[] is INITIAL.
ret = 2. " No log record
* Dequeue lock object
CALL FUNCTION 'DEQUEUE_EZSIH_LOG'
EXPORTING
MODE_ZSIH_LOG = 'X'
MANDT = SY-MANDT
ZPROGRAM = im_prog
.
endif.
check ret = 0.
* Insert log record
insert zsih_log from table im_tlog ACCEPTING DUPLICATE KEYS.
if sy-subrc <> 0.
ret = 3. " Insert record failed
* Dequeue lock object
CALL FUNCTION 'DEQUEUE_EZSIH_LOG'
EXPORTING
MODE_ZSIH_LOG = 'X'
MANDT = SY-MANDT
ZPROGRAM = im_prog
.
ROLLBACK WORK.
endif.
check ret = 0.
* Commit work
commit WORK and WAIT.
* Dequeue lock object
CALL FUNCTION 'DEQUEUE_EZSIH_LOG'
EXPORTING
MODE_ZSIH_LOG = 'X'
MANDT = SY-MANDT
ZPROGRAM = im_prog
.
endmethod.method OPEN_OBJ.
* Data definition
data: x_echtl TYPE c.
* Processing archive with test
IF arch_test IS INITIAL.
x_echtl = 'X'.
ENDIF.
* Open archive object for write
CALL FUNCTION 'ARCHIVE_OPEN_FOR_WRITE'
EXPORTING
object = arch_object
create_archive_file = x_echtl
call_delete_job_in_test_mode = space
comments = arch_rem
IMPORTING
archive_handle = archive_handle.
* Get archive information
CALL FUNCTION 'ARCHIVE_GET_INFORMATION'
EXPORTING
archive_handle = archive_handle
IMPORTING
archive_name = archive_name.
endmethod.method PREPARE_FIELDCAT.
* Local data definition
data: ref_field TYPE ref to lvc_s_fcat.
data: sfat type lvc_s_fcat.
if detail_flag is INITIAL.
* Get table reference
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = 'ZSIH_LOG'
CHANGING
ct_fieldcat = alv_fieldcat
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
* Edit fieldcat
loop at alv_fieldcat REFERENCE INTO ref_field.
CASE ref_field->fieldname.
when 'ZMESSAGE1' or 'ZMESSAGE2' or 'ZMESSAGE3' or 'ZMESSAGE4' or 'ZMESSAGE5'
or 'ZMESSAGE6' or 'ZMESSAGE7' or 'ZMESSAGE8' or 'ZMESSAGE9' or 'ZINDEX'.
ref_field->NO_OUT = 'X'.
when 'ZTYPE'.
ref_field->outputlen = 10.
when 'ZUSER'.
ref_field->outputlen = 19.
when ''.
endcase.
endloop.
else.
sfat-fieldname = 'STR'.
sfat-SELTEXT = text-002.
sfat-SCRTEXT_L = text-002.
sfat-SCRTEXT_M = text-002.
sfat-outputlen = 112.
append sfat to det_field.
endif.
endmethod.method PREPARE_LAYOUT.
* Edit layout
if detail_flag is INITIAL.
alv_layout-grid_title = text-001.
alv_layout-excp_fname ='EXCP' .
else.
det_lay-NO_TOOLBAR = 'X'.
det_lay-excp_fname ='EXP' .
det_lay-EXCP_LED = 'X'.
endif.
endmethod.method RIC_ARCH.
* Local data definition
data:
archive_write_handle LIKE sy-tabix,
archive_read_handle LIKE sy-tabix,
archive_release type SYSAPRL,
str_name type RKZ_DBNA,
str_wa(10092) TYPE c,
str_flags type CHAR08,
str_len TYPE i,
cnt_log type i,
cnt_commit TYPE i,
max_commit TYPE i value 5000.
data: wa type zsih_log.
FIELD-SYMBOLS: <s> type any, <t> type any.
* Do transformation, separated with unicode and un-unicode
DEFINE transform.
if archive_release < '21A'.
assign str_wa(str_len) to <s>.
clear &1.
assign &1(str_len) to <t>.
<t> = <s>.
else.
call method cl_abap_container_utilities=>read_container_c
exporting IM_CONTAINER = str_wa
importing EX_VALUE = &1
exceptions ILLEGAL_PARAMETER_TYPE = 1
others = 2.
endif.
END-OF-DEFINITION.
* Open archive for move
CALL FUNCTION 'ARCHIVE_OPEN_FOR_MOVE'
EXPORTING object = arch_object
test_mode = arch_test
IMPORTING archive_read_handle = archive_read_handle
archive_write_handle = archive_write_handle.
* Get archive information
CALL FUNCTION 'ARCHIVE_GET_INFORMATION'
EXPORTING archive_handle = archive_read_handle
IMPORTING archive_creation_release = archive_release
archive_name = archive_name.
* Processing
DO.
CALL FUNCTION 'ARCHIVE_GET_NEXT_OBJECT'
EXPORTING archive_handle = archive_read_handle
EXCEPTIONS end_of_file = 01.
IF sy-subrc <> 0.
EXIT.
ENDIF.
* Get and restore
do.
CALL FUNCTION 'ARCHIVE_GET_NEXT_RECORD'
EXPORTING archive_handle = archive_read_handle
IMPORTING record_structure = str_name
record_length = str_len
record = str_wa
EXCEPTIONS end_of_object = 01.
IF sy-subrc <> 0.
EXIT.
ENDIF.
ADD 1 TO cnt_log.
add 1 to cnt_commit.
transform wa.
IF arch_test IS INITIAL.
insert zsih_log from wa.
IF cnt_commit >= max_commit.
commit work.
cnt_commit = 0.
endif.
endif.
CLEAR wa.
enddo.
IF arch_test IS INITIAL.
* Reload object
CALL FUNCTION 'ARCHIVE_RELOAD_OBJECT_DATA'
EXPORTING archive_handle = archive_read_handle
EXCEPTIONS wrong_access_to_archive = 01.
* Save object
CALL FUNCTION 'ARCHIVE_SAVE_OBJECT'
EXPORTING archive_handle = archive_write_handle.
ENDIF.
ENDDO.
endmethod.method SELECT_DATA.
* Selection data
select * from zsih_log
into CORRESPONDING FIELDS OF TABLE me->tb_log
where ZPROGRAM in im_prog
and ZTCODE in im_tod
and ZDATE in im_date
and ZUSER in im_usr
and ZTYPE in im_typ.
endmethod.method SHOW_ALV.
* Create ALV object
CREATE OBJECT ref_alv
EXPORTING i_parent = container.
SET HANDLER handle_double_click FOR ref_alv.
* Set data display
call method ref_alv->set_table_for_first_display
EXPORTING
is_layout = alv_layout
CHANGING
it_outtab = alv_tab
it_fieldcatalog = alv_fieldcat
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4.
endmethod.method SHOW_DETAIL.
* Local data definition
data: begin of tab ,
str(255) type c,
exp(1) type c,
end of tab.
data: rtab like tab,itab like TABLE OF tab.
data: wa type zsih_log.
FIELD-SYMBOLS: <fs> type any.
data: ls(30) type c, ls1(2) type c.
* Create detail ALV list
CREATE OBJECT ref_dtl EXPORTING i_parent = im_con.
* Get selected data
read table tb_log index e_row-INDEX into wa.
if sy-subrc = 0.
* Edit error data
do 9 times.
ls1 = sy-index.
CONCATENATE 'WA-ZMESSAGE' ls1 into ls.
assign (LS) to <fs>.
if <fs> is not INITIAL.
if <fs>+0(1) = '#'.
case <fs>+1(1).
when 'S'.
rtab-exp = '3'.
when 'E'.
rtab-exp = '1'.
when 'W'.
rtab-exp = '2'.
endcase.
clear: <fs>+0(2).
else.
rtab-exp = '1'.
endif.
rtab-str = <fs>.
append rtab to itab.
endif.
enddo.
endif.
* Display detail data
call method ref_dtl->set_table_for_first_display
EXPORTING
is_layout = det_lay
CHANGING
it_outtab = itab
it_fieldcatalog = det_field
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4.
endmethod.class ZSIH_LOG_PRO definition
public
final
create public .
*"* public components of class ZSIH_LOG_PRO
*"* do not include other source files here!!!
public section.
types:
BEGIN OF ty_tab.
INCLUDE TYPE zsih_log.
* TYPES:rowcolor(4) TYPE c.
* TYPES:cellcolor TYPE lvc_t_scol.
TYPES:excp(1) TYPE c.
TYPES:END OF ty_tab .
data:
ALV_TAB type table of TY_TAB .
methods CONSTRUCTOR
importing
value(TYPE) type C optional
value(TEST) type C optional
value(REM) type ADMI_TEXT optional .
methods ARCHIVE
importing
!IM_PROG type ZTRANGE
!IM_TOD type ZTRANGE
!IM_DATE type ZTRANGE
!IM_USR type ZTRANGE
!IM_TYP type ZTRANGE
!IM_DAY type BAPI_JBD_DTE_STITEL optional
returning
value(SUBR) like SY-SUBRC .
methods DEL_FILE .
methods RIC_ARCH .
class-methods INSERT_LOG
importing
!IM_TLOG type ZTLOG
!IM_PROG type PROGNAME
returning
value(RET) like SY-SUBRC .
methods DISPLAY_LOG
importing
!IM_PROG type ZTRANGE optional
!IM_TOD type ZTRANGE optional
!IM_DATE type ZTRANGE optional
!IM_USR type ZTRANGE optional
!IM_TYP type ZTRANGE optional
changing
!IM_CONTAINER type ref to CL_GUI_CUSTOM_CONTAINER .*"* protected components of class ZSIH_LOG_PRO
*"* do not include other source files here!!!
protected section.*"* private components of class ZSIH_LOG_PRO
*"* do not include other source files here!!!
private section.
data ARCH_OBJECT type OBJCT_TR01 .
data ARCH_TYP type C .
data ARCH_TEST type C .
data ARCH_REM type ADMI_TEXT .
data ARCHIVE_HANDLE type INT4 .
data ARCHIVE_NAME type ARKEY .
data TB_LOG type ZT_SIHLOG .
data ARCHIVE_FLAGS type ARC_BUFFER-FLAGS .
data ALV_LAYOUT type LVC_S_LAYO .
data ALV_FIELDCAT type LVC_T_FCAT .
data REF_ALV type ref to CL_GUI_ALV_GRID .
data REF_DTL type ref to CL_GUI_ALV_GRID .
data DET_LAY type LVC_S_LAYO .
data DET_FIELD type LVC_T_FCAT .
data REF_SPLIT type ref to CL_GUI_EASY_SPLITTER_CONTAINER .
data ALV_CON type ref to CL_GUI_CONTAINER .
data DET_CON type ref to CL_GUI_CONTAINER .
data SPLIT_CON type ref to CL_GUI_CUSTOM_CONTAINER .
data SPLIT_FLAG type C .
methods OPEN_OBJ .
methods SELECT_DATA
importing
!IM_PROG type ZTRANGE optional
!IM_TOD type ZTRANGE optional
!IM_DATE type ZTRANGE optional
!IM_USR type ZTRANGE optional
!IM_TYP type ZTRANGE optional
returning
value(SUBR) like SY-SUBRC .
methods ARCH_OBJ .
methods ARCH_STATUS .
methods PREPARE_LAYOUT
importing
value(DETAIL_FLAG) type C optional .
methods PREPARE_FIELDCAT
importing
value(DETAIL_FLAG) type C optional .
methods SHOW_ALV
importing
!CONTAINER type ref to CL_GUI_CONTAINER .
methods HANDLE_DOUBLE_CLICK
for event DOUBLE_CLICK of CL_GUI_ALV_GRID
importing
!E_ROW .
methods SHOW_DETAIL
importing
!IM_CON type ref to CL_GUI_CONTAINER
!E_ROW type LVC_S_ROW .*"* local class implementation for public class
*"* use this source file for the implementation part of
*"* local helper classes*"* use this source file for any type declarations (class
*"* definitions, interfaces or data types) you need for method
*"* implementation or private method's signature*"* use this source file for any macro definitions you need
*"* in the implementation part of the classmethod ARCHIVE.
* Local data definition
data: wa type zsih_log.
* Open Object
call METHOD me->open_obj.
* Getting data
subr = SELECT_DATA( im_prog = im_prog
im_tod = im_tod im_date = im_date im_usr = im_usr im_typ = im_typ ).
check subr = 0.
* Archive processing
call method me->ARCH_OBJ.
endmethod.method ARCH_OBJ.
* Local data definition
data: wa type zsih_log.
* Open archive
CALL FUNCTION 'ARCHIVE_OPEN_FOR_WRITE'
EXPORTING
call_delete_job_in_test_mode = space
* create_archive_file = v_wriprd
object = 'ZSIH_LOG'
IMPORTING
archive_handle = archive_handle.
loop at tb_log into wa.
* Create new archive
CALL FUNCTION 'ARCHIVE_NEW_OBJECT'
EXPORTING archive_handle = archive_handle.
* Put record to archive
CALL FUNCTION 'ARCHIVE_PUT_RECORD'
EXPORTING
archive_handle = archive_handle
record_flags = ARCHIVE_FLAGS
record_structure = 'ZSIH_LOG'
record = WA.
* Save archive object
CALL FUNCTION 'ARCHIVE_SAVE_OBJECT'
EXPORTING archive_handle = archive_handle.
endloop.
* Update status
CALL FUNCTION 'ARCHIVE_WRITE_STATISTICS'
EXPORTING
archive_handle = archive_handle.
* Close file
CALL FUNCTION 'ARCHIVE_CLOSE_FILE'
EXPORTING
archive_handle = archive_handle.
endmethod.method ARCH_STATUS.
* Write archive status
CALL FUNCTION 'ARCHIVE_WRITE_STATISTICS'
EXPORTING
archive_handle = archive_handle
EXCEPTIONS
internal_error = 1
OTHERS = 2
.
* Close archive file
CALL FUNCTION 'ARCHIVE_CLOSE_FILE'
EXPORTING
archive_handle = archive_handle.
endmethod.method CONSTRUCTOR.
me->arch_typ = type.
me->arch_test = test.
me->arch_object = 'ZSIH_LOG'.
me->arch_rem = rem.
endmethod.method DEL_FILE.
* Local data definition
DATA: str_name type RKZ_DBNA,
str_wa(10092) TYPE c,
str_flags type CHAR08,
cnt_commit TYPE i,
max_commit TYPE i,
cnt_log TYPE i.
data: wa type zsih_log.
* Archive open for deletion
CALL FUNCTION 'ARCHIVE_OPEN_FOR_DELETE'
EXPORTING object = arch_object
test_mode = arch_test
IMPORTING archive_handle = archive_handle
EXCEPTIONS no_files_available = 01.
IF sy-subrc <> 0.
MESSAGE e003(zsih_msg_bc).
ENDIF.
* Get archive information
CALL FUNCTION 'ARCHIVE_GET_INFORMATION'
EXPORTING archive_handle = archive_handle
IMPORTING archive_name = archive_name.
* Get customize data
CALL FUNCTION 'ARCHIVE_GET_CUSTOMIZING_DATA'
EXPORTING object = arch_object
IMPORTING commit_count_for_delete_prg = max_commit.
DO.
CALL FUNCTION 'ARCHIVE_GET_NEXT_OBJECT'
EXPORTING archive_handle = archive_handle
EXCEPTIONS end_of_file = 01.
IF sy-subrc <> 0.
EXIT.
ENDIF.
DO.
CALL FUNCTION 'ARCHIVE_GET_NEXT_RECORD'
EXPORTING archive_handle = archive_handle
IMPORTING record_structure = str_name
record_flags = str_flags
record = str_wa
EXCEPTIONS end_of_object = 01.
IF sy-subrc <> 0.
EXIT.
ENDIF.
add 1 to cnt_log.
add 1 to cnt_commit.
class CL_ABAP_CONTAINER_UTILITIES definition load.
call method cl_abap_container_utilities=>read_container_c
exporting IM_CONTAINER = str_wa
importing EX_VALUE = wa
exceptions ILLEGAL_PARAMETER_TYPE = 1
others = 2.
IF str_flags = archive_flags.
call method cl_abap_container_utilities=>read_container_c
exporting IM_CONTAINER = str_wa
importing EX_VALUE = wa
exceptions ILLEGAL_PARAMETER_TYPE = 1
others = 2.
IF arch_test IS INITIAL.
delete zsih_log from wa.
endif.
endif.
enddo.
* Check if not test run
IF arch_test IS INITIAL.
CALL FUNCTION 'ARCHIVE_DELETE_OBJECT_DATA'
EXPORTING archive_handle = archive_handle.
ENDIF.
enddo.
* Close archive file
CALL FUNCTION 'ARCHIVE_CLOSE_FILE'
EXPORTING
archive_handle = archive_handle.
endmethod.method DISPLAY_LOG.
* local data definition
data: wa type ty_tab.
data: log type ref to ty_tab.
* Selection data
SELECT_DATA( im_prog = im_prog
im_tod = im_tod im_date = im_date im_usr = im_usr im_typ = im_typ ).
check tb_log[] is not INITIAL.
loop at tb_log into wa.
* Edit data
append wa to alv_tab.
endloop.
* Edit the record
loop at alv_tab REFERENCE INTO log.
case log->ZTYPE.
when 'E'.
log->excp = 1.
when 'S'.
log->excp = 3.
when 'W'.
log->excp = 2.
ENDCASE.
endloop.
* Prepare layout
call method prepare_layout.
* Prepare fieldcat
call method prepare_fieldcat.
* Show data
call method show_alv EXPORTING container = im_container.
* Get original split container
split_con = im_container.
endmethod.method HANDLE_DOUBLE_CLICK.
if split_flag is INITIAL.
* Free over all alv object
call method ref_alv->free.
* Create splitter
CREATE OBJECT ref_split EXPORTING
parent = split_con orientation = 0 SASH_POSITION = 80.
* Get the separated control
alv_con = ref_split->top_left_container.
det_con = ref_split->bottom_right_container.
* Show data
call method show_alv EXPORTING container = alv_con.
* Add detail alv layout and fieldcat
call method prepare_layout EXPORTING detail_flag = 'X'.
call method prepare_fieldcat EXPORTING detail_flag = 'X'.
* Show detail
call method show_detail EXPORTING im_con = det_con e_row = e_row.
CALL METHOD cl_gui_cfw=>flush
EXCEPTIONS cntl_system_error = 1
cntl_error = 2.
IF sy-subrc <> 0.
* error handling
ENDIF.
split_flag = 'X'.
else.
if ref_dtl is not INITIAL.
call method ref_dtl->free.
endif.
* Show detail
call method show_detail EXPORTING im_con = det_con e_row = e_row.
endif.
endmethod.method INSERT_LOG.
* Lock log table
CALL FUNCTION 'ENQUEUE_EZSIH_LOG'
EXPORTING
MODE_ZSIH_LOG = 'X'
MANDT = SY-MANDT
ZPROGRAM = im_prog
EXCEPTIONS
FOREIGN_LOCK = 1
SYSTEM_FAILURE = 2
OTHERS = 3
.
if sy-subrc <> 0.
ret = 1. " Lock failed
endif.
check ret = 0.
* Check log record
if im_tlog[] is INITIAL.
ret = 2. " No log record
* Dequeue lock object
CALL FUNCTION 'DEQUEUE_EZSIH_LOG'
EXPORTING
MODE_ZSIH_LOG = 'X'
MANDT = SY-MANDT
ZPROGRAM = im_prog
.
endif.
check ret = 0.
* Insert log record
insert zsih_log from table im_tlog ACCEPTING DUPLICATE KEYS.
if sy-subrc <> 0.
ret = 3. " Insert record failed
* Dequeue lock object
CALL FUNCTION 'DEQUEUE_EZSIH_LOG'
EXPORTING
MODE_ZSIH_LOG = 'X'
MANDT = SY-MANDT
ZPROGRAM = im_prog
.
ROLLBACK WORK.
endif.
check ret = 0.
* Commit work
commit WORK and WAIT.
* Dequeue lock object
CALL FUNCTION 'DEQUEUE_EZSIH_LOG'
EXPORTING
MODE_ZSIH_LOG = 'X'
MANDT = SY-MANDT
ZPROGRAM = im_prog
.
endmethod.method OPEN_OBJ.
* Data definition
data: x_echtl TYPE c.
* Processing archive with test
IF arch_test IS INITIAL.
x_echtl = 'X'.
ENDIF.
* Open archive object for write
CALL FUNCTION 'ARCHIVE_OPEN_FOR_WRITE'
EXPORTING
object = arch_object
create_archive_file = x_echtl
call_delete_job_in_test_mode = space
comments = arch_rem
IMPORTING
archive_handle = archive_handle.
* Get archive information
CALL FUNCTION 'ARCHIVE_GET_INFORMATION'
EXPORTING
archive_handle = archive_handle
IMPORTING
archive_name = archive_name.
endmethod.method PREPARE_FIELDCAT.
* Local data definition
data: ref_field TYPE ref to lvc_s_fcat.
data: sfat type lvc_s_fcat.
if detail_flag is INITIAL.
* Get table reference
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = 'ZSIH_LOG'
CHANGING
ct_fieldcat = alv_fieldcat
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
* Edit fieldcat
loop at alv_fieldcat REFERENCE INTO ref_field.
CASE ref_field->fieldname.
when 'ZMESSAGE1' or 'ZMESSAGE2' or 'ZMESSAGE3' or 'ZMESSAGE4' or 'ZMESSAGE5'
or 'ZMESSAGE6' or 'ZMESSAGE7' or 'ZMESSAGE8' or 'ZMESSAGE9' or 'ZINDEX'.
ref_field->NO_OUT = 'X'.
when 'ZTYPE'.
ref_field->outputlen = 10.
when 'ZUSER'.
ref_field->outputlen = 19.
when ''.
endcase.
endloop.
else.
sfat-fieldname = 'STR'.
sfat-SELTEXT = text-002.
sfat-SCRTEXT_L = text-002.
sfat-SCRTEXT_M = text-002.
sfat-outputlen = 112.
append sfat to det_field.
endif.
endmethod.method PREPARE_LAYOUT.
* Edit layout
if detail_flag is INITIAL.
alv_layout-grid_title = text-001.
alv_layout-excp_fname ='EXCP' .
else.
det_lay-NO_TOOLBAR = 'X'.
det_lay-excp_fname ='EXP' .
det_lay-EXCP_LED = 'X'.
endif.
endmethod.method RIC_ARCH.
* Local data definition
data:
archive_write_handle LIKE sy-tabix,
archive_read_handle LIKE sy-tabix,
archive_release type SYSAPRL,
str_name type RKZ_DBNA,
str_wa(10092) TYPE c,
str_flags type CHAR08,
str_len TYPE i,
cnt_log type i,
cnt_commit TYPE i,
max_commit TYPE i value 5000.
data: wa type zsih_log.
FIELD-SYMBOLS: <s> type any, <t> type any.
* Do transformation, separated with unicode and un-unicode
DEFINE transform.
if archive_release < '21A'.
assign str_wa(str_len) to <s>.
clear &1.
assign &1(str_len) to <t>.
<t> = <s>.
else.
call method cl_abap_container_utilities=>read_container_c
exporting IM_CONTAINER = str_wa
importing EX_VALUE = &1
exceptions ILLEGAL_PARAMETER_TYPE = 1
others = 2.
endif.
END-OF-DEFINITION.
* Open archive for move
CALL FUNCTION 'ARCHIVE_OPEN_FOR_MOVE'
EXPORTING object = arch_object
test_mode = arch_test
IMPORTING archive_read_handle = archive_read_handle
archive_write_handle = archive_write_handle.
* Get archive information
CALL FUNCTION 'ARCHIVE_GET_INFORMATION'
EXPORTING archive_handle = archive_read_handle
IMPORTING archive_creation_release = archive_release
archive_name = archive_name.
* Processing
DO.
CALL FUNCTION 'ARCHIVE_GET_NEXT_OBJECT'
EXPORTING archive_handle = archive_read_handle
EXCEPTIONS end_of_file = 01.
IF sy-subrc <> 0.
EXIT.
ENDIF.
* Get and restore
do.
CALL FUNCTION 'ARCHIVE_GET_NEXT_RECORD'
EXPORTING archive_handle = archive_read_handle
IMPORTING record_structure = str_name
record_length = str_len
record = str_wa
EXCEPTIONS end_of_object = 01.
IF sy-subrc <> 0.
EXIT.
ENDIF.
ADD 1 TO cnt_log.
add 1 to cnt_commit.
transform wa.
IF arch_test IS INITIAL.
insert zsih_log from wa.
IF cnt_commit >= max_commit.
commit work.
cnt_commit = 0.
endif.
endif.
CLEAR wa.
enddo.
IF arch_test IS INITIAL.
* Reload object
CALL FUNCTION 'ARCHIVE_RELOAD_OBJECT_DATA'
EXPORTING archive_handle = archive_read_handle
EXCEPTIONS wrong_access_to_archive = 01.
* Save object
CALL FUNCTION 'ARCHIVE_SAVE_OBJECT'
EXPORTING archive_handle = archive_write_handle.
ENDIF.
ENDDO.
endmethod.method SELECT_DATA.
* Selection data
select * from zsih_log
into CORRESPONDING FIELDS OF TABLE me->tb_log
where ZPROGRAM in im_prog
and ZTCODE in im_tod
and ZDATE in im_date
and ZUSER in im_usr
and ZTYPE in im_typ.
endmethod.method SHOW_ALV.
* Create ALV object
CREATE OBJECT ref_alv
EXPORTING i_parent = container.
SET HANDLER handle_double_click FOR ref_alv.
* Set data display
call method ref_alv->set_table_for_first_display
EXPORTING
is_layout = alv_layout
CHANGING
it_outtab = alv_tab
it_fieldcatalog = alv_fieldcat
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4.
endmethod.method SHOW_DETAIL.
* Local data definition
data: begin of tab ,
str(255) type c,
exp(1) type c,
end of tab.
data: rtab like tab,itab like TABLE OF tab.
data: wa type zsih_log.
FIELD-SYMBOLS: <fs> type any.
data: ls(30) type c, ls1(2) type c.
* Create detail ALV list
CREATE OBJECT ref_dtl EXPORTING i_parent = im_con.
* Get selected data
read table tb_log index e_row-INDEX into wa.
if sy-subrc = 0.
* Edit error data
do 9 times.
ls1 = sy-index.
CONCATENATE 'WA-ZMESSAGE' ls1 into ls.
assign (LS) to <fs>.
if <fs> is not INITIAL.
if <fs>+0(1) = '#'.
case <fs>+1(1).
when 'S'.
rtab-exp = '3'.
when 'E'.
rtab-exp = '1'.
when 'W'.
rtab-exp = '2'.
endcase.
clear: <fs>+0(2).
else.
rtab-exp = '1'.
endif.
rtab-str = <fs>.
append rtab to itab.
endif.
enddo.
endif.
* Display detail data
call method ref_dtl->set_table_for_first_display
EXPORTING
is_layout = det_lay
CHANGING
it_outtab = itab
it_fieldcatalog = det_field
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4.
endmethod.************************************************************************
* Program Name : ZDEL_SIH_LOG *
* *
* Programmer : Bob.Xu @ HP *
* Creation Date : 13/04/2009 *
* *
* Description : ARCHIVIAZIONE SIH Log *
************************************************************************
REPORT ZDEL_SIH_LOG
NO STANDARD PAGE HEADING
LINE-SIZE 130
LINE-COUNT 65(0)
MESSAGE-ID zsih_msg_bc.
************************************************************************
* Tables declaration *
************************************************************************
TABLES: ZSIH_LOG.
************************************************************************
* Selection-screen
************************************************************************
*selection-screen BEGIN OF block block1 WITH frame title text-001.
*
*PARAMETER: testrun LIKE rfpdo-f040test DEFAULT ' '.
*
*SELECTION-SCREEN END OF BLOCK block1.
************************************************************************
* Global data definition
************************************************************************
data: ref_log type REF TO ZSIH_LOG_PRO.
*----------------------------------------------------------------------*
START-OF-SELECTION.
*----------------------------------------------------------------------*
* Create log object
create object ref_log
EXPORTING TYPE = 'D'.
write: / 'Start deletion!'.
* Delete archive
call method ref_log->DEL_FILE.************************************************************************
* Program Name : ZARCH_SIH_LOG *
* *
* Programmer : Bob.Xu @ HP *
* Creation Date : 13/04/2009 *
* *
* Description : ARCHIVIAZIONE SIH Log *
************************************************************************
REPORT ZARCH_SIH_LOG
NO STANDARD PAGE HEADING
LINE-SIZE 130
LINE-COUNT 65(0)
MESSAGE-ID zsih_msg_bc.
************************************************************************
* Tables declaration *
************************************************************************
TABLES: ZSIH_LOG.
************************************************************************
* Selection-screen
************************************************************************
SELECTION-SCREEN BEGIN OF BLOCK block1 WITH FRAME TITLE text-001.
*SELECTION-SCREEN BEGIN OF LINE.
* SELECTION-SCREEN COMMENT 1(31) text-002.
* PARAMETER day(3) type N OBLIGATORY.
* SELECTION-SCREEN COMMENT 40(5) text-003.
*selection-screen end of LINE.
SELECTION-SCREEN SKIP.
SELECT-OPTIONS:
s_prog for ZSIH_LOG-ZPROGRAM,
s_tod for ZSIH_LOG-ZTCODE,
s_date for ZSIH_LOG-ZDATE,
s_usr for ZSIH_LOG-ZUSER,
s_typ for ZSIH_LOG-ZTYPE.
PARAMETER: admi_rem LIKE admi_run-comments.
PARAMETER: testrun LIKE rfpdo-f040test DEFAULT 'X'.
SELECTION-SCREEN END OF BLOCK block1.
************************************************************************
* Global data definition
************************************************************************
data:
ret like sy-subrc,
ref_log type REF TO ZSIH_LOG_PRO.
data:
prog type ztrange,tod type ztrange,zdate type ztrange,
usr type ztrange,typ type ztrange.
*----------------------------------------------------------------------*
START-OF-SELECTION.
*----------------------------------------------------------------------*
* Create log object
create object ref_log
EXPORTING TYPE = 'A' TEST = testrun REM = admi_rem.
* Archive
prog[] = s_prog[].
tod[] = s_tod[].
zdate[] = s_date[].
usr[] = s_usr[].
typ[] = s_typ[].
ret = ref_log->ARCHIVE(
IM_PROG = prog
IM_TOD = tod
IM_DATE = zdate
IM_USR = usr
IM_TYP = typ
).
if ret = 0.
write: / 'Write completed!'.
else.
write: / 'Write error!'.
message e002.
endif.************************************************************************
* Program Name : ZRIC_SIH_LOG *
* *
* Programmer : Bob.Xu @ HP *
* Creation Date : 13/04/2009 *
* *
* Description : ARCHIVIAZIONE SIH Log *
************************************************************************
REPORT ZRIC_SIH_LOG
NO STANDARD PAGE HEADING
LINE-SIZE 130
LINE-COUNT 65(0)
MESSAGE-ID zsih_msg_bc.
************************************************************************
* Tables declaration *
************************************************************************
TABLES: ZSIH_LOG.
************************************************************************
* Selection-screen
************************************************************************
SELECTION-SCREEN BEGIN OF BLOCK block1 WITH FRAME TITLE text-021.
PARAMETERS: testrun LIKE rfpdo-f040test DEFAULT 'X'.
SELECTION-SCREEN END OF BLOCK block1.
************************************************************************
* Global data definition
************************************************************************
data: ref_log type REF TO ZSIH_LOG_PRO.
*----------------------------------------------------------------------*
START-OF-SELECTION.
*----------------------------------------------------------------------*
* Create log object
create object ref_log
EXPORTING TYPE = 'R' TEST = testrun.
* Reload
call method ref_log->ric_arch.PROCESS BEFORE OUTPUT.
MODULE STATUS_9000.
*
PROCESS AFTER INPUT.
MODULE USER_COMMAND_9000.* Program ID/Name: ZSIH_BC_LOG_DISPLAY Date written: 20090414
* Author's name: Bob.Xu@HP Last update: 20090414
* Program title: SIH log display
* Project Name: SIH
* Version: Initial Version
* Function Spec ID:
* Analyst:
*----------------------------------------------------------------------*
* Description: (Incl. Related Function Area and System)
*
*----------------------------------------------------------------------*
* Calls: (RFC and BPI)
*
*----------------------------------------------------------------------*
* Function Modules:
*
*----------------------------------------------------------------------*
* Table:
*
*----------------------------------------------------------------------*
* Result:
*
*---------------------------------------------------------------------*
* Change History
*----------------------------------------------------------------------*
* Date | Programmer | Corr. # | Description
* | | |
* | | |
************************************************************************
REPORT ZSIH_BC_LOG_DISPLAY.
************************************************************************
* Tables declaration *
************************************************************************
TABLES: ZSIH_LOG.
************************************************************************
* Global data definition
************************************************************************
data:
ref type ref to ZSIH_LOG_PRO, " Log processing object
save_ok LIKE sy-ucomm, " Screen command
ok_code LIKE sy-ucomm. " Screen command
* Container
DATA ref_con TYPE REF TO cl_gui_custom_container .
* Screen init flag
data init.
data:
prog type ztrange,tod type ztrange,zdate type ztrange,
usr type ztrange,typ type ztrange.
************************************************************************
* Selection-screen
************************************************************************
SELECTION-SCREEN BEGIN OF BLOCK block1 WITH FRAME TITLE text-001.
SELECT-OPTIONS:
s_prog for ZSIH_LOG-ZPROGRAM,
s_tod for ZSIH_LOG-ZTCODE,
s_date for ZSIH_LOG-ZDATE,
s_usr for ZSIH_LOG-ZUSER,
s_typ for ZSIH_LOG-ZTYPE.
SELECTION-SCREEN END OF BLOCK block1.
*----------------------------------------------------------------------
START-OF-SELECTION.
*----------------------------------------------------------------------
prog[] = s_prog[].
tod[] = s_tod[].
zdate[] = s_date[].
usr[] = s_usr[].
typ[] = s_typ[].
* Goto the main screen
call screen 9000.
*&---------------------------------------------------------------------*
*& Module STATUS_9000 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
module STATUS_9000 output.
* Set status and title
SET PF-STATUS 'STAT'.
set TITLEBAR 'TIT'.
* Display with ALV
PERFORM frm_display_alv.
endmodule. " STATUS_9000 OUTPUT
*&---------------------------------------------------------------------*
*& Form frm_display_alv
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form frm_display_alv .
*-->Create customer container
if init is INITIAL.
CREATE OBJECT ref_con
EXPORTING
container_name = 'ALV_CON'.
create object ref.
* Show log
call method ref->DISPLAY_LOG
EXPORTING
IM_PROG = prog
IM_TOD = tod
IM_DATE = zdate
IM_USR = usr
IM_TYP = typ
CHANGING
im_container = ref_con .
init = 'X'.
endif.
endform. " frm_display_alv
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_9000 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
module USER_COMMAND_9000 input.
* Exit command processing
save_ok = ok_code.
CASE save_ok.
WHEN 'BACK' OR 'EXIT' OR 'CANC'.
LEAVE to SCREEN 0.
endcase.
endmodule. " USER_COMMAND_9000 INPUTPROCESS BEFORE OUTPUT.
MODULE STATUS_9000.
*
PROCESS AFTER INPUT.
MODULE USER_COMMAND_9000.* Program ID/Name: ZSIH_BC_LOG_DISPLAY Date written: 20090414
* Author's name: Bob.Xu@HP Last update: 20090414
* Program title: SIH log display
* Project Name: SIH
* Version: Initial Version
* Function Spec ID:
* Analyst:
*----------------------------------------------------------------------*
* Description: (Incl. Related Function Area and System)
*
*----------------------------------------------------------------------*
* Calls: (RFC and BPI)
*
*----------------------------------------------------------------------*
* Function Modules:
*
*----------------------------------------------------------------------*
* Table:
*
*----------------------------------------------------------------------*
* Result:
*
*---------------------------------------------------------------------*
* Change History
*----------------------------------------------------------------------*
* Date | Programmer | Corr. # | Description
* | | |
* | | |
************************************************************************
REPORT ZSIH_BC_LOG_DISPLAY.
************************************************************************
* Tables declaration *
************************************************************************
TABLES: ZSIH_LOG.
************************************************************************
* Global data definition
************************************************************************
data:
ref type ref to ZSIH_LOG_PRO, " Log processing object
save_ok LIKE sy-ucomm, " Screen command
ok_code LIKE sy-ucomm. " Screen command
* Container
DATA ref_con TYPE REF TO cl_gui_custom_container .
* Screen init flag
data init.
data:
prog type ztrange,tod type ztrange,zdate type ztrange,
usr type ztrange,typ type ztrange.
************************************************************************
* Selection-screen
************************************************************************
SELECTION-SCREEN BEGIN OF BLOCK block1 WITH FRAME TITLE text-001.
SELECT-OPTIONS:
s_prog for ZSIH_LOG-ZPROGRAM,
s_tod for ZSIH_LOG-ZTCODE,
s_date for ZSIH_LOG-ZDATE,
s_usr for ZSIH_LOG-ZUSER,
s_typ for ZSIH_LOG-ZTYPE.
SELECTION-SCREEN END OF BLOCK block1.
*----------------------------------------------------------------------
START-OF-SELECTION.
*----------------------------------------------------------------------
prog[] = s_prog[].
tod[] = s_tod[].
zdate[] = s_date[].
usr[] = s_usr[].
typ[] = s_typ[].
* Goto the main screen
call screen 9000.
*&---------------------------------------------------------------------*
*& Module STATUS_9000 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
module STATUS_9000 output.
* Set status and title
SET PF-STATUS 'STAT'.
set TITLEBAR 'TIT'.
* Display with ALV
PERFORM frm_display_alv.
endmodule. " STATUS_9000 OUTPUT
*&---------------------------------------------------------------------*
*& Form frm_display_alv
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form frm_display_alv .
*-->Create customer container
if init is INITIAL.
CREATE OBJECT ref_con
EXPORTING
container_name = 'ALV_CON'.
create object ref.
* Show log
call method ref->DISPLAY_LOG
EXPORTING
IM_PROG = prog
IM_TOD = tod
IM_DATE = zdate
IM_USR = usr
IM_TYP = typ
CHANGING
im_container = ref_con .
init = 'X'.
endif.
endform. " frm_display_alv
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_9000 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
module USER_COMMAND_9000 input.
* Exit command processing
save_ok = ok_code.
CASE save_ok.
WHEN 'BACK' OR 'EXIT' OR 'CANC'.
LEAVE to SCREEN 0.
endcase.
endmodule. " USER_COMMAND_9000 INPUT************************************************************************
* Program Name : ZRIC_SIH_LOG *
* *
* Programmer : Bob.Xu @ HP *
* Creation Date : 13/04/2009 *
* *
* Description : ARCHIVIAZIONE SIH Log *
************************************************************************
REPORT ZRIC_SIH_LOG
NO STANDARD PAGE HEADING
LINE-SIZE 130
LINE-COUNT 65(0)
MESSAGE-ID zsih_msg_bc.
************************************************************************
* Tables declaration *
************************************************************************
TABLES: ZSIH_LOG.
************************************************************************
* Selection-screen
************************************************************************
SELECTION-SCREEN BEGIN OF BLOCK block1 WITH FRAME TITLE text-021.
PARAMETERS: testrun LIKE rfpdo-f040test DEFAULT 'X'.
SELECTION-SCREEN END OF BLOCK block1.
************************************************************************
* Global data definition
************************************************************************
data: ref_log type REF TO ZSIH_LOG_PRO.
*----------------------------------------------------------------------*
START-OF-SELECTION.
*----------------------------------------------------------------------*
* Create log object
create object ref_log
EXPORTING TYPE = 'R' TEST = testrun.
* Reload
call method ref_log->ric_arch.************************************************************************
* Program Name : ZDEL_SIH_LOG *
* *
* Programmer : Bob.Xu @ HP *
* Creation Date : 13/04/2009 *
* *
* Description : ARCHIVIAZIONE SIH Log *
************************************************************************
REPORT ZDEL_SIH_LOG
NO STANDARD PAGE HEADING
LINE-SIZE 130
LINE-COUNT 65(0)
MESSAGE-ID zsih_msg_bc.
************************************************************************
* Tables declaration *
************************************************************************
TABLES: ZSIH_LOG.
************************************************************************
* Selection-screen
************************************************************************
*selection-screen BEGIN OF block block1 WITH frame title text-001.
*
*PARAMETER: testrun LIKE rfpdo-f040test DEFAULT ' '.
*
*SELECTION-SCREEN END OF BLOCK block1.
************************************************************************
* Global data definition
************************************************************************
data: ref_log type REF TO ZSIH_LOG_PRO.
*----------------------------------------------------------------------*
START-OF-SELECTION.
*----------------------------------------------------------------------*
* Create log object
create object ref_log
EXPORTING TYPE = 'D'.
write: / 'Start deletion!'.
* Delete archive
call method ref_log->DEL_FILE.************************************************************************
* Program Name : ZARCH_SIH_LOG *
* *
* Programmer : Bob.Xu @ HP *
* Creation Date : 13/04/2009 *
* *
* Description : ARCHIVIAZIONE SIH Log *
************************************************************************
REPORT ZARCH_SIH_LOG
NO STANDARD PAGE HEADING
LINE-SIZE 130
LINE-COUNT 65(0)
MESSAGE-ID zsih_msg_bc.
************************************************************************
* Tables declaration *
************************************************************************
TABLES: ZSIH_LOG.
************************************************************************
* Selection-screen
************************************************************************
SELECTION-SCREEN BEGIN OF BLOCK block1 WITH FRAME TITLE text-001.
*SELECTION-SCREEN BEGIN OF LINE.
* SELECTION-SCREEN COMMENT 1(31) text-002.
* PARAMETER day(3) type N OBLIGATORY.
* SELECTION-SCREEN COMMENT 40(5) text-003.
*selection-screen end of LINE.
SELECTION-SCREEN SKIP.
SELECT-OPTIONS:
s_prog for ZSIH_LOG-ZPROGRAM,
s_tod for ZSIH_LOG-ZTCODE,
s_date for ZSIH_LOG-ZDATE,
s_usr for ZSIH_LOG-ZUSER,
s_typ for ZSIH_LOG-ZTYPE.
PARAMETER: admi_rem LIKE admi_run-comments.
PARAMETER: testrun LIKE rfpdo-f040test DEFAULT 'X'.
SELECTION-SCREEN END OF BLOCK block1.
************************************************************************
* Global data definition
************************************************************************
data:
ret like sy-subrc,
ref_log type REF TO ZSIH_LOG_PRO.
data:
prog type ztrange,tod type ztrange,zdate type ztrange,
usr type ztrange,typ type ztrange.
*----------------------------------------------------------------------*
START-OF-SELECTION.
*----------------------------------------------------------------------*
* Create log object
create object ref_log
EXPORTING TYPE = 'A' TEST = testrun REM = admi_rem.
* Archive
prog[] = s_prog[].
tod[] = s_tod[].
zdate[] = s_date[].
usr[] = s_usr[].
typ[] = s_typ[].
ret = ref_log->ARCHIVE(
IM_PROG = prog
IM_TOD = tod
IM_DATE = zdate
IM_USR = usr
IM_TYP = typ
).
if ret = 0.
write: / 'Write completed!'.
else.
write: / 'Write error!'.
message e002.
endif.class ZSIH_LOG_PRO definition
public
final
create public .
*"* public components of class ZSIH_LOG_PRO
*"* do not include other source files here!!!
public section.
types:
BEGIN OF ty_tab.
INCLUDE TYPE zsih_log.
* TYPES:rowcolor(4) TYPE c.
* TYPES:cellcolor TYPE lvc_t_scol.
TYPES:excp(1) TYPE c.
TYPES:END OF ty_tab .
data:
ALV_TAB type table of TY_TAB .
methods CONSTRUCTOR
importing
value(TYPE) type C optional
value(TEST) type C optional
value(REM) type ADMI_TEXT optional .
methods ARCHIVE
importing
!IM_PROG type ZTRANGE
!IM_TOD type ZTRANGE
!IM_DATE type ZTRANGE
!IM_USR type ZTRANGE
!IM_TYP type ZTRANGE
!IM_DAY type BAPI_JBD_DTE_STITEL optional
returning
value(SUBR) like SY-SUBRC .
methods DEL_FILE .
methods RIC_ARCH .
class-methods INSERT_LOG
importing
!IM_TLOG type ZTLOG
!IM_PROG type PROGNAME
returning
value(RET) like SY-SUBRC .
methods DISPLAY_LOG
importing
!IM_PROG type ZTRANGE optional
!IM_TOD type ZTRANGE optional
!IM_DATE type ZTRANGE optional
!IM_USR type ZTRANGE optional
!IM_TYP type ZTRANGE optional
changing
!IM_CONTAINER type ref to CL_GUI_CUSTOM_CONTAINER .*"* protected components of class ZSIH_LOG_PRO
*"* do not include other source files here!!!
protected section.*"* private components of class ZSIH_LOG_PRO
*"* do not include other source files here!!!
private section.
data ARCH_OBJECT type OBJCT_TR01 .
data ARCH_TYP type C .
data ARCH_TEST type C .
data ARCH_REM type ADMI_TEXT .
data ARCHIVE_HANDLE type INT4 .
data ARCHIVE_NAME type ARKEY .
data TB_LOG type ZT_SIHLOG .
data ARCHIVE_FLAGS type ARC_BUFFER-FLAGS .
data ALV_LAYOUT type LVC_S_LAYO .
data ALV_FIELDCAT type LVC_T_FCAT .
data REF_ALV type ref to CL_GUI_ALV_GRID .
data REF_DTL type ref to CL_GUI_ALV_GRID .
data DET_LAY type LVC_S_LAYO .
data DET_FIELD type LVC_T_FCAT .
data REF_SPLIT type ref to CL_GUI_EASY_SPLITTER_CONTAINER .
data ALV_CON type ref to CL_GUI_CONTAINER .
data DET_CON type ref to CL_GUI_CONTAINER .
data SPLIT_CON type ref to CL_GUI_CUSTOM_CONTAINER .
data SPLIT_FLAG type C .
methods OPEN_OBJ .
methods SELECT_DATA
importing
!IM_PROG type ZTRANGE optional
!IM_TOD type ZTRANGE optional
!IM_DATE type ZTRANGE optional
!IM_USR type ZTRANGE optional
!IM_TYP type ZTRANGE optional
returning
value(SUBR) like SY-SUBRC .
methods ARCH_OBJ .
methods ARCH_STATUS .
methods PREPARE_LAYOUT
importing
value(DETAIL_FLAG) type C optional .
methods PREPARE_FIELDCAT
importing
value(DETAIL_FLAG) type C optional .
methods SHOW_ALV
importing
!CONTAINER type ref to CL_GUI_CONTAINER .
methods HANDLE_DOUBLE_CLICK
for event DOUBLE_CLICK of CL_GUI_ALV_GRID
importing
!E_ROW .
methods SHOW_DETAIL
importing
!IM_CON type ref to CL_GUI_CONTAINER
!E_ROW type LVC_S_ROW .*"* local class implementation for public class
*"* use this source file for the implementation part of
*"* local helper classes*"* use this source file for any type declarations (class
*"* definitions, interfaces or data types) you need for method
*"* implementation or private method's signature*"* use this source file for any macro definitions you need
*"* in the implementation part of the classmethod ARCHIVE.
* Local data definition
data: wa type zsih_log.
* Open Object
call METHOD me->open_obj.
* Getting data
subr = SELECT_DATA( im_prog = im_prog
im_tod = im_tod im_date = im_date im_usr = im_usr im_typ = im_typ ).
check subr = 0.
* Archive processing
call method me->ARCH_OBJ.
endmethod.method ARCH_OBJ.
* Local data definition
data: wa type zsih_log.
* Open archive
CALL FUNCTION 'ARCHIVE_OPEN_FOR_WRITE'
EXPORTING
call_delete_job_in_test_mode = space
* create_archive_file = v_wriprd
object = 'ZSIH_LOG'
IMPORTING
archive_handle = archive_handle.
loop at tb_log into wa.
* Create new archive
CALL FUNCTION 'ARCHIVE_NEW_OBJECT'
EXPORTING archive_handle = archive_handle.
* Put record to archive
CALL FUNCTION 'ARCHIVE_PUT_RECORD'
EXPORTING
archive_handle = archive_handle
record_flags = ARCHIVE_FLAGS
record_structure = 'ZSIH_LOG'
record = WA.
* Save archive object
CALL FUNCTION 'ARCHIVE_SAVE_OBJECT'
EXPORTING archive_handle = archive_handle.
endloop.
* Update status
CALL FUNCTION 'ARCHIVE_WRITE_STATISTICS'
EXPORTING
archive_handle = archive_handle.
* Close file
CALL FUNCTION 'ARCHIVE_CLOSE_FILE'
EXPORTING
archive_handle = archive_handle.
endmethod.method ARCH_STATUS.
* Write archive status
CALL FUNCTION 'ARCHIVE_WRITE_STATISTICS'
EXPORTING
archive_handle = archive_handle
EXCEPTIONS
internal_error = 1
OTHERS = 2
.
* Close archive file
CALL FUNCTION 'ARCHIVE_CLOSE_FILE'
EXPORTING
archive_handle = archive_handle.
endmethod.method CONSTRUCTOR.
me->arch_typ = type.
me->arch_test = test.
me->arch_object = 'ZSIH_LOG'.
me->arch_rem = rem.
endmethod.method DEL_FILE.
* Local data definition
DATA: str_name type RKZ_DBNA,
str_wa(10092) TYPE c,
str_flags type CHAR08,
cnt_commit TYPE i,
max_commit TYPE i,
cnt_log TYPE i.
data: wa type zsih_log.
* Archive open for deletion
CALL FUNCTION 'ARCHIVE_OPEN_FOR_DELETE'
EXPORTING object = arch_object
test_mode = arch_test
IMPORTING archive_handle = archive_handle
EXCEPTIONS no_files_available = 01.
IF sy-subrc <> 0.
MESSAGE e003(zsih_msg_bc).
ENDIF.
* Get archive information
CALL FUNCTION 'ARCHIVE_GET_INFORMATION'
EXPORTING archive_handle = archive_handle
IMPORTING archive_name = archive_name.
* Get customize data
CALL FUNCTION 'ARCHIVE_GET_CUSTOMIZING_DATA'
EXPORTING object = arch_object
IMPORTING commit_count_for_delete_prg = max_commit.
DO.
CALL FUNCTION 'ARCHIVE_GET_NEXT_OBJECT'
EXPORTING archive_handle = archive_handle
EXCEPTIONS end_of_file = 01.
IF sy-subrc <> 0.
EXIT.
ENDIF.
DO.
CALL FUNCTION 'ARCHIVE_GET_NEXT_RECORD'
EXPORTING archive_handle = archive_handle
IMPORTING record_structure = str_name
record_flags = str_flags
record = str_wa
EXCEPTIONS end_of_object = 01.
IF sy-subrc <> 0.
EXIT.
ENDIF.
add 1 to cnt_log.
add 1 to cnt_commit.
class CL_ABAP_CONTAINER_UTILITIES definition load.
call method cl_abap_container_utilities=>read_container_c
exporting IM_CONTAINER = str_wa
importing EX_VALUE = wa
exceptions ILLEGAL_PARAMETER_TYPE = 1
others = 2.
IF str_flags = archive_flags.
call method cl_abap_container_utilities=>read_container_c
exporting IM_CONTAINER = str_wa
importing EX_VALUE = wa
exceptions ILLEGAL_PARAMETER_TYPE = 1
others = 2.
IF arch_test IS INITIAL.
delete zsih_log from wa.
endif.
endif.
enddo.
* Check if not test run
IF arch_test IS INITIAL.
CALL FUNCTION 'ARCHIVE_DELETE_OBJECT_DATA'
EXPORTING archive_handle = archive_handle.
ENDIF.
enddo.
* Close archive file
CALL FUNCTION 'ARCHIVE_CLOSE_FILE'
EXPORTING
archive_handle = archive_handle.
endmethod.method DISPLAY_LOG.
* local data definition
data: wa type ty_tab.
data: log type ref to ty_tab.
* Selection data
SELECT_DATA( im_prog = im_prog
im_tod = im_tod im_date = im_date im_usr = im_usr im_typ = im_typ ).
check tb_log[] is not INITIAL.
loop at tb_log into wa.
* Edit data
append wa to alv_tab.
endloop.
* Edit the record
loop at alv_tab REFERENCE INTO log.
case log->ZTYPE.
when 'E'.
log->excp = 1.
when 'S'.
log->excp = 3.
when 'W'.
log->excp = 2.
ENDCASE.
endloop.
* Prepare layout
call method prepare_layout.
* Prepare fieldcat
call method prepare_fieldcat.
* Show data
call method show_alv EXPORTING container = im_container.
* Get original split container
split_con = im_container.
endmethod.method HANDLE_DOUBLE_CLICK.
if split_flag is INITIAL.
* Free over all alv object
call method ref_alv->free.
* Create splitter
CREATE OBJECT ref_split EXPORTING
parent = split_con orientation = 0 SASH_POSITION = 80.
* Get the separated control
alv_con = ref_split->top_left_container.
det_con = ref_split->bottom_right_container.
* Show data
call method show_alv EXPORTING container = alv_con.
* Add detail alv layout and fieldcat
call method prepare_layout EXPORTING detail_flag = 'X'.
call method prepare_fieldcat EXPORTING detail_flag = 'X'.
* Show detail
call method show_detail EXPORTING im_con = det_con e_row = e_row.
CALL METHOD cl_gui_cfw=>flush
EXCEPTIONS cntl_system_error = 1
cntl_error = 2.
IF sy-subrc <> 0.
* error handling
ENDIF.
split_flag = 'X'.
else.
if ref_dtl is not INITIAL.
call method ref_dtl->free.
endif.
* Show detail
call method show_detail EXPORTING im_con = det_con e_row = e_row.
endif.
endmethod.method INSERT_LOG.
* Lock log table
CALL FUNCTION 'ENQUEUE_EZSIH_LOG'
EXPORTING
MODE_ZSIH_LOG = 'X'
MANDT = SY-MANDT
ZPROGRAM = im_prog
EXCEPTIONS
FOREIGN_LOCK = 1
SYSTEM_FAILURE = 2
OTHERS = 3
.
if sy-subrc <> 0.
ret = 1. " Lock failed
endif.
check ret = 0.
* Check log record
if im_tlog[] is INITIAL.
ret = 2. " No log record
* Dequeue lock object
CALL FUNCTION 'DEQUEUE_EZSIH_LOG'
EXPORTING
MODE_ZSIH_LOG = 'X'
MANDT = SY-MANDT
ZPROGRAM = im_prog
.
endif.
check ret = 0.
* Insert log record
insert zsih_log from table im_tlog ACCEPTING DUPLICATE KEYS.
if sy-subrc <> 0.
ret = 3. " Insert record failed
* Dequeue lock object
CALL FUNCTION 'DEQUEUE_EZSIH_LOG'
EXPORTING
MODE_ZSIH_LOG = 'X'
MANDT = SY-MANDT
ZPROGRAM = im_prog
.
ROLLBACK WORK.
endif.
check ret = 0.
* Commit work
commit WORK and WAIT.
* Dequeue lock object
CALL FUNCTION 'DEQUEUE_EZSIH_LOG'
EXPORTING
MODE_ZSIH_LOG = 'X'
MANDT = SY-MANDT
ZPROGRAM = im_prog
.
endmethod.method OPEN_OBJ.
* Data definition
data: x_echtl TYPE c.
* Processing archive with test
IF arch_test IS INITIAL.
x_echtl = 'X'.
ENDIF.
* Open archive object for write
CALL FUNCTION 'ARCHIVE_OPEN_FOR_WRITE'
EXPORTING
object = arch_object
create_archive_file = x_echtl
call_delete_job_in_test_mode = space
comments = arch_rem
IMPORTING
archive_handle = archive_handle.
* Get archive information
CALL FUNCTION 'ARCHIVE_GET_INFORMATION'
EXPORTING
archive_handle = archive_handle
IMPORTING
archive_name = archive_name.
endmethod.method PREPARE_FIELDCAT.
* Local data definition
data: ref_field TYPE ref to lvc_s_fcat.
data: sfat type lvc_s_fcat.
if detail_flag is INITIAL.
* Get table reference
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = 'ZSIH_LOG'
CHANGING
ct_fieldcat = alv_fieldcat
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
* Edit fieldcat
loop at alv_fieldcat REFERENCE INTO ref_field.
CASE ref_field->fieldname.
when 'ZMESSAGE1' or 'ZMESSAGE2' or 'ZMESSAGE3' or 'ZMESSAGE4' or 'ZMESSAGE5'
or 'ZMESSAGE6' or 'ZMESSAGE7' or 'ZMESSAGE8' or 'ZMESSAGE9' or 'ZINDEX'.
ref_field->NO_OUT = 'X'.
when 'ZTYPE'.
ref_field->outputlen = 10.
when 'ZUSER'.
ref_field->outputlen = 19.
when ''.
endcase.
endloop.
else.
sfat-fieldname = 'STR'.
sfat-SELTEXT = text-002.
sfat-SCRTEXT_L = text-002.
sfat-SCRTEXT_M = text-002.
sfat-outputlen = 112.
append sfat to det_field.
endif.
endmethod.method PREPARE_LAYOUT.
* Edit layout
if detail_flag is INITIAL.
alv_layout-grid_title = text-001.
alv_layout-excp_fname ='EXCP' .
else.
det_lay-NO_TOOLBAR = 'X'.
det_lay-excp_fname ='EXP' .
det_lay-EXCP_LED = 'X'.
endif.
endmethod.method RIC_ARCH.
* Local data definition
data:
archive_write_handle LIKE sy-tabix,
archive_read_handle LIKE sy-tabix,
archive_release type SYSAPRL,
str_name type RKZ_DBNA,
str_wa(10092) TYPE c,
str_flags type CHAR08,
str_len TYPE i,
cnt_log type i,
cnt_commit TYPE i,
max_commit TYPE i value 5000.
data: wa type zsih_log.
FIELD-SYMBOLS: <s> type any, <t> type any.
* Do transformation, separated with unicode and un-unicode
DEFINE transform.
if archive_release < '21A'.
assign str_wa(str_len) to <s>.
clear &1.
assign &1(str_len) to <t>.
<t> = <s>.
else.
call method cl_abap_container_utilities=>read_container_c
exporting IM_CONTAINER = str_wa
importing EX_VALUE = &1
exceptions ILLEGAL_PARAMETER_TYPE = 1
others = 2.
endif.
END-OF-DEFINITION.
* Open archive for move
CALL FUNCTION 'ARCHIVE_OPEN_FOR_MOVE'
EXPORTING object = arch_object
test_mode = arch_test
IMPORTING archive_read_handle = archive_read_handle
archive_write_handle = archive_write_handle.
* Get archive information
CALL FUNCTION 'ARCHIVE_GET_INFORMATION'
EXPORTING archive_handle = archive_read_handle
IMPORTING archive_creation_release = archive_release
archive_name = archive_name.
* Processing
DO.
CALL FUNCTION 'ARCHIVE_GET_NEXT_OBJECT'
EXPORTING archive_handle = archive_read_handle
EXCEPTIONS end_of_file = 01.
IF sy-subrc <> 0.
EXIT.
ENDIF.
* Get and restore
do.
CALL FUNCTION 'ARCHIVE_GET_NEXT_RECORD'
EXPORTING archive_handle = archive_read_handle
IMPORTING record_structure = str_name
record_length = str_len
record = str_wa
EXCEPTIONS end_of_object = 01.
IF sy-subrc <> 0.
EXIT.
ENDIF.
ADD 1 TO cnt_log.
add 1 to cnt_commit.
transform wa.
IF arch_test IS INITIAL.
insert zsih_log from wa.
IF cnt_commit >= max_commit.
commit work.
cnt_commit = 0.
endif.
endif.
CLEAR wa.
enddo.
IF arch_test IS INITIAL.
* Reload object
CALL FUNCTION 'ARCHIVE_RELOAD_OBJECT_DATA'
EXPORTING archive_handle = archive_read_handle
EXCEPTIONS wrong_access_to_archive = 01.
* Save object
CALL FUNCTION 'ARCHIVE_SAVE_OBJECT'
EXPORTING archive_handle = archive_write_handle.
ENDIF.
ENDDO.
endmethod.method SELECT_DATA.
* Selection data
select * from zsih_log
into CORRESPONDING FIELDS OF TABLE me->tb_log
where ZPROGRAM in im_prog
and ZTCODE in im_tod
and ZDATE in im_date
and ZUSER in im_usr
and ZTYPE in im_typ.
endmethod.method SHOW_ALV.
* Create ALV object
CREATE OBJECT ref_alv
EXPORTING i_parent = container.
SET HANDLER handle_double_click FOR ref_alv.
* Set data display
call method ref_alv->set_table_for_first_display
EXPORTING
is_layout = alv_layout
CHANGING
it_outtab = alv_tab
it_fieldcatalog = alv_fieldcat
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4.
endmethod.method SHOW_DETAIL.
* Local data definition
data: begin of tab ,
str(255) type c,
exp(1) type c,
end of tab.
data: rtab like tab,itab like TABLE OF tab.
data: wa type zsih_log.
FIELD-SYMBOLS: <fs> type any.
data: ls(30) type c, ls1(2) type c.
* Create detail ALV list
CREATE OBJECT ref_dtl EXPORTING i_parent = im_con.
* Get selected data
read table tb_log index e_row-INDEX into wa.
if sy-subrc = 0.
* Edit error data
do 9 times.
ls1 = sy-index.
CONCATENATE 'WA-ZMESSAGE' ls1 into ls.
assign (LS) to <fs>.
if <fs> is not INITIAL.
if <fs>+0(1) = '#'.
case <fs>+1(1).
when 'S'.
rtab-exp = '3'.
when 'E'.
rtab-exp = '1'.
when 'W'.
rtab-exp = '2'.
endcase.
clear: <fs>+0(2).
else.
rtab-exp = '1'.
endif.
rtab-str = <fs>.
append rtab to itab.
endif.
enddo.
endif.
* Display detail data
call method ref_dtl->set_table_for_first_display
EXPORTING
is_layout = det_lay
CHANGING
it_outtab = itab
it_fieldcatalog = det_field
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4.
endmethod.************************************************************************
* Program Name : ZARCH_SIH_LOG *
* *
* Programmer : Bob.Xu @ HP *
* Creation Date : 13/04/2009 *
* *
* Description : ARCHIVIAZIONE SIH Log *
************************************************************************
REPORT ZARCH_SIH_LOG
NO STANDARD PAGE HEADING
LINE-SIZE 130
LINE-COUNT 65(0)
MESSAGE-ID zsih_msg_bc.
************************************************************************
* Tables declaration *
************************************************************************
TABLES: ZSIH_LOG.
************************************************************************
* Selection-screen
************************************************************************
SELECTION-SCREEN BEGIN OF BLOCK block1 WITH FRAME TITLE text-001.
*SELECTION-SCREEN BEGIN OF LINE.
* SELECTION-SCREEN COMMENT 1(31) text-002.
* PARAMETER day(3) type N OBLIGATORY.
* SELECTION-SCREEN COMMENT 40(5) text-003.
*selection-screen end of LINE.
SELECTION-SCREEN SKIP.
SELECT-OPTIONS:
s_prog for ZSIH_LOG-ZPROGRAM,
s_tod for ZSIH_LOG-ZTCODE,
s_date for ZSIH_LOG-ZDATE,
s_usr for ZSIH_LOG-ZUSER,
s_typ for ZSIH_LOG-ZTYPE.
PARAMETER: admi_rem LIKE admi_run-comments.
PARAMETER: testrun LIKE rfpdo-f040test DEFAULT 'X'.
SELECTION-SCREEN END OF BLOCK block1.
************************************************************************
* Global data definition
************************************************************************
data:
ret like sy-subrc,
ref_log type REF TO ZSIH_LOG_PRO.
data:
prog type ztrange,tod type ztrange,zdate type ztrange,
usr type ztrange,typ type ztrange.
*----------------------------------------------------------------------*
START-OF-SELECTION.
*----------------------------------------------------------------------*
* Create log object
create object ref_log
EXPORTING TYPE = 'A' TEST = testrun REM = admi_rem.
* Archive
prog[] = s_prog[].
tod[] = s_tod[].
zdate[] = s_date[].
usr[] = s_usr[].
typ[] = s_typ[].
ret = ref_log->ARCHIVE(
IM_PROG = prog
IM_TOD = tod
IM_DATE = zdate
IM_USR = usr
IM_TYP = typ
).
if ret = 0.
write: / 'Write completed!'.
else.
write: / 'Write error!'.
message e002.
endif.************************************************************************
* Program Name : ZDEL_SIH_LOG *
* *
* Programmer : Bob.Xu @ HP *
* Creation Date : 13/04/2009 *
* *
* Description : ARCHIVIAZIONE SIH Log *
************************************************************************
REPORT ZDEL_SIH_LOG
NO STANDARD PAGE HEADING
LINE-SIZE 130
LINE-COUNT 65(0)
MESSAGE-ID zsih_msg_bc.
************************************************************************
* Tables declaration *
************************************************************************
TABLES: ZSIH_LOG.
************************************************************************
* Selection-screen
************************************************************************
*selection-screen BEGIN OF block block1 WITH frame title text-001.
*
*PARAMETER: testrun LIKE rfpdo-f040test DEFAULT ' '.
*
*SELECTION-SCREEN END OF BLOCK block1.
************************************************************************
* Global data definition
************************************************************************
data: ref_log type REF TO ZSIH_LOG_PRO.
*----------------------------------------------------------------------*
START-OF-SELECTION.
*----------------------------------------------------------------------*
* Create log object
create object ref_log
EXPORTING TYPE = 'D'.
write: / 'Start deletion!'.
* Delete archive
call method ref_log->DEL_FILE.************************************************************************
* Program Name : ZRIC_SIH_LOG *
* *
* Programmer : Bob.Xu @ HP *
* Creation Date : 13/04/2009 *
* *
* Description : ARCHIVIAZIONE SIH Log *
************************************************************************
REPORT ZRIC_SIH_LOG
NO STANDARD PAGE HEADING
LINE-SIZE 130
LINE-COUNT 65(0)
MESSAGE-ID zsih_msg_bc.
************************************************************************
* Tables declaration *
************************************************************************
TABLES: ZSIH_LOG.
************************************************************************
* Selection-screen
************************************************************************
SELECTION-SCREEN BEGIN OF BLOCK block1 WITH FRAME TITLE text-021.
PARAMETERS: testrun LIKE rfpdo-f040test DEFAULT 'X'.
SELECTION-SCREEN END OF BLOCK block1.
************************************************************************
* Global data definition
************************************************************************
data: ref_log type REF TO ZSIH_LOG_PRO.
*----------------------------------------------------------------------*
START-OF-SELECTION.
*----------------------------------------------------------------------*
* Create log object
create object ref_log
EXPORTING TYPE = 'R' TEST = testrun.
* Reload
call method ref_log->ric_arch.PROCESS BEFORE OUTPUT.
MODULE STATUS_9000.
*
PROCESS AFTER INPUT.
MODULE USER_COMMAND_9000.* Program ID/Name: ZSIH_BC_LOG_DISPLAY Date written: 20090414
* Author's name: Bob.Xu@HP Last update: 20090414
* Program title: SIH log display
* Project Name: SIH
* Version: Initial Version
* Function Spec ID:
* Analyst:
*----------------------------------------------------------------------*
* Description: (Incl. Related Function Area and System)
*
*----------------------------------------------------------------------*
* Calls: (RFC and BPI)
*
*----------------------------------------------------------------------*
* Function Modules:
*
*----------------------------------------------------------------------*
* Table:
*
*----------------------------------------------------------------------*
* Result:
*
*---------------------------------------------------------------------*
* Change History
*----------------------------------------------------------------------*
* Date | Programmer | Corr. # | Description
* | | |
* | | |
************************************************************************
REPORT ZSIH_BC_LOG_DISPLAY.
************************************************************************
* Tables declaration *
************************************************************************
TABLES: ZSIH_LOG.
************************************************************************
* Global data definition
************************************************************************
data:
ref type ref to ZSIH_LOG_PRO, " Log processing object
save_ok LIKE sy-ucomm, " Screen command
ok_code LIKE sy-ucomm. " Screen command
* Container
DATA ref_con TYPE REF TO cl_gui_custom_container .
* Screen init flag
data init.
data:
prog type ztrange,tod type ztrange,zdate type ztrange,
usr type ztrange,typ type ztrange.
************************************************************************
* Selection-screen
************************************************************************
SELECTION-SCREEN BEGIN OF BLOCK block1 WITH FRAME TITLE text-001.
SELECT-OPTIONS:
s_prog for ZSIH_LOG-ZPROGRAM,
s_tod for ZSIH_LOG-ZTCODE,
s_date for ZSIH_LOG-ZDATE,
s_usr for ZSIH_LOG-ZUSER,
s_typ for ZSIH_LOG-ZTYPE.
SELECTION-SCREEN END OF BLOCK block1.
*----------------------------------------------------------------------
START-OF-SELECTION.
*----------------------------------------------------------------------
prog[] = s_prog[].
tod[] = s_tod[].
zdate[] = s_date[].
usr[] = s_usr[].
typ[] = s_typ[].
* Goto the main screen
call screen 9000.
*&---------------------------------------------------------------------*
*& Module STATUS_9000 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
module STATUS_9000 output.
* Set status and title
SET PF-STATUS 'STAT'.
set TITLEBAR 'TIT'.
* Display with ALV
PERFORM frm_display_alv.
endmodule. " STATUS_9000 OUTPUT
*&---------------------------------------------------------------------*
*& Form frm_display_alv
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form frm_display_alv .
*-->Create customer container
if init is INITIAL.
CREATE OBJECT ref_con
EXPORTING
container_name = 'ALV_CON'.
create object ref.
* Show log
call method ref->DISPLAY_LOG
EXPORTING
IM_PROG = prog
IM_TOD = tod
IM_DATE = zdate
IM_USR = usr
IM_TYP = typ
CHANGING
im_container = ref_con .
init = 'X'.
endif.
endform. " frm_display_alv
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_9000 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
module USER_COMMAND_9000 input.
* Exit command processing
save_ok = ok_code.
CASE save_ok.
WHEN 'BACK' OR 'EXIT' OR 'CANC'.
LEAVE to SCREEN 0.
endcase.
endmodule. " USER_COMMAND_9000 INPUT