You are on page 1of 7

0001 - Create Reports That Fill The Page

by Rich Thu Mar 26, 2009 11:39 am

Create Reports That Fill The Page


When you print a report upto 132 chars wide, it fills the page. Go over 132 characters wide and it looks like "a postage stamp in the top left corner". How do you get the text to fill the page ? The reason this happens is because when you print, SAP looks for a page format that fits the page you are about to print in terms of line count and line width. Once you get past X_65_132 there are no page formats upto X_65_255 so any reports wider than 132 characters get squashed into the top left corner of the page This question has been asked quite a few times before (and answered before), but without some vital values..... If you use Transaction SPAD and click Full Administration, you can define new formats from existing formats. This will enable you to provide page formats so that all report sizes neatly fill the entire page. Click the Device Types tab and then Format Types and you end up with a list that looks something like this:

Change from Display mode to edit mode and then select the line X_65_132. Select the 'Create Using Template' option from the format menu. This will give you a screen like so:

Enter the new format name (X_65_140) in the format field, and then the new number of columns (140) in the No. of clmns and Description fields. Save this and return to the main SPAD screen. Click on Device Types. Double click on the device type that you want to add the new page formats to. This will then display the device type information. Click the Formats button. Add the new format (X_65_140) by clicking the New button and entering x_65_140 in the Format field. When the new format has been added to the formats displayed, double click the line containing the new format and the following screen will be displayed:

Click the Copy From button (the two pages), and enter the page format code for the preceding format - in this case X_65_132. Now you have to change the page formats to suit. Up to 255 characters wide all you need to change is the HMI - the horizontal motion index which defines the gap between the characters. This is contain in the printer initialisation sequence which looks like this:

Below is the code for an HP Laser jet in full: Code: Select all
# enter PJL mode and switch to PCL language \e%-12345X@PJL\r\n @PJL ENTER LANGUAGE=PCL\r\n # reset \eE # Landscape mode \e&l1O # ECMA-94 Latin 1 character set \e(0N # Skip perforation region off \e&l0L # set vertical spacing (VMI, X/48 inch) for 65 lines (landscape!) \e&l5.2C # Define 2 macros: Macro 1 will select Normal font # Macro 2 will select Bold font # Start of MACRO 1: \e&f1y0X # select Courier 16.67 CPI normal font \e(s0p16.67h0s0b4099T # set horizontal spacing (HMI, X/120 inch) for 132 characters (landsc.) \e&k9.2H

# End of MACRO 1: \e&f1y1X # Start of MACRO 2: \e&f2y0X # select Courier 16.67 CPI bold font \e(s0p16.67h0s3b4099T # set horizontal spacing (HMI, X/120 inch) for 132 characters (landsc.) \e&k9.2H # End of MACRO 2: \e&f2y1X # Execute Macro 1 to set normal font: \e&f1Y\e&f2X #>RSPO0060 - begin of generated data # Macros for drawing of frames. #e&f470y0X\e(10U\e&k9.2H\xC5\e(0N\e&k9.2H\e&f470y1X #e&f460y0X\e(10U\e&k9.2H\xC4\e(0N\e&k9.2H\e&f460y1X \e&f461y0X\e(10U\e&k9.2H\xB3\e(0N\e&k9.2H\e&f461y1X #e&f462y0X\e(10U\e&k9.2H\xDA\e(0N\e&k9.2H\e&f462y1X \e&f463y0X\e(10U\e&k9.2H\xBF\e(0N\e&k9.2H\e&f463y1X #e&f464y0X\e(10U\e&k9.2H\xC0\e(0N\e&k9.2H\e&f464y1X \e&f465y0X\e(10U\e&k9.2H\xD9\e(0N\e&k9.2H\e&f465y1X #e&f466y0X\e(10U\e&k9.2H\xC3\e(0N\e&k9.2H\e&f466y1X \e&f467y0X\e(10U\e&k9.2H\xB4\e(0N\e&k9.2H\e&f467y1X #e&f468y0X\e(10U\e&k9.2H\xC2\e(0N\e&k9.2H\e&f468y1X #e&f469y0X\e(10U\e&k9.2H\xC1\e(0N\e&k9.2H\e&f469y1X #<RSPO0060 - end of generated data # Manual modifications: make right arms of symbols longer, to reach # next symbol even with widened horizontal spacing. \e&f470y0X\e(10U\e&k4.6H\xC5\xC4\e(0N\e&k9.2H\e&f470y1X \e&f460y0X\e(10U\e&k4.6H\xC4\xC4\e(0N\e&k9.2H\e&f460y1X \e&f462y0X\e(10U\e&k4.6H\xDA\xC4\e(0N\e&k9.2H\e&f462y1X \e&f464y0X\e(10U\e&k4.6H\xC0\xC4\e(0N\e&k9.2H\e&f464y1X \e&f466y0X\e(10U\e&k4.6H\xC3\xC4\e(0N\e&k9.2H\e&f466y1X \e&f468y0X\e(10U\e&k4.6H\xC2\xC4\e(0N\e&k9.2H\e&f468y1X \e&f469y0X\e(10U\e&k4.6H\xC1\xC4\e(0N\e&k9.2H\e&f469y1X

The two sets of figures you need to change are the HMI for standard characters (in this case the 9.2) and the HMI for box drawing characters( 4.6). Substitute them with the figures from the table below and then save them once on the Editor screen and once on the 'Maintain Format' screen. Page Width/HMI/Box Characters HMI 132 9.2 4.6 140 9.2 4.6 150 9.0 4.5 160 8.4 4.2 170 8.0 4.0 180 7.5 3.75 190 7.1 3.55 200 6.7 3.35 210 6.3 3.15 220 5.9 2.95 230 5.7 2.85 240 5.5 2.75 Lastly, you need an ABAP report to check the report format....

Define Test_Report. Report ZTest Line-count 64 line-size &1. Start-Of-Selection. * Data: begin of t_cols occurs 0, line(&1) type c, End of t_cols, w_count type i, w_num(3) type n, w_string type c. * Do 3 times. Compute w_count = sy-index - 1. Clear t_cols-line. Do &1 times. Move sy-index to w_num. Move w_num+w_count(1) to w_string. If w_string = ''. Move '0' to w_string. EndIf. Concatenate t_cols-line w_string into t_cols-line. EndDo. Append t_cols. EndDo. * Loop at t_cols. Write :/ t_cols-line. EndLoop. Skip. Do 3 times. Write: / '----', at 20 '--------------------', / '| |', at 20 '| |', / '| |', at 20 '--------------------', / '| |', at 20 '| |', / '| |', at 20 '--------------------', / '| |', at 20 '| |', / '| |', at 20 '--------------------', / '----', at 20 '| |'. EndDo. Skip. Loop at t_cols. Write :/ t_cols-line. EndLoop. End-Of-Definition. * Test_report 180.

To check different page widths change the line 'TEST_REPORT 180' to contain the relevant line width. Repeat that for the pages up to 240 (it only takes a few minutes per page), and then all the reports printed will fill the page, rather than ending up squashed up in the top left corner with users poring over them with microscopes! Oh btw.... this is printer dependant so don't expect the same solution to work for anything other than HP series printers! (PCL ones at that too!). Regards Rich

Abap KC

SFMDR Rich Posts: 6651 Joined: Thu Oct 31, 2002 4:47 pm Location: Geneva

Top Post a reply 1 post Page 1 of 1 Return to ABAPers


Copyright 2012 SAPFANS All Rights Reserved.
This website is not affiliated with, sponsored by, or approved by SAP AG.

You might also like