12 Replies Latest reply: Jun 26, 2012 7:20 PM by Ravi Chandra

# Customer Exits to find value from Cal year/mth (column), based on User input on Fiscal Year

Currently Being Moderated

Hi BW/BI gurus,

Currently, The Query look like below:-

User need to enter Fiscal Year, and in this example, User entered Fiscal Year: 2012

How the Query currently Look like
 Fiscal Year 2012 Calendar Year/Month APR 2011 MAY 2011 JUN 2011 JUL 2011 AUG 2011 SEP 2011 OCT 2011 NOV 2011 DEC 2011 JAN 2012 FEB 2012 MAR 2012 No of Days (First Calendar Year/Month)(Hide) X X X X X X X X X X X X No of Days in Year (Derived from Cal Month)(Hide) X X X X X X X X X X X X No of Months (First - Selected Cal Month) X X X X X X X X X X X X

The Cal year/mth is automatically generated based on the Fiscal Year entered

Example of What I Need
 Fiscal Year 2012 Calendar Year/Month APR 2011 MAY 2011 JUN 2011 No of Days (First Calendar Year/Month)(Hide) 30 61 91 No of Days in Year (Derived from Cal Month)(Hide) 365 365 365 No of Months (First - Selected Cal Month) 1 2 3

What I need to find out 3 things:-

1. No of Days in Calendar Year/Month

2. No of Days in Year

3. No of Months

The current Codes I have is the find all these 3 things based on User Manual Input for Cal Year/Mth

1. No of Days in Calendar Year/Month

1. No of Days in Calendar Year/Month

WHEN 'ZVAR_NO_DAYS_FIRST_CAL_MTH'.
LOOP AT i_t_var_range INTO loc_var_range
WHERE vnam = '0PCALMON'.
CLEAR l_s_range.
zcalyear = loc_var_range-low(4).
zcalmonth2 = loc_var_range-low+4(2).

CONCATENATE zcalyear zcalmonth2 '01' INTO zcalday.

IF zcalmonth2 BETWEEN 01 AND 03.
zcalyear = zcalyear - 1.
ENDIF.

CALL FUNCTION 'SLS_MISC_GET_LAST_DAY_OF_MONTH'
EXPORTING
day_in            = zcalday
IMPORTING
last_day_of_month = zcalday1
EXCEPTIONS
day_in_not_valid  = 1.

CONCATENATE zcalyear '0401' INTO zcalday2.
zdays = zcalday1 - zcalday2 + 1.
l_s_range-low = zdays.
l_s_range-sign = 'I'.
l_s_range-opt 'EQ'.
APPEND l_s_range TO e_t_range.
ENDLOOP.
CLEAR: zcalyear, zcalmonth, zcalmonth2, zdays.

2. No of Days in Year

WHEN 'ZVAR_NO_DAYS_YR_FR_CAL_MTH'.
LOOP AT i_t_var_range INTO loc_var_range
WHERE vnam = '0PCALMON'.
CLEAR l_s_range.

CONCATENATE loc_var_range-low '01' INTO zcalday.

CALL FUNCTION 'DATE_TO_PERIOD_CONVERT'
EXPORTING
i_date   = zcalday
i_monmit = '00'
i_periv  = 'V3'
IMPORTING
e_gjahr  = zfiscyear.
*              e_buper = zfiscper3.

IF zfiscyear MOD 4 = 0 AND NOT zfiscyear MOD 100 = 0.
zdays = 366.
ELSE.
zdays = 365.
ENDIF.

l_s_range-low = zdays.
l_s_range-sign = 'I'.
l_s_range-opt 'EQ'.
APPEND l_s_range TO e_t_range.
ENDLOOP.
CLEAR: zcalday, zdays, zfiscyear.

3. No of Months

WHEN 'ZVAR_NO_MONTHS_FIRST_CAL_MTH'.
LOOP AT i_t_var_range INTO loc_var_range
WHERE vnam = '0PCALMON'.
CLEAR l_s_range.

zcalyear = loc_var_range-low(4).
zcalmonth2 = loc_var_range-low+4(2).

CONCATENATE zcalyear zcalmonth2 INTO zcalday1.

IF zcalmonth2 BETWEEN 01 AND 03.
zcalyear = zcalyear - 1.
ENDIF.

CONCATENATE zcalyear '04' INTO zcalday2.

CALL FUNCTION 'MONTHS_BETWEEN_TWO_DATES'
EXPORTING
i_datum_bis   = zcalday1
i_datum_von   = zcalday2
*             I_KZ_INCL_BIS = ' '
IMPORTING
e_monate      = months.

l_s_range-low = months + 1.
l_s_range-sign = 'I'.
l_s_range-opt 'EQ'.
APPEND l_s_range TO e_t_range.
EXIT.
ENDLOOP.
CLEAR: zcalday1, zcalday2, zcalmonth2, zcalyear.

But Right now, I need to change the Query so that the User Only need to enter: Fiscal Year.

And the Query will display accordingly.

Can anyone please advice on how to modify the codes? to get the data from the Columns based on Fiscal Year entered instead of data coming from Manual Input?

Many thanks,

Vince

• ###### Re: Customer Exits to find value from Cal year/mth (column), based on User input on Fiscal Year
Currently Being Moderated

obviously your fist check (where clause of the loop statement) should be on your new variable

next I suggest using function modules RSARCH_DATE_SHIFT & DAYS_BETWEEN_TWO_DATES... it's not that hard

think, try, ... and if you don't succeed, ask a developer

• ###### Re: Customer Exits to find value from Cal year/mth (column), based on User input on Fiscal Year
Currently Being Moderated

HI vincent ,

I did not get u . Please explain clearly.

Regards,

Ravichandra

• ###### Re: Customer Exits to find value from Cal year/mth (column), based on User input on Fiscal Year
Currently Being Moderated

Hi Ravi,

Okay, I will explain further about the issue.

Currently, The Query look like below:-

The Query have only one Variable: Fiscal Year

The Query Rows and Columns Selections:-

RowColumn

Since we are using Fiscal Year Variant V3,

This is Currently how the Query displayed.

 Fiscal Year 2012 Calendar Year/Month APR 2011 MAY 2011 JUN 2011 JUL 2011 AUG 2011 SEP 2011 OCT 2011 NOV 2011 DEC 2011 JAN 2012 FEB 2012 MAR 2012 No of Days (First Calendar Year/Month)(Hide) X X X X X X X X X X X X No of Days in Year (Derived from Cal Month)(Hide) X X X X X X X X X X X X No of Months (First - Selected Cal Month) X X X X X X X X X X X X

I need to find a way for this query to display, Number Of Days in Month, Number Of Days in Year, and Number Of month according to Fiscal Year User entered in the variables.

So, for example:-

User entered Fiscal Year 2012.

The Calendar Month will display according to the Fiscal Year entered which will be April 2011 - Mar 2012

And I need the Number Of Days in Month, Year and Number of Month will display as below:-

 Calendar Year/Month APR 2011 MAY 2011 JUN 2011 JUL 2011 AUG 2011 SEP 2011 OCT 2011 NOV 2011 DEC 2011 JAN 2012 FEB 2012 MAR 2012 No of Days (First Calendar Year/Month)(Hide) 30 61 91 122 153 183 214 244 275 306 335 366 No of Days in Year (Derived from Cal Month)(Hide) 366 366 366 366 366 366 366 366 366 366 366 366 No Of Months 1 2 3 4 5 6 7 8 9 10 11 12

Is my explanation make sense?

Many thanks,
Vince

• ###### Re: Customer Exits to find value from Cal year/mth (column), based on User input on Fiscal Year
Currently Being Moderated

Hi

I got the question clearly,

Why to write all those unncecassary code .

For No. of days in Year u can check whether the given fiscal year is leap year or not. If it is leap year then directly u give values as 366 . and if it is not leap year then give the value as 365.

and For No. of Month u can increment the values from starting till end.

and for No. of days u can write the functionmodule to calculate the no. of days between 2 date.

Hope u got it,

Regards,

RaviChandra

• ###### Re: Customer Exits to find value from Cal year/mth (column), based on User input on Fiscal Year
Currently Being Moderated

Hi Ravi,

For No. of days in Year u can check whether the given fiscal year is leap year or not. If it is leap year then directly u give values as 366 . and if it is not leap year then give the value as 365

May I know the steps on how to do this?

and For No. of Month u can increment the values from starting till end.

How do I do the increment of the values from Starting till end?

Many thanks,

Vince

• ###### Re: Customer Exits to find value from Cal year/mth (column), based on User input on Fiscal Year
Currently Being Moderated

handrHi

Can u explain the what is the column

APR11 MAY 11 JUN 11 ....

refers to .

Are they selection or keyfigures.

Regards,

RaviChandra

• ###### Re: Customer Exits to find value from Cal year/mth (column), based on User input on Fiscal Year
Currently Being Moderated

Hi Ravi,

The APR 11, MAY 11 are time characteristics without any restriction.

The Key figures restriction is actually on Row Section (Structure Selections.)

Regards,
Vince

• ###### Re: Customer Exits to find value from Cal year/mth (column), based on User input on Fiscal Year
Currently Being Moderated

Hi

Please mention the selection and what are the keyfigures u have    dragged in the selection and with what characteristic u have restricuted that . Please display those information.

Regards,

RaviChandra

• ###### Re: Customer Exits to find value from Cal year/mth (column), based on User input on Fiscal Year
Currently Being Moderated

Hi Ravi,

This is selection of each Month:-

E.g. April and May selections are as following:-

AprilMay

0P_FISCYEAR is User Manual Input Variable.

What I need is :-

 Accumulated No of Days in Month Apr + May + June … 30+31+30+…. No of Days in Year Normal Year or Leap Year 365/366 No of Days in Month Number of Days in in a Month either 28 or 29 for FEB, and 30 or 31 for other months Accumulated No of month Apr + May + June… 1+1+1+…..

The Query only prompt User Input for Fiscal Year.

If you got time to spare, can you teach me step by step on how to get these 4 based on the description above?

I am ABAP-illiterate, but I am willing to learn.

Greatly appreciated for any help at all.

Many thanks,
Vince

• ###### Re: Customer Exits to find value from Cal year/mth (column), based on User input on Fiscal Year
Currently Being Moderated

Hi vincent,

Please follow the above code, Revert back if u have any doubt regarding the above code.

Regards,
RaviChandra

• ###### Re: Customer Exits to find value from Cal year/mth (column), based on User input on Fiscal Year
Currently Being Moderated

Hi

I think u won't get the o/p as mentioned because u r restricting that particular keyfigure with that corresponding customer exit. So u will  get the keyfigures values restricted to that particular days.

Hope u got it,

Regards,

RaviChandra

• ###### Re: Customer Exits to find value from Cal year/mth (column), based on User input on Fiscal Year
Currently Being Moderated

Hi

data ly type i.

"suppose if the user gives the 2012 as input.

ly = wa2-low+2(2).  " in ly the value 12 will be assigned.

now divide the ly with 4 and if remainder is 0 then it is leap year else not a leap year.

declare a static variable of type i.

Regards,

RaviCHandra