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 non initial values

Former Member
0 Likes
2,461

Hi,

I have set of ten fields to be concatenated with a separator.

But only the fields which are not initial should be concatenated.

Is there any easy way available to do this or each time should I have to check all the ten fields and then concatenate?

5 REPLIES 5
Read only

kesavadas_thekkillath
Active Contributor
0 Likes
1,497

Concatenate all the fields and in next step just use

condense lv_string. This will delete the spaces.

Read only

Former Member
0 Likes
1,497

the separator in my case is '/'.

for example,

text1 = blank

text2 = str1

text3 = str3

concatenate text1 text2 text3 into text separated by '/'.

now the o/p is,

/str1/str3

now i don want the first '/' to be displayed.

how can this be done?

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
1,497

Hi Sharan,

Check this code snippet;

PARAMETERS:
p_text1 TYPE char10,
p_text2 TYPE char10,
p_text3 TYPE char10,
p_text4 TYPE char10,
p_text5 TYPE char10,
p_delim TYPE char1.

DATA: v_output TYPE string,
      itab  TYPE STANDARD TABLE OF char10,
      wa TYPE char10.

CONCATENATE p_text1
            p_text2
            p_text3
            p_text4
            p_text5
INTO v_output SEPARATED BY p_delim.

WRITE: / v_output.

SPLIT v_output AT p_delim INTO TABLE itab.
CLEAR v_output.

DELETE itab WHERE table_line IS INITIAL. "delete initial recs

LOOP AT itab INTO wa.
  IF sy-tabix = 1.
    v_output = wa. "Without this output'll be corrupted ;-)
  ELSE.
    CONCATENATE v_output wa INTO v_output SEPARATED BY p_delim.
  ENDIF.
ENDLOOP.

WRITE: / v_output.

Hope this is of some use.

BR,

Suhas

Read only

Former Member
0 Likes
1,497

thanks suhas for ur inputs..

but solved the issue by this way,

append text1 to itab.

append text2 to itab.

append text3 to itab.

delete itab where table_line is initial.

concatenate lines of itab into text seperated by '/'.

Read only

0 Likes
1,497

It works Thanks