Neler Yeni

SAP BLOG Virtual Char/KF in SAP BW 7.4 (w/o changing Cube)

SAP Blog

Kayıtlı Üye
Katılım
22 Ara 2017
Mesajlar
319
Beğeniler
3
Puanları
6
#1
Hi All,

Scope : how to enable Virtual Char and KF in BEx query without adding our required fields in the desired cube .

Assumption : The reporting is done over Multiprovider i.e. BEx Query is created over multiprovider.
If the BEx Query is created over cube then virtual char/kf needs to be added in the cube.



Step 1 : Create a cube exclusively for Virtual Char and KF. Add all the char and KF required in this cube. Now add this cube in the Multiprovider on which BEx Query is created.
Assign/Map all the Chars and KF in Multiprovider as 1-to-1.

Virtual Char/KF in SAP BW 7.4 (w/o changing Cube)


Step 2 : Create Implementation and Class to write BADI (to implement Business Logic).

  • SE19 : Create Classic BADI using RSR_OLAP_BADI.
  • Properties Tab : Add the required Multiprovider.
  • Interface Tab : Check and Change name of Implementing Class (if required).

Virtual Char/KF in SAP BW 7.4 (w/o changing Cube)


Virtual Char/KF in SAP BW 7.4 (w/o changing Cube)


Virtual Char/KF in SAP BW 7.4 (w/o changing Cube)




Step 3 : Add attributes in Implementing Class.

Identify the fields required to implement the Business logic.

Add all the required Char and KF with pre-defined format.

Char : P_CHA_ (P_CHA_0FISCPER)

KF : P_KYF_ (P_KYF_0AMOUNT)

Level : Instance Attribute & Visibilty : Pubilc.

All the attributes will be of ASSOCIATED TYPE : I.

Virtual Char/KF in SAP BW 7.4 (w/o changing Cube)


Note :

  • First 5 attributes are those which are existing in cube used in derivation of business logic. . Last 6 are new ones i.e. Virtual Char/KF, which will be populated in the BADI.
  • 2nd attribute is Nav_attr available in the cube.

Step 4 : DEFINE, INITIALIZE & COMPUTE.

Define : Definition of all fields are required here.

Initialize : As name suggests, a default value is assigned (We will not touch this area).

Compute : Actual logic will be written here.



DEFINE : Double click on Define Method (Interface Tab). Similarly define all the attributes (class).
(Not all char and KF are shown in below code).

method IF_EX_RSR_OLAP_BADI~DEFINE.

DATA: l_s_chanm TYPE rrke_s_chanm,
l_kyfnm TYPE rsd_kyfnm.
FIELD-SYMBOLS:
<l_s_chanm> TYPE rrke_s_chanm.

CASE i_s_rkb1d-infocube.

WHEN 'ZXXXXXXX'. "Multiprovider Name

* characteristic
l_s_chanm-chanm = 'XXXXXX_NO'. "Existing
l_s_chanm-mode = rrke_c_mode-no_selection.
APPEND l_s_chanm TO c_t_chanm.
Clear l_s_chanm.

l_s_chanm-chanm = 'ZXXXXXXXXXXXXXX25'. "Existing Nav Attr
l_s_chanm-mode = rrke_c_mode-no_selection .
APPEND l_s_chanm TO c_t_chanm.
Clear l_s_chanm.

l_s_chanm-chanm = 'XXXXPOLPS'. "Virtual Char
l_s_chanm-mode = rrke_c_mode-no_selection .
APPEND l_s_chanm TO c_t_chanm.
Clear l_s_chanm.

l_s_chanm-chanm = 'XXXXPOLOP'. "Virtual Char
l_s_chanm-mode = rrke_c_mode-no_selection .
APPEND l_s_chanm TO c_t_chanm.
Clear l_s_chanm.

* Keyfigure
l_kyfnm = 'XXXXXX3'. "Existing
APPEND l_kyfnm TO c_t_kyfnm.
Clear l_kyfnm.

l_kyfnm = 'XXXCOUNT'. "Virtual KF
APPEND l_kyfnm TO c_t_kyfnm.
Clear l_kyfnm.

ENDCASE.
endmethod.

INITIALIZE : No change is required here.



COMPUTE : (Not all char and KF are shown in below code).

  • Field-Symbols are defined (all the attributes or what we have in DEFINE section).
  • Assignment of Attributes to Field-Symbol.
  • Actual Business logic using Field-Symbol.

method IF_EX_RSR_OLAP_BADI~COMPUTE.

FIELD-SYMBOLS :

<l_ZXXXXXXXXXXXXXX25> type /BIC/OIXXXXXX25,
<l_XXXXXXXXX3> type /BIC/OIXXXXXXX3,

<l_XXXXPOLMT> type /BIC/OIXXXXPOLMT,
<l_XXXXPOLPS> type /BIC/OIXXXXPOLMT,
<l_XXXXCOUNT> type /BIC/OIXXXCOUNT.

Assign component P_CHA_ZXXXXXXXXXXXXXX25 of STRUCTURE C_S_DATA to <l_ZXXXXXXXXXXXXXX25>.
Assign component P_KYF_XXXXXXXXX3 of STRUCTURE C_S_DATA to <l_XXXXXXXXX3>.

Assign component P_CHA_XXXXPOLMT of STRUCTURE C_S_DATA to <l_XXXXPOLMT>.
Assign component P_CHA_XXXXPOLPS of STRUCTURE C_S_DATA to <l_XXXXPOLPS>.
Assign component P_KYF_XXXXCOUNT of STRUCTURE C_S_DATA to <l_XXXXCOUNT>.

<l_XXXXPOLPS> = 'Above Threshold'.

IF <l_ZXXXXXXXXXXXXXX25> = 'MAHARASHTRA'.

IF <l_XXXXXXXXX3> > 120 .
<l_XXXXPOLMT> = 'Above Threshold'.
ELSE.
<l_XXXXPOLMT> = 'Within Threshold'.
ENDIF.

ENDIF.

<l_XXXXCOUNT> = 1.

endmethod.



Step 5 : Add the Virtual Char/KF in the BEx Query and execute.
Exclude the Virtual Char/KF cube from the BEx Query or use only those Infoproviders from which data is required for output. (Infoprov = ZCUBE1 or ZCUBE2).



Points to be considered :

  1. Characteristic will not be populated with the values if SIDs are not created in that IOBJ for those values.
  2. Output of the Virtual Char/KF is derived based on the granularity kept in the BEx query output.
    So if the calculation is required at very least granularity then, create a CKF and use EXCEPTION AGGREGATION on a characteristic which has least granularity i.e. PO number or Material.





Regards,

Himanshu Sarawagi

Okumaya devam et...
 
Üst