You are on page 1of 9

*----------------------------------------------------------------------*

***INCLUDE MZFICOM003I01 .
*----------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*&
Module tb_comissao_mark INPUT
*&---------------------------------------------------------------------*
*
TELA 0200 - Atualiza marcao de linhas do table control
*----------------------------------------------------------------------*
module tb_comissao_mark input.
wa_item-mark = v_mark.
modify t_item from wa_item index tb_comissao-current_line
transporting mark.
endmodule.
" tb_comissao_mark INPUT
*&---------------------------------------------------------------------*
*&
Module tb_historico_mark INPUT
*&---------------------------------------------------------------------*
*
TELA 0400 - Atualiza marcao de linhas do table control
*----------------------------------------------------------------------*
module tb_historico_mark input.
wa_historico-mark = v_mark.
modify t_historico from wa_historico index tb_historico-current_line
transporting mark.
endmodule.

" tb_historico_mark INPUT

*&---------------------------------------------------------------------*
*&
Module user_command_0100 INPUT
*&---------------------------------------------------------------------*
*
rotina de comandos de tela
*----------------------------------------------------------------------*
module user_command_0100 input.
data: v_jobname like tbtcjob-jobname,
v_jobcount like tbtcjob-jobcount,
v_actvt(2) type n.
clear v_actvt.
case sy-ucomm.
when 'CRIA'.
when 'INFO'.
when 'PAGA'.
when 'ESTO'.
when 'ELIM'.
when 'INDI'.
endcase.

v_actvt
v_actvt
v_actvt
v_actvt
v_actvt
v_actvt

=
=
=
=
=
=

'01'.
'22'.
'45'.
'85'.
'06'.
'01'.

if ( not v_actvt is initial ).


authority-check object 'Z_ARMZ_002'
id 'WERKS' dummy
id 'MOTIVO' field 'COMISSAO'
id 'ACTVT' field v_actvt.
if ( sy-subrc ne
case sy-ucomm.
when 'CRIA'.
when 'INFO'.
when 'PAGA'.
when 'ESTO'.
when 'ELIM'.

0 ).
message
message
message
message
message

e001(zfi).
e002(zfi).
e003(zfi).
e004(zfi).
e005(zfi).

when 'INDI'. message e006(zfi).


endcase.
endif.
endif.
code100 = sy-ucomm.
clear v_copied.
perform f_limpa_variaveis.
case code100.
when 'CRIA'.
refresh t_spopli.
clear wa_spopli.
wa_spopli-varoption = text-m13.
append wa_spopli to t_spopli.
wa_spopli-varoption = text-m14.
append wa_spopli to t_spopli.
call function 'POPUP_TO_DECIDE_LIST'
exporting
start_col = 35
start_row = 13
textline1 = text-m15
titel
= text-m16
importing
answer
= v_rescisao
tables
t_spopli = t_spopli.
check ( v_rescisao ne 'A' ).
*> Checa se existe resciso algum pagamento de resciso realizado
if ( v_rescisao eq '2' ).
select * from zfitcom003
into table t_zfitcom003
where ( status in ('1', '2', '3') )
and ( bukrs eq p_bukrs
)
and ( vkbur in s_vkbur
)
and ( resctr eq 'X'
).
if ( sy-subrc eq 0 ).
message w999(zarm) with text-m17 text-m18.
exit.
endif.
endif.
if ( p_excjob eq c_mark ).
break abap02.
v_jobname = 'CALC_PGTO_COMISSAO'.
call function 'JOB_OPEN'
exporting
jobname
= v_jobname
importing
jobcount
= v_jobcount
exceptions
cant_create_job = 1
invalid_job_data = 2
jobname_missing = 3
others
= 4.

*
submit zficomr007 and return
with s_vkbur in s_vkbur
with s_pagnr in s_pagnr
with s_docto in s_docto
with p_data eq p_data
with p_novcom eq p_novcom
with p_ctocom eq p_ctocom
with p_resc eq v_rescisao
with p_excjob eq p_excjob
user
sy-uname
via job v_jobname
number v_jobcount
to sap-spool
without spool dynpro.
*
call function 'JOB_CLOSE'
exporting
jobcount
jobname
strtimmed
exceptions
cant_start_immediate
invalid_startdate
jobname_missing
job_close_failed
job_nosteps
job_notex
lock_failed
others
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*

= v_jobcount
= v_jobname
= 'X'
=
=
=
=
=
=
=
=

1
2
3
4
5
6
7
8.

v_dest = 'NONE'.
call function 'Z_FI_RFC_CRIA_PAGAMENTO'
in background task
destination v_dest
exporting
quinzena
= p_data
ucomm
= code100
comissao
= p_novcom
contencioso = p_ctocom
rescisao
= v_rescisao
background = p_excjob
tables
tb_tvbur
= t_tvbur
tb_lfa1
= t_lfa1
tb_xref3
= s_xref3.
call function 'ID_OF_BACKGROUNDTASK'
exporting
dest = v_dest
importing
tid = wa_id.

FNUM

if ( sy-subrc eq 0 ).
commit work.
message i999(zarm) with 'Task iniciada com nro.'
wa_id.
endif.
=

else.
perform f_valida_vkbur.
if ( not t_tverr[] is initial ).
call screen '0500' starting at 20 5.
endif.
if ( t_tvbur[] is initial ).
message w999(zarm) with text-m30.
else.
loop at t_tvbur into wa_tvbur.
call function 'ENQUEUE_EZFITCOM005'
exporting
mode_zfitcom005 = 'E'
mandt
= sy-mandt
vkbur
= wa_tvbur-vkbur
x_vkbur
= ' '
_scope
= '2'
_wait
= ' '
_collect
= ' '
exceptions
foreign_lock
= 1
system_failure = 2
others
= 3.
if sy-subrc ne 0.
delete t_tvbur.
endif.
endloop.
if ( t_tvbur[] is initial ).
message w999(zarm) with text-m33.
exit.
endif.
p_quinz
p_code100
p_newcom
p_concom
p_rescisao
p_background
s_belnr[]
t_tvbur1[]
t_auxlfa1[]

=
=
=
=
=
=
=
=
=

p_data.
code100.
p_novcom.
p_ctocom.
v_rescisao.
p_excjob.
s_docto[].
t_tvbur[].
t_lfa1[].

perform f_selecao_de_criacao.
if ( t_bsis[] is initial ) and ( v_rescisao ne '2' ).
message w999(zarm) with text-m06.
exit.
endif.
perform f_apura_pagamentos.
call screen '0200'.
loop at t_tvbur into wa_tvbur.
call function 'DEQUEUE_EZFITCOM005'
exporting
mode_zfitcom005 = 'E'
mandt
= sy-mandt
vkbur
= wa_tvbur-vkbur
x_vkbur
= ' '
_scope
= '3'

_synchron
_collect

= ' '
= ' '.

endloop.
endif.
endif.
when 'INFO'.
when 'PAGA'.
when 'ESTO'.
when 'ELIM'.
when 'INDI'.

perform f_menu_pagamentos using '1' text-m01.


perform f_menu_pagamentos using '2' text-m12.
perform f_menu_pagamentos using '3' text-m26.
perform f_menu_pagamentos using 'E' text-m28.
call selection-screen '0120' starting at 20 5.

when 'RW' or '%EX'.


leave to screen 0.
when 'CANCEL'.
leave program.
endcase.
endmodule.

" user_command_0100 INPUT

*&---------------------------------------------------------------------*
*&
Module user_command_0200 INPUT
*&---------------------------------------------------------------------*
*
rotina de comandos das telas
*----------------------------------------------------------------------*
module user_command input.
ok_code = sy-ucomm.
case ok_code.
when 'MODE'.
*
check ( sy-uname(04) eq 'ABAP' or sy-uname eq 'FABIANO' or
*
sy-uname eq 'PATI' or sy-uname eq 'SILVIO' ).
* Verifica se usurio pode executar BI em modo visvel
select single * from zfitcom014
where bname = sy-uname
and
tcode = sy-tcode.
if sy-subrc eq 0.
call screen '0101' starting at 20 5.
endif.
when 'MOD3'.
if ( v_mod3 ne c_mark ).
v_mod3 = c_mark.
else.
clear v_mod3.
endif.
when 'ENTER'.
if ( sy-dynnr eq '0300' ) or ( sy-dynnr eq '0500' ).
clear ok_code.
leave to screen 0.
endif.
when '%EX' or 'RW' or 'CANCEL'.
clear ok_code.
leave to screen 0.
when 'FIRST'. v_indice = 1.
when 'PREV'.
v_indice = v_indice - 1.
if ( v_indice eq 0 ).

v_indice = 1.
endif.
when 'NEXT'.
v_indice = v_indice + 1.
if ( v_indice gt v_totvend ).
v_indice = v_totvend.
endif.
when 'LAST'. v_indice = v_totvend.
when 'P--' or 'P-' or 'P+' or 'P++' or 'SALL' or 'DSAL'.
perform user_ok_tc using 'TB_COMISSAO' 'T_ITEM' 'MARK'
changing ok_code.
when 'IP--' or 'IP-' or 'IP+' or 'IP++'.
ok_code = ok_code+01(04).
perform user_ok_tc using 'TB_IMPOSTOS' 'T_LFBW' ' '
changing ok_code.
when 'HP--' or 'HP-' or 'HP+' or 'HP++' or 'HSALL' or 'HDSAL'.
ok_code = ok_code+01(04).
perform user_ok_tc using 'TB_HISTORICO' 'T_HISTORICO' 'MARK'
changing ok_code.
when 'SAVE'.
call function 'POPUP_TO_CONFIRM_STEP'
exporting
textline1 = text-m20
textline2 = text-m21
titel
= text-m23
importing
answer
= v_confirm.
if ( v_confirm eq 'J' ).
case code100.
when 'CRIA'. perform f_gera_arquivo.
when 'INFO'. perform f_verifica_nota.
when 'PAGA'. perform f_gera_pagamento.
when 'ESTO'. perform f_gera_estorno.
when 'ELIM'. perform f_elimina_pagamento.
endcase.
perform f_grava_dados.
clear ok_code.
leave to screen 0.
endif.
when 'ADIC'. call screen '0300' starting at 20 05.
when 'HIST'.
clear v_cop400.
call screen '0400'.
when 'PRN'.
t_auxprn[] = t_zfitcom004[].
delete t_auxprn where ( mark ne c_mark ).
perform f_calcula_totais tables t_auxprn
t_lfbw
t_lfa1
changing zfiecom002-totalnf
zfiecom002-totcom
zfiecom002-totimp.
refresh t_spopli.
clear wa_spopli.
wa_spopli-varoption = text-m04.

append wa_spopli to t_spopli.


wa_spopli-varoption = text-m05.
append wa_spopli to t_spopli.
call function 'POPUP_TO_DECIDE_LIST'
exporting
start_col = 35
start_row = 13
textline1 = text-m02
titel
= text-m03
importing
answer
= v_answer
tables
t_spopli = t_spopli.
if ( v_answer ne 'A' ).
call screen '9999'.
endif.
endcase.
clear: ok_code, sy-ucomm.
endmodule.
" user_command_0200 INPUT
*&---------------------------------------------------------------------*
*&
Module atualiza_comissao INPUT
*&---------------------------------------------------------------------*
*&
Rotina que atualiza comisses selecionadas
*&---------------------------------------------------------------------*
*&
module atualiza_comissao input.
check t_oldite[] ne t_item[].
t_oldite[] = t_item[].
loop at t_item into wa_item.
read table t_zfitcom004 into zfitcom004
with key pagnr = wa_item-pagnr
belnr = wa_item-belnr
buzei = wa_item-buzei binary search.
*
READ TABLE t_zfitcom004 INTO zfitcom004 index sy-tabix.
if ( sy-subrc eq 0 ).
modify t_zfitcom004 from wa_item index sy-tabix.
endif.
endloop.
endmodule.
" atualiza_comissao INPUT
*&---------------------------------------------------------------------*
*&
Module atualiza_historico INPUT
*&---------------------------------------------------------------------*
*&
Rotina que atualiza histricos de resciso selecionados
*&---------------------------------------------------------------------*
*&
module atualiza_historico input.
check t_oldhist[] ne t_historico[].
t_oldhist[] = t_historico[].
loop at t_historico into wa_historico.
read table t_base12 into wa_base12

with key pagnr = wa_historico-pagnr


nroite = wa_historico-nroite
binary search.
if ( sy-subrc eq 0 ).
modify t_base12 from wa_historico index sy-tabix.
endif.
endloop.
endmodule.
" atualiza_historico INPUT
*&---------------------------------------------------------------------*
*&
Module nota_fiscal INPUT
*&---------------------------------------------------------------------*
*
Rotina de atualizao do campo nota
*----------------------------------------------------------------------*
module nota_fiscal input.
select single * from zfitcom003
into wa_aux
where ( vkbur eq zfitcom003-vkbur
and ( nfnum eq zfitcom003-nfnum
and ( status ne '4'
and ( pagnr ne zfitcom003-pagnr
if ( sy-subrc eq 0 ).
message e999(zarm) with text-m27.
endif.

)
)
)
).

endmodule.
" nota_fiscal INPUT
*&---------------------------------------------------------------------*
*&
Module tb_comissao_fb03 INPUT
*&---------------------------------------------------------------------*
*
Rotina para executar double-click no table control comissao
*----------------------------------------------------------------------*
module tb_comissao_fb03 input.
check ( not zfitcom004-belnr eq '9999999999' ).
set parameter id 'BLN' field zfitcom004-belnr.
set parameter id 'BUK' field zfitcom004-bukrs.
set parameter id 'GJR' field zfitcom004-gjahr.
call transaction 'FB03' and skip first screen.
exit.
endmodule.
" tb_comissao_fb03 INPUT
*&---------------------------------------------------------------------*
*&
Module data_nota INPUT
*&---------------------------------------------------------------------*
*
Checa a data de emisso da nota fiscal
*----------------------------------------------------------------------*
module data_nota input.
if ( zfitcom003-datnf gt sy-datum ).
message e999(zarm) with text-m35.
endif.
*BDS
* if
if
*BDS

- Ajuste p/que compare a dt da quinzena e no execuo do calculo


( zfitcom003-datnf lt zfitcom003-dtcal ).
( zfitcom003-datnf lt zfitcom003-quinzena ).
- end
message e999(zarm) with text-m36.
endif.

endmodule.

" data_nota INPUT

*&---------------------------------------------------------------------*
*&
Module check_data INPUT
*&---------------------------------------------------------------------*
*
Checa obrigatoriedade do campo data
*----------------------------------------------------------------------*
module check_data input.
if ( not zfitcom003-nfnum is initial ) and
(
zfitcom003-datnf is initial ).
message e999(zarm) with text-m37.
endif.
read table t_zfitcom003 into wa_aux
with key pagnr = zfitcom003-pagnr binary search.
if ( sy-subrc eq 0 ).
wa_aux-nfnum = zfitcom003-nfnum.
wa_aux-datnf = zfitcom003-datnf.
modify t_zfitcom003 from wa_aux index sy-tabix
transporting nfnum datnf.
endif.
endmodule.

" check_data INPUT

You might also like