Você está na página 1de 6

Code for virtual characteristic

Before coming to ABAP code portion we first need to know what basically 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 +,-.

*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 and characteristics. he ABAP program has three parts. "n the "nclude &,/*/012 we have to make the virtual field setting. his include is re!uired for the selection of characteristics which needs to be read or written. #haracteristics have to be stored in table E_T_CHANM whereas 3ey figures have to be stored in table E_T_ !"NM So#e $seudo code is here %ith scree& shot' As !uery is built on multiprovider ZMPMC030 W456 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.

"n "nclude &,/*/ 'P we have to define the ;lobal parameter which must be in the form ;)P'*)<"6=' #0B5>)<6A(5 '= "6=' 'B?5# > type ". Pseudo code is attached (elo% %ith scree& shot' @A A. ;)P'*)&(P(#181)&) 5#' AP5 ". @A A. ;)P'*)&(P(#181)&P()(#(P AP5 ". @A A. ;)P'*)&(P(#181)&#'()* A AP5 ".

"n "nclude &,/*/&&& we have to write the actual code to calculate virtual figures as per infocube records. "n this last section, the ABAP is processed for every "nfo#ube record. he program contains the actual user exit where the virtual characteristics and key figures are calculated. A standard ABAP form needs 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 0reater tha& or e1ual to +Teco ,ateor +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.-+$

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 %I0E SY'&ATUM$

If TEC4 ,ATE is &ot set8 the& the Curre&t ,ate &eeds to (e ta9e&
IF )%_Z_TECO+ IS INITIA%$ )%_Z_TECO+ 1 SY'&ATUM234$ EN&IF$ F1 1 )%_0FINISH&ATE+ 5 30$ IF F1 GE )%_Z_TECO+$ )%_ZCOM_STAT+ 1 676$ EN&IF$ EN&FORM$

Você também pode gostar