on 09-23-2015 1:38 PM
Pessoal,
Alguém sabe como localizar via tabela ou por outro meio, os motivos de que as notas ficam paradas no monitor fiscal?
Tenho, por exemplo, 100 notas paradas no step "simulação da NF-e", que se divide em "n" motivos (ICMS/IPI/CNPJ/etc). Minha intenção é trazer num relatório/tabela a mensagem que hoje hoje só visualizo no monitor fiscal a clicar nota a nota.
Desta maneira consigo solicitar os diversos ajustes, por tipo de erro, e assim enviar ao responsável pelo ajuste. E não precisaria clicar documento por documento.
Rodrigo.
Rodrigo,
Primeiro você precisa ler a tabela /XNFE/INNFEHD e pegar o GUID da mensagem. Depois, vá na tabela /XNFE/INNFEHIST e para a etapa com problema, você vai achar o LOG_HANDLE.
Com o LOG_HANDLE, leia a tabela BALHDR onde você vai pegar o cabecalho do log (SLG1).
Com ele, você pode usar as funções BAL_DB_LOAD para carregar o log em memória e BAL_LOG_MSG_READ para ler o log.
Exemplo (código está tosco, mas é só um exemplo):
REPORT ZGET_LOG.
PARAMETERS: p_nfeid TYPE /xnfe/id.
DATA: lv_guid TYPE /xnfe/guid_16,
lv_handle TYPE BALLOGHNDL,
ls_balhdr TYPE balhdr,
lt_log_header TYPE balhdr_t,
lt_log_hdr TYPE BALHDR_T,
lt_log_handle TYPE BAL_T_LOGH,
lt_msg_handle TYPE BAL_T_MSGH,
ls_MSG_HANDLE TYPE BALMSGHNDL,
ls_msg TYPE BAL_S_MSG.
START-OF-SELECTION.
SELECT SINGLE guid_header
FROM /xnfe/innfehd
INTO lv_guid
WHERE nfeid = p_nfeid.
IF sy-subrc NE 0.
WRITE 'Erro ao selecionar INNFEHD.'.
EXIT.
ENDIF.
SELECT SINGLE log_handle
FROM /xnfe/innfhist
INTO lv_handle
WHERE guid_header = lv_guid AND
log_handle NE space.
IF sy-subrc NE 0.
WRITE 'Log handle não encontrado!'.
EXIT.
ENDIF.
SELECT SINGLE *
FROM balhdr
INTO ls_balhdr
WHERE log_handle = lv_handle.
IF sy-subrc NE 0.
WRITE 'Falha ao ler BALHDR'.
EXIT.
ENDIF.
APPEND ls_balhdr TO lt_log_header.
CALL FUNCTION 'BAL_DB_LOAD'
exporting
I_T_LOG_HEADER = lt_log_header
importing
E_T_LOG_HANDLE = lt_log_handle
E_T_MSG_HANDLE = lt_msg_handle
exceptions
NO_LOGS_SPECIFIED = 1
LOG_NOT_FOUND = 2
LOG_ALREADY_LOADED = 3
OTHERS = 4.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
LOOP AT lt_msg_handle INTO ls_msg_handle.
CALL FUNCTION 'BAL_LOG_MSG_READ'
exporting
I_S_MSG_HANDLE = ls_msg_handle
importing
E_S_MSG = ls_msg
exceptions
LOG_NOT_FOUND = 1
MSG_NOT_FOUND = 2
OTHERS = 3.
if sy-subrc EQ 0.
"Sua mensagem está na estrutura LS_MSG
endif.
ENDLOOP.
[]'s
JN
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
As duas propostas de atender a duvidas foram bem vindas e úteis para nossa empresa.
Esperamos que futuramente tenhamos via SP uma ferramenta/monitor que vise a gestão do processo.
Obrigado a todos.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Eu utilizo a função APPL_LOG_READ_DB basta passar o GUI para ela com um asterisco no parametro EXTERNAL_NUMBER (Ex.: 002655A9BF521ED3AEDED46670381D06*).
Fica mais simples por não precisar do log handle.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
14 | |
4 | |
2 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.