You are on page 1of 24

*&---------------------------------------------------------------------*

*& NOME DO PROGRAMA : ZFI_CARGA_DADMERCADO


*& TTULO DO PROGRAMA : Carga de Dados de Mercado (SRIES, etc.)
*& PROGRAMADOR
: Jos Henrique Bachour
*& DATA
: 12/11/2010
*& LTIMA ATUALIZAO : DD/MM/AAAA
*&
*& DESCRIO
: Este programa uma cpia do programa
*&
ZFI_I_DDMERC_X_SAP que far a interface dos
*&
dados de mercado. Ele foi copiado devido a
*&
alteraes na forma de obteno dos dados de
*&
entrada e no volume desses dados.
*&---------------------------------------------------------------------*
*& LISTA DE MODIFICAES:
*
*& DATA
AUTOR
REQUEST #
DESCRIO
*
*& 12/11/2010 JHBAC
ED1K912004
Adaptao aos processos de *
*&
carga.
*
*&---------------------------------------------------------------------*
REPORT zfi_carga_dadmercado.
*&---------------------------------------------------------------------*
*& Declarao de tabelas transparentes
*&---------------------------------------------------------------------*
TABLES:
zfi_tctrmigracao, "Controle de Arquivos Processados em Migraes de BP
zfi_t_dadmercado, " Dados de mercado
zfi_e_carga_series, " Estrutura de arquivo
t001,
" Empresas
vwpbono.
" Cotao na bolsa ttulos
*&---------------------------------------------------------------------*
*& Definio de estruturas
*&---------------------------------------------------------------------*
TYPES:
BEGIN OF y_interfaces, "Estrutura para descrio das interfaces
domvalue_l TYPE dd07t-domvalue_l,
ddtext
TYPE dd07t-ddtext,
END OF y_interfaces,
BEGIN OF y_deparaanb,
rkey1
TYPE vtb_market-rkey1,
ideserie TYPE zfi_e_series_sap-ideserie,
END OF y_deparaanb,
BEGIN OF y_infile,
linha(1000)
END OF y_infile.

TYPE c,

*&---------------------------------------------------------------------*
*& Definio de variveis
*&---------------------------------------------------------------------*
DATA: vg_dummy TYPE string.
" Varivel para mensagem
*&---------------------------------------------------------------------*
*& Definio de tabelas internas
*&---------------------------------------------------------------------*
DATA:
t_tctrmigracao TYPE STANDARD TABLE OF zfi_tctrmigracao,
t_infile
TYPE STANDARD TABLE OF y_infile,

t_infileer
t_dadmercado
t_interfaces
t_periodo
t_deparaanb
t_vtb_market

TYPE
TYPE
TYPE
TYPE
TYPE
TYPE

STANDARD
TABLE OF
TABLE OF
TABLE OF
TABLE OF
TABLE OF

TABLE OF y_infile,
zfi_t_dadmercado,
y_interfaces,
y_interfaces,
y_deparaanb,
vtb_market.

*&---------------------------------------------------------------------*
*& Definio de work areas
*&---------------------------------------------------------------------*
DATA:
wa_tctrmigracao TYPE zfi_tctrmigracao,
wa_infile
TYPE string,
wa_serieser
TYPE string,
wa_interfaces
TYPE y_interfaces,
wa_periodo
TYPE y_interfaces,
wa_interface
TYPE zbc_t_interface,
wa_deparaanb
TYPE y_deparaanb,
wa_vtb_market
TYPE vtb_market.
*&---------------------------------------------------------------------*
*& Definio de ranges
*&---------------------------------------------------------------------*
DATA rg_ftdad TYPE RANGE OF zfi_t_dadmercado-ftdad.
*&---------------------------------------------------------------------*
*& Definio variveis globais
*&---------------------------------------------------------------------*
DATA:
vg_seqnz
TYPE seqnz,
vg_path
TYPE localfile,
vg_timestamp
TYPE char16,
vg_substfile
TYPE localfile,
vg_subrc
TYPE sy-subrc,
vg_indnegativo TYPE c.
*&---------------------------------------------------------------------*
*& Definio de constantes
*&---------------------------------------------------------------------*
CONSTANTS:
c_txt(04)
TYPE c
VALUE '.TXT',
c_serieser
TYPE string
VALUE 'ERROS_SERIES',
c_series
TYPE string
VALUE 'SERIES',
c_only(04)
TYPE c
VALUE 'ONLI',
c_bar(01)
TYPE c
VALUE '/',
c_u(01)
TYPE c
VALUE '_',
c_x(01)
TYPE c
VALUE 'X',
c_menos
TYPE c
VALUE '-',
c_01
TYPE vtb_market-sclass VALUE '01',
c_03
TYPE vtb_market-sclass VALUE '03'.
*&---------------------------------------------------------------------*
*& Declarao de Telas de Seleo
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Definio de parmetros
*&---------------------------------------------------------------------*
***********************************************************************

* PARMETROS
SELECTION-SCREEN BEGIN OF BLOCK list WITH FRAME TITLE text-sel.
PARAMETERS: p_buk TYPE t001-bukrs OBLIGATORY.
PARAMETERS: "rb_tds RADIOBUTTON GROUP g001 DEFAULT 'X', " Todos os sistemas
rb_ser RADIOBUTTON GROUP g001 DEFAULT 'X', " Sistema Series
rb_blm RADIOBUTTON GROUP g001,
" Sistema Bloomberg
rb_anb RADIOBUTTON GROUP g001,
" Sistema Ambima
rb_bmf RADIOBUTTON GROUP g001.
" Sistema BM&FBOVESPA
PARAMETERS: p_idmem TYPE char20 NO-DISPLAY.
SELECTION-SCREEN END OF BLOCK list.
SELECTION-SCREEN BEGIN OF BLOCK 100 WITH FRAME TITLE text-100.
PARAMETERS:
p_pathl
TYPE localfile DEFAULT text-002 OBLIGATORY,
p_direl
TYPE localfile DEFAULT text-002 OBLIGATORY,
p_dires
TYPE localfile DEFAULT text-003 OBLIGATORY.
*Bruno
*p_idtes(30) TYPE c
*
DEFAULT 'Teste Integrado 01' OBLIGATORY.
SELECTION-SCREEN END OF BLOCK 100.
SELECTION-SCREEN BEGIN OF BLOCK 200 WITH FRAME TITLE text-200.
PARAMETER: rb_locl RADIOBUTTON GROUP rb01 DEFAULT 'X', "Local
rb_serv RADIOBUTTON GROUP rb01.
"Servidor
SELECTION-SCREEN END OF BLOCK 200.
*&---------------------------------------------------------------------*
* Evento INITIALIZATION
*&---------------------------------------------------------------------*
INITIALIZATION.
DATA: vl_interface TYPE zz_de_interface VALUE sy-repid.
REFRESH: t_interfaces, t_periodo.
CLEAR: wa_interface.
SELECT domvalue_l ddtext
INTO TABLE t_interfaces
FROM dd07t
WHERE domname
EQ 'ZZDO_FTDAD'
AND ddlanguage EQ sy-langu.
SELECT domvalue_l ddtext
INTO TABLE t_periodo
FROM dd07t
WHERE domname
EQ 'ZZDO_PERIODIC' "BENUN - 02/08/11
*
WHERE domname
EQ 'ZZDO_FTDAD'
"BENUN - 02/08/11
AND ddlanguage EQ sy-langu.
*&---------------------------------------------------------------------*
* Eventos
*&---------------------------------------------------------------------*
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_pathl.
DATA: vl_path TYPE rlgrap-filename.
CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
EXPORTING
mask
= ',*.*,*.*.'

CHANGING
file_name = vl_path.
p_pathl = vg_path = vl_path.
* BENUN - 02/08/11 - INICIO
*AT SELECTION-SCREEN OUTPUT.
* PROGRAMA HABILIDO PARA FUNCIONAR COM QUALQUER FONTE
* CHECK rb_anb IS INITIAL
* AND rb_bmf IS INITIAL.
*
**** Determinando que as opes para as interfaces do ANBIMA e BM&F
**** sejam invisivis ao usurio, pois sero chamadas somente atravs de RFC
* LOOP AT SCREEN.
*
IF screen-name CS 'RB_ANB'
*
OR screen-name CS 'RB_BMF'.
*
screen-output
= 0.
*
screen-invisible = 1.
*
ENDIF.
*
MODIFY SCREEN.
* ENDLOOP.
* BENUN - 02/08/11 - FIM
AT SELECTION-SCREEN.
*** Determinando os sistemas de interface para a tabela De-Para (ZFI_T_DADMERCAD
O)
DATA: lwa_ftdad LIKE LINE OF rg_ftdad.
FREE: rg_ftdad.
lwa_ftdad-sign = 'I'.
lwa_ftdad-option = 'EQ'.
CASE 'X'.
*
WHEN rb_tds.
** BENUN - 02/08/2011 - INICIO
**
DO sy-dbcnt TIMES.
**
lwa_ftdad-low = sy-index.
**
APPEND lwa_ftdad TO rg_ftdad.
**
ENDDO.
*
CLEAR: lwa_ftdad.
*
lwa_ftdad-sign = 'I'.
*
lwa_ftdad-option = 'BT'.
*
lwa_ftdad-low = '1'.
*
lwa_ftdad-high = '4'.
*
APPEND lwa_ftdad TO rg_ftdad.
* BENUN - 02/08/2011 - FIM
WHEN rb_ser.
lwa_ftdad-low = '1'.
APPEND lwa_ftdad TO rg_ftdad.
WHEN rb_blm.
lwa_ftdad-low = '2'.
APPEND lwa_ftdad TO rg_ftdad.
WHEN rb_anb.
lwa_ftdad-low = '3'.
APPEND lwa_ftdad TO rg_ftdad.
WHEN rb_bmf.
lwa_ftdad-low = '4'.

APPEND lwa_ftdad TO rg_ftdad.


WHEN OTHERS.
" Nada a Fazer
ENDCASE.
*** Eliminando da tabela de interfaces as interfaces que no sero executadas
SORT t_interfaces BY domvalue_l ASCENDING.
DELETE t_interfaces
WHERE NOT domvalue_l IN rg_ftdad.
READ TABLE t_interfaces INTO wa_interfaces INDEX 1.
*** Buscando os dados da empresa
SELECT SINGLE *
FROM t001
WHERE bukrs EQ p_buk.
IF NOT sy-subrc IS INITIAL.
MESSAGE e011(/kyk/fi) WITH p_buk INTO vg_dummy. "A empresa &1 no existe. Veri
ficar a entrada
PERFORM f_insere_log_standard.
*** Gravao do Log
PERFORM finaliza_migracao.
LEAVE PROGRAM.
ENDIF.
*&---------------------------------------------------------------------*
* Evento START-OF-SELECTION
*&---------------------------------------------------------------------*
START-OF-SELECTION.
* Recupera os dados da Interface para a montagem do LOG standard
CALL METHOD zcl_componentes_diversos=>inicializar_interface
EXPORTING
vl_interface
= sy-repid(30)
EXCEPTIONS
interface_not_found = 1.
IF sy-subrc IS NOT INITIAL.
MESSAGE e141(zbc001).
LEAVE LIST-PROCESSING.
ENDIF.
IF rb_locl = c_x.
IF sy-ucomm <> c_only AND sy-batch <> space.
"EST PROCESSANDO BACKGR.
MESSAGE e011(zbc001).
PERFORM finaliza_migracao.
LEAVE LIST-PROCESSING.
ELSE.
CHECK vg_subrc IS INITIAL.
PERFORM critica_parametros.
PERFORM upload_arquivos_local.
ENDIF.
ELSE.
*
IF sy-ucomm = c_only OR sy-batch = space. "BENUN - 03/08/11
*
MESSAGE e012(zbc001).
*
PERFORM finaliza_migracao.

*
*

LEAVE LIST-PROCESSING.
ELSE.
CHECK vg_subrc IS INITIAL.
PERFORM critica_parametros.
PERFORM upload_arquivos_servidor.
*
ENDIF.
ENDIF.
* Busca Dados de Controle
PERFORM f_busca_ddctrl.
* Solicita dados aos Sistemas Legados
PERFORM f_soldd_sisleg.
* Gravao dos dados
PERFORM f_grava_dados.
PERFORM finaliza_migracao.
*&---------------------------------------------------------------------*
*&
Form F_BUSCA_DDCTRL
*&---------------------------------------------------------------------*
*
Busca Dados de Controle
*----------------------------------------------------------------------*
FORM f_busca_ddctrl .
*** Busca os dados de De-Para
PERFORM f_busca_depara.
ENDFORM.

" F_BUSCA_DDCTRL

*** Solicitando os dados ao sistema legado


*&---------------------------------------------------------------------*
*&
Form F_BUSCA_DEPARA
*&---------------------------------------------------------------------*
*
Busca os dados de De-Para
*----------------------------------------------------------------------*
FORM f_busca_depara .
DATA: lwa_ftdad LIKE LINE OF rg_ftdad.
FREE: t_dadmercado.
SELECT *
INTO TABLE t_dadmercado
FROM zfi_t_dadmercado
WHERE ftdad IN rg_ftdad.
IF NOT sy-subrc IS INITIAL.
LOOP AT rg_ftdad INTO lwa_ftdad.
READ TABLE t_interfaces INTO wa_interfaces
WITH KEY
domvalue_l = lwa_ftdad-low.
CLEAR: vg_dummy.
MESSAGE e001(zfi) WITH wa_interfaces-ddtext INTO vg_dummy.
PERFORM f_insere_log_standard.
*** Gravao do Log
PERFORM finaliza_migracao.
ENDLOOP.

LEAVE LIST-PROCESSING.
ENDIF.
ENDFORM.

" F_BUSCA_DEPARA

*&---------------------------------------------------------------------*
*&
Form F_SOLDD_SISLEG
*&---------------------------------------------------------------------*
*
Solicita dados aos Sistemas Legados
*----------------------------------------------------------------------*
FORM f_soldd_sisleg .
*&---------------------------------------------------------------------*
*& Definio de constantes
*&---------------------------------------------------------------------*
DATA: tl_series_sap
TYPE TABLE OF zfi_e_carga_series,
tl_series_sap_aux TYPE TABLE OF zfi_e_carga_series.
DATA: vl_arqmonit TYPE string,
vl_msg
TYPE string VALUE 'OK'.

" Parmetro p/ sistema


" Retorno de Mensagens

FREE: t_vtb_market.
tl_series_sap[] = t_infile[].
SORT t_dadmercado BY cdext ASCENDING
ftdad ASCENDING
*--> Eric Doria - 19.11.2011
*>>> BEGIN <<<
*
stati DESCENDING "BENUN - 14/07/11
stati DESCENDING "ERIC - 19/11/11
*>>> END <<<
tpval ASCENDING.
* Preparar os dados para a incluso dos dados no SAP
PERFORM f_prepara_ddsap TABLES tl_series_sap
t_vtb_market
USING wa_interfaces.
ENDFORM.
" F_SOLDD_SISLEG
*&---------------------------------------------------------------------*
*&
Form F_INSERE_LOG_STANDARD
*&---------------------------------------------------------------------*
FORM f_insere_log_standard .
CALL METHOD zcl_componentes_diversos=>inserir_log
EXPORTING
vl_idmen = wa_interface-idmen.
ENDFORM.
" F_INSERE_LOG_STANDARD
*&---------------------------------------------------------------------*
*&
Form F_PREPARA_DDSAP
*&---------------------------------------------------------------------*
*
Preparar os dados para a incluso dos dados no SAP
*----------------------------------------------------------------------*
*
-->P_SERIES_SAP
Tabela com os dados do sistema legado
*
-->P_VTB_MARKET
Tabela para os dados a serem cadastrados
*
-->P_INTERFACE
Interface Executada
*----------------------------------------------------------------------*
FORM f_prepara_ddsap TABLES p_series_sap STRUCTURE zfi_e_carga_series
p_vtb_market STRUCTURE vtb_market

USING
p_interface STRUCTURE wa_interfaces.
*&---------------------------------------------------------------------*
*& Definio de work areas
*&---------------------------------------------------------------------*
DATA: wa_series_sap TYPE zfi_e_carga_series.
DATA: lv_tpval LIKE zfi_t_dadmercado-tpval.
REFRESH: t_deparaanb.
SORT p_series_sap BY ideserie ASCENDING.
LOOP AT p_series_sap INTO wa_series_sap.
*** Registrando valores de Fechamento
PERFORM f_registra_dados TABLES p_vtb_market
USING wa_series_sap
p_interface
*
'F'.
"BENUN - 02/08/11
CHANGING lv_tpval."BENUN - 02/08/11
* BENUN - 02/08/11 - INICIO
*** Registrando valores Mdios
*
PERFORM f_registra_dados TABLES p_vtb_market
*
USING wa_series_sap
*
p_interface
*
'M'.
* BENUN - 02/08/11 - FIM
ENDLOOP.
ENDFORM.
" F_PREPARA_DDSAP
*&---------------------------------------------------------------------*
*&
Form F_VER_PERIOD
*&---------------------------------------------------------------------*
*
Verifica a periodicidade de execuo
*----------------------------------------------------------------------*
*
-->P_DDMERC Dados de De-Para para Dados de Mercado
*
<--P_GRAVA Grava Registro
*----------------------------------------------------------------------*
FORM f_ver_period USING
p_ddmerc STRUCTURE zfi_t_dadmercado
CHANGING p_grava.
CLEAR: p_grava.
*** Verificando o intervalo para a periodicidade
CASE p_ddmerc-perio.
WHEN 1. "Dirio
PERFORM f_ver_intervalo USING
zfi_t_dadmercado-dtmoe
p_ddmerc-perio
1
CHANGING p_grava.
WHEN 2. "Semanal
PERFORM f_ver_intervalo USING
zfi_t_dadmercado-dtmoe
p_ddmerc-perio
7
CHANGING p_grava.
WHEN 3. "Mensal
PERFORM f_ver_intervalo USING
zfi_t_dadmercado-dtmoe
p_ddmerc-perio
1
CHANGING p_grava.
WHEN 4. "Trimestral
PERFORM f_ver_intervalo USING
zfi_t_dadmercado-dtmoe

p_ddmerc-perio
3
CHANGING p_grava.
WHEN 5. "Semestral
PERFORM f_ver_intervalo USING

zfi_t_dadmercado-dtmoe
p_ddmerc-perio
6
CHANGING p_grava.

WHEN 6. "Anual
PERFORM f_ver_intervalo USING

zfi_t_dadmercado-dtmoe
p_ddmerc-perio
1
CHANGING p_grava.

WHEN OTHERS.
ENDCASE.
ENDFORM.
" F_VER_PERIOD
*&---------------------------------------------------------------------*
*&
Form F_VER_INTERVALO
*&---------------------------------------------------------------------*
*
Verificando o intervalo para a periodicidade
*----------------------------------------------------------------------*
*
-->P_DATA
Data da ltima execuo
*
-->P_PERIO
Periodicidade
*
-->P_INTERVALO Valor do Intervalo
*
<--P_GRAVA
Grava Registro
*----------------------------------------------------------------------*
FORM f_ver_intervalo USING
p_data
p_perio
p_intervalo
CHANGING p_grava.
*&---------------------------------------------------------------------*
*& Definio de variveis
*&---------------------------------------------------------------------*
DATA: vl_intervalo TYPE i,
" Intervalo entre datas
vl_interdia TYPE i,
" Intervalo em dias
vl_intermes TYPE i,
" Intervalo em mes
vl_interano TYPE i,
" Intervalo em ano
vl_dtmoe
TYPE zfi_t_dadmercado-dtmoe.
CLEAR: p_grava, vl_intervalo, vl_dtmoe.
vl_dtmoe = p_data.
IF vl_dtmoe IS INITIAL.
vl_dtmoe = '19000101'.
ENDIF.
CALL FUNCTION 'FIMA_DAYS_AND_MONTHS_AND_YEARS'
EXPORTING
i_date_from
= vl_dtmoe
i_date_to
= sy-datum
i_flg_separate = 'X'
IMPORTING
e_days
= vl_interdia
e_months
= vl_intermes
e_years
= vl_interano.
CASE p_perio.
WHEN '1'. "Se dirio = 1 dia

IF vl_interdia >= p_intervalo.


vl_intervalo = vl_interdia.
ELSEIF NOT vl_intermes IS INITIAL.
vl_intervalo = vl_intermes.
ELSEIF NOT vl_interano IS INITIAL.
vl_intervalo = vl_interano.
ENDIF.
WHEN '2'. "Se semanal = 7 dias
IF vl_interdia >= p_intervalo.
vl_intervalo = vl_interdia.
ELSEIF NOT vl_intermes IS INITIAL.
vl_intervalo = vl_intermes * 30.
ELSEIF NOT vl_interano IS INITIAL.
vl_intervalo = vl_interano * 365.
ENDIF.
WHEN '3'. "Se mensal = 1 ms
*

Dias no computados para processamento mensal


IF NOT vl_intermes IS INITIAL.
vl_intervalo = vl_intermes.
ELSEIF NOT vl_interano IS INITIAL.
vl_intervalo = vl_interano * 12.
ENDIF.
WHEN '4'. "Se trimestral = 3 meses

Dias no computados para processamento trimestral


IF vl_intermes >= p_intervalo.
vl_intervalo = vl_intermes.
ELSEIF NOT vl_interano IS INITIAL.
vl_intervalo = vl_interano * 12.
ENDIF.
WHEN '5'. "Se semestral = 6 meses

Dias no computados para processamento semestral


IF vl_intermes >= p_intervalo.
vl_intervalo = vl_intermes.
ELSEIF NOT vl_interano IS INITIAL.
vl_intervalo = vl_interano * 12.
ENDIF.
WHEN '6'. "Se anual = 1 ano

*
*

Dias no computados para processamento anual


Meses no computados para processamento anual
IF NOT vl_interano IS INITIAL.
vl_intervalo = vl_interano.
ENDIF.
WHEN OTHERS.
ENDCASE.
IF vl_intervalo GE p_intervalo.
p_grava = 'X'.
ENDIF.

ENDFORM.
" F_VER_INTERVALO
*&---------------------------------------------------------------------*
*&
Form F_GRAVA_DADOS
*&---------------------------------------------------------------------*
*
Gravao dos dados
*----------------------------------------------------------------------*
FORM f_grava_dados.
* BENUN - 02/08/11 - INICIO
IF t_vtb_market[] IS INITIAL
AND vg_indnegativo IS INITIAL.
* IF t_vtb_market[] IS INITIAL.
CLEAR: vg_dummy.
MESSAGE e137(bp) INTO vg_dummy.
PERFORM f_insere_log_standard.
EXIT.
ELSEIF t_vtb_market[] IS INITIAL.
EXIT.
ENDIF.
* BENUN - 02/08/11 - INICIO
SORT: t_vtb_market BY sclass ASCENDING
rkey1 ASCENDING
ddate ASCENDING.
CALL FUNCTION 'MESSAGES_INITIALIZE' .
CALL FUNCTION 'TB_DATAFEED_R3TABLES_UPDATE'
EXPORTING
message_collect = 'X'
TABLES
sap_answer
= t_vtb_market
EXCEPTIONS
update_error
= 1.
IF sy-subrc <> 0.
CLEAR: vg_dummy.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4 INTO vg_dummy.
PERFORM f_insere_log_standard.
ENDIF.
SORT: t_vtb_market BY rdone
sclass
rkey1
ddate
t_dadmercado BY cdsap

ASCENDING
ASCENDING
ASCENDING
ASCENDING,
ASCENDING.

LOOP AT t_vtb_market INTO wa_vtb_market.


IF NOT wa_vtb_market-rdone IS INITIAL.
*** Atualizando a data de execuo
*BENUN - 03/08/11 - INICIO
*
IF rb_anb IS INITIAL.
*
READ TABLE t_dadmercado INTO zfi_t_dadmercado
*
WITH KEY
*
cdsap = wa_vtb_market-rkey1
*
BINARY SEARCH.
*
ELSE.
*
READ TABLE t_deparaanb INTO wa_deparaanb

*
*
*
*
*
*
*

WITH KEY
rkey1 = wa_vtb_market-rkey1.
READ TABLE t_dadmercado INTO zfi_t_dadmercado
WITH KEY
cdsap = wa_deparaanb-ideserie
BINARY SEARCH.
ENDIF.
READ TABLE t_dadmercado INTO zfi_t_dadmercado
WITH KEY
cdsap = wa_vtb_market-rkey1
BINARY SEARCH.
*BENUN - 03/08/11 - FIM
IF sy-subrc IS INITIAL.
zfi_t_dadmercado-dtmoe = sy-datum.
MODIFY t_dadmercado FROM zfi_t_dadmercado INDEX sy-tabix
TRANSPORTING dtmoe.
UPDATE zfi_t_dadmercado
*
SET dtmoe = sy-datum "BENUN - 22/06/2011
SET dtmoe = wa_vtb_market-ddate
aenam = sy-uname "BENUN - 06/07/2011
aedat = sy-datum "BENUN - 06/07/2011
aezet = sy-uzeit "BENUN - 06/07/2011
WHERE cdsap = zfi_t_dadmercado-cdsap.
*
WHERE cdsap = wa_vtb_market-rkey1.
IF sy-subrc IS INITIAL.
COMMIT WORK.
CLEAR: vg_dummy.
MESSAGE s000(zfi)
WITH wa_vtb_market-sclass wa_vtb_market-rkey1
text-suc
INTO vg_dummy.
PERFORM f_insere_log_standard.
ELSE.
CLEAR: vg_dummy.
MESSAGE e000(zfi)
WITH wa_vtb_market-sclass wa_vtb_market-rkey1
text-e02
INTO vg_dummy.
PERFORM f_insere_log_standard.
ENDIF.
ENDIF.
ELSE.
CLEAR: vg_dummy.
*
MESSAGE s000(zfi)
MESSAGE e000(zfi)
WITH wa_vtb_market-sclass wa_vtb_market-rkey1
wa_vtb_market-error
INTO vg_dummy.
PERFORM f_insere_log_standard.
ENDIF.
ENDLOOP.
ENDFORM.
" F_GRAVA_DADOS
*&---------------------------------------------------------------------*
*&
Form F_REGISTRA_DADOS
*&---------------------------------------------------------------------*
*
Registrando valores de Fechamento
*----------------------------------------------------------------------*
*
-->P_SERIES_SAP Registro legado
*
-->P_INTERFACE Registro de tipo de interface

*
-->P_TPVAL
Tipo de valor do registro
*
F - Valor Fechamento
*
M - Valor Mdio
*----------------------------------------------------------------------*
FORM f_registra_dados TABLES p_vtb_market STRUCTURE vtb_market
USING p_series_sap STRUCTURE zfi_e_carga_series
p_interface STRUCTURE wa_interfaces
CHANGING
p_tpval
TYPE zfi_t_dadmercado-tpval.
*&---------------------------------------------------------------------*
*& Definio de variveis
*&---------------------------------------------------------------------*
DATA: vl_tabix
TYPE sy-tabix,
" varivel de ndice de tabela
vl_grava
TYPE xfeld,
" Determina gravao do registr
o
vl_dtint
TYPE sy-datum,
" Data convertida
vl_valorobsf TYPE zfi_e_series_sap-valorobs, " Valor Fechamento
vl_valorobsm TYPE zfi_e_series_sap-valorobs, " Valor Mdio
vl_msg
TYPE sy-msgv1,
" Item de mensagem
vl_ideserie TYPE zfi_e_series_sap-ideserie, " Cdigo Externo
vl_rkey1
TYPE vtb_market-rkey1,
" Cdigo SAP
v_ranl
TYPE vwpbono-ranl,
vl_mask
TYPE sy-datum, "BENUN - 22/06/11
vl_strlen
TYPE i.
" Tamanho do valor
CLEAR: vl_valorobsf, vl_valorobsm, wa_deparaanb.

*
*
*
*
*

vl_valorobsf = p_series_sap-valorobs.
SEARCH vl_valorobsf FOR '@'.
IF sy-subrc IS INITIAL.
SPLIT vl_valorobsf AT '@' INTO vl_valorobsf vl_valorobsm.
ENDIF.
BENUN - 02/08/2011 - INCIO
IF
p_tpval EQ 'F'
" Se for registro de fechamento
AND NOT vl_valorobsm IS INITIAL. " E tiver valor Mdio
EXIT.
" Ignora registro
ENDIF.

* IF p_tpval EQ 'M'.
" Se for registro de Valor Mdio
*
SEARCH p_series_sap-valorobs FOR '@'.
*
IF NOT sy-subrc IS INITIAL.
" E no tiver valor mdio
*
EXIT.
" Ignora registro
*
ENDIF.
*
vl_msg = text-med.
* ENDIF.
* BENUN - 02/08/2011 - FIM
vl_msg = text-fec.
vl_ideserie = p_series_sap-ideserie.
* IF NOT rb_anb IS INITIAL."BENUN - 03/08/11
PERFORM f_trata_titulo CHANGING vl_ideserie
vl_mask
vl_rkey1
p_idmem.
* ENDIF.
"BENUN - 03/08/11
READ TABLE t_dadmercado INTO zfi_t_dadmercado
WITH KEY
cdext = vl_ideserie.

*
*
*

ftdad = 1
"BENUN - 02/08/11
tpval = p_tpval."BENUN - 15/07/11
BINARY SEARCH. "BENUN - 15/07/11

IF NOT sy-subrc IS INITIAL.


CLEAR: vg_dummy.
*
vg_dummy = text-e04.
*
vl_strlen = STRLEN( p_series_sap-ideserie ).
*
REPLACE '&' WITH p_series_sap-ideserie(vl_strlen) INTO vg_dummy.
MESSAGE e000(zfi) WITH text-e04 vl_ideserie
p_series_sap-dataobscompl INTO vg_dummy.
PERFORM f_insere_log_standard.
EXIT.
ENDIF.
vl_tabix = sy-tabix.
p_tpval = zfi_t_dadmercado-tpval. "BENUN - 02/08/11
LOOP AT t_dadmercado INTO zfi_t_dadmercado FROM vl_tabix.
*

IF zfi_t_dadmercado-cdext NE vl_ideserie
OR zfi_t_dadmercado-ftdad NE 1 "BENUN - 02/08/11
OR zfi_t_dadmercado-stati NE 'X'.
EXIT.
ENDIF.

*
IF zfi_t_dadmercado-dtmoe GT p_series_sap-dataobscompl.
*
CLEAR: vg_dummy.
** BENUN - 14/06/11 - INCIO
**
MESSAGE e000(zfi) WITH text-w01 p_series_sap-dataobscompl '<' zfi_t_dadm
ercado-dtmoe INTO vg_dummy.
*
MESSAGE w000(zfi) WITH text-w01 zfi_t_dadmercado-cdsap p_series_sap-datao
bscompl INTO vg_dummy.
** BENUN - 14/06/11 - FIM
*
PERFORM f_insere_log_standard.
*
CONTINUE.
*
ENDIF.
*--> Eric Doria - 19.11.2011
*>>> BEGIN <<<
*** Verifica a periodicidade de execuo
*
PERFORM f_ver_period USING
zfi_t_dadmercado
*
CHANGING vl_grava.
*>>> END <<<
******************************************************************
* RETIRAR APS TESTES
vl_grava = 'X'.
******************************************************************
IF vl_grava IS INITIAL.
READ TABLE t_periodo INTO wa_periodo
WITH KEY
domvalue_l = zfi_t_dadmercado-perio.
CLEAR: vg_dummy.
MESSAGE e000(zfi) WITH text-w02 zfi_t_dadmercado-cdsap p_series_sap-dataob
scompl
INTO vg_dummy.
PERFORM f_insere_log_standard.
CONTINUE.

ENDIF.
CLEAR: wa_vtb_market.
wa_vtb_market-mandt
= sy-mandt.
wa_vtb_market-sclass
= zfi_t_dadmercado-sclass.
wa_vtb_market-rkey1
= zfi_t_dadmercado-cdsap.
* Ambima somente ser processada atravs de rfc
IF NOT rb_anb IS INITIAL.
wa_deparaanb-ideserie = wa_vtb_market-rkey1.
IF NOT vl_rkey1 IS INITIAL.
vl_strlen = STRLEN( vl_rkey1 ).
REPLACE '&' WITH vl_rkey1(vl_strlen) INTO wa_vtb_market-rkey1.
*
wa_deparaanb-rkey1 = wa_vtb_market-rkey1.
MOVE wa_vtb_market-rkey1 TO v_ranl.
PERFORM f_check_titulo USING '2'
v_ranl
'ANBIMA'
CHANGING vl_grava.
CHECK NOT vl_grava IS INITIAL.
ENDIF.
wa_deparaanb-rkey1 = wa_vtb_market-rkey1.
ENDIF.
CASE wa_vtb_market-sclass.
WHEN '01'.
wa_vtb_market-rkey2
= t001-waers.
WHEN '02' OR '03'.
wa_vtb_market-rkey2
= p_interface-ddtext.
WHEN OTHERS.
ENDCASE.
wa_vtb_market-sinstrumnt = zfi_t_dadmercado-sinstrumnt.
wa_vtb_market-rfeedname = p_interface-ddtext.
wa_vtb_market-rupdhist = 'X'.
wa_vtb_market-ddate
= p_series_sap-dataobscompl.
IF vl_valorobsf(01) = '+'.
wa_vtb_market-value
= vl_valorobsf+1(20).
ELSE.
wa_vtb_market-value
= vl_valorobsf.
ENDIF.
IF p_tpval EQ 'M'.
IF vl_valorobsm(01) = '+'.
wa_vtb_market-value
= vl_valorobsm+1(20).
ELSE.
wa_vtb_market-value
= vl_valorobsm.
ENDIF.
ENDIF.
wa_vtb_market-uname
= sy-uname.
*BENUN - 22/06/11 - INCIO
*
IF wa_vtb_market-value CO '0 .,'."BENUN - 03/08/11
IF wa_vtb_market-value CO '0 .,' "BENUN - 03/08/11
AND wa_vtb_market-sclass <> c_03. "BENUN - 03/08/11
CLEAR: vg_dummy.
MESSAGE w000(zfi) WITH text-w03
wa_vtb_market-value wa_vtb_market-rkey1
wa_vtb_market-ddate INTO vg_dummy.
PERFORM f_insere_log_standard.
CONTINUE.
ENDIF.
*BENUN - 22/06/11 - FIM

* Incio - benun - 24/05/2011


PERFORM f_fator_conversao USING wa_vtb_market
CHANGING vl_grava.
CHECK NOT vl_grava IS INITIAL.
PERFORM f_check_decimals_size USING wa_vtb_market-value
zfi_t_dadmercado-cdsap
wa_vtb_market-sclass
CHANGING vl_grava.
CHECK NOT vl_grava IS INITIAL.
* Fim - benun - 24/05/2011
*BENUN - 02/08/11 - INICIO
FIND FIRST OCCURRENCE OF c_menos IN wa_vtb_market-value.
IF sy-subrc = 0.
PERFORM grava_indice_negativo IN PROGRAM zfi_i_ddmerc_x_sap
USING wa_vtb_market
vg_indnegativo.
ELSE.
APPEND wa_vtb_market TO p_vtb_market.

*
*

IF NOT zfi_t_dadmercado-cdder IS INITIAL.


PERFORM f_trata_moeda_derivada USING zfi_t_dadmercado-cdder
zfi_t_dadmercado-dias
zfi_t_dadmercado-calendar
'1'
p_tpval
CHANGING wa_vtb_market-ddate
wa_vtb_market-rkey1.

IF NOT wa_vtb_market-rkey1 IS INITIAL.


APPEND wa_vtb_market TO p_vtb_market.
ENDIF.
ENDIF.
ENDIF.
*BENUN - 02/08/11 - FIM
IF NOT wa_deparaanb IS INITIAL.
COLLECT wa_deparaanb INTO t_deparaanb.
ENDIF.
ENDLOOP.
ENDFORM.

" F_REGISTRA_DADOS

*&---------------------------------------------------------------------*
*&
Form FINALIZA_MIGRACAO
*&---------------------------------------------------------------------*
FORM finaliza_migracao .
PERFORM fecha_controle_migracoes.
CALL METHOD zcl_componentes_diversos=>resumo_interface.
PERFORM download_arquivos_erros.
ENDFORM.

" FINALIZA_MIGRACAO

*&---------------------------------------------------------------------*
*&
Form CRITICA_PARAMETROS
*&---------------------------------------------------------------------*

FORM critica_parametros .
DATA: vl_data(10)
vl_hora(08)
vl_dati
vl_hori
vl_path

TYPE
TYPE
TYPE
TYPE
TYPE

c,
c,
sy-datum,
sy-uzeit,
localfile.

CLEAR vg_subrc.
IF vg_path IS INITIAL.
vg_path = p_pathl.
ENDIF.
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*

SELECT * FROM zfi_tctrmigracao INTO TABLE t_tctrmigracao


WHERE arquivo = vg_path.
IF sy-subrc IS INITIAL.
READ TABLE t_tctrmigracao INTO wa_tctrmigracao
WITH KEY arquivo = vg_path.
IF sy-subrc IS INITIAL.
vg_subrc = 1.
WRITE wa_tctrmigracao-datimig TO vl_data.
WRITE wa_tctrmigracao-horimig TO vl_hora.
MESSAGE e078(zbc001) WITH vg_path vl_data vl_hora.
ENDIF.
ENDIF.
vl_dati = sy-datum.
vl_hori = sy-uzeit.
REFRESH t_tctrmigracao.
wa_tctrmigracao-arquivo
wa_tctrmigracao-datimig
wa_tctrmigracao-horimig
wa_tctrmigracao-idteste
wa_tctrmigracao-direrro
APPEND wa_tctrmigracao TO

ENDFORM.

= vg_path.
= vl_dati.
= vl_hori.
= p_idtes.
= p_direl.
t_tctrmigracao.
" CRITICA_PARAMETROS

*&---------------------------------------------------------------------*
*&
Form UPLOAD_ARQUIVOS_LOCAL
*&---------------------------------------------------------------------*
FORM upload_arquivos_local .
DATA:
vl_path

TYPE string.

vl_path = vg_path.
CHECK vl_path IS NOT INITIAL.
*

Arquivo no PC Local.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename
= vl_path

filetype
TABLES
data_tab
EXCEPTIONS
file_open_error
file_read_error
no_batch
gui_refuse_filetransfer
invalid_type
no_authority
unknown_error
bad_data_format
header_not_allowed
separator_not_allowed
header_too_long
unknown_dp_error
access_denied
dp_out_of_memory
disk_full
dp_timeout
OTHERS

= 'ASC'
= t_infile
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17.

IF sy-subrc <> 0.
MESSAGE e035(zbc001) WITH sy-subrc c_u vl_path INTO vg_dummy.
PERFORM insere_log_standard.
ENDIF.
ENDFORM.

" UPLOAD_ARQUIVOS_LOCAL

*&---------------------------------------------------------------------*
*&
Form UPLOAD_ARQUIVOS_SERVIDOR
*&---------------------------------------------------------------------*
FORM upload_arquivos_servidor .
DATA: vl_data
vl_hora
vl_times
vl_path
vl_pathname
vl_filename
vl_strname
tl_infile
vl_infile

TYPE
TYPE
TYPE
TYPE
TYPE
TYPE
TYPE
TYPE
LIKE

char10,
char8,
tzonref-tstamps,
localfile,
zz_de_pathextern,
fileextern,
strukname,
STANDARD TABLE OF zfi_e_carga_series,
LINE OF t_infile.

MESSAGE i159(zbc001) WITH vg_timestamp+1(15) INTO vg_dummy.


PERFORM insere_log_standard.
* Ler o arquivo de Dados Bsicos do BP
CONCATENATE c_series vg_timestamp c_txt INTO vg_substfile.
vg_seqnz = 1.
CALL METHOD zcl_componentes_diversos=>processar_interface
EXPORTING
vl_seqnz
= vg_seqnz
vl_substfile = vg_substfile
IMPORTING
t_data
= tl_infile
EXCEPTIONS
open_error = 1.
IF sy-subrc IS NOT INITIAL.

vg_subrc = sy-subrc.
EXIT.
ENDIF.
LOOP AT tl_infile INTO zfi_e_carga_series.
vl_infile = zfi_e_carga_series.
APPEND vl_infile TO t_infile.
ENDLOOP.
ENDFORM.

" UPLOAD_ARQUIVOS_SERVIDOR

*&---------------------------------------------------------------------*
*&
Form DOWNLOAD_ARQUIVOS_ERROS
*&---------------------------------------------------------------------*
FORM download_arquivos_erros .
IF rb_locl = c_x.
PERFORM download_local.
ELSE.
PERFORM download_servidor.
ENDIF.
ENDFORM.

" DOWNLOAD_ARQUIVOS_ERROS

*&---------------------------------------------------------------------*
*&
Form DOWNLOAD_LOCAL
*&---------------------------------------------------------------------*
FORM download_local.
DATA:

vl_data TYPE sy-datum,


vl_path TYPE string,
vl_hora TYPE sy-uzeit.

IF t_infileer[] IS NOT INITIAL.


vl_data = sy-datum.
vl_hora = sy-uzeit.
vl_path = vg_path.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename
=
TABLES
data_tab
=
EXCEPTIONS
file_write_error
=
no_batch
=
gui_refuse_filetransfer =
invalid_type
=
no_authority
=
unknown_error
=
header_not_allowed
=
separator_not_allowed =
filesize_not_allowed
=
header_too_long
=
dp_error_create
=
dp_error_send
=
dp_error_write
=
unknown_dp_error
=
access_denied
=
dp_out_of_memory
=

vl_path
t_infileer
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16

disk_full
= 17
dp_timeout
= 18
file_not_found
= 19
dataprovider_exception = 20
control_flush_error
= 21
OTHERS
= 22.
IF sy-subrc <> 0.
MESSAGE e037(zbc001) WITH sy-subrc vg_path INTO vg_dummy.
PERFORM insere_log_standard.
ENDIF.
ENDIF.
ENDFORM.

" DOWNLOAD_LOCAL

*&---------------------------------------------------------------------*
*&
Form DOWNLOAD_SERVIDOR
*&---------------------------------------------------------------------*
FORM download_servidor .
DATA: vl_data
vl_hora

TYPE sy-datum,
TYPE sy-uzeit.

vl_data = sy-datum.
vl_hora = sy-uzeit.
IF t_infileer[] IS NOT INITIAL.
CONCATENATE p_dires c_bar c_serieser c_u vg_timestamp c_txt
INTO vg_path.
OPEN DATASET: vg_path FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
IF sy-subrc <> 0.
MESSAGE e039(zbc001) WITH sy-subrc vg_path INTO vg_dummy.
PERFORM insere_log_standard.
ENDIF.
LOOP AT t_infileer INTO wa_infile.
TRANSFER wa_infile TO vg_path LENGTH 36.
IF sy-subrc <> 0.
MESSAGE e038(zbc001) WITH sy-subrc vg_path INTO vg_dummy.
PERFORM insere_log_standard.
ENDIF.
ENDLOOP.
ENDIF.
ENDFORM.

" DOWNLOAD_SERVIDOR

*&---------------------------------------------------------------------*
*&
Form FECHA_CONTROLE_MIGRACOES
*&---------------------------------------------------------------------*
FORM fecha_controle_migracoes .
DATA: vl_datf
vl_horf

TYPE sy-datum,
TYPE sy-uzeit.

vl_datf = sy-datum.
vl_horf = sy-uzeit.
LOOP AT t_tctrmigracao INTO zfi_tctrmigracao.
zfi_tctrmigracao-datfmig = vl_datf.
zfi_tctrmigracao-horfmig = vl_horf.
INSERT zfi_tctrmigracao.
ENDLOOP.

ENDFORM.

" FECHA_CONTROLE_MIGRACOES

*&---------------------------------------------------------------------*
*&
Form INSERE_LOG_STANDARD
*&---------------------------------------------------------------------*
FORM insere_log_standard .
*
*

CALL METHOD zcl_componentes_diversos=>inserir_log.


EXPORTING
vl_idmen = wa_interface-idmen.

ENDFORM.
" INSERE_LOG_STANDARD
*&---------------------------------------------------------------------*
*&
Form F_FATOR_CONVERSAO
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
*
-->P_WA_VTB_MARKET text
*----------------------------------------------------------------------*
FORM f_fator_conversao CHANGING p_wa_vtb_market TYPE vtb_market
p_grava.
DATA: vl_rate_type
vl_fcurr
vl_tcurr
vl_reciprocal
wa_tcurf

TYPE
TYPE
TYPE
TYPE
TYPE

tcurf-kurst,
tcurf-fcurr,
tcurf-tcurr,
bvald-bvald,
tcurf .

CHECK p_wa_vtb_market-sclass = c_01.


MOVE:
p_wa_vtb_market-sinstrumnt TO vl_rate_type,
p_wa_vtb_market-rkey1
TO vl_fcurr,
p_wa_vtb_market-rkey2
TO vl_tcurr.
CALL FUNCTION 'WLF_READ_TCURF'
EXPORTING
i_date
= p_wa_vtb_market-ddate
i_rate_type
= vl_rate_type
i_fcurr
= vl_fcurr
i_tcurr
= vl_tcurr
i_reciprocal = vl_reciprocal
IMPORTING
e_tcurf
= wa_tcurf
EXCEPTIONS
not_found
= 1
internal_error = 2
OTHERS
= 3.
IF sy-subrc <> 0.
CLEAR: p_grava.
CLEAR: vg_dummy.
MESSAGE w000(zfi) WITH text-e06 wa_vtb_market-value wa_vtb_market-rkey1
INTO vg_dummy.
PERFORM f_insere_log_standard.
ELSE.
p_wa_vtb_market-value = ( ( wa_tcurf-ffact * p_wa_vtb_market-value ) / wa_tc
urf-tfact ).
ENDIF.

ENDFORM.
" F_FATOR_CONVERSAO
*&---------------------------------------------------------------------*
*&
Form F_CHECK_DECIMALS_SIZE
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
*
-->P_WA_VTB_MARKET_VALUE text
*----------------------------------------------------------------------*
FORM f_check_decimals_size USING p_value TYPE vtb_market-value
p_moeda TYPE zfi_t_dadmercado-cdsap
p_sclass TYPE vtb_market-sclass
CHANGING p_grava.
CHECK p_sclass = c_01.
DATA: vl_str1 TYPE string,
vl_str2 TYPE string,
vl_size TYPE i.
SPLIT p_value AT '.' INTO vl_str1 vl_str2.
vl_size = STRLEN( vl_str2 ).
IF vl_size > 5.
CLEAR: vg_dummy.
MESSAGE e000(zfi) WITH text-e05 p_moeda INTO vg_dummy.
PERFORM f_insere_log_standard.
CLEAR: p_grava.
ELSE.
p_grava = c_x.
ENDIF.
ENDFORM.
" F_CHECK_DECIMALS_SIZE
*&---------------------------------------------------------------------*
*&
Form F_TRATA_TITULO
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
* --> p1
text
* <-- p2
text
*----------------------------------------------------------------------*
FORM f_trata_titulo CHANGING p_ideserie
p_mask
p_rkey1
p_idmem.
SEARCH p_ideserie FOR '_'.
IF sy-subrc IS INITIAL.
* Verifica se ttulo ou seja, o nome da cotaco est no padro XXX_AAAADDMM
* BENUN - 22/06/11 - INCIO
SPLIT p_ideserie AT '_' INTO p_ideserie p_mask.
WRITE p_mask TO p_rkey1 DDMMYY. "converte data vinda de tit.publico
* BENUN - 22/06/11 - FIM
"no formato AAAAMMDD para DDMMAA
ENDIF.
ENDFORM.
" F_TRATA_TITULO
*&---------------------------------------------------------------------*
*&
Form F_TRATA_MOEDA_DERIVADA
*&---------------------------------------------------------------------*
*
text

*----------------------------------------------------------------------*
* --> p1
text
* <-- p2
text
*----------------------------------------------------------------------*
FORM f_trata_moeda_derivada USING p_cdder TYPE zfi_t_dadmercado-cdder
p_dias TYPE zfi_t_dadmercado-dias
p_calendario TYPE zfi_t_dadmercado-calendar
*
p_domvalue TYPE y_interfaces-domvalue_l
*
p_tpval TYPE zfi_t_dadmercado-tpval
CHANGING p_ddate TYPE vtb_market-ddate
p_rkey1 TYPE vtb_market-rkey1.
CALL FUNCTION
EXPORTING
date
days
months
signum
years
IMPORTING
calc_date

'RP_CALC_DATE_IN_INTERVAL'
=
=
=
=
=

p_ddate
p_dias
'00'
'-'
'00'

= p_ddate.

CALL FUNCTION 'BKK_GET_PRIOR_WORKDAY'


EXPORTING
i_date
= p_ddate
i_calendar1
= p_calendario
i_calendar2
= 'BN'
IMPORTING
e_workday
= p_ddate
EXCEPTIONS
calendar_error = 1
OTHERS
= 2.
IF sy-subrc <> 0.
CLEAR: vg_dummy.
MESSAGE e000(zfi) WITH text-e07 p_cdder p_ddate
INTO vg_dummy.
PERFORM f_insere_log_standard.
CLEAR: p_rkey1.
ELSE.
p_rkey1 = p_cdder.
ENDIF.
ENDFORM.
" F_TRATA_MOEDA_DERIVADA
*&---------------------------------------------------------------------*
*&
Form F_CHECK_TITULO
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
*
-->P_2
text
*
-->P_WA_VTB_MARKET_RKEY1 text
*
-->P_1418 text
*
<--P_VL_GRAVA text
*----------------------------------------------------------------------*
FORM f_check_titulo USING
p_rantyp TYPE vwpbono-rantyp
p_ranl
TYPE vwpbono-ranl
p_rhandpl TYPE vwpbono-rhandpl
CHANGING p_grava.

SELECT SINGLE
WHERE
AND
AND
AND

* FROM
mandt
rantyp
ranl
rhandpl

vwpbono CLIENT SPECIFIED


= sy-mandt
= p_rantyp
= p_ranl
= p_rhandpl.

IF NOT sy-subrc IS INITIAL.


CLEAR p_grava.
CLEAR: vg_dummy.
MESSAGE e717(64) WITH p_ranl p_rhandpl
INTO vg_dummy.
PERFORM f_insere_log_standard.
ENDIF.
ENDFORM.

" F_CHECK_TITULO