Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Dynamic Concat

Hi all

i need to concat the field in the table? Below is my code

My ZSTUDGARY table contain admino, fname, lname field.

How to convert:

CONCATENATE <b>it_vbak-admino it_vbak-fname it_vbak-lname</b> into val

SEPARATED BY space.

to

CONCATENATE <b>it_vbak-field1 it_vbak-field2 it_vbak-field3</b> into val

SEPARATED BY space.

REPORT ZGARY_CONCAT1.

DATA: val type string.

PARAMETERS:field1(30).

PARAMETERS:field2(30).

PARAMETERS:field3(30).

TABLES: ZSTUDGARY.

DATA: it_vbak TYPE TABLE OF ZSTUDGARY WITH HEADER LINE,

wa_fld(72) TYPE C,

it_fldtab LIKE TABLE OF wa_fld.

if field1 <> ''.

append field1 to it_fldtab.

endif.

if field2 <> ''.

append field2 to it_fldtab.

endif.

if field3 <> ''.

append field3 to it_fldtab.

endif.

SELECT (it_fldtab)

INTO CORRESPONDING FIELDS OF TABLE it_vbak

FROM ZSTUDGARY.

IF SY-SUBRC = 0.

LOOP AT it_vbak.

CONCATENATE <b>it_vbak-admino it_vbak-fname it_vbak-lname</b> into val

SEPARATED BY space.

write:/ val.

ENDLOOP.

ENDIF.

Tags:
Former Member
Not what you were looking for? View more on this topic or Ask a question