6 Replies Latest reply: Nov 24, 2011 6:43 AM by Murthy Gunuputi RSS

Customer Exit for MTD

Murali R
Currently Being Moderated

Hi,

 

My requirement is to create Customer exit variable to calculate the Month to date (MTD) value (Quantity) in a query.  I created a Customer exit variable for MTD (0CALDAY) in Query & wrote code in CMOD for the same as follows.

 

DATA: ZYEAR(4) TYPE N,

      ZMON(2) TYPE N,

      ZDAY(2) TYPE N.

 

CASE I_VNAM.

  WHEN 'ZVCE_MTD'.

    IF I_STEP = 2.

 

      REFRESH E_T_RANGE.

 

      LOOP AT I_T_VAR_RANGE INTO LOC_VAR_RANGE.

 

        ZYEAR = LOC_VAR_RANGE-LOW+0(4).

        ZMON = LOC_VAR_RANGE-LOW+4(2).

        ZDAY = LOC_VAR_RANGE-LOW+6(2).

 

        CLEAR L_S_RANGE.

        CONCATENATE ZYEAR ZMON '01' INTO L_S_RANGE-LOW.

        CONCATENATE ZYEAR ZMON ZDAY INTO L_S_RANGE-HIGH.

        L_S_RANGE-SIGN   = 'I'.

        L_S_RANGE-OPT = 'BT'.

        APPEND L_S_RANGE TO E_T_RANGE.

        EXIT.

      ENDLOOP.

 

    ENDIF.

ENDCASE.

 

I debugged this code by putting a break point & running the query in RSRT, the code is getting executed & i am getting the From & To dates in E_T_RANGE output.

 

But when I execute the Query, I am getting the output Quantity for FTD only, not MTD.

 

For example, if i give 05-12-2009 as variable input for 0CALDAY when i execute the query, i should get the summed up quantity for 01 Dec to 05 Dec in a single cell.  But now, i am getting the summed up quantity for 05 Dec only.

 

Help me in resolving this.

 

Regards,

Murali

  • Re: Customer Exit for MTD
    Murthy Gunuputi
    Currently Being Moderated

    Hi

     

    Please restrict the keyfigure with the customer exit variable you have created.

    Code seems to be perfect.

     

    Regards

    Murthy

  • Re: Customer Exit for MTD
    binu v. rajan
    Currently Being Moderated

    Hi Murali,

     

    Where did you give restriction for FTD, is it global filter ?? then you will not get MTD in your report.

     

    Instead of giving global filter you can go for local filter.  ...

     

     

     

     

    -


    Thanks

    BVR

    • Re: Customer Exit for MTD
      Murali R
      Currently Being Moderated

      Hi Binu,

       

      I have put 0CALDAY in Filters section of the Query & restricted it with FTD variable.  So, the date entered by the user is taken as FTD & quantity value is processed based on it.

       

      But for MTD, i wrote Customer exit in CMOD for the Variable.  I debugged the variable, it is properly getting the From & To values in E_T_RANGE.  But somehow, the summed up value for this MTD is not coming, instead its showing the FTD value only.

       

      "Instead of giving global filter you can go for local filter. ..."  Could you please elaborate this?  Also, if you have any standard code to calculate MTD, kindly let me know.

       

      Regards,

      Murali

      • Re: Customer Exit for MTD
        binu v. rajan
        Currently Being Moderated

        Hi Murali,

         

        Hope your coding is working properly so, do below

         

        Drag and Drop Chars in Row

        Context Menu of Colum New Selection,

        Select your KF (Revanue),

        Drag and drop 0calday beneath of KF Restrict with variable (FTD)

           -


        FTD  Variable should be : Manual Input, Mandatory, ready for input , single value,

        Again :

        New Selection

        Select your KF (Revanue)

        Drag and drop 0calday beneath of KF Restrict with variable (MTD)

          --- MTD Variable should be : Customer Exit, Not ready for input, Interval value.

         

        Save and Execute. if your Coding is right you will be getting out put:

         

        Eg.

         

        Customer    Revanue (FTD) ---Revanue (MTD)

        c01 -


        1000$-----25000$

        c02 -


        2000$-----35000$

         

        I am not an abaper , but in your coding i have not seen reading of your value from variable table..

         

        You can try with below coding;;;;; 

         

         

         

        when 'VAR_MTD'.

            data: l_first_day_of_month type D,

          l_s_var_range type rrrangeexit,

          l_s_range1 type RSR_S_RANGESID.

            if i_step = 2.

        •      BREAK-POINT.

              read table i_t_var_range into l_s_var_range

              with key vnam = 'VAR_FTD'. 

              if sy-subrc = 0.

                concatenate l_s_var_range-low+0(6) '01' into l_first_day_of_month.

                clear l_s_range1.

                l_s_range1-low = l_first_day_of_month.

                l_s_range1-high = l_s_var_range-low.

                l_s_range1-opt = 'BT'.

                l_s_range1-sign = 'I'.

                append l_s_range1 to e_t_range.

              else.

                exit.

              endif.

            endif.

         

         

        Note  :  here 'VAR_FTD' is one which user input during the execution of the query ..

         

        -


        Thanks

        BVR

      • Re: Customer Exit for MTD
        Murthy Gunuputi
        Currently Being Moderated

        Hi

         

        The restrictios that are used in Characteristic Restrictions act as global restrictions for that query. This means that if you restrict Calmonth/Year = '01.2010' - '12.2010' at characteristic restrictions, this will be applicaable to all the key figures in the query.

         

        Local restriction would be to restrict one particular key figure with required restrictions like in your case, right click on the particular key figure and click on edit button and then drag and drop the MTD variable you have created. Now this variable will be visible below the key figure. This acts as a restriction to this particular key figure. All the other key figures in the query would have FTD as restriction whereas this particular KF will have MTD as restriction.

         

        Hope I have explained well.

         

        Regards

        Murthy

Actions