Copyright 2024 - BV TallVision IT

Sapscript is the predecessor of Smartforms. But they are still around and require changes every now ant then. Thus: Sapscript in a nutshell:

Transaction SE71 can be used to maintain a Sapscript form. When you are about to create a new form, you should create a Smartform, but surely enough you will have some reason to work with Sapscript (e.g. change a SAP standard form like MEDRUCK).

 

A Sapscript form is controlled from a driver program, which is often set up via customizing settings on table TNAPR. The driver program is usually started via a call to some form routine, which will:

  1. Select relevant data and make it available in globally defined variables (DATA definitions)
  2. Open the form (function module OPEN_FORM), the name of the form, the language and also and alternative start page can be defined here.
  3. The driver program executes a number of element calls (function module WRITE_FORM) in which an element on a given window is processed.
  4. When all elements are processed, the form can be closed (function module CLOSE_FORM and output is completed.

The driver program can also insert/execute control statements so no element for the statement(s) are required on the Sapscript form (function module CONTROL_FORM). It is also possible to string several Sapscript forms together into a single spool output by closing the current form (function module END_FORM) and starting the next (new) one (function module START_FORM). This could be used to produce a list of similar documents as a single document. Too much for a nutshel description, but READ_FORM_ELEMENTS and READ_FORM_LINES (of an element) can also give more control to the driver program.

Thus the driver program has control over: data supply and call sequence of elements. An element is effectively a bit of Sapscript logic, much like a routine, which can be initiated/called several times. There could e.g. be an element /E ITEMLINE in which the data for an item is processed (printed/displayed).

Sapscript editing is done in the Sapscript text editor, which is still used in e.g. SO10 longtexts editing as well. Hence long texts are often called Sapscript texts. The paragraph indicator is available on every text line, and has special use in the Sapscript editor:

  • /E to start an element (no need to finish the last one)
  • /: to start a command, for which there are many options available. A brief (incomplete) summary:
    • INCLUDE to include/incorporate a long text
    • ADDRESS show an address (with full formatting options)
    • NEW-PAGE to start a new page (which can be specified explicitly) PROTECT to prevent page breaks
    • BOX, POSITION, SIZE define a box, position it, shading
    • IF, ENDIF conditional element content

The Sapscript form is composed of a MAIN window and up to as many as you need regular windows, which are to be placed/positioned on a page. Sapscript can have multiple pages, each with their own layout. Usually page FIRST and NEXT are available. The first page will contain full contact details, the follow-up pages will have a larger MAIN window allowing more content to be processed. Elements are defined on windows, and usually the main window will hold the most elements.

The driver program will call the required elements to be processed, which will eventually fill the window. If it is the main window that is filled, the next page will automatially be started. If a regular window is filled, the information that is displayed should fit in the window, otherwise it is ignored.

Positioning for fields and columns is done in paragraph settings, which can be made available through a style. This part was much improved in Smartforms. Then last but not least: the text symbol: any information on the form of which the content should be displayed is called a text symbol. If the driver program has a globally defined variable DATA: GV_TITLE(40) TYPE C DEFAULT 'Super document'. , then the Sapscript form can process this via &GV_TITLE&. There is also a suite of predefined variables such as &DATE&, &DAY&, &MONTH&, &NAME_OF_MONTH&, &PAGE& and &SAPscript-FORMPAGES&