cancel
Showing results for 
Search instead for 
Did you mean: 

finding no. of days in a month in formula variable

Former Member
0 Kudos

Hi all

I wanted to find out no. of days in a month in formula variable customer exit at bex. I did the following code, which returning X value. Can anybody helps here.

WHEN 'ZFV_NO_DAYS_MONTH'.


     IF I_STEP = 2.
       CLEAR L_S_RANGE.


       READ TABLE I_T_VAR_RANGE INTO XTAB WITH KEY VNAM = 'zdate1'.


       V_DATE = XTAB-LOW.

       P_DATE = V_DATE+6(2).


       CALL FUNCTION 'HR_E_NUM_OF_DAYS_OF_MONTH'
         EXPORTING
           P_FECHA        = V_DATE
         IMPORTING
           NUMBER_OF_DAYS = V_DATE1.

       V_RES = V_DATE1 - P_DATE.
       L_S_RANGE-LOW = V_RES.


       APPEND L_S_RANGE TO E_T_RANGE.


     ENDIF.



Regrds

swetha

Accepted Solutions (1)

Accepted Solutions (1)

former_member199945
Active Contributor
0 Kudos

Hi,

Instead of customer exit code, you can also try with  standard variable 0NUMDAY ----Number of Days.

Thanks.

Former Member
0 Kudos

how do we write this. user is passing date through another variable which is manual input. I need only that date. where do i use this 0NUMDAY variable. can u explain.

former_member199945
Active Contributor
0 Kudos

Hi,

As you mentioned need to calculate no of days in a month  thta'ts why i suggested 0NUMDAY ,

Refer below how to use that :

User is passing data through another variable i.e of which format either 0calday/0calmonth /Zdate

Also check like this Put Date field (created Customer Exit variable Reference field ) in rows .

Thanks.

yasemin_kilinc
Active Contributor
0 Kudos

Hi Swetha,

You code seems correct. Just make sure that the data types of v_date1 and p_date are P. Please put a breakpoint inside and debug running through bex analyzer.

regards

Yasemin...

Loed
Active Contributor
0 Kudos

Hi Swetha,

After reading the thread, just post here if you encountered any problem..

You may also try this if you want to know the number of days of a given month based on the entered date by the user (I revised your code):

NOTE: I assume that the user enters a DATE..

DATA: temp_month type i length 2,

           temp_year type i length 4,

           temp_day type i length 2.

WHEN 'ZFV_NO_DAYS_MONTH'.


     IF I_STEP = 2.
       CLEAR L_S_RANGE.


       READ TABLE I_T_VAR_RANGE INTO XTAB WITH KEY VNAM = 'zdate1'.


       temp_month = XTAB-LOW+4(2).

       temp_year = XTAB-LOW(4).


       CALL FUNCTION '/SDF/RBE_GET_DAYS_PER_MONTH'
         EXPORTING
           PAR_MONTH        = temp_month

           PAR_YEAR        = temp_year
         IMPORTING
           PAR_DAYS = temp_day

***May I ask why did you subtract V_DATE1 and P_DATE in your code? Anyway, this revised code will only get the number of days in a month..

       L_S_RANGE-LOW = temp_day.


       APPEND L_S_RANGE TO E_T_RANGE.


     ENDIF.

Regards,

Loed

Answers (1)

Answers (1)

former_member209606
Participant
0 Kudos

Hi Swetha

in your code itself just change something as mentioned below

VDATE1 type as integer.

WHEN 'ZFV_NO_DAYS_MONTH'.


     IF I_STEP = 2.
       CLEAR L_S_RANGE.


       READ TABLE I_T_VAR_RANGE INTO XTAB WITH KEY VNAM = 'zdate1'.


       V_DATE = XTAB-LOW.

    *Hide No need***   P_DATE = V_DATE+6(2).


       CALL FUNCTION 'HR_E_NUM_OF_DAYS_OF_MONTH'
         EXPORTING
           P_FECHA        = V_DATE
         IMPORTING
           NUMBER_OF_DAYS = V_DATE1.

   *hide**    V_RES = V_DATE1 - P_DATE.
   *hide**     L_S_RANGE-LOW = V_RES.

*Add the below new line

L_S_RANGE-LOW = V_DATE1.


       APPEND L_S_RANGE TO E_T_RANGE.


     ENDIF.



Regards

Sureshkumar C