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

Using offset

Former Member
0 Likes
1,660

Can anyone help me ,how to use OFFSET in my code ?

REASON : I want to change the current date to the first date of the current month.

example: 2006.12.11(yyyy.mm.dd) to 2006.12.01(yyyy.mm.dd)

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,561
try this


REPORT YCHATEST LINE-SIZE 350.

DATA : V_DATE LIKE SY-DATUM,
       V_START_DATE(10).

V_DATE = SY-DATUM.

CONCATENATE V_DATE+0(4) V_DATE+4(2) '01' INTO V_START_DATE SEPARATED BY '.'.

WRITE : V_START_DATE.
5 REPLIES 5
Read only

anversha_s
Active Contributor
0 Likes
1,561

hi,

a sugestion is.

use this FM.

u will get the start and end date.

data:f_date type sy-datum,
l_date type sydatum.


CALL FUNCTION 'HR_JP_MONTH_BEGIN_END_DATE'
EXPORTING
iv_date = sy-datum
IMPORTING
EV_MONTH_BEGIN_DATE = f_date
EV_MONTH_END_DATE = l_date.

or u want to go with offset.

V_DATE_IN = '2006.12.11'.

V_DATE_IN+0(4) "<--for Year

V_DATE_IN+5(2) "<--for month

V_DATE_IN+8(2) "<--for Day

rgds

Anver

Read only

Former Member
0 Likes
1,561

Hello,

You can try it as below :

string str.

date1 = 2006.12.11

str = date1.

str+8(2) = '01'.

or you can use some stanrdard functions for this change.

Thanks.

Read only

Former Member
0 Likes
1,561

Hello,

You can use the sub-string operation.

data v_date type sy-datum value sy-datum.

here v_date = 20061212

v_date+6(2) = '01'.

here v_date = 20061201

The above code will change 2 characters from the seventh characters onwards. In this case day.

Regards,

Manoj

Read only

Former Member
0 Likes
1,562
try this


REPORT YCHATEST LINE-SIZE 350.

DATA : V_DATE LIKE SY-DATUM,
       V_START_DATE(10).

V_DATE = SY-DATUM.

CONCATENATE V_DATE+0(4) V_DATE+4(2) '01' INTO V_START_DATE SEPARATED BY '.'.

WRITE : V_START_DATE.
Read only

Former Member
0 Likes
1,561

Hi Shashank ,

Since the variable containing date will be of type DATUM and the internal rep of it is YYYYMMDD , so date like 22.12.2006 will be rep as 20061222.

Now if you want to convert it to 01.12.2006 all you have to do it

v_date+6(2) = '01'. where v_date is the variable storing the date.

Regards

Arun