10-11-2007 9:05 AM
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.
10-11-2007 9:10 AM
Hi,
Try this.
CALL FUNCTION 'NAMETAB_GET'
EXPORTING
langu = sy-langu
tabname = 'ZSTUDGARY'
TABLES
nametab = i_nametab.
LOOP AT i_nametab INTO w_nametab .
concatenate val w_nametab-fieldname into val separated by space.
endloop.
Try to restrict the field based on conditions.
Reward point if usefull
Regards,
Niyaz
10-11-2007 9:13 AM
Can you help me to put inside my code. The code can gt from the previous post
. Advance thank!
10-11-2007 9:22 AM
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.
DATA : i_nametab TYPE TABLE OF dntab, " <b>NEW CODE</b>
w_nametab TYPE dntab. <b>" NEW CODE</b>
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.
CALL FUNCTION 'NAMETAB_GET'
EXPORTING
langu = sy-langu
tabname = 'ZSTUDGARY'
TABLES
nametab = i_nametab.
IF SY-SUBRC = 0.
LOOP AT i_nametab INTO w_nametab .
concatenate val w_nametab-fieldname into val separated by space.
endloop.
Write: val.
write:/ sy-uline.
LOOP AT it_vbak.
clear val.
CONCATENATE it_vbak-admino it_vbak-fname it_vbak-lname into val
SEPARATED BY space.
write:/ val.
ENDLOOP.
ENDIF.
The output will be like this
admino fname lname
-
10 xxx yyy
Regards,
Niyaz
Please award points for all usefull answers...
10-11-2007 9:32 AM
sorry think u gt me wrong
i want to display the concat record out base on the seq order of the parameter value
field1 -
lname
field2----
admino
field3----
fname
if the user specify the above
after the concat
the result gt is : <b>gary 1234 yip</b>
This is the result i want
but now the result i gt is: <b>123 yip gary</b>
This follow the table seq after the concat which i dont want.
Below is my code. Thks advance for amending the code
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.
<b>CONCATENATE it_vbak-admino it_vbak-fname it_vbak-lname into val
SEPARATED BY space.</b>
write:/ val.
ENDLOOP.
ENDIF.