Quantcast
Channel: SCN : All Content - ABAP Development
Viewing all articles
Browse latest Browse all 8332

Change validity date of business partner role / Get all roles (also currently invalid ones)

$
0
0
The following code works for the cases
- CRM000 role is not present at all, ever (the code adds it)
- the CRM000 role is valid today (the code changes the valid-from date to 01.01.2000 and valid-to date to 31.12.2000 ... also for any other role; currently it does not check whether the dates need adjustment, but I will implement that check next)
But if failes when
- the CRM000 role is present, but not valid today (because it is not retrieved with BUPA_ROLES_GET_2, but BUPA_ROLE_ADD_2 fails because it is already present).
I have tried all the non-deprecated APIs and BAPIs with BUPA and ROLE in the name that looked like they could solve the problem, but none worked. I am unable to retrieve all BP roles, valid on any days - I can only ever get the roles valid on a specific date (e.g. today).
Header 1

METHOD roles.

  DATA: lt_return         TYPE          bapirettab,
        lt_partnerroles   TYPE TABLE OF bapibus1006_bproles,
        ls_partnerrole    TYPE          bapibus1006_bproles,
        ls_crm000_present TYPE          crmt_boolean.

  FIELD-SYMBOLS: <fs_partnerrole> TYPE bapibus1006_bproles.

  CALL FUNCTION 'BUPA_ROLES_GET_2'
    EXPORTING
      iv_partner      = iv_partner_id
    TABLES
      et_partnerroles = lt_partnerroles
      et_return       = lt_return.

  LOOP AT lt_partnerroles ASSIGNING <fs_partnerrole>.

    IF <fs_partnerrole>-partnerrole = 'CRM000'.
      ls_crm000_present = 'X'.
    ENDIF.

    WRITE: / 'Adjusting valid-from date of role',<fs_partnerrole>-partnerrole,'if necessary'.

    <fs_partnerrole>-valid_from = '20000101'.
    <fs_partnerrole>-valid_to   = '99991231'.

    CLEAR lt_return.

    CALL FUNCTION 'BUPA_ROLE_CHANGE'
      EXPORTING
        iv_partner             = iv_partner_id
        iv_partnerrolecategory = <fs_partnerrole>-partnerrolecategory
*       IV_X_ALL_PARTNERROLES  = ' '
        iv_partnerrole         = <fs_partnerrole>-partnerrole
*       IV_DIFFTYPEVALUE       =
        iv_validfrom           = <fs_partnerrole>-valid_from
        iv_validfrom_x         = 'X'
        iv_validto             = <fs_partnerrole>-valid_to
        iv_validto_x           = 'X'
        iv_x_save              = 'X'
      TABLES
        et_return              = lt_return.

    print_errors( lt_return ).

  ENDLOOP.

  IF ls_crm000_present IS INITIAL.

    WRITE: / 'Adding role CRM000 (Sold-to party)'.

    ls_partnerrole-valid_from          = '20000101'.
    ls_partnerrole-valid_to            = '99991231'.
    ls_partnerrole-partnerrole         = 'CRM000'.
    ls_partnerrole-partnerrolecategory = 'CRM000'.

    CALL FUNCTION 'BUPA_ROLE_ADD_2'
      EXPORTING
        iv_partner             = iv_partner_id
        iv_partnerrolecategory = ls_partnerrole-partnerrolecategory
*       IV_X_ALL_PARTNERROLES  = ' '
        iv_partnerrole         = ls_partnerrole-partnerrole
*       IV_DIFFTYPEVALUE       =
        iv_validfrom           = ls_partnerrole-valid_from
        iv_validto             = ls_partnerrole-valid_to
        iv_x_save              = 'X'
*       IV_CREATE_CP           =
      TABLES
        et_return              = lt_return.

    print_errors( lt_return ).

  ENDIF.

ENDMETHOD.

BUPA_ROLES_GET gets all roles, without validity dates, but it is deprecated. Is it the only way to get all roles? It does not return the validity dates (presumably it stems from a time before roles had validity dates). BUPA_ROLES_READ also does not return the validity dates, there is no BUPA_ROLES_READ_2. So even if I use BUPA_ROLES_GET ... how do I get the validity dates for those roles that are not currently valid?

Viewing all articles
Browse latest Browse all 8332

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>