Created
August 13, 2019 14:54
-
-
Save antelio/f1aaa6347ffdded6b3cdc92321c28f59 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
*&---------------------------------------------------------------------* | |
*& Include ZXM08U16 | |
*&---------------------------------------------------------------------* | |
****************************************************** | |
* Validar se a Nota Fiscal foi preenchida corretamente | |
* | |
*DATA: nf(10) TYPE c, | |
* nf_out(7) TYPE c. | |
* | |
*nf = e_trbkpv-xblnr. | |
* | |
*CALL FUNCTION 'ZLW_CHECK_NF' | |
* EXPORTING | |
* nf = nf | |
* EXCEPTIONS | |
* invalid_format = 1 | |
* OTHERS = 2. | |
* | |
*IF sy-subrc IS NOT INITIAL. | |
* MESSAGE e021(zlw) WITH nf. | |
** Nota Fiscal (&) não informada ou formato inválido. Formato: 0000000 | |
*ENDIF. | |
* | |
* | |
************************* | |
** Tipos permitidos de Categoria de Nota Fiscal: | |
** EE - NF de Entrada para Estoque | |
** EC - NF de Entrada Conjugada (para Estoque + Serviço) | |
** ES - NF de Entrada de Serviço | |
** EL - NF de Entrada para NF Eletrônica do Munic. de SP | |
*IF e_trbkpv-j_1bnftype NE 'EE' AND | |
* e_trbkpv-j_1bnftype NE 'EC' AND | |
* e_trbkpv-j_1bnftype NE 'ES' AND | |
* e_trbkpv-j_1bnftype NE 'EL' AND | |
* e_trbkpv-blart EQ 'RE'. | |
* MESSAGE e016(zmm) WITH e_trbkpv-j_1bnftype. | |
** Categoria de Nota Fiscal (&) não é permitida. Use apenas EE,EC,ES ou EL. | |
*ENDIF. | |
* | |
* | |
*IF e_trbkpv-j_1bnftype EQ 'EE'. "Verifica se fornecedor pode usar NF de Entrada em Estoque | |
* PERFORM check_valid_ee | |
* TABLES e_trbkpv-h_rbws "Tabela de impostos | |
* USING e_trbkpv-j_1bnftype "Tipo de NF | |
* e_trbkpv-lifnr "Codigo do Fornecedor | |
* e_trbkpv-bukrs. "Empresa | |
* | |
*ELSEIF e_trbkpv-j_1bnftype EQ 'EC'. "Verif. se forn. pode usar NF Conjugada | |
* PERFORM check_valid_ec | |
* USING e_trbkpv-j_1bnftype "Tipo de NF | |
* e_trbkpv-lifnr "Codigo do Fornecedor | |
* e_trbkpv-bukrs. "Empresa | |
* | |
*ELSEIF e_trbkpv-j_1bnftype EQ 'ES'. "Verif. se forn. pode usar NF Servico | |
* PERFORM check_valid_es | |
* USING e_trbkpv-j_1bnftype "Tipo de NF | |
* e_trbkpv-lifnr "Codigo do Fornecedor | |
* e_trbkpv-bukrs. "Empresa | |
* | |
*ELSEIF e_trbkpv-j_1bnftype EQ 'EL'. "Vefir. se forn. pode usar NF Eletronica Munic. SP | |
* PERFORM check_valid_el | |
* USING e_trbkpv-j_1bnftype "Tipo de NF | |
* e_trbkpv-lifnr "Codigo do Fornecedor | |
* e_trbkpv-bukrs. "Empresa | |
*ENDIF. | |
* | |
* | |
*IF e_trbkpv-j_1bnftype EQ 'EC' OR | |
* e_trbkpv-j_1bnftype EQ 'ES'. | |
* | |
* DATA: g_typ_nf LIKE bseg-xref1, | |
* g_ser_nf LIKE bseg-xref2. | |
* | |
* IMPORT g_typ_nf FROM MEMORY ID 'Z_NF_TYPE'. | |
* IMPORT g_ser_nf FROM MEMORY ID 'Z_NF_SERIE'. | |
* | |
* DATA: t_values TYPE TABLE OF setvalues. | |
* CALL FUNCTION 'G_SET_TREE_IMPORT' | |
* EXPORTING | |
* setid = '0000TIPO_NF' | |
* TABLES | |
* set_values = t_values | |
* EXCEPTIONS | |
* set_not_found = 1 | |
* illegal_field_replacement = 2 | |
* illegal_table_replacement = 3 | |
* set_is_damaged = 4 | |
* OTHERS = 5. | |
* CHECK sy-subrc IS INITIAL. | |
* | |
* IF g_typ_nf IS INITIAL OR g_ser_nf IS INITIAL. | |
* MESSAGE e003(zlw). | |
** Tipo Nota Fiscal e Série são de Preenchimento Obrigatório | |
* ELSEIF g_typ_nf IS NOT INITIAL. | |
* | |
* READ TABLE t_values WITH KEY FROM = g_typ_nf TRANSPORTING NO FIELDS. | |
* IF sy-subrc IS NOT INITIAL. | |
* MESSAGE e019(zlw). | |
** Tipo Nota Fiscal e Série são de Preenchimento Obrigatório | |
* ENDIF. | |
* ENDIF. | |
*ENDIF. | |
* | |
*TYPE-POOLS: mmcr. | |
* | |
*DATA: tdrseg LIKE LINE OF e_tdrseg, | |
* bukrs TYPE bukrs. | |
* | |
*LOOP AT e_tdrseg INTO tdrseg. | |
* | |
* IF tdrseg-ebeln IS NOT INITIAL. | |
* SELECT SINGLE bukrs FROM ekko INTO bukrs | |
* WHERE ebeln = tdrseg-ebeln. | |
* | |
* CHECK sy-subrc IS INITIAL. | |
* IF bukrs NE e_trbkpv-bukrs. | |
* MESSAGE e033(zmm) WITH e_trbkpv-bukrs bukrs tdrseg-ebeln. | |
** A Empresa da Fatura & diverge da Empresa & do Pedido de Compra & | |
* ENDIF. | |
* | |
* ENDIF. | |
* | |
* | |
*ENDLOOP. | |
* Check BLDAT vs BUDAT | |
* BUDAT = Post Date | |
* BLDAT = Document Date | |
* | |
* Rules: | |
* - BUDAT must be > BLDAT | |
* - BLDAT - BUDAT (days) must be < 90 days | |
IF e_trbkpv-bldat "Document Date ex: 20160110 | |
> e_trbkpv-budat. "Post Date ex: 20160101 | |
MESSAGE e090(zmm). | |
* Data de Lançamento não deve ser anterior a Data de Documento | |
ELSE. | |
DATA: days TYPE i, | |
days_limit TYPE i, | |
si_value TYPE zelsi_value. | |
CALL FUNCTION 'ZFMSI_GET_VALUE' | |
EXPORTING | |
parameter = 'MIRO_LIMIT' | |
IMPORTING | |
value = si_value | |
EXCEPTIONS | |
invalid_parameter = 1 | |
invalid_logsys = 2 | |
OTHERS = 3. | |
IF sy-subrc <> 0. | |
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO | |
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. | |
days_limit = 90. | |
ELSE. | |
days_limit = si_value. | |
ENDIF. | |
days = e_trbkpv-budat - e_trbkpv-bldat. | |
IF days > days_limit. | |
MESSAGE e091(zmm) WITH days_limit. | |
* Data de Documento não deve exceder 90 dias da Data de Lançamento | |
ENDIF. | |
ENDIF. | |
" Entrar Condição de pagamento(Cond.pgto na Aba Pagamento), | |
" para tipo de operação Logística fatura(RD) | |
IF e_trbkpv-zterm IS INITIAL AND e_trbkpv-vgart EQ 'RD'. | |
MESSAGE e101(zmm). | |
ENDIF. | |
IF e_trbkpv-vgart EQ 'RD'. | |
IF e_trbkpv-zterm(1) = 'L' OR | |
e_trbkpv-zterm(1) = 'P'. | |
DATA: t_vtopis TYPE TABLE OF vtopis, | |
w_vtopis LIKE LINE OF t_vtopis, | |
w_t052 TYPE t052. | |
CLEAR w_t052. | |
CALL FUNCTION 'FI_TERMS_OF_PAYMENT_CHECK' | |
EXPORTING | |
i_zterm = e_trbkpv-zterm | |
IMPORTING | |
e_t052 = w_t052 | |
EXCEPTIONS | |
terms_of_payment = 1 | |
conditions = 2 | |
OTHERS = 3. | |
IF w_t052-xsplt IS INITIAL. | |
CALL FUNCTION 'SD_PRINT_TERMS_OF_PAYMENT' | |
EXPORTING | |
bldat = e_trbkpv-bldat | |
budat = e_trbkpv-budat | |
cpudt = e_trbkpv-cpudt | |
* LANGUAGE = ' ' | |
terms_of_payment = e_trbkpv-zterm | |
* COUNTRY = ' ' | |
* HOLDBACK = ' ' | |
* TOP_HOLDBACK_INFO = | |
* DOCUMENT_CURRENCY = ' ' | |
* IMPORTING | |
* BASELINE_DATE = | |
* PAYMENT_SPLIT = | |
* ZFBDT = | |
TABLES | |
top_text_split = t_vtopis | |
EXCEPTIONS | |
terms_of_payment_not_in_t052 = 1 | |
OTHERS = 2 | |
. | |
IF sy-subrc <> 0. | |
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO | |
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. | |
ENDIF. | |
ELSE. | |
CALL FUNCTION 'SD_PRINT_TERMS_OF_PAYMENT_SPLI' | |
EXPORTING | |
bldat = e_trbkpv-bldat | |
budat = e_trbkpv-budat | |
cpudt = e_trbkpv-cpudt | |
* LANGUAGE = ' ' | |
terms_of_payment = e_trbkpv-zterm | |
wert = e_trbkpv-wwert | |
waerk = e_trbkpv-waers | |
* FKDAT = 00000000 | |
* SKFBT = 00000000 | |
* I_COMPANY_CODE = | |
* I_COUNTRY = | |
* IMPORTING | |
* BASELINE_DATE = | |
TABLES | |
top_text_split = t_vtopis | |
EXCEPTIONS | |
terms_of_payment_not_in_t052 = 1 | |
terms_of_payment_not_in_t052s = 2 | |
OTHERS = 3 | |
. | |
IF sy-subrc <> 0. | |
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO | |
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. | |
ENDIF. | |
ENDIF. | |
IF t_vtopis[] IS NOT INITIAL. | |
SORT t_vtopis BY hdatum. | |
READ TABLE t_vtopis INDEX 1 INTO w_vtopis. | |
IF w_vtopis-hdatum < sy-datum. | |
MESSAGE e149(f5) WITH w_vtopis-hdatum. | |
* Vencimento líquido a & situa-se no passado | |
ENDIF. | |
ENDIF. | |
ENDIF. | |
ENDIF. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment