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

Concatenate date fields issue

Former Member
0 Likes
974

Hi All,

I am facing an issue with the Concatenate statement in my program:

Data : w_date type sy-datum,

w_date1 type sy-datum,

W_OPTION_1(60) TYPE C.

w_date1 = sy-datum.

w_date = sy-datum - 40.

CONCATENATE 'ERDAT between' w_date 'and' w_date1 INTO W_OPTION_1 SEPARATED BY SPACE.

write : / w_option_1.

The output comes as :

I want these dates in quotes as below.

ERDAT BETWEEN '20090702' AND '20090811'

Can anyone help pls.

Thanks alot.

Edited by: Rob Burbank on Aug 11, 2009 2:21 PM

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
905

Hi

U can't do it by only one step, before cancateniting all in W_OPTION_1 u need to concatenate the dates in a distinctit step:

DATA : W_DATE  TYPE SY-DATUM,
       W_DATE1 TYPE SY-DATUM,
       W_OPTION_1(60) TYPE C.

DATA: W_DATE_A(10),
      W_DATE1_A(10).

W_DATE1 = SY-DATUM.
W_DATE = SY-DATUM - 40.


CONCATENATE '''' W_DATE  '''' INTO W_DATE_A.
CONCATENATE '''' W_DATE1 '''' INTO W_DATE1_A.

CONCATENATE 'ERDAT between'
            W_DATE_A
            'and'
            W_DATE1_A
            INTO W_OPTION_1 SEPARATED BY SPACE.

WRITE : / W_OPTION_1.

Max

9 REPLIES 9
Read only

Former Member
0 Likes
905

Hi,

Assign a text-element as apostrophe ( ' ) and then use it in the concatenate statement like


Data : w_date type sy-datum,
w_date1 type sy-datum,
W_OPTION_1(60) TYPE C.

w_date1 = sy-datum.
w_date = sy-datum - 40.

CONCATENATE 'ERDAT between' text-001 w_date text-001 'and' text-001 w_date1 text-001 INTO W_OPTION_1 SEPARATED BY SPACE.

write : / w_option_1.

Now you will get the desired output.

Regards,

Vik

Read only

Former Member
0 Likes
905

Welcome to SCN.

Please read the rules of engagement and do not use expressions like ASAP. Everyone's problem is important.

Rob

Read only

0 Likes
905

ok thanks alot.

Read only

former_member194669
Active Contributor
0 Likes
905

Try this way

Please read the forum rules


Constants: c_quot(4)     type c value ''''.        " For value '

CONCATENATE 'ERDAT between' c_quot w_date c_quot 'and' c_quot w_date1 c_quot INTO W_OPTION_1 SEPARATED BY SPACE.

a®

Read only

0 Likes
905

Hi ..

CONCATENATE 'ERDAT between' c_quot w_date c_quot 'and' c_quot w_date1 c_quot INTO W_OPTION_1 SEPARATED BY SPACE.

this doesn't work as it returns

ERDAT between ' 20090702 ' and ' 20090811 '.

I dont want space between the quote and the date.

Read only

Former Member
0 Likes
906

Hi

U can't do it by only one step, before cancateniting all in W_OPTION_1 u need to concatenate the dates in a distinctit step:

DATA : W_DATE  TYPE SY-DATUM,
       W_DATE1 TYPE SY-DATUM,
       W_OPTION_1(60) TYPE C.

DATA: W_DATE_A(10),
      W_DATE1_A(10).

W_DATE1 = SY-DATUM.
W_DATE = SY-DATUM - 40.


CONCATENATE '''' W_DATE  '''' INTO W_DATE_A.
CONCATENATE '''' W_DATE1 '''' INTO W_DATE1_A.

CONCATENATE 'ERDAT between'
            W_DATE_A
            'and'
            W_DATE1_A
            INTO W_OPTION_1 SEPARATED BY SPACE.

WRITE : / W_OPTION_1.

Max

Read only

0 Likes
905

Thanks a lot Max.

And thanks to everyone who helped.

Read only

former_member194669
Active Contributor
0 Likes
905

Then


data : v_text1(15) type c, v_text2(15) type c.
Constants: c_quot(4)     type c value ''''.        " For value '
 write : w_date to v_text1.
write : w_date1 to v_text2.
concatenate c_quot v_text1 c_quot to v_text1. condense v_text1 no-gaps.
concatenate c_quot v_text2 c_quot to v_text2. condense v_text2 no-gaps.
CONCATENATE 'ERDAT between' v_text1  'and' v_text2 INTO W_OPTION_1 SEPARATED BY SPACE.

a®

Read only

Former Member
0 Likes
905

hi,

try this code.

Data : w_date type sy-datum,

w_date1 type sy-datum,

W_OPTION_1(60) TYPE C,

lv_str1(10) type c,

lv_str2(10) type c.

w_date1 = sy-datum.

w_date = sy-datum - 40.

concatenate '''' w_date'''' into lv_str1.

concatenate '''' w_date1 '''' into lv_str2.

CONCATENATE 'ERDAT between' lv_str1 'and' lv_str2 INTO W_OPTION_1 SEPARATED BY SPACE.

.

write : / w_option_1.