Usually a SAPscript layout set consists of the following objects:

Header data
Paragraph and character formats
Windows and text elements
Page windows


The header data of a layout set consists of global data, such as the page format used, the page orientation, or the initially used font. And it includes the name of the layout set, its description, the layout set class, and the status. In addition, the user can enter some other standard and font attributes.
If you display or edit the layout set header in the layout set maintenance transaction, the screen looks like this.


To format texts in layout sets, you need paragraph and character formats. You define them in the layout set itself. The paragraphs you define here appear in the possible values list (F4) for the format column beside the system-defined standard paragraphs. The figure below shows an example of how to maintain a paragraph within transaction SE71 (Layout Set: Request). Use the push buttons Font, Tabs, and Outline to refine paragraph definitions according to your requirements.


You can combine the information contained in a document into certain groups and make each group appear on the printed page in an individual area. SAPscript calls such a group a window. To refer to windows via the programming interface, each window must have a unique name.
Frequently used window names in application layout sets are ADDRESS, SENDER, MAIN, or PAGE.
You can assign texts to each layout set window. These so-called text elements are part of the layout set and stored together with the other layout set elements. Text elements also receive names. You use these names to refer to the respective text elements via the programming interface.
The control commands and variable symbols used in the editor when creating text elements correspond to the SAPscript notation used to maintain long texts.
You can create each window only once on each page, except the main window, which may appear up to 99 times on each page (for example, for printing labels). Windows may overlap, which can be of importance in certain output situations.
For more information on editing SAPscript texts, see the R/3 online help documentation Word Processing in the SAPscript Editor.


The individual pages of a document often have different layouts: The first page of an invoice differs from the subsequent pages, on which you need not repeat general information, such as address or customer data. Just as the text elements of a window, the pages also have names. You may need these names to specify the subsequent page in case of a page break. The more variable you want the layout of a document to be, the more different pages you will define in the SAPscript layout set.
The figure below shows an example of how to maintain a page within transaction SE71 (Layout Set: Request). The page names (FIRST and NEXT) and their definitions have been chosen at will.


When defining windows and pages, you do not yet determine the position and spacing of the texts to be output. To do this, you combine a window and a layout set page to create a so-called page window. A page window defines the rectangular output area in the output medium (for example, DIN A4 paper page) by specifying the left upper edge of the output area and its width and hight.
When defining a page window, you determine

• which windows appear on a certain page,
• what size the windows have (width, hight),
• their position (distance between the left upper window edge and the left and upper page margins).


SAPscript calls the individual text components of a layout set text elements. To achieve good structuring and readability, you assign a fixed name to each text element in the layout set. The print program then uses these names to access the elements. This name applies also for translated versions of a text element, while the contents of the text elements depend on the language.
Text elements are related to a window, that is, a print program can call for each window only those text elements that exist in this window. The figure below shows the definition of the text elements HEADING and FLIGHTLIST in the window MAIN. The variables used within '&...&' are replaced by the system at output time.
You can compare text elements with numbered texts in ABAP/4 programs (for example, TEXT-001). However, text elements are much more flexible:

• The length of a text element is unlimited.
• Text elements may contain variable symbols.
• You can use several different formatting options within one text element.
• You can use SAPscript control statements in text elements.

In each window, you may use two different kinds of text elements:
Text elements with names
Text elements without names
The print program can Activate text elements.


You recognize named text elements by the paragraph format /E. Such a paragraph may look like this:
The character string NAME represents the name of the text element. This name can be up to 30 characters long and may consist of letters, digits and/or special characters. The name is followed by the text lines of this text element. The end of a text element definition is marked by the beginning of the next text element (the next /E line).
Note that names of text elements are valid only locally. That is, different windows may contain text elements with the same names.
To output named text elements, you must use the interface function module WRITE_FORM, which is called in the print program.
The example below shows text elements for a column heading within an invoice (AS indicates the standard paragraph format and , , indicates the tab):
You can output named text elements only in the windows, in which they are defined. For this reason, you need in the interface function module WRITE_FORM, apart from the name of the text element, the name of the window in which the text element is defined. You call the interface function module from within the print program.


Nameless text elements or default text elements are those text lines and control statements that appear at the beginning of the corresponding window contents without having the /E paragraph format. They include all lines up to the next /E paragraph or to the end of text if no other named element follows. Thus, you can have only one nameless text element in each window.
The differences between named an nameless text elements are:

• The system outputs named text elements only if the print program explicitly calls them in the function module WRITE_FORM. But it outputs nameless text element automatically whenever it processes the corresponding window.
• The nameless text element of the MAIN window appears only once at the beginning of the main window. It does not appear on the subsequent pages of the layout set which also contain the main window.
• The nameless text elements of all other windows (except MAIN) appear each time.

The following example shows a default text element in the window ADDRESS of a layout set. The text element outputs the address of a customer, thereby including on the first page the sender short form as include variable for a standard text. To maintain an output-related logic even within the layout set, SAP script additionally offers the control statements IF and CASE, which you can use to control the print output depending on the data constellation.


R/3 applications (FI, CO, MM and so on) deliver standardized layout sets and print programs that customers may have to adapt to their special needs. Only the close interaction of print program and predefined layout set allows the user to print layout sets such as orders or invoices.
One important feature of SAPscript is that layout sets contain texts with variables besides the layout information. These variables are replaced independent of the formatting and appear as values in the printout. The print program is responsible for retrieving the data from the R/3 system and for the control logic of the output.
This allows the user of SAPscript layout sets to separate the logic of retrieving data from the layout of the output. The print program retrieves or calculates the required data and determines their output order. SAPscript is responsible for formatting and positioning this data on a print page. Thus, you can modify the layout of the layout set without having to change the print program.
At runtime of the print program, SAPscript can automatically access data that is defined in the controlling program. Technically speaking: SAPscript retrieves the values directly from the data fields of this program.
For technical reasons, SAPscript cannot access any data fields themselves, but uses their work areas defined with a TABLES statement in the calling program. Since these data structures must be defined in the ABAP/4 Dictionary, SAPscript can use the formatting definitions determined for each field in the Dictionary. However, you cannot use SAPscript to read data directly from a database table.


The example below shows a typical print program. This simple print program creates an invoice that contains company-related information, date, page numbering, customer address, and all flight bookings of a customer (compare S_EXAMPLE_1 and the corresponding print program RSTEXP1).

* (1) Get customer data
tables: scustom, sbook,...
data: bookings like sbook ...
select * from ...
* (2) Open layout set
call function 'OPEN_FORM'
form = 'S_EXAMPLE_1'
* (3) Print table heading
call function 'WRITE_FORM'
element = 'HEADING'
type = 'TOP'
window = 'MAIN'
function = 'SET'
* (4) Print customer bookings
loop at bookings where ...
call function 'WRITE_FORM'
element = 'BOOKING'
type = 'BODY'
window = 'MAIN'

* (5) Close layout set
call function 'CLOSE_FORM'

In this example, the first section reads the required data from the database and fills it into internal tables (for example, BOOKINGS). In section (2), the function module OPEN_FORM is called to initialize the print output of the layout set S_EXAMPLE_1. Then, WRITE_FORM uses the text element HEADING to output general text and the column heading of the invoice in the MAIN window (section (3)). In section (4), the text element BOOKING in the MAIN window is used to output the bookings of a customer that are read in a loop from the internal table BOOKINGS. The address of the customer as well as company-related information is output in other layout set windows directly, using default text elements. CLOSE_FORM finally ends the printing of the layout set.
For each printout of a layout set, you must use the pair of function modules OPEN_FORM and CLOSE_FORM. You can also use a print program to print several layout sets, which you can either maintain in separate spool requests or combine into one. In the latter case, you must use the function modules START_FORM and END_FORM.



No comments :

Post a Comment