Skip to Content

Applies to:

 

SAP BW 3.0b, SAP BW 3.5, Will also work on SAP BI 7 For more information, visit the Business Intelligence homepage.

 

Summary:

In most of the reports, we want to display the headings for Keyfigures, Eg: If I give input data then based on that I want to display the heading and keyfigures data  like below….

Input Date, Input Date-1 and Input Date-2.

 

Eg: We have a InfoCube having following InfoObejcts….

 

Characteristics:

Division

Plant

Material

 

KeyFigures:

STR

STO

Actual Shipment

 

Time Characteristics:

0Calday

0Calmonth

 

Based on user input date we need to display the STRs, STOs, and Actual Shipment for the Input date, Input Date-1 and Input Date-2.

 

The steps:

 

  1. Create ZCDAY variable on 0CALDAY, the properties are..

Type of Variable  = Characteristic

Variable Name    =  ZCDAY

Processing by     =  User Entry/Default Value

Characteristic      =  CalenderDay

Variable Represents  = Single

Variable Entry   = Mandatory

Check ready for input.

 

 

  1. Create a report, drag and drop Division, Plant and Material in Rows. And create new selection in columns and restrict the key figures like below..

 

          In first selection drag and drop  Calendar Day –  0CALDAY and Key Figure –  STO

          and restrict 0CALDAY with variable ZCDAY.

          And give description =  STR’s &ZT_DAY&

 

            Note: &ZT_DAY&, this is text variable you need to create like below..

 

Create three Text variables like below…

 

Variable Name  =    ZT_DAY

Description        =    Input Date

Processing by    =    Customer Exit

Characteristic    =    Text Variable

Variable Entry   =    Mandatory

And uncheck the ready for input

 

In the same way you create the second selection and drag and drop  Calendar Day –  0CALDAY and Key Figure –  STO  and restrict 0CALDAY with variable ZCDAY.

And give description =  STO’s &ZT_DAY&

 

And create third selection for Actual Shipment i.e. Calendar Day –  0CALDAY and Key Figure –  STO  and restrict 0CALDAY with variable ZCDAY.

And give description =  Actual Shipment &ZT_DAY&

 

In the same way you create the selections for Input day-1 and input day-2. The variable names are given below.

 

Variable Name  =    ZT_DAY1

Description        =    Input Date-1

Processing by    =    Customer Exit

Characteristic    =    Text Variable

Variable Entry   =    Mandatory

And uncheck the ready for input

 

Variable Name  =    ZT_DAY2

Description        =    Input Date-2

Processing by    =    Customer Exit

Characteristic    =    Text Variable

Variable Entry   =    Mandatory

And uncheck the ready for input

 

For Input day-1 selection you need to restrict the Calendar Day –  0CALDAY with ZCDAY-1 (this you need to set in offset values) and Key Figure –  STO.

 

For Input day-2 selection you need to restrict the Calendar Day –  0CALDAY with ZCDAY-2 (this you need to set in offset values) and Key Figure –  STO.

 

 

So finally your report contains 9 selections in columns, like below..

 

 

 

For Input Day:

 

STR’s &ZT_DAY& :

KeyFigure =  STR

0Calday restricted by ZCDAY

 

STO’s &ZT_DAY&

KeyFigure =  STO

0Calday restricted by ZCDAY

 

Actual Shipment &ZT_DAY&

KeyFigure =  Actual Shipment

0Calday restricted by ZCDAY

 

 

For Input Day -1:

 

STR’s &ZT_DAY1& :

KeyFigure =  STR

0Calday restricted by ZCDAY-1

 

STO’s &ZT_DAY1&

KeyFigure =  STO

0Calday restricted by ZCDAY-1

 

Actual Shipment &ZT_DAY1&

KeyFigure =  Actual Shipment

0Calday restricted by ZCDAY-1

 

 

For Input Day -2:

 

STR’s &ZT_DAY2& :

KeyFigure =  STR

0Calday restricted by ZCDAY-2

 

STO’s &ZT_DAY2&

KeyFigure =  STO

0Calday restricted by ZCDAY-2

 

Actual Shipment &ZT_DAY2&

KeyFigure =  Actual Shipment

0Calday restricted by ZCDAY-2

 

 

 

 

 

  1. Then write the following code in CMOD.. in BW system…

 

           Go to CMOD and give project name  = ZXYZ (your project name already created,

           else you need to create), select components and click on change and you can see

           Function exit EXIT_SAPLRRS0_001,double click on that and the double click on

           INCLUDE ZXRSRU01, it will takes to coding window.

 

 

DATA :  l_s_range TYPE rsr_s_rangesid,

        loc_var_range LIKE rrrangeexit.

 

DATA:     ZT_DT1 TYPE SY-DATUM,

          ZT_DT2 TYPE SY-DATUM,

          ZT_SDT TYPE SY-DATUM,

          ZT_YR(4) TYPE N,

          ZT_DY(2) TYPE N,

          ZT_MT(2) TYPE N,

          ZE_TT(2) TYPE N.

 

          ZT_SDT = SY-DATUM.

 

 

IF i_step = 2.

  CASE i_vnam.

 

****Begin*****TO get the Date (TEXT VAR) based on ZCDAY Input variable***********

 

    WHEN ‘ZT_DAY’ .

      LOOP AT i_t_var_range INTO loc_var_range WHERE vnam = ‘ZCDAY’.

        IF sy-subrc = 0.

          CLEAR: l_s_range.

          l_s_range-low+0(2) = loc_var_range-low+6(2).

          l_s_range-low+2(1) = ‘.’.

          l_s_range-low+3(2) = loc_var_range-low+4(2).

          l_s_range-low+5(1) =’.’.

          l_s_range-low+6(4) = loc_var_range-low+0(4).

          l_s_range-sign = ‘I’.

          l_s_range-opt = ‘EQ’.

          APPEND l_s_range TO e_t_range.

        ENDIF.

      ENDLOOP.

 

****End*****TO get the Date (TEXT VAR) based on ZCDAY Input variable***************

 

 

 

****Begin*****TO get the Date-1(TEXT VAR) based on ZCDAY Input variable***********

 

    WHEN ‘ZT_DAY1’ .

 

      LOOP AT i_t_var_range INTO loc_var_range WHERE vnam = ‘ZCDAY’.

        IF sy-subrc = 0.

          CLEAR: l_s_range.

 

          ZT_DY = loc_var_range-low+6(2).

          ZT_MT = loc_var_range-low+4(2).

          ZT_YR = loc_var_range-low+0(4).

 

      CONCATENATE ZT_YR ZT_MT ZT_DY INTO ZT_DT1.  “YYYYMMDD

 

      CALL FUNCTION ‘DATE_CREATE_2’

        EXPORTING

         i_datum_ein                   = ZT_DT1

         I_KZ_INCL_AUS                 = ‘1’

         I_KZ_INCL_EIN                 = ‘0’

         I_KZ_ULT_AUS                  = ‘X’

         I_KZ_ULT_EIN                  = ‘X’

         I_STGMETH                     = ‘0’

         I_SZBMETH                     = ‘0’

         I_TAGE                        =  0

       IMPORTING

         E_DATUM_AUS                   = ZT_DT2.

 

          l_s_range-low+0(2) = ZT_DT2+6(2).

          l_s_range-low+2(1) = ‘.’.

          l_s_range-low+3(2) = ZT_DT2+4(2).

          l_s_range-low+5(1) =’.’.

          l_s_range-low+6(4) = ZT_DT2+0(4).

          l_s_range-sign = ‘I’.

          l_s_range-opt = ‘EQ’.

          APPEND l_s_range TO e_t_range.

 

        ENDIF.

      ENDLOOP.

 

 

****End*****TO get the Date-1 based on ZCDAY Input variable***********

 

 

 

****Begin*****TO get the Date-2 based on ZCDAY Input variable***********

 

    WHEN ‘ZT_DAY2’ .

 

 

      LOOP AT i_t_var_range INTO loc_var_range WHERE vnam = ‘ZCDAY’.

        IF sy-subrc = 0.

          CLEAR: l_s_range.

 

          ZT_DY = loc_var_range-low+6(2).

          ZT_MT = loc_var_range-low+4(2).

          ZT_YR = loc_var_range-low+0(4).

 

      CONCATENATE ZT_YR ZT_MT ZT_DY INTO ZT_DT1.  “YYYYMMDD

 

      CALL FUNCTION ‘DATE_CREATE_2’

        EXPORTING

         i_datum_ein                   = ZT_DT1

         I_KZ_INCL_AUS                 = ‘2’

         I_KZ_INCL_EIN                 = ‘0’

         I_KZ_ULT_AUS                  = ‘X’

         I_KZ_ULT_EIN                  = ‘X’

         I_STGMETH                     = ‘0’

         I_SZBMETH                     = ‘0’

         I_TAGE                        =  0

       IMPORTING

         E_DATUM_AUS                   = ZT_DT2.

 

          l_s_range-low+0(2) = ZT_DT2+6(2).

          l_s_range-low+2(1) = ‘.’.

          l_s_range-low+3(2) = ZT_DT2+4(2).

          l_s_range-low+5(1) =’.’.

          l_s_range-low+6(4) = ZT_DT2+0(4).

          l_s_range-sign = ‘I’.

          l_s_range-opt = ‘EQ’.

          APPEND l_s_range TO e_t_range.

 

        ENDIF.

      ENDLOOP.

 

 

****End*****TO get the Date-2 based on ZCDAY Input variable***********

 

 

  ENDCASE.

ENDIF.

 

After executing the report you can see the report like below. I given input date = 12.02.2009.

Note: This is junk data, only to explain the scenario.

Division

Plant Material STR’s12.02.2009    STO’s
12.02.2009
Actual Shipmt  12.02.2009 STR’s
11.02.2009
STO’s
11.02.2009
Actual Shipmt 
11.02.2009
 STR’s  
10.02.2009
   STO’s 
10.02.2009
Actual Shipmt   
10.02.2009
AT1 P1 M1 100.00 100.00 90.00 100.00 100.00 90.00 100.00 90.00 90.00
    M2 200.00 200.00 150.00 200.00 200.00 150.00 200.00 150.00 150.00
    M3 300.00 300.00 300.00 300.00 300.00 300.00 300.00 300.00 300.00
    M4 400.00 400.00 350.00 400.00 400.00 350.00 400.00 350.00 350.00
BI1 P2 M5 300.00 300.00 300.00 300.00 300.00 300.00 300.00 300.00 300.00
To report this post you need to login first.

10 Comments

You must be Logged on to comment or reply to a post.

  1. Arun Varadarajan
    Surendra ,
    The Blog would be very useful to many … but…

    IMHO this could have been an article …
    also when you give code in your weblogs – try and use a textarea this helps in keeping the blog browser friendly – also I am not able to scroll on my browser – I am not sure if anyone else has faced this – the resultant is that the end point of most of your lines is lost unless I select the line and drag it to the end …

    I am not trying to point out things that you could have done – but more from a usability perspective..

    (0) 
  2. Christopher Smith
    Surendra,
    Very useful blog… any reason you chose to describe the legacy user exit methods?  Is there a BADI version to this example?  This would be really useful for those in the BW7 world who are trying to use the new techniques.
    Just a thought
    thanks for blog and useful info
    C.
    (0) 
  3. Vishall Pradeep

    Hi Surendara,

    Is it possible for us to give the heading for CKF’s.. like if a user enters 10.2010 from selection screen and consider i am having 2 RKF which shows values of 0VALSTCK and 0TOTALSTK for October as per our input and for this this if we use the logic which u said above will give the column heading correctly for RKF and now i am having a CKF in my column next like STCK = 0TOTALSTK – 0VALSTCK… for this how can we get the text ?? I need to get the text for future months also for this CKF

    ex:

    0VALSTCK- OCT 0TOTALSTK-OCT STCK-OCT 0VALSTCK- NOV 0TOTALSTK-NOV STCK-NOV

    How to get the text for CKF?? since we don have any restriction with calmonth here in CKF

    It would be very grateful if anyone would help me in this 🙂

    Thanks,

    Vishall

    (0) 

Leave a Reply