cancel
Showing results for 
Search instead for 
Did you mean: 

ABAP report output as preformatted text on BSP page ?

Former Member
0 Kudos

Hi,

I am trying to create a BSP page which contains the output of an ABAP report. This output ( which should look similar to an old fashioned ABAP list ) should be pre-formatted, keeping the white spaces in the list lines as they are.

The data is contained in a table ( I_LIST ) with 1 field ( ZEILE ). Part of the layout section of the BSP looks like this :

<% DATA: blue TYPE I. %>

<PRE CLASS="list">

<% LOOP AT I_LIST INTO W_LIST. %>

<% blue = SY-TABIX MOD 2. %>

<SPAN CLASS="r<%= blue %>"><%= W_LIST-ZEILE %></SPAN>

<% ENDLOOP.%>

</PRE>

( The "blue" variable toggles between 0 & 1, which corresponds with 2 different shades of blue in a CSS type sheet. )

In order to ensure pre-formatting, , I use the <PRE> tags.

The side-effect of this, is, that a blank line is inserted after each list line.

I have tried using <TABLE> tags and placing a line in each table row, but this destroys the whitespaces.

Does anyone know a easy way to avoid the blank lines while keeping the pre-formatting ?

( I have only started with BSP, so I might be missing something very obvious )

Fred van de Langenberg

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member181879
Active Contributor
0 Kudos

Hallo Fred,

Now this is the type of question and the challange that I actually like to see in this forum.

<u>First question: what does <pre> mean?</u> Effectively output every thing verbatim. So if there are CRLF (Carriage Return/Line Feed) sequences in that text, they are outputted as is.

<u>Next question: From where does those extra CRLF comes?</u> This simple fact is that your wrote them! Let us look at your source again with my comments:


<pre><code>CRLF
<% LOOP AT I_LIST INTO W_LIST. %>CRLF
<% blue = SY-TABIX MOD 2. %>CRLF
<SPAN CLASS="r<%= blue %>"><%= W_LIST-ZEILE %></SPAN>CRLF
<% ENDLOOP.%>CRLF
</code></pre>

What I have added onto your code (just visualized for you!) are all the extra CRLF characters that you wrote but never see. They are there in the editor, and they are blasted out to the browser.

<u>Idea 1:</u> The simplest solution would be to write just some of your code onto one line!


<pre><code>CRLF
<% LOOP AT I_LIST INTO W_LIST. %>CRLF
<% blue = SY-TABIX MOD 2. %><SPAN ...</SPAN>CRLF
<% ENDLOOP.%>CRLF
</code></pre>

From my estimate, just having the blue calculations plus the span on one line should already do the trick. The loop/endloop just add additional CRLF before after the sequence.

<u>Idea 2:</u> Why not look at the properties tab of your page. There are some compression options to actually strip CRLF completely from the output, to make it smaller. See also:

BSP Performance: Compression

/people/brian.mckellar/blog/2003/10/13/bsp-performance-compression

<u>Problem with Idea 2:</u> Of course, this will also strip the CRLF from behind the span, rendering all your output on one line! So you have to manually render these also out. Just add the following:


...
<SPAN CLASS="r<%= blue %>"><%= W_LIST-ZEILE %></SPAN>
<%= CL_ABAP_CHAR_UTILITIES=>CR_LF %>
...

All of the above shot in the dark (it is night outside!), I leave the final tests for you to enjoy!

++bcm

Former Member
0 Kudos

Hallo Brian,

Thanks very much for your clear answer !

The page works very nice now, and your tip gave me a deeper understanding of what actually happens with the code in the BSP layout sections.

Thanks also for your page compression article ( very usefull indeed !)

With regards,

Fred van de Langenberg