Application Development 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: 

need to change the date format i have written pls correct me if i m wrong

Former Member
0 Kudos

Hi All,     Here in Write  Statement I only need to chage DDMMYY with DD/MM/YYYY, but one question, as BLDAT taking 8 char and DD/MM/YYYY will take 10 char so in internal table data declaration while declaring bldat need to put like: DATA: t_dat(10)  LIKE BSID-BLDAT. Pls suggest me as code is alo attached. Thanks and Regards Sankil

6 REPLIES 6

arivazhagan_sivasamy
Active Contributor
0 Kudos

Hi Sankil,

Write a code like below.

PARAMETERS: P_DATE TYPE MKPF-BUDAT.
DATA: DATE1(8) TYPE C.

WRITE P_DATE TO DATE1 DDMMYY.
WRITE DATE1.


Arivazhagan S

former_member212002
Active Contributor
0 Kudos

Date separators depend upon the user parameters maintained in transaction SU3.

However if you want to display date always as DD/MM/YYYY, than you can try something like this


DATA : LV_DATE TYPE CHAR10.

CONCATENATE sy-datum+6(2) sy-datum+4(2) sy-datum+0(4) into LV_DATE

SEPARATED BY '/'

Thanks, Abhinab

sivaganesh_krishnan
Contributor
0 Kudos

HI sankil,

You just want to write the date right ??

Try writing the write statement as this ,

data: date type  BSID-BLDAT.

WRITE:   date USING EDIT MASK '__/__/____'.



Regards,

Sivaganesh.

Former Member
0 Kudos

Check this example...

DATA : v_date(10) TYPE c,

        i_date(8) TYPE c,

        day(2) TYPE c,

        month(2) TYPE c,

        year(4) TYPE c,

        result(12) TYPE c.

i_date = 201213.

day = i_date+1(2).

month = i_date+3(2).

year = i_date+5(2).

year = year + 2000.

concatenate day '/' month '/' year into v_date.

WRITE v_date.

thangam_perumal
Contributor
0 Kudos

Hi Sankil Pandiya,

                          SAP standard format is DDMMYYYY like this only.. while printing or writing it will become DD.MM.YYYY . if you need to print as your desired format mean you have to code little bit.

Consider:

DATA: date TYPE sy-datum .
data: date_new(10).

date = sy-datum.
CONCATENATE date+6(2) '/' date+4(2) '/' date+0(4) INTO date_new.

WRITE : DATE_NEW .

let me know after facing the same problem.

Regards,

Thangam.P

Former Member
0 Kudos

hi sankil

BSID-BLDAT is a DATS type variable.

for DATS the input length is 8 but the output length is 10. so you dont have to make any changes in the declaration. it will automatically print in DD/MM/YYYY format.

for test purpose you can try this piece of code.

TABLES:

   BSID.

PARAMETERS:

   p_date TYPE BSID-BLDAT.

write:/ p_date.