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

problem with data format in the screen

Former Member
0 Likes
1,995

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

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,943

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

14 REPLIES 14
Read only

Former Member
0 Likes
1,943

Hi Priyanka

Why not


WRITE l_str_date TO FRMDATE.

Pushpraj

Read only

Former Member
0 Likes
1,943

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

Read only

Former Member
0 Likes
1,943

HI,

Instead of declaring FRMDATE parameter as sy-datum or D declare as CHAR10.

Read only

0 Likes
1,943

mY FRMDATE is a screen field. which is refering to database table

Regards

Priyanka

Read only

0 Likes
1,943

Hi ,

Can u provide the refrring database table anf field name.

Is this standrd transaction or Custom one?

regards

Naveen

Read only

0 Likes
1,943

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

Read only

0 Likes
1,943

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

Read only

0 Likes
1,943

But what will if my users date format are differnrt

so iam facing problem der..

Regards

Priyanka

Read only

0 Likes
1,943

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

Read only

Former Member
0 Likes
1,943

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

Read only

Former Member
0 Likes
1,943

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

Read only

Former Member
0 Likes
1,944

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

Read only

0 Likes
1,943

i have use the same code...

but iam not gettingthe correct output...

Regards

Priyanka

Read only

0 Likes
1,943

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.