ZLOGLO99TOP
ZLOGLO99TOP
ZLOGLO99TOP
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*&- Includes
INCLUDE zimacros.
*&---------------------------------------------------------------------*
*&- Estruturas
TABLES: ekko, zlog_trnsf_merc, sscrfields, zlog_xml_ag.
*&---------------------------------------------------------------------*
*&- Constantes
CONSTANTS c_dir_request_xml TYPE filename-fileintern VALUE 'ZNFE_ENTRADA'.
CONSTANTS c_dir_response_xml TYPE filename-fileintern VALUE 'ZNFE_SAIDA'.
CONSTANTS c_job TYPE btcjob VALUE 'LO_I_PROC_BOL_AG_150'.
CONSTANTS c_secao TYPE char10 VALUE 'LO_AG_150 '.
CONSTANTS c_docmat TYPE j_1breftyp VALUE 'MD'.
CONSTANTS c_header TYPE char1 VALUE '1'.
CONSTANTS c_detail TYPE char1 VALUE '2'.
CONSTANTS c_segundos TYPE i VALUE 15.
CONSTANTS c_separator TYPE i VALUE 3.
CONSTANTS c_button_normal TYPE i VALUE 0.
*&---------------------------------------------------------------------*
*&- Tipos
TYPE-POOLS: slis, rmdi, icon, abap.
TYPES:
BEGIN OF y_saida,
werks TYPE werks,
ebeln TYPE ebeln,
matnr TYPE matnr,
dt_ini TYPE sydatum,
dt_fim TYPE sydatum,
qtd_ped TYPE bstmg,
qtd_dst TYPE bstmg,
st_proc TYPE z_sit_proc_it_ped_dep,
st_atd TYPE z_sit_atend_it_ped,
tx_proc TYPE rmdi_domvl-ddtext,
tx_atd TYPE rmdi_domvl-ddtext,
refkey TYPE j_1brefkey,
docnum TYPE j_1bdocnum,
nfenum TYPE j_1bnfnum9,
maktx TYPE maktx,
status TYPE char4,
acckey TYPE j_1b_nfe_access_key_dtel44,
mark TYPE char1,
baixado TYPE char4, "suhett
END OF y_saida,
ty_saida TYPE STANDARD TABLE OF y_saida,
BEGIN OF y_mat,
matnr TYPE mara-matnr,
maktx TYPE makt-maktx,
END OF y_mat,
ty_mat TYPE STANDARD TABLE OF y_mat,
BEGIN OF y_ekbe,
ebeln TYPE ebeln,
gjahr TYPE mjahr,
belnr TYPE mblnr,
END OF y_ekbe,
ty_ekbe TYPE STANDARD TABLE OF y_ekbe,
BEGIN OF y_nfdoc,
docnum TYPE j_1bdocnum,
nfenum TYPE j_1bnfnum9,
END OF y_nfdoc,
ty_nfdoc TYPE STANDARD TABLE OF y_nfdoc,
BEGIN OF y_nflin,
docnum TYPE j_1bdocnum,
maktx TYPE maktx,
refkey TYPE j_1brefkey,
END OF y_nflin,
ty_nflin TYPE STANDARD TABLE OF y_nflin,
BEGIN OF y_nfact,
docnum TYPE j_1bnfe_active-docnum,
code TYPE j_1bnfe_active-code,
regio TYPE j_1bnfe_active-regio,
nfyear TYPE j_1bnfe_active-nfyear,
nfmonth TYPE j_1bnfe_active-nfmonth,
stcd1 TYPE j_1bnfe_active-stcd1,
model TYPE j_1bnfe_active-model,
serie TYPE j_1bnfe_active-serie,
nfnum9 TYPE j_1bnfe_active-nfnum9,
docnum9 TYPE j_1bnfe_active-docnum9,
cdv TYPE j_1bnfe_active-cdv,
END OF y_nfact,
ty_nfact TYPE STANDARD TABLE OF y_nfact,
BEGIN OF y_nf,
docnum TYPE j_1bnfe_active-docnum,
nfenum TYPE j_1bnfnum9,
acckey TYPE j_1b_nfe_access_key_dtel44,
mark TYPE char1,
baixado TYPE char4, " suhett
END OF y_nf,
ty_nf TYPE STANDARD TABLE OF y_nf,
*&---------------------------------------------------------------------*
*&- OO
DATA obj_dcontainer TYPE REF TO cl_gui_docking_container.
DATA obj_balvgrid TYPE REF TO cl_gui_alv_grid.
*&---------------------------------------------------------------------*
*&- Variveis
DATA gt_detail TYPE ty_saida.
DATA gt_header TYPE ty_saida.
DATA gt_nfact TYPE ty_nfact.
DATA gt_nf TYPE ty_nf.
DATA gt_zlog_xml_ag TYPE ty_zlog_xml_ag. " Suhett
DATA gt_proc TYPE rmdi_domvl_t.
DATA gt_atd TYPE rmdi_domvl_t.
DATA gt_fcat_nf TYPE lvc_t_fcat.
DATA gs_domain TYPE rmdi_domvl.
DATA gs_header TYPE y_saida.
DATA g_dock_cons TYPE char1.
DATA g_txt TYPE tline-tdline.
DATA g_result TYPE abap_bool.
*&---------------------------------------------------------------------*
*&- Macros
DEFINE _read_status_proc.
read table gt_proc into gs_domain with key domvalue_l = &1.
if sy-subrc = 0.
&2 = gs_domain-ddtext.
endif.
END-OF-DEFINITION.
DEFINE _read_status_atd.
read table gt_atd into gs_atd with key domvalue_l = &1.
if sy-subrc = 0.
&2 = gs_atd-ddtext.
endif.
END-OF-DEFINITION.
DEFINE _clear_table.
clear &1.
refresh &1.
END-OF-DEFINITION.
DEFINE _select_dir.
call method cl_gui_frontend_services=>directory_browse
changing
selected_folder = &1
exceptions
cntl_error = 1
error_no_gui = 2
not_supported_by_gui = 3
others = 4.
if sy-subrc <> 0.
message e001 display like 'I' with 'Destino invlido!'.
exit.
endif.
if not &1 is initial.
concatenate &1 '\' into &1.
endif.
END-OF-DEFINITION.
DEFINE _inc.
&1 = &1 + 1.
END-OF-DEFINITION.
DEFINE _add_xml.
refresh &1.
append '<NeoGridConsultaSped compressed="false">' to &1.
append '<xServ>DOWNLOAD</xServ>' to &1.
append '<filtroDownload>' to &1.
append '<tipo>1</tipo>' to &1.
concatenate '<chave>' &2 '</chave>' into g_txt.
append g_txt to &1.
append '</filtroDownload>' to &1.
append '</NeoGridConsultaSped>' to &1.
END-OF-DEFINITION.
DEFINE _get_dir_request_xml.
clear &1.
* if sy-sysid = 'PRD'.
call function 'FILE_GET_NAME'
exporting
logical_filename = c_dir_request_xml
importing
file_name = &1
exceptions
file_not_found = 08.
* else.
* &1 = 'Y:\Request\'.
* &1 = '52.31.152.210\TESTE\RETRIEVENFE\REQUEST\'.
* endif.
dir_exist &1.
END-OF-DEFINITION.
DEFINE _get_dir_response_xml.
clear &1.
* if sy-sysid = 'PRD'.
call function 'FILE_GET_NAME'
exporting
logical_filename = c_dir_response_xml
importing
file_name = &1
exceptions
file_not_found = 08.
* else.
** &1 = 'Y:\Response\'.
* &1 = '52.31.152.210\TESTE\RETRIEVENFE\response\'.
* endif.
dir_exist &1.
END-OF-DEFINITION.
DEFINE _download_file.
call function 'GUI_DOWNLOAD'
exporting
filename = &2
tables
data_tab = &1
exceptions
others = 17.
END-OF-DEFINITION.
DEFINE _upload_file.
refresh &1.
call function 'GUI_UPLOAD'
exporting
filename = &2
tables
data_tab = &1
exceptions
others = 17.
END-OF-DEFINITION.
DEFINE _int_to_char.
write &1 to &2 left-justified.
END-OF-DEFINITION.
DEFINE dir_exist.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
elseif g_result = abap_false.
message e001 display like 'I' with 'Diretrio inexistente. Contacte o
suporte.'.
exit.
endif.
END-OF-DEFINITION.
*&---------------------------------------------------------------------*
*&- OO
CLASS cl_event DEFINITION DEFERRED.
*----------------------------------------------------------------------*
* CLASS cl_event DEFINITION
*----------------------------------------------------------------------*
CLASS cl_event DEFINITION.
PUBLIC SECTION.
CLASS-METHODS:
handle_toolbar
FOR EVENT toolbar OF cl_gui_alv_grid
IMPORTING e_object e_interactive,
handle_hotspot_click
FOR EVENT hotspot_click OF cl_gui_alv_grid
IMPORTING e_column_id es_row_no,
handle_user_command
FOR EVENT user_command OF cl_gui_alv_grid
IMPORTING e_ucomm.
PRIVATE SECTION.
*----------------------------------------------------------------------*
* CLASS cl_event IMPLEMENTATION
*----------------------------------------------------------------------*
CLASS cl_event IMPLEMENTATION.
METHOD handle_toolbar.
DATA ls_toolbar TYPE stb_button.
CLEAR ls_toolbar.
MOVE 'XML' TO ls_toolbar-function.
MOVE icon_xml_doc TO ls_toolbar-icon.
MOVE ' Download do XML' TO ls_toolbar-text.
MOVE 'Download do XML' TO ls_toolbar-quickinfo.
MOVE c_button_normal TO ls_toolbar-butn_type.
MOVE space TO ls_toolbar-disabled.
APPEND ls_toolbar TO e_object->mt_toolbar.
CLEAR ls_toolbar.
MOVE 'CLOSE' TO ls_toolbar-function.
MOVE 'Fechar Janela' TO ls_toolbar-quickinfo.
MOVE c_button_normal TO ls_toolbar-butn_type.
MOVE space TO ls_toolbar-disabled.
MOVE 'Fechar' TO ls_toolbar-text.
APPEND ls_toolbar TO e_object->mt_toolbar.
ENDMETHOD. "handle_toolbar
METHOD handle_hotspot_click.
FIELD-SYMBOLS <fs> TYPE y_nf.
ENDMETHOD. "handle_hotspot_click
METHOD handle_user_command.
CASE e_ucomm.
WHEN 'XML'.
PERFORM download_xml TABLES gt_nf USING gs_header.
PERFORM busca_baixados TABLES gt_header gt_detail.
PERFORM refresh_alv.
WHEN 'CLOSE'.
PERFORM close_alv_oo CHANGING g_dock_cons.
ENDCASE.
CLEAR e_ucomm.
ENDMETHOD. "handle_user_command