Zfirp0001 F01
Zfirp0001 F01
Zfirp0001 F01
*&---------------------------------------------------------------------*
*& FORM F_SEL_FILE
*&---------------------------------------------------------------------*
*& TEXT
*&---------------------------------------------------------------------*
FORM f_sel_file .
DATA: gt_file TYPE filetable,
lt_file TYPE file_table,
lv_rc TYPE i.
IF sy-subrc EQ 0.
READ TABLE gt_file INTO lt_file INDEX 1.
IF sy-subrc EQ 0.
p_file = lt_file-filename.
ENDIF.
ENDIF.
ENDFORM.
*&---------------------------------------------------------------------*
*& FORM F_CARREGA_TXT
*&---------------------------------------------------------------------*
*& TEXT
*&---------------------------------------------------------------------*
FORM f_carrega_txt .
gt_file = p_file.
CASE <fs_raw>+9(1).
WHEN 1.
lt_layout-sequencia = <fs_raw>(9).
lt_layout-cod_reg = <fs_raw>+9(1).
lt_layout-cnpj_cliente = <fs_raw>+10(9).
lt_layout-cnpj_consultado = <fs_raw>+19(9).
lt_layout-score = <fs_raw>+328(4).
IF sy-subrc EQ 0. "1-REGRA
SELECT SINGLE *
FROM ukmbp_cms
INTO @DATA(lt_ukmbp_cms)
WHERE partner = @lt_dfkkbptaxnum-partner. "PASSO 30
IF sy-subrc EQ 0.
" PASSO 45
IF lt_layout-score > 450.
gv_aux_grade = 'A'.
gv_aux_tendency = '++'.
ELSEIF lt_layout-score > 250.
gv_aux_grade = 'B'.
gv_aux_tendency = '+'.
"PASSO 50 - SE LOCALIZAR O BP
CALL FUNCTION 'UKM_BUPA_BP1012_GET'
EXPORTING
i_partner = lt_dfkkbptaxnum-partner
TABLES
et_bp1012 = gt_bp1012.
IF sy-subrc EQ 0.
LOOP AT gt_bp1012 INTO lt_bp1012 WHERE partner =
lt_dfkkbptaxnum-partner
AND grade_method = 'SERASA'
AND date_to > sy-datum.
IF lt_bp1012-grade = gv_aux_grade.
IF lt_bp1012-text NE lt_layout-score.
* ATUALIZA SCORE
lt_bp1012-text = lt_layout-score.
APPEND lt_bp1012 TO gt_bp1012_aux.
CLEAR gt_bp1012_x.
lt_bp1012_x-text = 'X'.
APPEND lt_bp1012_x TO gt_bp1012_x.
IF sy-subrc EQ 0.
COMMIT WORK.
ELSE.
ROLLBACK WORK.
ENDIF.
ENDIF.
ELSE.
lt_bp1012-date_to = sy-datum - 1.
APPEND lt_bp1012 TO gt_bp1012_aux.
CLEAR gt_bp1012_x.
lt_bp1012_x-date_to = 'X'.
APPEND lt_bp1012_x TO gt_bp1012_x.
IF sy-subrc EQ 0.
COMMIT WORK.
ELSE.
ROLLBACK WORK.
ENDIF.
lt_bp1012-grade = gv_aux_grade.
lt_bp1012-tendency = gv_aux_tendency.
lt_bp1012-date_when = sy-datum.
lt_bp1012-text = lt_layout-score.
CLEAR gt_bp1012_aux.
APPEND lt_bp1012 TO gt_bp1012_aux.
IF sy-subrc EQ 0.
COMMIT WORK.
lt_log-cnpj = lt_layout-cnpj_consultado. "PASSO 40
lt_log-bp = lt_dfkkbptaxnum-partner.
lt_log-historico = TEXT-002 && ` ` && lt_dfkkbptaxnum-partner
&& ` ` && TEXT-003 && ` ` && gv_aux_grade .
APPEND lt_log TO gt_log.
ELSE.
ROLLBACK WORK.
ENDIF.
ENDIF.
ENDLOOP.
IF sy-subrc EQ 0.
COMMIT WORK.
lt_log-cnpj = lt_layout-cnpj_consultado. "PASSO 40
lt_log-bp = lt_dfkkbptaxnum-partner.
lt_log-historico = TEXT-002 && ` ` && lt_dfkkbptaxnum-partner && `
` && TEXT-003 && ` ` && gv_aux_grade.
APPEND lt_log TO gt_log.
ELSE.
ROLLBACK WORK.
ENDIF.
ENDIF.
ELSE.
lt_log-cnpj = lt_layout-cnpj_consultado. "PASSO 40
lt_log-bp = lt_dfkkbptaxnum-partner.
lt_log-historico = TEXT-002 && ` ` && lt_dfkkbptaxnum-partner && ` `
&& TEXT-004.
APPEND lt_log TO gt_log.
ENDIF.
ENDIF.
ENDCASE.
ENDLOOP.
ENDFORM.
*&---------------------------------------------------------------------*
*& FORM F_EXIBE_DADOS
*&---------------------------------------------------------------------*
*& TEXT
*&---------------------------------------------------------------------*
FORM f_exibe_dados .
TRY.
cl_salv_table=>factory(
IMPORTING
r_salv_table = lr_log
CHANGING
t_table = gt_log[]
).
lr_columns = lr_log->get_columns( ).
TRY.
lr_column ?= lr_columns->get_column( 'CNPJ' ).
lr_column->set_short_text( 'CNPJ' ).
lr_column->set_medium_text( 'CNPJ ' ).
lr_column->set_long_text( 'CNPJ' ).
lr_column->set_visible( abap_true ).
CATCH cx_root.
ENDTRY.
TRY.
lr_column ?= lr_columns->get_column( 'BP' ).
lr_column->set_short_text( 'BP' ).
lr_column->set_medium_text( 'BP' ).
lr_column->set_long_text( 'BP' ).
lr_column->set_visible( abap_true ).
CATCH cx_root.
ENDTRY.
TRY.
lr_column ?= lr_columns->get_column( 'HISTORICO' ).
lr_column->set_short_text( 'HISTOR' ).
lr_column->set_medium_text( 'HIST�RICO' ).
lr_column->set_long_text( 'HIST�RICO' ).
lr_column->set_visible( abap_true ).
CATCH cx_root.
ENDTRY.
* FUNCTION
lr_functions = lr_log->get_functions( ).
lr_functions->set_all( abap_true ).
lr_log->display( ).
ENDTRY.
ENDFORM.