2008 Aug 09 12:29 PM
hi
how can i write only sy-datum first two character ?
2008 Aug 09 12:31 PM
2008 Aug 09 12:33 PM
Hi,
You should declare a temporary variable & use offset (of 2 characters)
Example:-
data :
w_var(2) type c.
w_var = sy-datum+0(2).
write w_var.Luck,
Bhumika
2008 Aug 09 12:34 PM
Hi,
Data: w_offset(2) type c.
w_offset = sy-datum+0(2).
Write: w_offset.
2008 Aug 09 12:38 PM
2008 Aug 09 12:39 PM
2008 Aug 09 12:39 PM
Hi,
as date will be yyyymmdd.
so to get the date..
w_c = sy-datum+6(2).
Good luck
Narin
2008 Aug 09 12:41 PM
Hi,
Chenge then,
Data: w_offset(2) type c.
w_offset = sy-datum+6(2).
Write: w_offset.
2008 Aug 09 12:35 PM
hi,
Use Offset. By using Offset you can extract any number of characters from a string from any position.
You can extract this date part by applying Offset settings.
Date1 type sy-datum.
date(2) type c.
Date = Date1+0(2).
Write:/ Date.
Regards
Sumit Agarwal
2008 Aug 09 12:35 PM
>
> hi
>
> how can i write only sy-datum first two character ?
write sy-datum+0(2).
2008 Aug 09 12:35 PM
Hi,
Here you can offset to get the value of your requirment
Syntax 1:
data :
temp(2) type c.
temp = sy-datum+0(2).Syntax 2:
data :
temp type string.
temp = sy-datum+0(2).for detail in offset check
http://help.sap.com/saphelp_nw04/Helpdata/EN/79/c55470b3dc11d5993800508b6b8b11/content.htm
Regards,
Anirban
2008 Aug 09 12:36 PM
Hi
Data:
w_date(2) type c.
to get the first two character the specify the offset length as 2.
so to get from the starting position specify it as 0.
w_date = sy-datum+0(2).
0--> Postion
2--> length of characters
Hope this would help you.
Good luck
Narin
2008 Aug 09 12:38 PM
hey copy this program and directly execute.
DATA: DAT LIKE SY-DATUM,
DAT1(2) type c.
DAT = SY-DATUM.
write:/ 'IF U WANT TO DISPLAY DATE '.
dat1 = dat+6(2).
WRITE:DAT1.
write:/ 'IF U WANT TO DISPLAY month '.
DAT1 = DAT+4(2).
WRITE:DAT1.
write:/ 'if u want to display 20 of 2008'.
DAT1 = DAT+0(2).
WRITE:DAT1.
2008 Aug 09 12:39 PM
as others have also said, do it like:
write: sy-datum+6(2). " for day
write: sy-datum+4(2). " for month
write: sy-datum+2(2). " for year
With luck,
Pritam.
2008 Aug 09 12:41 PM
2008 Aug 09 12:40 PM
Hi,
Data : sdat type c.
clear sdat.
sdat = sy-datum+0(2). //it will first 2 character from the date.
// here 0 indicates starting position of the word.
// (2) indicates how many characters from the starting position.
Regards,
Harish
2008 Aug 09 12:43 PM
hi..
check out this
DATA: L_DAY(2) TYPE C,
L_MONTH(2) TYPE C,
L_YEAR(4) TYPE C,
L_LTEXT TYPE T247-LTX.
DATA: L_DATE TYPE STRING.
CALL FUNCTION 'HR_IN_GET_DATE_COMPONENTS'
EXPORTING
IDATE = SY-DATUM
IMPORTING
DAY = L_DAY
MONTH = L_MONTH
YEAR = L_YEAR
LTEXT = L_LTEXT
EXCEPTIONS
INPUT_DATE_IS_INITIAL = 1
TEXT_FOR_MONTH_NOT_MAINTAINED = 2
OTHERS = 3.
now choose from this what you want?
2008 Aug 09 1:08 PM
Anyone who's used offset, go and read this article about "magic numbers" to understand why they are BAD http://en.wikipedia.org/wiki/Magic_number_%28programming%29#Unnamed_numerical_constant
The correct way of parsing sy-datum is:
BEGIN OF data_ty,
yyyy TYPE c length 4,
mm TYPE c length 2,
dd TYPE c length 2,
END OF data_ty.
DATA: l_mydat TYPE data_ty.
l_mydat = sy-daturm.
WRITE: / l_mydat-ddThis is much more meaningful and obvious than sy-datum+2(6). By using the type formulation, you've explicitly said with the structure of sy-datum is. If it changes (highly unlikely, I know, but it's the principle), then you only have to change the type definition- not potentially a hundred places in your program.
matt
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |