cancel
Showing results for 
Search instead for 
Did you mean: 

How to extract Week from a Date Formula

Former Member
0 Kudos

Hi everyone,

i have created a a formula "Date" in Bex. the Data look like this:

16.06.2016

17.06.2016

18.06.2016

and now based on this Formula, i want to extract Week and year. some thing looks like this:

WW.YYY

25.2016

26.2016

Can you please help me how to do it?

Thanks

Accepted Solutions (1)

Accepted Solutions (1)

former_member200967
Active Participant
0 Kudos

HI Pha,

You can use the FM 'DATE_GET_WEEK' to get the Week . Just pass the date to this FM and it returns the Calendar week.

PS: the output of this FM is in the format YYYYWW, you might need it to convert it to format WW.YYYY.

Regards,

Manpreet

Former Member
0 Kudos

Thanks Manpreet,

i am newbie with ABAP, could you please tell me which steps i need to use FM 'DATE_GET_WEEK' to get the Week?

it would be very nice of you

many thanks

former_member200967
Active Participant
0 Kudos

Hi Pha,

Can you first tell me from where are the date values coming from? Are they present in the backend ? Or have you created a Replacement Path Formula variable on some date field?

Regards,

Manpreet

Former Member
0 Kudos

Hi Manpreet,

The Date field is a column in Cube FIAP.

former_member200967
Active Participant
0 Kudos

Then the simplest option is to  add the 0CALWEEK in the underlying Cube and map the date field to the 0CALWEEK. Use the 0CALWEEK characteristic in the report then, you will be able to see the calweek of the date.

Regards,

Manpreet

Former Member
0 Kudos

is there any other way?. i have heard of the start routine in transformation.

How can we do it?

Thankyou very much!

Former Member
0 Kudos

Hi Pha,

Using the the FM 'DATE_GET_WEEK' , we can get the week in the format YYYYWW.

After this, we can call this result to a local variable(say as lv_weekyear) into other two local variables as,

lv_week of type c,

lv_year of type c,

lv_wkyr(7) type c.

lv_week= lv_weekyear+4(2).

lv_year=lv_weekyear+1(2).

Concatenate lv_week lv_year into lv_wky seperated by '.'.

Result= lv_wkyr.


Now you can get the week of a year in the format WW.YYYY.


Hope this one helps.


Thanks,

Jai Ganesh J

Former Member
0 Kudos

Hi Jai,

Thanks for your Help.

But where i will use this FM?. in routine in transformation or in bex?

sorry for asking. i am really new with ABAP

Former Member
0 Kudos

Hi Pha,

You need to use this code in Transformation.

Thanks,

Jai Ganesh J

former_member200967
Active Participant
0 Kudos

You need to add a new Infoobject in your underlying cube and this new Infoobject should be of type NUMC length 7.

Add this New Infoobject in your cube and in transformation, map the date field from the source to this New IOBJ.  Follow the steps mentioned in this document http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/609eea32-455e-2c10-c08a-c23adf8c9...

to write a Characteristics/Field Routine.

In the code for the Field routine use the below code.

Data: WeekValue type kweek.

CALL FUNCTION 'DATE_GET_WEEK'

   EXPORTING

     DATE               = SOURCE_FIELDS-"name of the source infobject"

IMPORTING

    WEEK               = WeekValue.

CONCATENATE WeekValue+4(2) WeekValue+0(4) SEPERATED BY '.' INTO RESULT.

Regards,

Manpreet

Answers (0)