Tag Archives: locks

Delete all locks to Planning Cube via BEx Workbook

clearlocks

In our planning application we give the central controller the possibility of deleting all locks to the Planning Infocube to prepare for some central functions (as central settlement of all WBSs, or central version copy).

Here is how we proceed.

1) Create a Custom Planning Function type. This planning function type does nothing to the data it receives, but instead removes all locks on the desired Infoprovider. See below the code for the EXECUTE Method and the Settings for the PF Type. Note that the Planning Function has 1 parameter which is the name of the Infoprovider to be unlocked.

2) Create a Planning Function on any Aggregation Level not related to the Planning Cube that you wish to unlock. (Otherwise, the unlock Function might fail due to  locking conflicts with the locks it aims to clear!!).  Assign a BEx Variable of type Char, Single Value, Mandatory initial not allowed, on 0INFOPROV to the input parameter.

3) Create a filter in such a way that it will always return at least 1 record (otherwise the Planning Functions EXECUTE method will not be called).

4) Create a Planning Sequence on the Aggregation Level above, using the filter and the planning function.

5) Call the Planning Sequence from a BEx Command Button in the BEx Workbook. The button should contain the following command sequence.
CMD      1     EXECUTE_PLANNING_SEQUENCE
PLANNING_SEQUENCE_NAME 1 <name of the Planning Sequence>
VAR_1_NAME    1  <name of variable on 0INFOPROV>
VAR_1_VALUE   1  <name of Infoprovider to unlock>

Settings for the planning function in RSPLF1

Properties Tab
- Without blocks
- Hide Column of Chars. To Be Changed
Parameter Tab
Parameter = INFOPROV / Description = INFOPROV
Parameter Type = Elementary
InfoObject = 0INFOPROV
Variables Allowed => Checked.

Code for the EXECUTE method of the planning function

method if_rsplfa_srvtype_imp_exec~execute.

*********************************************************************************
*
*               DECLARATIONS
*
*********************************************************************************

  data:
        l_r_param type ref to if_rsplfa_param_elem,
        l_infoprov type rsinfoprov.

  data:
        l_msgv type symsgv,
        log_handle type balloghndl,
        t_log_handle type bal_t_logh,
        log type bal_s_log,
        log_msg type bal_s_msg.

********************************************************************************
*
*               LOGIC
*
*********************************************************************************
  "Log some infos

  field-symbols:
        <s_data_charsel> type rsplf_s_charsel.

  log-extnumber = 'Infrabel IP Logging'.
  log-object  = 'ZIIP'.
  log-subobject = 'ZIIP'.
  log-aldate = sy-datum.
  log-altime = sy-uzeit.
  log-aluser    = sy-uname.
  log-alprog    = sy-repid.
  call function 'BAL_LOG_CREATE'
    exporting
      i_s_log      = log
    importing
      e_log_handle = log_handle
    exceptions
      others       = 1.

  " Get number of periods to be closed via parameter 'PERIODS' type FISCPER3
  l_r_param = i_r_param_set->get_param_elem( 'INFOPROV' ).
  l_r_param->get_value( importing e_value = l_infoprov ).

  concatenate 'Remove all user locks to: ' l_infoprov into l_msgv.
  log_msg-msgty     = 'I'.
  log_msg-msgid     = 'ZIIP'.
  log_msg-msgno     = '000'.
  log_msg-msgv1     = l_msgv.  " set to Planning Function
  log_msg-msgv2     = ''.  " set to value of filter
  log_msg-msgv3     = ''.  " set to planning sequence if any
  log_msg-msgv4     = ''.  " planning function step

  call function 'BAL_LOG_MSG_ADD'
    exporting
      i_log_handle     = log_handle
      i_s_msg          = log_msg
    exceptions
      log_not_found    = 1
      msg_inconsistent = 2
      log_is_full      = 3
      others           = 4.

  append log_handle to t_log_handle.
  call function 'BAL_DB_SAVE'
    exporting
      i_t_log_handle = t_log_handle.

  data: t_enq    type standard table of seqg3,
        t_enq_f  type standard table of seqg3,
        w_eng    type seqg3,
        v_result type sy-subrc,
        v_cube   type char30.

  refresh: t_enq_f,
           t_enq.

  move l_infoprov to v_cube.

* READ LOCKS
  call function 'ENQUEUE_READ'
    exporting
      gclient                     = sy-mandt
      gname                       = 'RSPLS_S_LOCK'
*   GARG                        = ' '
      guname                      = ''
*   LOCAL                       = ' '
*   FAST                        = ' '
* IMPORTING
*   NUMBER                      =
*   SUBRC                       =
    tables
      enq                         = t_enq
* EXCEPTIONS
*   COMMUNICATION_FAILURE       = 1
*   SYSTEM_FAILURE              = 2
*   OTHERS                      = 3
            .
  if sy-subrc = 0
     and t_enq[] is not initial.
* QUEUE NOT EMPTY

    if v_cube ne space.
*---ONLY FILTER ENTRIES FOR REQUESTED IP_CUBE
      loop at t_enq into w_eng.
        if w_eng-garg cs v_cube.
          append w_eng to t_enq_f.
        endif.
      endloop.
    else.
      t_enq_f[] = t_enq[].
    endif.

    if not t_enq_f[] is initial.
*---DELETE QUEUEE
      call function 'ENQUE_DELETE'
        exporting
          check_upd_requests    = 0
          suppress_syslog_entry = ' '
        importing
          subrc                 = v_result
        tables
          enq                   = t_enq_f.
    endif.
  endif.

endmethod.