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: 

Concatenatation of filed in one filed

Former Member
0 Kudos

Hi Experts,

I am concatenating few field to a character field..by separating with "|" symbol..it is something like this..

*|||***||** (* refers char value)

few field does not have value for which subsequent '|' symbol is there..

I want number of spaces (as per data-element) should be there instead of blank. Some thing like this..

*| | |***| |**

How to achieve this?

Thanks,

Rajesh

5 REPLIES 5

Former Member
0 Kudos

Try adding SEPARATED BY SPACE to your concatenate.

0 Kudos

I am already separating it by '|' (Pipe) symbol.

Thanks,

Rajesh

0 Kudos

You can try something like this:


REPORT  ZMP_TEST.

DATA: v_string1(3) TYPE C VALUE 'abc',
      v_string2(3) TYPE C VALUE '',
      v_string3(3) TYPE C VALUE 'def',
      v_string4(3) TYPE C VALUE 'ghi',
      v_output(50) TYPE C ,
      sep(1) VALUE '|'.

CONCATENATE v_string1 v_string2 v_string3 v_string4 INTO v_output SEPARATED BY sep RESPECTING BLANKS.
CONDENSE v_output.
BREAK-POINT.

It also depends on the fields you concatenating. The above logic will not work as desired if the other fields also have spaces in them.

0 Kudos

Hi,

Thanks for reply...

I am working in 4.7EE, where this code is not working...

any other way..??

Thanks,

Rajesh.

Former Member
0 Kudos

Another aproach, this one's dirty and doesn't use concatenate at all.

DATA:
one(3) TYPE c VALUE 'abc',
two(4) TYPE c,
three(3) TYPE c VALUE 'fgh',

BEGIN OF record,
first(3) TYPE c,
h1 TYPE c VALUE '|',
second(4) TYPE c,
h2 TYPE c VALUE '|',
third(3) TYPE c,
END OF record.

START-OF-SELECTION.


  record-first = one.
  record-second = two.
  record-third = three.
  WRITE record.