* make sure that posting period is open in FI:
call function 'FI_PERIOD_CHECK'
exporting
i_bukrs = ld_bukrs
i_gjahr = id_fisc_year
i_koart = '+' "period closed?
i_monat = id_period
exceptions
error_period = 1
error_period_acc = 2
others = 3.
if ( sy-subrc = 1 ) or
( sy-subrc = 2 ).
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4
raising period_closed.
elseif ( sy-subrc = 3 ).
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4
raising error_occurred.
endif.
Code:
* Geschaftsjahr und Periode aus Buchungskreis, Buchungsdatum ermitteln
CALL FUNCTION 'FI_PERIOD_DETERMINE'
EXPORTING
i_budat = pstng_date
i_bukrs = comp_code
IMPORTING
e_gjahr = fisc_year
e_poper = poper
EXCEPTIONS
fiscal_year = 1
period = 2
period_version = 3
posting_period = 4
special_period = 5
version = 6
posting_date = 7
error_message = 8 "Alle Fehler abfangen
OTHERS = 9.
IF ( sy-subrc <> 0 ).
* Ungultige Daten -> RETURN-Parameter fullen
CALL FUNCTION 'BALW_BAPIRETURN_GET1'
EXPORTING
type = sy-msgty
cl = sy-msgid
number = sy-msgno
par1 = sy-msgv1
par2 = sy-msgv2
par3 = sy-msgv3
par4 = sy-msgv4
IMPORTING
bapireturn = return_line.
APPEND return_line TO return.
error_flag = 'X'.
ENDIF.
* Bebuchbarkeit der Periode prufen
IF ( error_flag IS INITIAL ).
monat = poper.
CALL FUNCTION 'FI_PERIOD_CHECK'
EXPORTING
i_bukrs = comp_code
i_gjahr = fisc_year
i_koart = '+'
i_konto = '+'
i_monat = monat
EXCEPTIONS
error_period = 1
error_period_acc = 2
error_message = 3 "Alle Fehler abfangen
OTHERS = 4.
IF ( sy-subrc <> 0 ).
* Periode ist nicht bebuchbar -> RETURN-Parameter fullen
CALL FUNCTION 'BALW_BAPIRETURN_GET1'
EXPORTING
type = sy-msgty
cl = sy-msgid
number = sy-msgno
par1 = sy-msgv1
par2 = sy-msgv2
par3 = sy-msgv3
par4 = sy-msgv4
IMPORTING
bapireturn = return_line.
APPEND return_line TO return.
error_flag = 'X'.
ENDIF.
ENDIF. "ERROR_FLAG
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG. SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG. Every effort is made to ensure content integrity. Use information on this site at your own risk.