SAP Custom Page Format

In this blog we will see how to create new page format in SAP.

Some time back we had request to print cheques from SAP onto pre-printed cheques using dot matrix printer. Page size of cheque we were using didn’t match any of page format defined in SAP so we had to create our own settings. It turned out it is not as straightforward as I would have imagined. Here I am going to outline step you need to follow if you need to create custom page format for any of your requirement.

Page Format

Go to SPAD transaction and first press Full administration button.

You will then see Device Types tab. Navigate to Device Types tab and press Display next to Page Formats input.

This will give you list of all Page Formats defined in system, you can check this list to see if any of these matches your paper size. If it does then you won’t need any new Page Formats.

To create new Page Format first go to change mode and then press new button. Enter name of Page Format, Orientation and Dimension of page and save.

The page dimensions and orientation specified page format is just for smartform and sapscript and it do not affect any printer.

You may like to define both landscape and portrait definition here if you have that requirement. If you only define Portrait size and try and use landscape in smartform/sapscript you will get following messages.

Warning message SMARTFORMS291 in smartform – You have chosen ZCH1 landscape format as the page format. This page format is not available in the spool administration.

Error message TD108 – Page format ZCH1 L is not in the spool administration.

After you have defined page format you can start with your smartform/sapscript development. Page layout which you see in smartform/sapscript take page information from Page Format definition.

You will get warning message, (TD165) You have selected a page format ZCH1 for which there is no identical formatting type in the spool, in sapscript but it will let you work on sapscript. However you won’t be able to print just yet.

Format Types

Go back to transaction SPAD Full administration mode and under Device type click on Display next to Format Types input.

On next screen click on new button and create new format type ZCH1, yes Format Type and Page Format should have same name. Make sure you choose ‘Format type for SAPscript’ then select Page Format, Select Portrait specify something meaningful in comment and save.

Modifying Device Type Setting

Page Format store page information for sapscript/smartforms. Format type is created just for documentary purpose and does not hold any additional information. Printer code which actually sets page size on printer is defined in Device type for each Format type it supports. If you do not already know, printers in SAP points to Device type which stores all printer specific data including printer codes for all Format Type it supports. For your printer to support this page size you need to add Format Type in its Device type. And more importantly you need to specify printer code after you have added Format type in Device type to set page length and height on printer.

Below flow chart explains this relationship. We have already defined Page Format and Format Type. It’s time now to modify Device type of printer to support Format type ZCH1.

To find out which device type you printer is using. Run SPAD transaction and click on Display next to Output Devices input.

This will give you list of all printers installed in your SAP system. Double click on printer which you want to support new Page Format. In DeviceAttributes tab first field is Device Type. Note down this device type.

Now run SPAD in Full adminstation and under Device Types tab click on Display next to Device Types input.

Double click on device type which you have found in previous step and you should see details of device type. Click on Formats button and it will take you to list of formats currently supported by Device type.

On this screen, where list of supported format is displayed, click on new button.

And specify Format Type which we just created.

Press OK to add Format type to Device type.

Now we need to write printer specific code to set page length on printer along with some other commands on Printer initialization. What we can do here is copy code from Print Initialization of DINA4 format and change that to match our Page Length.

In the list of format types supported by device type double click on DINA4 and then go to Printer initialization section.

Copy the code which is in there and paste it in Printer initialization of form ZCH1 and save.

Page length is defined in terms of lines in hexadecimal format. There is bit of calculation here which I will be explaining in steps.

Page height in ZCH1 is 102 mm.
102 mm in inch is 4 inches.
Since we have 6 lines per inch, 4 inches would be 24 lines.
And 24 in hexadecimal is 0x18

In below screen shot I have highlighted the line where I have made this change.

Once you save these setting you should be able to issue print from sapscript and smartform on this paper size to printer.

2 Replies to “SAP Custom Page Format

  1. Great data partner, thanks! but if a wanna to define a set character…for example:

    # select character table 3 -> PC 437 character set
    \e\0x74\0x03

    But, i need to define the set character “1134 Printer SAPWIN ISO 8859-1 + 8859-5 + 8859-7” for mi printer but i don’t know the hexadecimal code. Can you know this value?

    Best regards.

Leave a Reply