Skip to Content
Author's profile photo Amit Upadhye

Trying out UBOI interfaces in SAP FS-PM solution

When one starts to work with  policy management solution from SAP it is important to get familiar with the product . Especially if you are tasked to work with some custom development.

There are few frameworks that make sure  things work smoothly in FSPM such as PBT (Policy based technology ) and Time model Functions( to enable the policy positioning n the past or in the future ) . Along with learning these frameworks it is always useful to play with the existing available UBOI interfaces and learn how it works .

Most of the tasks in the FSPM are depending on the policy business object which is manipulated  using various UBOI interfaces depending on the requirement.

Please find below sample program to start playing with UBOI interfaces in SAP FS-PM

DATA:

    lr_date_service         TYPE REF TO   /pm0/if_abp_bc_extcordt_srvcs,

    lr_date_service_init    TYPE REF TO   /pm0/cl_abp_bc_excodt_srvcs,

    ls_polpr_key            TYPE          /pm0/abvapolpr, “/PM0/ABVAPOLICY

    lt_polpr_keys           TYPE          /pm0/abvapolpr_t,

    lf_extenal_date         TYPE          abap_bool,

    lf_correspondence_date  TYPE          abap_bool,

    lf_bts_date             TYPE          abap_bool,

    lv_applnr_tt            TYPE          /pm0/abd_applnr_tt,

    iv_planstate_id         TYPE          /pm0/abd_stateextdate_id,

    it_polpr                TYPE          /pm0/abwapolpr_t,

    gr_get_policy           TYPE REF TO   /pm0/if_abp_tc_get_policy,

    gr_get_polpr            TYPE REF TO   /pm0/if_abp_tc_get_polpr,

    gr_get_cov              TYPE REF TO   /pm0/if_abp_tc_get_cov,

    lr_uboi                 TYPE REF TO   /pm0/cl_abp_bou_ctr_fac,

    ls_policy_key           TYPE          /pm0/abvapolicy,

    it_policy               TYPE TABLE OF /pm0/abwapolicy,

    lv_duedate               TYPE         /pm0/abd_duedate_dt.

  BREAK-POINT.

  DATA :

        it_covdetail TYPE TABLE OF /pm0/abwacov,

        is_sec_cov   TYPE /pm0/abvacov,

        ls_cov_det   TYPE /pm0/abwacov.

  /pm0/cl_ab_bpu_registry=>init( ‘D’).

  IF /pm0/cl_ab_bpu_registry=>gr_ctr_fac IS BOUND.

    gr_get_policy = /pm0/cl_ab_bpu_registry=>gr_ctr_fac->get_gb_policy( ).

    gr_get_polpr /pm0/cl_ab_bpu_registry=>gr_ctr_fac->get_gb_polpr( ).

    gr_get_cov /pm0/cl_ab_bpu_registry=>gr_ctr_fac->get_gb_cov( ).

  ENDIF.

  FIELD-SYMBOLS : <fs_polpr> TYPE /pm0/abwapolpr.

*get the application number for a certain existing policy

  SELECT SINGLE c~applnr_tt  INTO  lv_applnr_tt FROM /pm0/abdapolicy AS p INNER JOIN /pm0/abdapolpr AS c ON p~secpol_id = c~policy_id

      WHERE p~policynr_tt = .“enter existing policy number here

“initialize

  /pm0/cl_abp_bc_excodt_srvcs=>initialize_application().


*get reference to the date service

  lr_date_service = /pm0/cl_abp_bc_excodt_srvcs=>get_singleton( ).

  lr_date_service_init ?= lr_date_service.

*Load the application

  lr_date_service_init->load_application(

    EXPORTING

      iv_effective_dt = sydatum

      iv_policynr_tt  = “enter existing policy number here

      iv_polprnr_tt   = lv_applnr_tt

    IMPORTING

      es_polpr_key    = ls_polpr_key

      ev_planstate_id = iv_planstate_id

         ).

  CHECK iv_planstate_id EQ ‘0’. ” Plane State OK

  ls_policy_keybo_id = ls_polpr_keybo_id.

*Get policy Data

  TRY.

      CALL METHOD gr_get_policy->get_policy

        EXPORTING

          is_sec    = ls_policy_key

        IMPORTING

          et_policy = it_policy.

    CATCH /pm0/cx_abp_uboi .

      WRITE : ‘Exception in UBOI’.

    CATCH /pm0/cx_3ft_exception .

      WRITE : ‘Exception in Framework’.

  ENDTRY.

*Get contract data

  CALL METHOD gr_get_polpr->get_polpr

    EXPORTING

      is_sec   = ls_polpr_key

    IMPORTING

      et_polpr = it_polpr.

  READ TABLE it_polpr ASSIGNING <fs_polpr> INDEX 1.

  MOVE-CORRESPONDING ls_polpr_key TO  is_sec_cov.

*Get Coverage data

  TRY.

      CALL METHOD gr_get_cov->get_cov

        EXPORTING

          is_sec = is_sec_cov

        IMPORTING

          et_cov = it_covdetail.

    CATCH /pm0/cx_abp_uboi .

    CATCH /pm0/cx_3ft_exception .

  ENDTRY.


Similarly some other APIS can also be used once the policy BO is loaded


DATA:   et_document_cf TYPE /pm0/abcn_cashfl_t,

        et_cfdocs TYPE /pm0/abn_cashfl_t,

        account_data TYPE REF TO /pm0/cl_ab_int_ac,

        et_document_nc TYPE /pm0/abcn_nocash_t.

  CREATE OBJECT account_data.

*get cash-flow documents for certain Contract

  CALL METHOD account_data->/pm0/if_ab_int_ac~get_docs_cf

    EXPORTING

      is_polpr_key   = ls_polpr_key

    IMPORTING

      et_document_cf = et_document_cf

      et_cfdocs      = et_cfdocs.

*get non cash flow documents for certain contract

  CALL METHOD account_data->/pm0/if_ab_int_ac~get_docs_nc

    EXPORTING

      is_polpr_key   = ls_polpr_key

    IMPORTING

      et_document_nc = et_document_nc.

  BREAK-POINT.

Assigned Tags

      6 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Christian Lechner
      Christian Lechner

      Hi Amit,

      Ii just stumbled over your blog post being surprised that FS-PM now offers publicly available documented APIs. Well, it is not the case, it is the "good old" UBOI interfaces that allow you to interact with the business object (and some other objects in FS-PM like the journal) 🙂 .

      Taking a look at your code I have to make some remarks as several spots are not as they should be (at least from my experience):

      • The SELECT of the application of a policy/contract is completely random. Your SELECT statement just returns the first version it gets from the database without considering versions or status (like being inactive)
      • The initialization of the framework via the External and Correspondance date handler is at least unusual. Usually you set up the framework and the run mode directly as you can not be sure if the constraints of this handler (esp. as the internal code of the method does not check if the framework was already initialized)
      • The loading of the application is usually done via the journal UBOI. With your call of the external date handler you introduce a lot of overhead concerning the initialization of handlers that you do not need in the further code.
      • Before calling the GET_POLICY method you should fully qualify the key you are using. Beside your moving of the BO-ID (ls_policy_key-bo_id = ls_polpr_key-bo_id.) you should also move the POLICY_ID from the LS_POLPR structure to the field SECPOL_ID of the LS_POLICY_KEY
      • When fetching the contracts under the policy via GET_POLPR be aware that more than one contract can exist below the policy. Only if the key is fully qualified this reading is correct. This should be made clear by a comment from my point of view
      • You should never directly create an instance of the accounting component /pm0/cl_ab_int_ac as there is a factory /pm0/cl_ab_int_creator that provides you the right instance based on a customizing. This statement is by the way valid for any interface you interact with in FS-PM (like FS-CD)
      • You can reduce the amount of fetched CF and NCF documents by using the IT_VARIANT parameter. This is quite important from the point of view of performance as there can be quite a lot of cashflow and non-cashflwo documents in the database


      Cheers

      Christian

      Author's profile photo Amit Upadhye
      Amit Upadhye
      Blog Post Author

      Thank you very much for going through the blog and replying with really useful information .  I decided to share this as I started with FS-PM doing something  like this. Really appreciate your valuable inputs here.

      Author's profile photo Jan Wang
      Jan Wang

      the replying is really useful indeed, I would say, not only for guys just started with FS-PM but also for people who have worked with FS-PM for a while. the framework of FS-PM is so complex.

      Author's profile photo NAREN MONDAL
      NAREN MONDAL

      Thank you very much really helpful information .

      Can I get some materials related to the FSPM to get the clear concept related to the TMF and BTX.

      Thanks in advance.

      Author's profile photo Michael Hilberg
      Michael Hilberg

      Hi Naren,

      Check out the documentation page of FS-PM.

      The development team recently published a guide for both topics. You can find them under the right-hand side column labelled "How To-Guides".

      Cheers,

      Michael

       

       

      Author's profile photo NAREN MONDAL
      NAREN MONDAL

      Thanks for your valuable feedback.

      Really helpful information and documents on FSPM.