2009 Feb 24 10:14 AM
Hi friends,
Iam facing aproblem with date formats in for the fields on the screen.
i have FRMDATE field on the screen in which i want default date as ist date of the current year ie : 01/01/2009
and i have on more field TODATE in which i need last date of the current year ie : 31/12/2009
bot iam facing the data formats.
ie : iam getting differnr date formats.
code :
data :
l_date type sy-datum,
l_str_dat(10) type c.
l_date = sy-datum.
( Here in l_date iam getting as 20090224 )
l_date+4(4) = '0101'.
( now here after chaning i getting it as 20090101 )
write l_date to l_str_date.
( in l_str_dat iam getting it as 01/01/2009 )
FRMDATE = l_str_date .
( here in FRMDATE iamgetting it as 01/01/20 )
on screen in the field iam getting it as FRMDATE = 1//20/01/0
Can any one correct it.
Regards
Priyanka
2009 Feb 24 12:11 PM
Dear Priyanka,
I have written the follwoing code in PBO and getting the correct output.
tables: vbak.
data :
l_date type sy-datum,
l_str_dat(10) type c.
l_date = sy-datum.
l_date+4(4) = '0101'.
write l_date to l_str_dat.
vbak-erdat = l_str_dat .
Try with DATS format in the general attribute of screen field. Give DefLg and VisLg as 10. (Defined and Visible Length).
Hope this will solve your problem.
Regards,
Anil
Hi friends,
Iam facing aproblem with date formats in for the fields on the screen.
i have FRMDATE field on the screen in which i want default date as ist date of the current year ie : 01/01/2009
and i have on more field TODATE in which i need last date of the current year ie : 31/12/2009
bot iam facing the data formats.
ie : iam getting differnr date formats.
code :
data :
l_date type sy-datum,
l_str_dat(10) type c.
l_date = sy-datum.
( Here in l_date iam getting as 20090224 )
l_date+4(4) = '0101'.
( now here after chaning i getting it as 20090101 )
write l_date to l_str_date.
( in l_str_dat iam getting it as 01/01/2009 )
FRMDATE = l_str_date .
( here in FRMDATE iamgetting it as 01/01/20 )
on screen in the field iam getting it as FRMDATE = 1//20/01/0
Can any one correct it.
Regards
Priyanka
2009 Feb 24 10:19 AM
2009 Feb 24 10:20 AM
hi,
the problem is with FRMDATE data type as ithink it is 8 charcters and eventhough you pass 01/01/2008, it is ignoring last 2 numbers i.e 08.
so declare FRMDATE ascharacetr 10 and check it.
Regards,
Naveen
2009 Feb 24 10:23 AM
HI,
Instead of declaring FRMDATE parameter as sy-datum or D declare as CHAR10.
2009 Feb 24 10:43 AM
mY FRMDATE is a screen field. which is refering to database table
Regards
Priyanka
2009 Feb 24 10:45 AM
Hi ,
Can u provide the refrring database table anf field name.
Is this standrd transaction or Custom one?
regards
Naveen
2009 Feb 24 10:51 AM
its same field as VBAK-ERDAT
its a custom table and for that field FRMDATE i have used the same data element as ERDAT from vbak-erdat.
Can any one correct it.
Regards
Priyanka
2009 Feb 24 10:58 AM
ok, do like this.
l_date = sy-datum.
( Here in l_date iam getting as 20090224 )
l_date+4(4) = '0101'.
( now here after chaning i getting it as 20090101 )
*write l_date to l_str_date. <----comment it
( in l_str_dat iam getting it as 01/01/2009 )
FRMDATE = l_date.
( here in FRMDATE it will be 01012009, without any seperator '/' )
revert back,
regards,
Naveen
2009 Feb 24 11:16 AM
But what will if my users date format are differnrt
so iam facing problem der..
Regards
Priyanka
2009 Feb 24 11:20 AM
HI,
Instead of FRMDATE TYPE VBAK-ERDAT declare as FRMDATE TYPE CHAR10.
l_str_dat = 01/01/2009
Now you can pass l_str_dat to FRMDATE.
VBAK-ERDAT is of type DATS and it's length is 8 and display length is 10 with seprators.
Edited by: Avinash Kodarapu on Feb 24, 2009 4:51 PM
2009 Feb 24 11:56 AM
hi
try with this
selection-screen begin of block B1 with frame title text-001.
selection-screen begin of line.
selection-screen position 2.
parameter:lv_frdat like sy-datum default sy-datum.
selection-screen position 25.
parameter:lv_todat(10).
selection-screen end of line.
selection-screen end of block B1.
initialization.
concatenate '31.12.' sy-datum+(4) into lv_todat.
Regards
2009 Feb 24 11:59 AM
Hi,
check the below code.
But some more work should be done to get the user selected date in the selection screen parameter.
parameters:FRMDATE(10) type c.
initialization.
data :
l_date type sy-datum,
l_str_date(10) type c.
l_date = sy-datum.
l_date+4(4) = '0101'.
write l_date to l_str_date.
FRMDATE = l_str_date .
write : frmdate.
at selection-screen on value-request for frmdate.
CALL FUNCTION 'F4_DATE'
.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
regards,
Naveen
2009 Feb 24 12:11 PM
Dear Priyanka,
I have written the follwoing code in PBO and getting the correct output.
tables: vbak.
data :
l_date type sy-datum,
l_str_dat(10) type c.
l_date = sy-datum.
l_date+4(4) = '0101'.
write l_date to l_str_dat.
vbak-erdat = l_str_dat .
Try with DATS format in the general attribute of screen field. Give DefLg and VisLg as 10. (Defined and Visible Length).
Hope this will solve your problem.
Regards,
Anil
2009 Feb 24 2:43 PM
i have use the same code...
but iam not gettingthe correct output...
Regards
Priyanka
2009 Feb 24 2:54 PM
just use the move , instead of write. Yiou dont need to worry about the date fromat on the screen as SAp will take care of that automatcially based on user date format
code :
data :
l_date type sy-datum,
l_str_dat(10) type c.
l_date = sy-datum.
( Here in l_date iam getting as 20090224 )
l_date+4(4) = '0101'.
fromdate = i_date.
i_date+4(4) = '1231'.
todate = i_date.
| User | Count |
|---|---|
| 6 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |