Verificar periodo contable abierto
Transacción: OB52, SE38
Escenario: Necesito por programa verificar si está abierto el período contable de la fecha actual.
report zprueba_periodo.
data: w_gjahr like bkpf-gjahr,
w_monat like bkpf-monat,
w_poper like t009b-poper,
w_oper like t001b-frpe1,
w_budat like bkpf-budat,
wi_monat like t001b-frpe1,
w_bukrs like t001b-bukrs,
w_fecha(8).
start-of-selection.
w_bukrs = ‘1000’.
w_budat = sy-datum.
call function ‘FI_PERIOD_DETERMINE’
exporting
i_budat = w_budat
i_bukrs = w_bukrs
importing
e_gjahr = w_gjahr
e_monat = w_monat
e_poper = w_poper
exceptions
fiscal_year = 1
period = 2
period_version = 3
posting_period = 4
special_period = 5
version = 6
posting_date = 7
others = 8.
if sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
wi_monat = w_monat.
call function ‘FI_PERIOD_CHECK’
exporting
i_bukrs = w_bukrs
i_gjahr = w_gjahr
i_koart = ‘+’
i_monat = wi_monat
i_glvor = ‘RFBU’
importing
e_oper = w_oper
exceptions
error_period = 1
error_period_acc = 2
invalid_input = 3
others = 4.
if sy-subrc <> 0.
message s001(00) with ‘No se puede contabilizar en la fecha indicada’.
else.
message s001(00) with ‘OK’.
endif.
Link: http://www.sap4.com/index.php?title=FI_PERIOD_CHECK
http://www.mundosap.com/foro/showthread.php?t=35003
http://www.forosap.com/f17/funci-n-abap-periodo-contable-t2995/
Probando así tal cual el código no me valida el mes contable, es necesario ponerle la cuenta y el valor para MKOAR, así sí funciona.
Saludos.
genial, buen dato! gracias!
buen dato!