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: 

How to move the text field date into date field in my 'Z' table.

Former Member
0 Kudos

HI,

How to move the text field date into date field in my 'Z' table.

Actually i am getting date format DD.MM.YYYY from the application server.I have declared that date field in my internal table as BSTDK(10).

Then i am passing into my internal table.Actually i have to send this date into my 'Z' table.But in that table i have declared that date length as 8.

So i am splitting that date itab-bstdk at '.' sending into 3 variables.then i am concatenating into one variable.then i am passing into my 'Z' table.it is working.

BUT,when the date in the text file as 02032007 means it is not moving to my 'Z' table.

and one more way 02/03/2007 this also not moving into my table.and date is 02-03-2007 then also it is not moving to date field.

Only if the date 02.03.2007 is like this means it is moving successfully into my table.

IF the date is any format how can i send date into my 'Z' table.

PLS IF ANY ONE KNOWS SOLUTION PLS GUIDE ME.

regards,

lokesh.

6 REPLIES 6

Former Member
0 Kudos

hi,

if the date is in the form of 02/03/2007 or 02-03-2007,

do the same way what you are doing for 02.03.2007 format,

elese if there are no seperators in between like . or / or -,

then just take the offsets and concatenate them into a string and then pass it

Regards,

sowjanya

Former Member
0 Kudos

Date is always represented in the internal format as YYYYMMDD....If you need to display it in the manner u want call the function module

'CONVERT_DATE_TO_EXTERNAL'.

Hope this solution was helpful

PS : Please award points if helpful.

former_member480923
Active Contributor
0 Kudos

Hi

The following code piece might help, i hope that the external date format understands '.' rather than '/'. If it is other way round please interchange the signs.


data: v_date(10) type c value '01/01/2008',
        v_ext_dat type char10,
        v_clen(2)   type n.

v_clen = strlen( v_date ).

do v_clen times.
search v_date for '/'.
** Replace the '/' seprater by '.'
if sy-subrc = 0.
repalce '/' with '.' from  v_date into v_date.

call function 'CONVERT_DATE_TO_INTERNAL' .

endif. 

enddo. 

Hope that Helps

Anirban M.

former_member480923
Active Contributor
0 Kudos

Pass the entry from th FM to the ZTABLE and save it.

Former Member
0 Kudos

hi,

in a simple way you can do,

data:a type c,out type d,

inp(10) type c value '27032007'. <b>input date</b>

a = inp+2(1). <b>check 3rd char of ur input date</b>

if a ca '012346789'. <b>if it is numeric</b>

concatenate inp4(4) inp2(2) inp+0(2) into out.

else. <b> else</b>

concatenate inp6(4) inp3(2) inp+0(2) into out.

endif.

write:/ out.

*do awrd points for all heplful answers.

Regards

Former Member
0 Kudos

DATA:

char(10),

date type datum.

char = '20070122'.

write char to date.

write: / date.

clear date.

date(4) = char(4).

date4(2) = char4(2).

date6(2) = char6(2).

write: / date.

Here is the sample code..

Reward if helpful...