virtual characteristic

6
Code for virtual characteristic Before coming to ABAP code portion we first need to know what ba sically the virtual characteristics or key figures are. Virtual characteristics and key figures appear to the user like their normal counterparts, yet they are calculated in standard BW user exits, where you can program your own logic. his complex logic, which must be created in ABAP, is executed at the same time as the !uery. Although the virtual characteristics and key figures are not actually  populated in the database, we can not see data through infoprovider, though they are incorporated into an "nfo#ube data model so the ob$ects can be selected when designing a !uery. %ike other normal characteristics, virtual characteristics must also be incorporated into the appropriate dimension. he following example describes how to implement virtual characteristics, and these  principles also apply for setting up virtual key figures. "n our pro$ect scenario we have one characteristic &#'()*A, which does not  physically store any value, but it should be populated by +- during !uery runtime depending on two date fields. And ultimately one key figure will be restricted by this virtual characteristic with value +-.

Upload: kk6969

Post on 04-Jun-2018

232 views

Category:

Documents


0 download

TRANSCRIPT

8/13/2019 Virtual Characteristic

http://slidepdf.com/reader/full/virtual-characteristic 1/6

Code for virtual characteristic

Before coming to ABAP code portion we first need to know what basically the virtualcharacteristics or key figures are.Virtual characteristics and key figures appear to the user like their normal counterparts,

yet they are calculated in standard BW user exits, where you can program your ownlogic. his complex logic, which must be created in ABAP, is executed at the same timeas the !uery. Although the virtual characteristics and key figures are not actually

populated in the database, we can not see data through infoprovider, though they areincorporated into an "nfo#ube data model so the ob$ects can be selected when designing a!uery. %ike other normal characteristics, virtual characteristics must also be incorporatedinto the appropriate dimension.

he following example describes how to implement virtual characteristics, and these principles also apply for setting up virtual key figures.

"n our pro$ect scenario we have one characteristic &#'()* A , which does not physically store any value, but it should be populated by + - during !uery runtimedepending on two date fields. And ultimately one key figure will be restricted by thisvirtual characteristic with value + -.

8/13/2019 Virtual Characteristic

http://slidepdf.com/reader/full/virtual-characteristic 2/6

*o for this we have to write ABAP code in the enhancement component RSR00001 which contain the function module EXIT_SAPMRSRU_001 for virtual key figures andcharacteristics.

he ABAP program has three parts

"n the "nclude & /*/012 we have to make the virtual field setting. his includeis re!uired for the selection of characteristics which needs to be read or written.

#haracteristics have to be stored in table E_T_CHANM where as 3ey figureshave to be stored in table E_T_ !"NM

So#e $seudo code is here %ith scree& shot'As !uery is built on multiprovider ZMPMC030W456 7&(P(#1817.

l)s)chanm9chanm : 7 &P()(#(P7."f the characteristics should only be read, then use l)s)chanm9mode : rrke)c)mode9read.

append l)s)chanm to e)t)chanm.

l)s)chanm9chanm : 7&) 5#'7. l)s)chanm9mode : rrke)c)mode9read. append l)s)chanm to e)t)chanm.

l)s)chanm9chanm : 7&#'()* A 7."f the characteristics must be changed, then use l)s)chanm9mode : rrke)c)mode9no)selection. append l)s)chanm to e)t)chanm.

8/13/2019 Virtual Characteristic

http://slidepdf.com/reader/full/virtual-characteristic 3/6

"n "nclude & /*/ 'P we have to define the ;lobal parameter which must be inthe form ;)P'*)<"6=' #0B5>)<6A(5 '= "6=' 'B?5# > type ".

Pseudo code is attached (elo% %ith scree& shot'

@A A ;)P'*)&(P(#181)&) 5#' P5 ".@A A ;)P'*)&(P(#181)&P()(#(P P5 ".@A A ;)P'*)&(P(#181)&#'()* A P5 ".

8/13/2019 Virtual Characteristic

http://slidepdf.com/reader/full/virtual-characteristic 4/6

"n "nclude & /*/&&& we have to write the actual code to calculate virtualfigures as per infocube records. "n this last section, the ABAP is processed forevery "nfo#ube record. he program contains the actual user exit where thevirtual characteristics and key figures are calculated. A standard ABAP formneeds to be defined for each "nfo#ube in the following form9endform

='/( user_<InfoCube>

Programming logic

56@='/(.

Pseudo code is attached here%ith %ith scree& shot'Here the lo)ic is I" *+MCMP ,ATE - *. /0 reater tha& or e ual to +Teco ,ate-or +Curre&t ,ate- the& The 2irtual Characteristic 3C4M_STAT 5 6X7

FORM user_ZCPMC030 USING i_s_kb1d TYPE rsr_s_rkb1d CHANGING c_s_d ! TYPE "#$

FIE%&'SYM(O%S )*_Z_TECO+$ FIE%&'SYM(O%S )*_,-._.c.-+$

8/13/2019 Virtual Characteristic

http://slidepdf.com/reader/full/virtual-characteristic 5/6

FIE%&'SYM(O%S )%_ZCOM_STAT+$

ASSIGN COMPONENT G_POS_ZCPMC030_Z_TECO OF STRUCTURE c_s_d ! TO )%_Z_TECO+$ ZPM_MCMP ASSIGN COMPONENT G_POS_ZCPMC030_ZPM_MCMP OF STRUCTURE c_s_d ! TO )%_ ZPM_MCMP +$

ASSIGN COMPONENT G_POS_ZCPMC030_ZG&_CT OF STRUCTURE c_s_d ! TO )*_ZG&_CT+$

ASSIGN COMPONENT G_POS_ZCPMC030_ZCOM_STAT OF STRUCTURE c_s_d ! TO )%_ZCOM_STAT+$

&ATA/ F1 %I E SY'&ATUM$If TEC4 ,ATE is &ot set8 the& the Curre&t ,ate &eeds to (e ta9e& IF )%_Z_TECO+ IS INITIA%$ )%_Z_TECO+ SY'&ATUM2 4$

EN&IF$ F1 )%_0FINISH&ATE+ 5 30$

IF F1 GE )%_Z_TECO+$ )%_ZCOM_STAT+ 676$ EN&IF$

EN&FORM$

8/13/2019 Virtual Characteristic

http://slidepdf.com/reader/full/virtual-characteristic 6/6