Quelquepart

Blog d'un consultant SAP

Vous êtes ici : Accueil>Show code in Nugget

Show code in Nugget ZCUBE_DELETE.nugg

Table of content

Program ZCUBE_DELETE: Cube content deletion

ABAP Code

*&---------------------------------------------------------------------*
*& Program : ZCUBE_DELETE
*& Author  : S. Hermann
*& Date    : 2008
*& Version : 1.0
*&---------------------------------------------------------------------*
*& This program delete cube content with dim table, without
*& confirmation popup
*& To use in process chain (BW 3.x)
*&---------------------------------------------------------------------*
*& 2008       : Initial release
*&---------------------------------------------------------------------*

PROGRAM zcube_delete.

*######################################################################*
*
*                             DATA SECTION
*
*######################################################################*

* Type-pools are no more required in BI7.x, you can remove it
TYPE-POOLS rsenq.

DATA : o_dta  TYPE REF TO cl_rsd_dta,
       o_error TYPE REF TO cx_root,
       t_object TYPE rsenq_t_object,
       s_object TYPE rsenq_s_object,
       t_msg TYPE rs_t_msg,
       s_msg TYPE rs_s_msg,
       w_lockid TYPE rsenq_lockid.

*######################################################################*
*
*                             SELECTION SCREEN
*
*######################################################################*

PARAMETERS p_dta TYPE rsinfocube OBLIGATORY.


*######################################################################*
*
*                             MAIN PROGRAM
*
*######################################################################*

* Create Cube Object
TRY.
    CREATE OBJECT o_dta
      EXPORTING
        i_infoprov    = p_dta
      EXCEPTIONS
        input_invalid = 1
        not_found     = 2
        OTHERS        = 3.
  CATCH cx_root INTO o_error.
    sy-subrc = 1.
ENDTRY.
IF sy-subrc <> 0.
  MESSAGE e092(rsmpc) WITH p_dta.
ENDIF.

* Lock cube
s_object-object = 'DATATARGET'.
s_object-value  = p_dta.
APPEND s_object TO t_object.
REFRESH t_msg.
CALL FUNCTION 'RSENQ_ENQUEUE'
  EXPORTING
    i_action   = rsenq_c_refresh_datatarget
    i_t_object = t_object
  IMPORTING
    e_lockid   = w_lockid
  CHANGING
    c_t_msg    = t_msg
  EXCEPTIONS
    locked     = 1
    OTHERS     = 2.
IF sy-subrc <> 0.
  READ TABLE t_msg INTO s_msg INDEX 1.
  IF sy-subrc = 0 AND NOT s_msg-msgid IS INITIAL AND NOT
     s_msg-msgno IS INITIAL.
    MESSAGE ID s_msg-msgid TYPE 'I' NUMBER s_msg-msgno
          WITH s_msg-msgv1 s_msg-msgv2 s_msg-msgv3
               s_msg-msgv4.
  ELSE.
    MESSAGE e812(rsm) WITH text-386 p_dta.
  ENDIF.
ENDIF.

* Delete cube content
TRY.
    CALL METHOD o_dta->delete_data
      EXPORTING
        i_incl_dime   = 'X'
        i_with_dialog = space
      EXCEPTIONS
        cancelled     = 1
        not_found     = 2
        OTHERS        = 3.
  CATCH cx_root INTO o_error.
    sy-subrc = 1.
ENDTRY.

* Unlock cube
IF sy-subrc <> 0.
  IF NOT w_lockid IS INITIAL.
    CALL FUNCTION 'RSENQ_DEQUEUE'
      EXPORTING
        i_lockid      = w_lockid
      CHANGING
        c_t_msg       = t_msg
      EXCEPTIONS
        no_lock_found = 1
        OTHERS        = 2.
  ENDIF.
  MESSAGE e094(rsmpc) WITH p_dta.
ELSE.
  MESSAGE s095(rsmpc) WITH p_dta.
  IF NOT w_lockid IS INITIAL.
    CALL FUNCTION 'RSENQ_DEQUEUE'
      EXPORTING
        i_lockid      = w_lockid
      CHANGING
        c_t_msg       = t_msg
      EXCEPTIONS
        no_lock_found = 1
        OTHERS        = 2.
  ENDIF.
ENDIF.