As developers, many of us would have faced this challenge atleast once – the ‘Terms and Conditions’ Page. Most customers have T&C pages looking like this – with column view.

2016-07-12 11_11_05-terms-conditions.png (1475×1809).jpg

This is easily achievable in MS Word, using the option under Page Layout.

2016-07-12 11_15_41-Document1 - Microsoft Word.jpg

How do you achieve this in SAP? Traditional wisdom may tell you to keep 2 text boxes – on left & right and 2 text objects to include in them. But, what if the text content changes or the font changes? When using 2 text boxes, the text from 1st box doesn’t overflow to the 2nd box automatically.

Some other posts on SCN tells to scan the entire T&C Page as an image and include that as a graphic on the form. But, wouldn’t that require a transport whenever the text content needed to be changed (Agreed that T&C doesn’t change very often)? Also, including a high clarity image on the file means, increasing the file size.

Solution Play with the generated OTF. OTF data is a series of commands and contents. If you know how to play around with the commands, you can insert/delete/modify the structure of the output, different from the way it was originally designed in the Smartform/ SAPScript.

Here, I am taking an example of 2 column view. You may extend concept this to any number of columns.

Goto SO10, create the text, containing T&C details – or as an example upload any dummy text file.

2016-07-12 11_29_15-Change Standard text_ Z1 Language EN.jpg

Create a Smartform with 2 pages, both containing MAIN windows, at required column positions. Page1 should have Page2 as the next page and Page2 should have Page1 as the next page.

My Page1:

2016-07-12 11_31_48-SAP Form Builder_ Change Page PAGE1.jpg

My Page 2:

2016-07-12 11_31_58-SAP Form Builder_ Change Page PAGE2.jpg

Now, include the text object in the MAIN window.

2016-07-12 11_33_13-SAP Form Builder_ Change Text TEXT1.jpg

Create a driver program to call the Smartform and get back OTF data.

Without any modifications to the OTF structure, the output looks like this:

Page 1:

2016-07-12 11_36_33-merg.pdf - Adobe Reader.jpg

Page 2:

2016-07-12 11_36_47-merg.pdf - Adobe Reader.jpg

Just like the way it was designed in the Smartform.

Now, OTF analysis:

Everytime a new page begins, OTF uses command OP and everytime a page ends, OTF uses command EP (Full list of OTF commands are listed in program RSTXDATAOTF). If you delete OP and EP commands from OTF data, system wouldn’t know to split the page/ start a new page. This is the technique I am going to use here. Lets debug:

Here is my OTF data:

2016-07-12 11_43_11-ABAP Debugger.jpg

I have circled here the first OP command, which tells the system to begin the 1st page. Lets find the next page – that is by finding the next OP command.

2016-07-12 11_43_35-.jpg

Here is the next OP command. Here, you will see that 1st page is closed with EP command and the next page is started with OP command.

2016-07-12 11_43_47-ABAP Debugger.jpg

Lets delete these entries and see what happens.

2016-07-12 11_44_25-ABAP Debugger.jpg

Now, SAP wouldn’t know to start the next page and will think that the contents of the 2nd page in the Smartform is actually part of the 1st page in the output.

Have a look at this output. You will see that the contents from both pages have merged together to form a single page.

2016-07-12 11_44_54-merg.pdf - Adobe Reader.jpg

With this method, even if text or font changes in the included text, the contents adjust automatically. Please take note that common portions of page – like heading, logo, address, other texts etc, need to be defined only on Page1. If you need more columns in the output, you will need to have more intermediate pages in the Smartform.

Eg. to build a 3 column view:

Page1 (with logo, address, other constant texts, main window equivalent to the size of 1st column), having Next page as Page2

Page2 (main window equivalent to the size of 2nd column), having Next page as Page3

Page3 (main window equivalent to the size of 3nd column), having Next page as Page1

And, build a looping logic to delete OP commands for Pages 2 & 3 (so that 2nd & 3rd pages doesn’t start), and EP commands for Pages 1 & 2 (so that 1st & 2nd pages doesn’t close).

Once you have the manipulated OTF, use function modules CONVERT_OTF_2_PDF to convert it to PDF or PRINT_OTF to send it to printer spool.

Please let me know if any portion of this document is not clear, so that I may improve the relevant portions.

Thanks for reading,


To report this post you need to login first.


You must be Logged on to comment or reply to a post.

  1. Jānis B

    Overlaying pages – sounds pretty cool and very doable. I’ve “manipulated” OTF to:

    – feed “layout independent” OMS control commands as PostScript comments using OTF RD command;

    – merge 2 Smartforms into one “document” where we had no control over opening and closing of forms

    My dream is to one day find the time to get around the BDS storage for bitmap output (IGS charts without saving them to BDS first).

    OTF reference may be helpful to aspiring OTF manipulators πŸ™‚

  2. Jelena Perfiljeva

    Wow, this is some hard core artisanal stuff. πŸ™‚ Nice work with the blog!

    My dream is that one day “one main window” restriction will be gone. But I guess this happens when we can print the vertical text. Or pigs fly. Whichever comes first.

  3. Suhas Saha

    Thank God, we have an OMS in place πŸ˜€ From SAP we generate Smartforms as XSF only, the forms are generated by the OMS.

    All fancy stuff & magic happens in OMS.  

    It is not clear how manipulating the OTF data changes the spool πŸ˜•

  4. Mayank Vishnoi

    Hi Juwin, Thanks for your article. It really help me and I am able to get the desired result using this. There is a small problem I am facing here. If I am getting the OTF Data print preview doesn’t work. But the user wants to have the print preview option for him. Can you please help me with PRINT_OTF how can I show the print preview to user?

      1. Sunil Kumar kairamkonda


        it should work for terms and conditions usually.if you need Graphic in header you have to design the windows size & positions accordingly. Each window will work independently and you should be clear of what is printed inside and even if you loop data the information will remain in the window size. hope I answered you if not please provide details will try to clarify.


Leave a Reply