Skip to Content
author's profile photo Former Member
Former Member

problem with data format in the screen

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

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

6 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Feb 24, 2009 at 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

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      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.
      

  • Posted on Feb 24, 2009 at 10:19 AM

    Hi Priyanka

    Why not

    WRITE l_str_date TO FRMDATE.
    

    Pushpraj

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Feb 24, 2009 at 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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Feb 24, 2009 at 10:23 AM

    HI,

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

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      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

  • author's profile photo Former Member
    Former Member
    Posted on Feb 24, 2009 at 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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Feb 24, 2009 at 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

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.