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

Print program for large ALV Report

Former Member
0 Likes
2,996

I have an ALV report that has around 20 columns of data which I would approximate that it will take 3 pages to display the data.

When I use the print button for this report, the layout is changed to the max possible columns 65x255 and yet many columns go missing in the hard copy.

It seems I need to write some separate logic to print this document. How can I handle this?

I am using CL_SALV_TABLE t o generate the report. I am already handling events ON_USER_COMMAND & TOP_OF_PAGE.

Thank you.

1 ACCEPTED SOLUTION
Read only

former_member194669
Active Contributor
0 Likes
2,521

Try with capture the column position explicitly


data: gr_columns    type ref to cl_salv_columns_table.
...
...
 gr_columns->set_column_position( columnname = text-103 " MATNR
                                   position   = 1 ).
 gr_columns->set_column_position( columnname = text-104 " DOCNO
                                   position   = 2 ).
  gr_columns->set_column_position( columnname = text-105 " DESCR
                                   position   = 3 ).
 

Hi,

Because the standard format of ALV output setting is X_65_255, when you want to extend the column number, you have to choose other format type follow the steps below:

1.ALV screen, press 'print.' button->properties->

2.double click 'format X_65_255'->

3.In format field you can choose your setting with search help.

In R/3 system, we have several format as default, we can also define our own format by t-code: spad.

1.Spad->

2.Full administration->

3.Devices types->

4.Click 'Display' of Format types->

5.Now, you can find X_65_255 format type here, click modify button and create a new one.

6.Input format type, 'L' format type for ABAP lists, fill Attribuetes... ...

7.Spad->Full administration->Device types->Device Types-> choose the device type you alredy use and double click it

8.Click 'formats' button in application bar

9.Click 'Create' button in application bar.

10.Add the format you just created.

11.After above steps you added the format to your device type, double click the format you added.

12.In the tab page of Formats we have to fill the following Actions:

a.Printer initialization

b.End of page

c.End of line.

You can copy the code of each action from other formats, they are exactly the same!

You can find your own defined page format in the ALV print properity, now!

Best regards!

14 REPLIES 14
Read only

Former Member
0 Likes
2,521

You could separate the data in three different listings, keeping headers to help differentiate and relate the records in the 3 separate listings. This isn't elegant but it's way easier on the logic side.

Read only

0 Likes
2,521

Actually the no of columns in the report is dynamic. I only know during runtime how many columns the ALV report has. In fact I have designed the ALV using RTTS services. So it can even have 100 columns. Is there a way that I am able to pring the report keeping all the vertical lines that come with ALV such that after a certain number of columns a new page is triggered.

Read only

Former Member
0 Likes
2,521

Can anyone help me with this please?

There are too many columns in my report and they do not print. After clicking on the print button following warning message is displayed

System cannot print the last 65 columns of the report

I need to write some code that when the number of columns is larger than 255 line-size, then the rest of the columns should appear on a separate page.

Read only

Former Member
0 Likes
2,521

I was thinking, and a possible workaround could be to export the selected ALV data to a spreadsheet (excel or Open Office Calc) and then adjust and print from that program, wich lets you select exactly which areas you want to print. This way you could make more than one listing, thus printing all the data.

It's not a perfect solution, but it might work for you.

Read only

0 Likes
2,521

This would mean I am not using the print function of the screen. The users are used to printing the report and requesting them to export to excel and then print would require additional training which I dont think the functional folks will appreciate.

Isnt there anything I can do with respect to TOP_OF_PAGE or END_OF_PAGE events?

Read only

Former Member
0 Likes
2,521

Let's check the hard way then.

You'll need to know the max ammount of chars your printer prints in the font you use and the list of fields the users selected in the ALV. Then think a set of fixed header fields, and start adding them and the other fields while adding their lenghts and the lenght of the separating fields, checking that it doesn't pass the maximum lenght of the printer.

When the listing finishes, repeat the procedure with the fixed header files and start adding the fields, this time starting with the one that didn't enter in the last listing. List and repeat this till you finish with the field list.

Read only

0 Likes
2,521

Gustavo,

Thank you. So sounds like I will need to write a separate print program when the print button is clicked. Am I right? How will I trigger this print program? When I do a &RNT on user_command event, it does not seem to recognize it.

Read only

Former Member
0 Likes
2,521

Yes, you'll need a separate printing program for that to work.

Now, about the button, If you are working with Object Oriented ALV, you have a method for modifying buttons. If you are using a normal ALV, then you'll need to change the pf-status asociated with the ALV.

Read only

0 Likes
2,521

I am using CL_SALV_TABLE to display the report.

What is the button for PRINT?

For displaying the list in print out, will I be using the classical write statements? Or are there any ALV functions that can be used. I need to have vertical columns in the print out as well as stripped pattern.

Edited by: Megan Flores on Aug 3, 2009 5:05 PM

Read only

Former Member
0 Likes
2,521

Hi,

Because the standard format of ALV output setting is X_65_255, when you want to extend the column number, you have to choose other format type follow the steps below:

1.ALV screen, press 'print.' button->properties->

2.double click 'format X_65_255'->

3.In format field you can choose your setting with search help.

In R/3 system, we have several format as default, we can also define our own format by t-code: spad.

1.Spad->

2.Full administration->

3.Devices types->

4.Click 'Display' of Format types->

5.Now, you can find X_65_255 format type here, click modify button and create a new one.

6.Input format type, 'L' format type for ABAP lists, fill Attribuetes... ...

7.Spad->Full administration->Device types->Device Types-> choose the device type you alredy use and double click it

8.Click 'formats' button in application bar

9.Click 'Create' button in application bar.

10.Add the format you just created.

11.After above steps you added the format to your device type, double click the format you added.

12.In the tab page of Formats we have to fill the following Actions:

a.Printer initialization

b.End of page

c.End of line.

You can copy the code of each action from other formats, they are exactly the same!

You can find your own defined page format in the ALV print properity, now!

Best regards!

Read only

former_member194669
Active Contributor
0 Likes
2,522

Try with capture the column position explicitly


data: gr_columns    type ref to cl_salv_columns_table.
...
...
 gr_columns->set_column_position( columnname = text-103 " MATNR
                                   position   = 1 ).
 gr_columns->set_column_position( columnname = text-104 " DOCNO
                                   position   = 2 ).
  gr_columns->set_column_position( columnname = text-105 " DESCR
                                   position   = 3 ).
 

Read only

0 Likes
2,521

But how will capturing the column position help?

Lets say I have 20 columns 65 x 320. The max allowed is 65 x 255. So I get the message that last 65 columns cannot be displayed.

But I need to figure out a way that the last 65 columns are displayed in a separate page.

Read only

0 Likes
2,521

Is there a way that if there are 20 columns, then I can split them and the first 10 columns will print on Page1 and the last 10 columns will print on Page2?

Read only

0 Likes
2,521

You have 2 options

1. Create a new page format thru SPAD having a width of 65X300

2. Deactivate the Print Preview button and add custom button in the ALV OM toolbar for downloading to Excel or CSV