Recuperando texto da mensagem
lt_log = VALUE #( BASE lt_log
FOR ls_return IN lt_return
( ovret = lr_monfat->ovRet
fatret = lr_monfat->faturaRet
msgid = ls_return-id
msgty = ls_return-type
msgno = ls_return-number
message = cl_bs_soa_message_container=>get_msg_text( is_applmsg = VALUE #( type = ls_return-type
id = ls_return-id
number = ls_return-number
message_v1 = ls_return-message_v1
message_v2 = ls_return-message_v2
message_v3 = ls_return-message_v3
message_v4 = ls_return-message_v4
) ) ) ).
Cria LOG SLG1
METHOD set_log.
DATA lv_error_msg TYPE string.
CHECK it_return[] IS NOT INITIAL.
TRY.
" Create a new Application Log
DATA(lo_log) = cl_bali_log=>create( ).
" Add a header to the log
lo_log->set_header( header = cl_bali_header_setter=>create( object = c_log-object
subobject = c_log-subobject
external_id = CONV #( is_monfat-ovRet ) ) ).
LOOP AT it_return REFERENCE INTO DATA(lr_return).
"WHERE type = 'E'.
* rs_return = VALUE #( id = 'ZSD' type = 'E' number = '015' ).
" Add a message as item to the log
DATA(lo_message) = cl_bali_message_setter=>create( severity = lr_return->type "if_bali_constants=>c_severity_error
id = lr_return->id
number = lr_return->number
variable_1 = lr_return->message_v1
variable_2 = lr_return->message_v2
variable_3 = lr_return->message_v3
variable_4 = lr_return->message_v4
).
lo_log->add_item( item = lo_message ).
ENDLOOP.
" Save the log into the database
cl_bali_log_db=>get_instance( )->save_log( log = lo_log ).
CATCH cx_bali_not_possible INTO DATA(lx_not_possible).
lv_error_msg = lx_not_possible->get_text( ).
CATCH cx_bali_runtime INTO DATA(lx_runtime).
lv_error_msg = lx_runtime->get_text( ).
ENDTRY.
ENDMETHOD.
================
elimina log
METHOD delete_log.
TRY.
DATA(lo_filter) = cl_bali_log_filter=>create(
)->set_create_info( user = sy-uname
)->set_descriptor( object = c_log-object
subobject = c_log-subobject
external_id = CONV balnrext( iv_ordemvenda ) ).
DATA(lv_data_final) = utclong_current( ).
DATA(lv_data_inicio) = utclong_add( val = lv_data_final
days = '30-' ).
lo_filter->set_time_interval( start_time = lv_data_inicio
end_time = lv_data_final ).
lo_filter->set_maximum_log_number( max_log_number = 15 ).
DATA(lt_log_table) = cl_bali_log_db=>get_instance( )->load_logs_w_items_via_filter( filter = lo_filter ).
CATCH cx_bali_runtime INTO DATA(lx_exception). "##NEEDED
DATA(lv_error_msg) = lx_exception->get_text( ).
RETURN.
ENDTRY.
LOOP AT lt_log_table INTO DATA(lo_log).
cl_bali_log_db=>get_instance( )->delete_log( lo_log ).
ENDLOOP..
COMMIT WORK AND WAIT.
ENDMETHOD.
=========================
retorno de mensagem.
METHOD get_log.
DATA lv_cont TYPE n LENGTH 3.
TRY.
DATA(lo_filter) = cl_bali_log_filter=>create(
)->set_create_info( user = sy-uname
)->set_descriptor( object = c_log-object
subobject = c_log-subobject
external_id = CONV balnrext( iv_ordemvenda ) ).
DATA(lv_data_final) = utclong_current( ).
DATA(lv_data_inicio) = utclong_add( val = lv_data_final
days = '30-' ).
lo_filter->set_time_interval( start_time = lv_data_inicio
end_time = lv_data_final ).
lo_filter->set_maximum_log_number( max_log_number = 15 ).
DATA(lt_log_table) = cl_bali_log_db=>get_instance( )->load_logs_w_items_via_filter( filter = lo_filter ).
CATCH cx_bali_runtime INTO DATA(lx_exception). "##NEEDED
RETURN.
ENDTRY.
* sort lo_log_table by log_timestamp.
LOOP AT lt_log_table INTO DATA(lo_log). "#EC CI_NESTED
" Get log header and output attributes of the header
TRY.
DATA(lo_header) = lo_log->get_header( ).
ADD 1 TO lv_cont.
* APPEND INITIAL LINE TO rt_return ASSIGNING FIELD-SYMBOL(<lf_return>).
* <lf_return> = VALUE #( id = 'ZSD' type = 'E' number = '000'
* message_v1 = lv_cont "|{ lv_cont }- Data/hora log:|
* message_v2 = lo_header->log_timestamp
* message = |Data/hora log:| && ##NO_TEXT
* |{ lo_header->log_timestamp }| ).
" Get all items and output some data which exist in all item categories
DATA(lt_item_table) = lo_log->get_all_items( ).
LOOP AT lt_item_table INTO DATA(ls_item_entry). "#EC CI_NESTED
ADD 1 TO lv_cont.
" Output attributes which are specific for messages and exceptions
IF ls_item_entry-item->category = if_bali_constants=>c_category_message.
DATA(lo_message_ref) = CAST if_bali_message_getter( ls_item_entry-item ).
APPEND INITIAL LINE TO rt_return ASSIGNING FIELD-SYMBOL(<lf_return>).
<lf_return> = VALUE #( id = lo_message_ref->id
type = lo_message_ref->severity
number = lo_message_ref->number
message_v1 = lv_cont "lo_message_ref->variable_1
message_v2 = lo_message_ref->variable_2
message_v3 = lo_message_ref->variable_3
message_v4 = lo_message_ref->variable_4
* message = |{ lv_cont }- { lo_message_ref->get_message_text( ) }| ).
message = lo_message_ref->get_message_text( ) ).
ENDIF.
ENDLOOP.
SORT rt_return BY message_v1 DESCENDING. "#EC CI_SORTLOOP
CATCH cx_bali_runtime INTO DATA(lx_exc). "##NEEDED
DATA(lv_error_msg) = lx_exc->get_text( ).
ENDTRY.
ENDLOOP.
ENDMETHOD.
Nenhum comentário:
Postar um comentário