Requirement: There is report which needs to display delivery status based on delivery date, let say if delivery date is less than or equal to current month then delivery status is “Completed” , if delivery date is greater than current month then delivery status is “Pending”.
- 1. Writing VB macros
- 2. Writing JAVA/HTML code
- 3. Writing code in transformation while modeling itself.
- 4. Using BADI mechanism with RSR_OLAP_BADI
Pros and Cons of each Solution
- 1. Option only suitable when report output is in excel workbook,
- 2. Option only suitable when report output is in web portal
- 3. Option is not suitable at all because delivery date may change at any time its depends on the stock availability
- 4. Options is the best option to fit all requirement, hence choose virtual characters concept
Goto SE19 transaction code
Click on “Create Implementation” as shown in below image
Provide info provider name for which you want implement virtual characteristics as shown in below screenshot
Go to–>sample->Copy select menu as shown on below screenshot
Double click on highlighted implementation class
In attribute column provide characteristics which you want read data from info provider and also provide virtual characteristics information, here in my case, provided two infoobjects one ZDLDATE (which contain delivery date) and second ZSTATUS (virtual characteristic to specify delivery status).
Write code as shown in screenshot
Do not change anything here, this code is copied while performing step 5, please check
Write code in COMPUTE as like below
METHOD if_ex_rsr_olap_badi~compute .
<fs_date> TYPE ANY,
<fs_status> TYPE ANY.
DATA: firstdate TYPE sy-datum,
finaldate TYPE sy-datum,
day(2) TYPE n,
month(2) TYPE n,
year(4) TYPE n.
day = sy-datum+6(2).
month = sy-datum+4(2).
year = sy-datum+0(4).
CONCATENATE year month day INTO firstdate.
CALL FUNCTION ‘SLS_MISC_GET_LAST_DAY_OF_MONTH’
day_in = firstdate
last_day_of_month = finaldate
day_in_not_valid = 1
OTHERS = 2.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
IF p_cha_zdldate > 0 AND p_cha_zstatus > 0.
ASSIGN COMPONENT p_cha_zdldate OF STRUCTURE c_s_data TO <fs_date>.
ASSIGN COMPONENT p_cha_zstatus OF STRUCTURE c_s_data TO <fs_status>.
IF <fs_date> <= finaldate.
<fs_status> = ‘COMPLETED’.
<fs_status> = ‘PENDING’.
Highlighted one is virtual char in infocube, no data in infocube
Populated data at run-time for delivery status info object.