cancel
Showing results for 
Search instead for 
Did you mean: 

How to calculate number of days from a date field

Former Member
0 Kudos

Dear BW Experts.

I have a field 'Create Date' in the BEx query. Now we need to create a variable which should give the number of days from the date of running the query (sy-datum) to the Create Date.

This will help the users to get records which are say, 30 days old (Sy-datum - create date = 30) or 10 days old etc.

Could you suggest as to how to create this variable.

Thanks,

Sai

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Experts,

Not sure I got your suggestions correct.

I need this Day field in the BEx Query and not on the BW back end. I need this variable in the BEx query. This days should be calculated from the sy-datum, that is the date of running the report.

Kindly help.

Thanks,

Sai

Edited by: Sainath Vadathirthanathan on Jun 14, 2011 9:39 AM

Former Member
0 Kudos

you have to create 2 formula variables.

FV1 to get sy-datum.

Create FV1 with customer exit as processing type and in CMOD you have to write logic to pass sy-datum value to this formula variable. Pls note - In the last tab of your Formula Variable Screen, do not forget to select date as type for this Formula Variable.

FV2 to get create date.

Create FV2 with Replacement Path as processing type. Select Create date infoobject in the list and under replacement tab, make sure it is getting replaced with key value.

And then create a Formula and use FV1 - FV2. This would get you the total no of days.

--- Thanks...

Former Member
0 Kudos

hi rookie,

mine is the similar scenario, am trying to calculate no.of days form 2 char. date fields,

have reated 2 fv's with replacement path and created a formula defining " end date - start date".

But in the out put am not getting any value instead a "X" mark is displaying...

can you please tell me the possible way to solve this..

Thanks,

Malathi

Answers (5)

Answers (5)

Former Member
0 Kudos

Thank you so much rookie-sapbi . I got it.

God Bless you.

Initially I did not get it when I put the Text descrption of the variable in the CMOD exit. However when I put the technical name, then I got it.

Thanks again.

Sai

Former Member
0 Kudos

Thanks,

First time I am creating a Customer exit in our BW system.

I went to TC CMOD and created a project called "ZBWEXTRT". What is the enhancement assignment I have to add in order to see the EXIT_SAPLRRS0_001, where I can write the code.

Kindly help.

Thanks,

Sai

Former Member
0 Kudos

you have to add RSR00001 in the enhancement assignment. If it is already assigned to some other project, then goto that project and double click on EXIT_SAPLRRS0_001. you will see INCLUDE ZXRSRU01 .

double click on ZXRSRU01 and write you code there....



DATA: l_s_range TYPE rsr_s_rangesid.

IF I_VNAM = 'ZSY-DATUM'.
   L_S_RANGE-LOW = SY-DATUM.
  L_S_RANGE-SIGN = 'I'.
  L_S_RANGE-OPT = 'EQ'.
  APPEND L_S_RANGE TO E_T_RANGE.
ENDIF.

--- Thanks...

Former Member
0 Kudos

HI,

Hope sap delivered FM can do the calculation ... try the same in Customer Exit

http://www.erpdb.info/wp-content/uploads/2009/08/Function-Modules.pdf

Regards

BVR

former_member182470
Active Contributor
0 Kudos

Hi,

Step 1: Create variable on "Create Date" with User entry processing type

Step 2: Create a restricted KF for Sales & restrict it on "Create Date" to get "Sales on day"

Step 3: Manipulate the values of "Create Date" on which you could restrict "Sales" again and again to get other values

Step 4: Create one variable (ZPUTMNTH) for u201CMonth to Dateu201D with processing by u201CCustomer Exitu201D. This variable was created on u201CDateu201D characteristics.

Step 5 : Goto C-mod t-code and use EXIT_SAPLRRS0_001

*----


  • to calculate "month to date" user input is "Calday" Key Date

*----


WHEN 'ZPUTMNTH'.

IF I_STEP = 2. "after the popup

LOOP AT I_T_VAR_RANGE INTO LOC_VAR_RANGE

WHERE VNAM = 'ZPDATE'.

CLEAR L_S_RANGE.

L_S_RANGE-LOW = LOC_VAR_RANGE-LOW(6). "low value, e.g.YYYYMM (200606) part of key date (20060625)

L_S_RANGE-LOW+6(2) = '01'. u201C low value e..g. YYYYMM01 (20060601)

L_S_RANGE-HIGH = LOC_VAR_RANGE-LOW. "high value = input

L_S_RANGE-SIGN = 'I'.

L_S_RANGE-OPT = 'BT'.

APPEND L_S_RANGE TO E_T_RANGE.

EXIT.

ENDLOOP.

ENDIF.

Assign if helps.....

Regards,

Suman

Former Member
0 Kudos

Seems like you need to create customer exit variable. In Abap coding implement the logic to calculate the no. of days.