Header 1 |
---|
METHOD roles. DATA: lt_return TYPE bapirettab, FIELD-SYMBOLS: <fs_partnerrole> TYPE bapibus1006_bproles. CALL FUNCTION 'BUPA_ROLES_GET_2' LOOP AT lt_partnerroles ASSIGNING <fs_partnerrole>. IF <fs_partnerrole>-partnerrole = 'CRM000'. WRITE: / 'Adjusting valid-from date of role',<fs_partnerrole>-partnerrole,'if necessary'. <fs_partnerrole>-valid_from = '20000101'. CLEAR lt_return. CALL FUNCTION 'BUPA_ROLE_CHANGE' print_errors( lt_return ). ENDLOOP. IF ls_crm000_present IS INITIAL. WRITE: / 'Adding role CRM000 (Sold-to party)'. ls_partnerrole-valid_from = '20000101'. CALL FUNCTION 'BUPA_ROLE_ADD_2' print_errors( lt_return ). ENDIF. ENDMETHOD. |
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).
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?