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: 

Take date from the text variable.

Former Member
0 Kudos
112

Hi Experts,

I am a BW consultant and I have one requirement please help .

i have one transparent table where i have a text field where i have a date stored in it.

I want this date in the date varaible.

If i am directly reading this tabel and putting it inyo the date varaible IT gives me error

as : Target field and source field are mismatched.

Please help me put this date in the date variable from the text varaible.

Regards,

RG

8 REPLIES 8

Former Member
0 Kudos
75

HI,

You need to use the Offset to get the date into Date varaible from text variable.

EX : 25-03-2009 is in text varable then 

data :l_date type sy-datum
You need to write this way..
l_date = l_text+6(4).              " Year
l_date+4(2) = l_text+3(2).      " Month
l_date+6(2) = l_text(2).          " Day

0 Kudos
75

LENGHT of text vaiable is 60 char and value stored in it is

text_variable=20090121.

Could you tell me what will be code.... (data is stored in the varaible left to right OR left to right)

Thanks

RG

0 Kudos
75

first shift the data to the left

SHIFT <variable> LEFT DELETING LEADING SPACE.

Then determine the format you want and do like Avinash suggested.

Left to right OR left to right

Edited by: Micky Oestreich on Mar 26, 2009 8:14 AM

0 Kudos
75

Hi,

Does the date always start at the first position. ?

Try this

v_date = text_variable+0(8).

Regards

Former Member
0 Kudos
75

Hi

declare your variable the same type as the transparent table where you have the text field which stores date.

Eg:

if ztab is the table, and date is the field in the table, in your program, declare the variable as

DATA: l_date like ztab-date.

In the logic, move the data like

l_date = ztab-date

regards,

Arun

Former Member
0 Kudos
75

Hi RG,

Does this date always come at the same position. Then you can use offset to access it.

Something like

v_date = v_text+4(8).

Regards

Sm1tje
Active Contributor
0 Kudos
75

In addition to Avinash's comment: This depends on the format of the date in the text field.

Avinash's comment is correct if, and only if the date in the text field is formatted like this:

20082603

YYYYMMDD

Former Member
0 Kudos
75

Thanks for your help