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 converting char(10) to standard date

Former Member
0 Likes
3,045

Hi experts,

Here is my problem

A custom table-zone (zdate) has been (wrongly) declared as type char (10).

I have created a z-table with a Z-table-zone called zdate2 having the standard domain and data type DATS.

I am trying to do something like this :

SELECT * FROM ztsd_escompte

INTO CORRESPONDING FIELDS OF TABLE t_escompte

WHERE zdat2 <= vbrk-zdate1.

obviously this returns a sy-subrc = 4 since zdate1 and zdate 2 do not have the same type. How could I convert zdate1(char 10) to the same type as zdate2 (DATS) so that the select could work?

Helpful answers will be rewarded !

Many thanks,

C.K.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,693

data:

w_date(10) type c value '16.06.2008',

w_da(8) type c,

w_date1 type d,

w_year(4) type c,

w_month(2) type c,

w_day(2) type c.

w_year = w_date+6(4).

w_month = w_date+3(2).

w_day = w_date+0(2).

concatenate w_year w_month w_day into w_da.

write w_da.

w_date1 = w_da.

write:/ w_date1.

now give in selection

8 REPLIES 8
Read only

Former Member
0 Likes
1,693

Hi,

take a variable of type char 10 ,

convert vbrk-zdate1 into 10 char value and use it in where condition

u can convert it manually.....

it will work

regards,

lavanya

Read only

0 Likes
1,693

vbrk-zdate1 is already as a char (10) I'm trying to convert it to standard type DATS but do not know how to do ,

any more help please?

C.K.

Read only

0 Likes
1,693

Hi

in database how the values are stored in. i mean yyyy.mm.dd or dd.mm.yyyy

mention it..

Read only

Former Member
0 Likes
1,693

Hi

It depends on which format the date is stored in table-zone (zdate): I can suppose it's like DD/MM/YYYY, if it's so:

DATE(4) = Z-TABLE-ZONE+6(4).

DATE4(2) = Z-TABLE-ZONE3(2).

DATE+6(2) = Z-TABLE-ZONE(2).

Max

Read only

0 Likes
1,693

Hi, thanks for your answer is are the formats

zdate1 is dd.mm.yyyy (was built as char 10 in SE11)

zdate2 is dd/mm/yyyy (was built as DATS in SE11)

Read only

Former Member
0 Likes
1,693

hiii

here you can convert vbrk-zdate1 into character type with 10 length & use format of zdate1 there.so conversion problem will not affect there.

reward if useful

thx

twinkal

Read only

Former Member
0 Likes
1,693

In ABAP there is Automatic conversion is dr for converting Date format into character format.

The follwoing supporting document from SAP-Img :

Conversion table for source type D

Target

Conversion

C

The date is transported left-justified without conversion.

So i think dr is some mismatching in source structure and Target structure. Kindly put the error message also for reference.

Read only

Former Member
0 Likes
1,694

data:

w_date(10) type c value '16.06.2008',

w_da(8) type c,

w_date1 type d,

w_year(4) type c,

w_month(2) type c,

w_day(2) type c.

w_year = w_date+6(4).

w_month = w_date+3(2).

w_day = w_date+0(2).

concatenate w_year w_month w_day into w_da.

write w_da.

w_date1 = w_da.

write:/ w_date1.

now give in selection