Have a look at exit IWO10009
* get settlement rules from ABAP memory
call function 'K_SETTLEMENT_RULE_GET'
exporting
objnr = p_caufvd_imp-objnr
x_all = ' '
tables
e_cobra = lt_cobra
e_cobrb = lt_cobrb
exceptions
not_found = 1
others = 2.
if not sy-subrc = 0.
* if not found, then go to database for settlement rules
call function 'K_SRULE_READ_ARCHIVE'
exporting
i_archive_handle1 = 0
i_objnr = p_caufvd_imp-objnr
i_append = ' '
tables
t_cobra = lt_cobra
t_cobrb = lt_cobrb
exceptions
not_enough_info = 1
others = 2.
endif.
Make the validations you need.
Hope it helps, saludos!