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

Any ABAP code or Functional module to concatenate table value

pavneet_rana
Active Participant
0 Likes
1,900

Hi to all,

Can any one explain, is there any ABAP code or Functional module to read from table /SAPTRX/EH_INFO. (This is Database table in SAP EM).

Example: i have database table /SAPTRX/EH_INFO in SAP EM.

It have a field PARAM_NAME type C 32. and it contain 3 data

PARAM_NAME  (field name)

rocky                (field value)

john                  (field value)

mike                 (field value)

i want to concate rocky john mike and put in saome result field.

Can any one provide some light on it.

Regads

Pavneet Rana

Moderator Message - Unmarked as question.

Message was edited by: Suhas Saha

7 REPLIES 7
Read only

FredericGirod
Active Contributor
0 Likes
1,115

Hi,

I really don't understand why you would like to find a fm ...

select param_nam into w_param_name from ...  where ...

  concatenate w_sum w_param_name into w_sum separated by space.

endselect.

remove the first space ..

regards

Fred

Read only

bharat_rathod2
Active Participant
0 Likes
1,115

Dear,

Just read field value into variable and concatenate it to 1 final variable.

Read only

Former Member
0 Likes
1,115

Hi Rana,

You can use FM - RFC_READ_TABLE.

give parameters: QUERY_TABLE - your table name

DELIMITER - like , / ;

OPTIONS = your selection where condition (like VBELN = '1000' )

and you will get concatenated data in DATA table.

.

Thanks,
Chandra.

Message was edited by: Venkat Gowrishankar

Read only

former_member213275
Contributor
0 Likes
1,115

Hi Pavaneet Rana,

You can write below abap code to concatenate table fields.

data: itab type table of /SAPTRX/EH_INFO,

         wa type /SAPTRX/EH_INFO,

         result_field type string.

select * from /SAPTRX/EH_INFO

into table itab where......

loop at itab into wa.

concatenate  wa-param_name  result_field into  result_field seperated by space.

endloop.

Srikanth.

Read only

Former Member
0 Likes
1,115

Hi Pavneet,

You can refer this simple code,and code ur requirement accordingly.No need of any FM.

REPORT  ZTEST line-size 1000.

data : it_tab like table of /SAPTRX/EH_INFO with header line.

data:name type string.

select PARAM_NAME

   from /SAPTRX/EH_INFO

   into corresponding fields of table it_tab.

   loop at it_tab.

     concatenate name it_tab-PARAM_NAME into name.

     write:/ name.

   endloop.

Read only

former_member209120
Active Contributor
0 Likes
1,115

Hi Pavneet,

Functional  Module's  to concatenate table values

STRING_CONCATENATE

STRING_CONCATENATE_3

DATA: STRING(100) TYPE C.

PARAMETERS: A(20) TYPE C,
             B(20) TYPE C.

CALL FUNCTION 'STRING_CONCATENATE'
   EXPORTING
     STRING1         = A
     STRING2         = B
  IMPORTING
    STRING          = STRING
  EXCEPTIONS
    TOO_SMALL       = 1
    OTHERS          = 2
           .
IF SY-SUBRC <> 0.
  MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
          WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

WRITE😕 STRING.





clear : string.

CONCATENATE A B into string SEPARATED BY ' '.         " better use this method instead of FM

WRITE😕 STRING.

Regards,

Ramesh.T

Read only

andrewdiaz2000
Active Participant
0 Likes
1,115

Hi Rana,

As you have said in single field PARAM_NAME you are already getting 3 values . so how your getting them and how you want to change.

Example:-

if ur getting 3 values as comma seperated.

PARAM_FIELD = ROCKEY,JOHN,MIKE

and your anticipating output as

PARAM_FIELD = ROCKEY JOHN MIKE

then u can use REPLACE keyword..

if your still not clear about what it is give some more details to help you..

Hope it helps,

Andrew