Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Difference Between Weeks

Former Member
0 Likes
810

Hello All,

I have Year and Week 200952 in one variable. That means 52 week of year 2009.

However now i want to subtract 7 weeks from the 52 nd week,

Request you if we can get any standard function module for the same.

Regards

Anuja.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
738

Hello

I distrust that such FM is exist. Try this:


data: var1(6),
      var2(6),
      var3(2).
var1 = '200952'.
var3 = var1+4(2).
var3 = var3 - 7.
concatenate var1(4) var3 into var2.
write var2.

4 REPLIES 4
Read only

Former Member
0 Likes
739

Hello

I distrust that such FM is exist. Try this:


data: var1(6),
      var2(6),
      var3(2).
var1 = '200952'.
var3 = var1+4(2).
var3 = var3 - 7.
concatenate var1(4) var3 into var2.
write var2.

Read only

0 Likes
738

Hi,

Simple arithmatic is the answer, as suggested. But don't forget you'll need to add code to handle a week number less than 7.

Regards,

Nick

Read only

kesavadas_thekkillath
Active Contributor
0 Likes
738

How hard is it to subtract 7 from 52.

Read only

Former Member
0 Likes
738

I hope you can refer the code of standard fm LAST_WEEK and change it accordingly like

DATA : lv_week   TYPE scal-week,
       lv_monday TYPE sy-datum.

CALL FUNCTION 'GET_WEEK_INFO_BASED_ON_DATE'
  EXPORTING
    date   = sy-datum
  IMPORTING
    monday = lv_monday.
SUBTRACT 49 FROM lv_monday.

CALL FUNCTION 'DATE_GET_WEEK'
  EXPORTING
    date         = lv_monday
  IMPORTING
    week         = lv_week
  EXCEPTIONS
    date_invalid = 1
    OTHERS       = 2.
IF sy-subrc = 0.

  WRITE : / lv_week+4(2), '.', lv_week+0(4) .
ENDIF.

Regards

Shiba Prasad