Additional Blogs by Members
cancel
Showing results for 
Search instead for 
Did you mean: 
former_member181964
Active Contributor

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

PlantMaterialSTR's12.02.2009   STO's
12.02.2009
Actual Shipmt  12.02.2009STR'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
AT1P1M1100.00100.0090.00100.00100.0090.00100.0090.0090.00
  M2200.00200.00150.00200.00200.00150.00200.00150.00150.00
  M3300.00300.00300.00300.00300.00300.00300.00300.00300.00
  M4400.00400.00350.00400.00400.00350.00400.00350.00350.00
BI1P2M5300.00300.00300.00300.00300.00300.00300.00300.00300.00
10 Comments