Skip to Content
Author's profile photo Former Member

Bizzare Bex Report: Concatenating multiple rows in a single cell

How hard is it for Wally to abstain himself from igniting a new pandemonium every day? An arsonist would be less of a pain to bear- at least he will kill us all in one single day.

What does he want this time? He wants us to group all the plant inventory, contract price of a particular material in a single row.

i.e the report layout should look like this:

Material

Plant

Price

10098

1002;1003;2009;3008;3009

100$,97$,95$,101$,99$

 What we get from a bex report is

 

Material

Plant

Price

10098

1002

100$

 

1003

97$

 

2009

95$

 

3008

101$

 

3009

99$

 

Here is how to do it:

Write an APD> extract this query> select the fields from the query object to the source fields of the routine object (it_source+ is the internal table that will hold the data from the query),+ then write a logic that groups the Plant field and The price field in a single variable of type string, separated by “;”, and put it in a new internal table where the concatenated fields are defined as a String–> Then use a Function module to extract this new internal table to the presentation server as a xls file.

(note: you will have to use a terminating/target  block in your APD after the routine block; I suggest you use a dummy data target block for writing to a file)

 

If you don’t want to use an APD- just extract the query to a transparent table using RSCRM_BAPI.

Then write a ABAP report with select statement on this table and construct the internal table according to the your logic.

The table name will be generated with the following convention /BIC/0C<technical name of your extract>

(PS: Be careful when you are doing typecasting; you will basically be concatenating all values in a string variable inside each loop)

Assigned Tags

      5 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member
      I guess JavaScript might be a viable option for such a case to do the concatenation on the front-end. It will be a lot easier to maintain. Did you try it?

      Cheers,
      - Ali Q.

      Author's profile photo Former Member
      Former Member
      Blog Post Author
      Good point Ali. I didnt try using JavaScript so far; but i am surely going to try it now.
      Author's profile photo Prashanth konduru
      Prashanth konduru
      Why don't u post the logic... too.
      Author's profile photo Former Member
      Former Member
      This can also be done via web templates and calling a ABAP class with required formatting ( Web based reporting )
      Author's profile photo Former Member
      Former Member
      Blog Post Author
      Absolutely agree with you Ankush. Didnt occur to me at that point of time.
      Thanks 🙂