Skip to Content
Author's profile photo Juwin Pallipat Thomas

‘Column view’ in SAPScripts/ Smartforms

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,

Juwin

Assigned Tags

      14 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member

      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 🙂

      Author's profile photo Jelena Perfiljeva
      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.

      Author's profile photo Juwin Pallipat Thomas
      Juwin Pallipat Thomas
      Blog Post Author

      Thanks very much for your kind words.

      Author's profile photo Abhishek Gupta
      Abhishek Gupta

      nice idea,never thought it this way ➕

      Author's profile photo Former Member
      Former Member

      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 😕

      Author's profile photo Juwin Pallipat Thomas
      Juwin Pallipat Thomas
      Blog Post Author

      Thanks for the feedback. I have added that information now. Thanks, Juwin

      Author's profile photo Mayank Vishnoi
      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?

      Author's profile photo Juwin Pallipat Thomas
      Juwin Pallipat Thomas
      Blog Post Author

      Preview can be shown to the user, using DISPLAY_OTF function module.

      Thanks,

      Juwin

      Author's profile photo Sunil Kumar kairamkonda
      Sunil Kumar kairamkonda

      Nice idea, I always used split page into windows as LHS & RHS windows as 2 columns and printed information:) this is something new learning to try ! Great job.

      Author's profile photo Mayank Vishnoi
      Mayank Vishnoi

      Hi Sunil, is that approach (LHS & RHS) works even when the data has graphics in header the line items are in nested tables?

      Author's profile photo Sunil Kumar kairamkonda
      Sunil Kumar kairamkonda

      Hi,

      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.

      Author's profile photo Juwin Pallipat Thomas
      Juwin Pallipat Thomas
      Blog Post Author

      It worked for me with graphics. The example I had created, had graphics on it - not captured in screenshot.

      Thanks

      Author's profile photo Pranay Patel
      Pranay Patel

      That's a new learning for me today. Thanks Juwin for clearly explained document.

      Author's profile photo Raphael Pacheco
      Raphael Pacheco

      Another major contribution! Will be very useful for me when I have to do something similar (HAHA), thanks for sharing Juwin 😀