You are on page 1of 10

ABAP- SCRIPTS

SAP script is the SAP System’s own text-processing system. It looks and feels a lot like other leading text-processing systems. It is used to print preformatted text in pre-formatted forms.

Read more at http://www.saptraininghub.com/sap-script/#Wz6fjVJ33PRyyuuk.99

OVERVIEW To use layout sets efficiently, it is essential that you understand the inter dependencies between the individual components of SAP script. SAP script comprises these five components: • An editor for entering and editing the lines of a text. The application transactions automatically call this editor if the user decides to maintain texts that concern an application object. • Styles and layout sets for print layout. These are created independent of the individual texts using the corresponding maintenance transactions and are allocated to the texts later. • The composer as central output module. Its task is to prepare a text for a certain output device by including the corresponding formatting information. This information comes from the style and layout set allocated to the text. The SAP script composer is invisible on the outside. • A programming interface that allows you to include SAPscript components into your own application programs and to control the output of layout sets from within the programs. • Several database tables for storing texts, styles and layout sets. In short, layout set maintenance means to allocate to a text document a layout set that contains the information on how to layout the text (formats, fonts, layout, and so on). The print program retrieves the required data from the layout set and from the database and controls the output. You use certain function modules to activate the SAP script composer, which is responsible for processing the layout set. Not every user of the SAP system works with every component of SAPscript. Depending on the task, a user is confronted with different components. • Accounting clerks create texts concerning materials, orders, customers, vendors, and so on. They usually know only the SAP script editor. • Another user may be responsible for the print layout and will use the transactions for maintaining styles and layout sets. • A developer who integrates SAP script into his own applications or who wants to create print output using layout sets, sees SAP script from the programming interface view point. This documentation explains the basic principles of printing texts using layout sets. It describes in detail the interaction of layout set and print program and offers examples for better understanding. Building on this basic knowledge, the documentation then describes the programming interface which allows you to integrate the word processing functionality offered by SAPscript into

A programming interface that allows you to include SAP script components into your own application programs and to control the output of layout sets from within the programs 5.ABAP/4 programs. The header data comprises of 2 parts – Device Independent – Stores information like Start page . R/3 application programs need so-called layout sets (a kind of form). The SAP script composer is invisible to the outside 4. This interface is a collection of ABAP/4 function modules. which a print program can call. An editor for entering and editing the lines of a text 2. The selection of data for the document is done through the print program. When the print program is executed the document is printed on the screen. The print program selects the data from database table and feeds it to the layout set. Default paragraph . printer. Usually a SAPScript Layout consists of following components 1. Paragraph and Character Formats: Paragraphs are formatted using various attributes.In SAP script a layout set describes the layout of the individual print pages and uses text elements to supply definable output blocks. and control tables. Styles and layout sets for print layout. The composer is a central output module. Several database tables for storing texts. Components of SAP Script SAP Scripts comprises of five main components: 1.Language Attributes etc. These are created independent of the individual texts using the corresponding maintenance transactions and are allocated to the texts later 3. styles and layout sets Layout Set To output documents using the programming interface. Header Data: Header data is used for information and control of SAP printing. For instance Standard paragraph attributes .A layout set can be defined as a page design for a document Layout set on its own doesn’t contain any data. And Device Dependent stores information like Page format . different data structures.Orientation Lines per inch etc 2.

Line spacing etc. which is referred as Print Program. Each print program should have an ENTRY form . INCLUDE – To include the content of another text into current text PERFORM – To call a subroutine of any ABAP program Print Program The execution of script is done through an ABAP program.Font size etc. but are passed through to the SAP script Composer for processing. Windows and Text Elements: Windows are individual text areas (header address. Pages: They are individual pages of a document and must have a unique name. date. you do not yet determine the position and spacing of the texts to be output. formats them and prints them in the respective window. For a standard configuration we can see the form name (script name). line and page formatting. footer) in a page . on which you need not repeat general information. Alignment . print program name and output type in the table TNAPR. The print program accesses text elements by name.These commands are not interpreted by the SAP script editor. 4. The print program call either all or some of the form control functions to execute the script     OPEN_FORM (Mandatory) Opens the layout set output CLOSE_FORM (Mandatory) Ends the layout set output START_FORM (Optional) Starts a new layout set WRITE_FORM (Mandatory) Calls a layout set element .The print program uses the Form control functions to call the script. such as address or customer data. which will be called from customization. Syntax Enter /: in the paragraph format Examples     NEW-PAGE – Explicit page break PROTECT ………ENDPROTECT – To print complete paragraph in one page.specify Left or Right margin. You will often find different layouts for individual pages: The first page of an invoice differs from the subsequent pages.A page window defines the rectangular output area in the output medium by specifying the left upper edge of the output area and its width and height Control Commands The purpose of “control commands” is to allow control of the output formatting. It helps combine the information contained in a document into certain groups and make each group appear on the printed page in an individual area. This includes. Character formats allow to format entire blocks of text within a paragraph 3. for example. Font attributes specify Font family .You can define text elements (window texts) for each window. Page Windows: While defining windows and pages. The paragraph and the character formats used must be defined in the form. the formatting of text according to the paragraph and character formats specified. 5.

i.Unlike programs. The output type can also be an internal electronic mail message that you want to send to staff in another department. SAP script does not maintain any versions. Similarly “Fax” can be an output type. i. a printed form that you need for internal use or a form that you want to send to a customer or vendor . ensure that the changes are well documented in script. Chose Output under the menu Goto -> Header 4.0″ format (. Enter billing document number and press enter again 3. billing document) will be stored in the table NAST. So always test the output of the script on the printer.tif files on PC) SAP Script & Standard text elements can exported or imported between two systems using RSTXSCRP program Copying Scripts Across clients: SAP Script is a client dependent object. For copying script from one client to another.g. Here Z101 is an output type of a print output Standard Texts and Graphics Standard Texts for your report can be created using transaction SO10 Graphics and printer macros are uploaded with report RSTXLDMC into individual standard text documents or through transaction SE78. changes done to SAP script in one client will not be reflected in other clients. when this output type is executed a fax of the billing document is sent All the output types for any document (e. when this output type is executed the billing document is printed. 2. Example : Output type in a billing document1. from the original client using the transaction SCC1 . So when modifying the SAP script . For example “Print out” can be classified as one output type of a billing document. go to SE71 and use “Copy from Client” option available under Utilities menu or import the transport request. You might like: . Graphics are uploaded in “Baseline TIFF 6. Important Points to Note 1.Output types are executed through the program RSNAST00 .e.e. Go to VF03 2. This applies to the standard texts too. END_FORM (Optional) Ends the current layout set Output Types The output type can specify. in which the script is saved. The output of the form will differ when viewed on the screen and on the printer.

and so on. There can be only one window that triggers a page break. choose Tools set (or call transaction SE71 directly). The window thus controls the page break. R/3 application programs need so-called layout sets (a kind of form). In this example. order acknowledgments. Whenever this window on one page is full. the remaining text is automatically output on the subsequent page. and a main window for the actual letter text.saptraininghub. the start page consists of an area for outputting the address.Read more at http://www. In SAPscript a layout set describes the layout of the individual print pages and uses text elements to supply definable output blocks.com/sap-script/#Wz6fjVJ33PRyyuuk. General application layout sets are orders. The window for the text body differs from the other windows. which a print program can call. Such a window in SAP script is called main window. Each layout set consists of a start page and any number of subsequent pages. a window for page numbering. an information window containing reference data and the date. For more detailed information on maintaining layout sets. urging letters. Usually a SAPscript layout set consists of the following objects: Header data Paragraph and character formats Windows and text elements . see the documentation Style and Layout Set Maintenance. and change SAPscript layout sets. This window for the letter text appears on the subsequent pages as well. Structure of a layout set Text elements of a layout set Print programs Window types How the composer works Layout set control Output text lines and text elements STRUCTURE OF LAYOUT SET To output documents using the programming interface. The figure below shows a simple example of an invoice layout set created using SAPscript. display. depending on the length of the letter text. and. To call this transaction Layout Word processing from the initial R/3 screen.99 PRINTING TEXTS USING LAYOUT SETS This documentation describes in detail the basic principles of printing texts using layout sets and the interactions of the different SAPscript components. a window containing companyrelated data. in addition. you use a special maintenance transaction (Layout Set: Request). invoices. To create.

the page orientation. You can create each window only once on each page. for printing labels). WI NDOWS AND TEXT ELEMENTS 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. You define them in the layout set itself. Windows may overlap. SENDER. Tabs.Pages Page windows HEADER DATA The header data of a layout set consists of global data. such as the page format used. or the initially used font. such as address or customer data. on which you need not repeat general information. To refer to windows via the programming interface. its description. see the R/3 online help documentation Word Processing in the SAPscript Editor. and Outline to refine paragraph definitions according to your requirements. PARAGRAPH AND CHARACTER FORMATS To format texts in layout sets. The control commands and variable symbols used in the editor when creating text elements correspond to the SAPscript notation used to maintain long texts. MAIN. which may appear up to 99 times on each page (for example. the user can enter some other standard and font attributes. Text elements also receive names. SAPscript calls such a group a window. In addition. or PAGE. If you display or edit the layout set header in the layout set maintenance transaction. Just as the text elements of a window. Frequently used window names in application layout sets are ADDRESS. Use the pushbuttons Font. You use these names to refer to the respective text elements via the programming interface. These so-called text elements are part of the layout set and stored together with the other layout set elements. The paragraphs you define here appear in the possible values list (F4) for the format column beside the system-defined standard paragraphs. You . except the main window. You can assign texts to each layout set window. the layout set class. For more information on editing SAPscript texts. And it includes the name of the layout set. you need paragraph and character formats. the pages also have names. and the status. each window must have a unique name. the screen looks like this. PAGES The individual pages of a document often have different layouts: The first page of an invoice differs from the subsequent pages. which can be of importance in certain output situations. The figure below shows an example of how to maintain a paragraph within transaction SE71 (Layout Set: Request).

The figure below shows an example of how to maintain a page within transaction SE71 (Layout Set: Request). • what size the windows have (width. However. DIN A4 paper page) by specifying the left upper edge of the output area and its width and hight. The more variable you want the layout of a document to be. • You can use SAPscript control statements in text elements. TEXT ELEMENTS WITH NAMES You recognize named text elements by the paragraph format /E. When defining a page window. In each window. while the contents of the text elements depend on the language. This name applies also for translated versions of a text element. you determine • which windows appear on a certain page. You can compare text elements with numbered texts in ABAP/4 programs (for example. To do this.. The figure below shows the definition of the text elements HEADING and FLIGHTLIST in the window MAIN. PAGE WINDOWS When defining windows and pages. you may use two different kinds of text elements: Text elements with names Text elements without names The print program can Activate text elements.&' are replaced by the system at output time. The variables used within '&. • their position (distance between the left upper window edge and the left and upper p age margins). you do not yet determine the position and spacing of the texts to be output.may need these names to specify the subsequent page in case of a page break. Such a paragraph may look like . The print program then uses these names to access the elements. A page window defines the rectangular output area in the output medium (for example. • Text elements may contain variable symbols. you combine a window and a layout set page to create a so-called page window.. The page names (FIRST and NEXT) and their definitions have been chosen at will. a print program can call for each window only those text elements that exist in this window. To achieve good structuring and readability. TEXT ELEMENTS OF LAYOUT SET SAPscript calls the individual text components of a layout set text elements. hight). • You can use several different formatting options within one text element. text elements are much more flexible: • The length of a text element is unlimited. Text elements are related to a window. that is. you assign a fixed name to each text element in the layout set. the more different pages you will define in the SAPscript layout set. TEXT001).

They include all lines up to the next /E paragraph or to the end of text if no other named element follows. For this reason. That is. One important feature of SAPscript is that layout sets contain texts with variables besides the layout information. PRINT PROGRAMS R/3 applications (FI. thereby including on the first page the sender short form as include variable for a standard text. It does not appear on the subsequent pages of the layout set which also contain the main window. These variables are replaced independent of the formatting and appear as . digits and/or special characters. The differences between named an nameless text elements are: • The system outputs named text elements only if the print program explicitly calls t hem in the function module WRITE_FORM. which you can use to control the print output depending on the data constellation. • The nameless text elements of all other windows (except MAIN) appear each time. the name of the window in which the text element is defined. . To output named text elements. • The nameless text element of the MAIN window appears only once at the beginning of the main window. To maintain an output-related logic even within the layout set.this: The character string NAME represents the name of the text element. The following example shows a default text element in the window ADDRESS of a layout set. you need in the interface function module WRITE_FORM. SAP script additionally offers the control statements IF and CASE. Note that names of text elements are valid only locally. in which they are defined. you can have only one nameless text element in each window. The name is followed by the text lines of this text element. The text element outputs the address of a customer. But it outputs nameless text element automatically whenever it processes the corresponding window. TEXT ELEMENTS WITHOUT NAMES 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. The example below shows text elements for a column heading within an invoice (AS indicates the standard paragraph format and . This name can be up to 30 characters long and may consist of letters. You call the interface function module from within the print program. MM and so on) deliver standardized layout sets and print programs that customers may have to adapt to their special needs. different windows may contain text elements with the same names. which is called in the print program. Only the close interaction of print program and predefined layout set allows the user to print layout sets such as orders or invoices. The end of a text element definition is marked by the beginning of the next text element (the next /E line). you must use the interface function module WRITE_FORM. Thus. indicates the tab): You can output named text elements only in the windows. CO. apart from the name of the text element.

but uses their work areas defined with a TABLES statement in the calling program.. * (4) Print customer bookings loop at bookings where . * (1) Get customer data tables: scustom. you can modify the layout of the layout set without having to change the print program. call function 'WRITE_FORM' exporting element = 'BOOKING' .. This allows the user of SAPscript layout sets to separate the logic of retrieving data from the layout of the output. For technical reasons. * (3) Print table heading call function 'WRITE_FORM' exporting element = 'HEADING' type = 'TOP' window = 'MAIN' function = 'SET' . EXAMPLE OF PRI NT PROGRAM The example below shows a typical print program. However. customer address. The print program retrieves or calculates the required data and determines their output order. SAPscript can automatically access data that is defined in the controlling program. SAPscript can use the formatting definitions determined for each field in the Dictionary. Since these data structures must be defined in the ABAP/4 Dictionary. Technically speaking: SAPscript retrieves the values directly from the data fields of this program.. sbook. Thus.. and all flight bookings of a customer (compare S_EXAMPLE_1 and the corresponding print program RSTEXP1). page numbering. select * from .values in the printout. you cannot use SAPscript to read data directly from a database table.. This simple print program creates an invoice that contains company-related information. data: bookings like sbook ... date. At runtime of the print program... * (2) Open layout set call function 'OPEN_FORM' exporting form = 'S_EXAMPLE_1' . SAPscript cannot access any data fields themselves. The print program is responsible for retrieving the data from the R/3 system and for the control logic of the output.... SAPscript is responsible for formatting and positioning this data on a print page..

type = 'BODY' window = 'MAIN' . . In this example. In the latter case. Then.. BOOKINGS). you must use the function modules START_FORM and END_FORM.. the function module OPEN_FORM is called to initialize the print output of the layout set S_EXAMPLE_1. In section (2)... In section (4). 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. the first section reads the required data from the database and fills it into internal tables (for example. 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. endloop. using default text elements. CLOSE_FORM finally ends the printing of the layout set. The address of the customer as well as company-related information is output in other layout set windows directly. * (5) Close layout set call function 'CLOSE_FORM' . which you can either maintain in separate spool requests or combine into one. For each printout of a layout set. WRITE_FORM uses the text element HEADING to output general text and the column heading of the invoice in the MAIN window (section (3)).