SAP SCRIPT CONTROLS 1

SAP SCRIPT CONTROLS


The functionality of the SAPscript editor is made available through a set of commands which the user selects either from the menu or via the function (F-) keys. These commands give you full editing control over your text. They are executed immediately when called.


There is, however, another kind of SAPscript command, namely the control commands. The purpose of these is to allow control of the output formatting. These commands are not interpreted by the SAPscript editor, but are passed through to the SAPscript Composer for processing.

The Composer is the program that converts text from the form displayed in the editor to the form used for printing. This includes, for example, line and page formatting, the replacement of symbols with their current values and the formatting of text according to the paragraph and character formats specified.

The SAPscript control commands are described in the following sections.

The Syntax of Control Commands
Explicit Page Break: NEW-PAGE
Preventing Page Breaks: PROTECT
Next Main Window: NEW-WINDOW
Assigning a Value to a Text Symbol: DEFINE
Formatting Date Fields: SET DATE MASK
Formatting Time Fields: SET TIME MASK
Country-Dependent Formatting: SET COUNTRY
Position of the Leading Sign: SET SIGN
Initializing Numbered Paragraphs: RESET
Including Other Texts: INCLUDE
Changing the Style: STYLE
Formatting Addresses: ADDRESS
Setting a Header Text in the Main Window: TOP
Setting a Footer Text in the Main Window: BOTTOM
Conditional Text: IF
The CASE command
Calling ABAP/4 Subroutines: PERFORM
Inserting Print Controls: PRINT-CONTROL
Boxes, Lines, Shading: BOX, POSITION, SIZE
Hexadecimal Data: HEX, ENDHEX
Summing a Program Symbol: SUMMING



The Syntax of Control Commands

SAPscript control commands are entered and edited in the text editor in the same way as a normal line of text. They do, however, differ from normal lines of text in respect to the following points:

• The paragraph format /: must be entered in the format column to identify a control command.
• You enter the command itself in the text line. You will notice that all key words and other parts of the specification not given as literal values enclosed in apostrophe characters are automatically converted to capital letters.
• A control command, together with any parameters it requires, may not occupy more than a single line.
• A maximum of one control command may appear in each line.
• The editor formatting has no effect on lines containing control commands.


If a control command is unknown or it contains syntax errors, the line containing it will be treated as a comment line. It will be neither interpreted nor output.

Explicit Page Break: NEW-PAGE

SAPscript automatically inserts a page break when the main window of a page (MAIN) is full. You can use the NEW-PAGE command to force a page break in the text at any point you want one. The text following this command will appear on a new page. The page break will always be performed (it is an unconditional page break).
The NEW-PAGE command completes the current page.

This means that all the windows that are still on the page will be output immediately. If you use the NEW-PAGE command without parameters then the page defined in the layout set for the current page as the next page will be taken next. If, however, your layout set contains a number of different pages then you can specify any one of these as the next page to be used.


Syntax:
/: NEW-PAGE [page_name]

/: NEW-PAGE
The current page will be completed and the text in the following lines will be written to the page specified in the layout set.
/: NEW-PAGE S1
As above, except that the page S1 will taken as the next page.

• If a page not contained in the layout set is specified in a NEW-PAGE command then this specification is ignored.
• You should take care that there is not an blank line immediately before a NEW-PAGE command. This would serve no useful purpose and may lead to an unexpected blank page being printed. This would happen if an implicit page break would normally occur within the blank line.


You can specify either in the style or in the layout set that a particular paragraph should not be split in two by a page break. If the page protect attribute is set then the complete paragraph is always output on a single page. This property applies only to that particular paragraph.


This attribute is not intended to be used to protect all paragraphs against a page break. The point is that a page break is by its very nature a dynamic event and the exact point at which it occurs depends on the current state (length and contents) of the preceding text. It is also possible that one may want to protect only certain parts of a paragraph against a page break. In principle one could achieve this through the use of the NEW-PAGE command immediately before the text concerned.

Explicitly beginning a new page at this point should ensure that a further page break does not occur within the text. However, this technique is not change-resistant.

Assume, for example, that you have formatted your text with the help of the NEW-PAGE command such that no page breaks occur where they should not, and that you now insert some new lines or delete some existing lines. These changes will cause all the subsequent text to be moved relative to the printed page, and you will therefore need to check each NEW-PAGE command you had previously inserted to see if it is still in the correct place.

SAPscript provides the PROTECT .. ENDPROTECT command pair to allow you to define the areas to be protected against a page break on an individual basis. If you enclose the text to be protected in these commands, then SAPscript will ensure that each line of this text is printed together on the same page.

If the complete text fits in the space remaining on the current page, then it is output on that page just as it would be if no PROTECT command had been used. If, however, the remaining space is not sufficient for the text, then the PROTECT command has the same effect as a NEW-PAGE command and text is printed on a new page.
Thus the PROTECT/ENDPROTECT commands may be regarded as a kind of conditional NEW-PAGE command, the condition being whether or not the lines enclosed between the two commands fit in the space remaining in the current main window.


Syntax:
/: PROTECT
:
:
/: ENDPROTECT

The text lines to be protected are enclosed between the two commands.

• An ENDPROTECT command without a preceding PROTECT command has no effect.
• If the terminating ENDPROTECT is missing, then it will be assumed at the end of the text.
• PROTECT .. ENDPROTECT command pairs cannot be nested. If a second PROTECT command occurs before the first one has been terminated by an ENDPROTECT, it will be ignored.

• If the text enclosed by a PROTECT .. ENDPROTECT pair is itself too long for a single page, then a page break is generated immediately before the text and the text is output in the normal way. It is then unavoidable that a page break will occur at some point within the text.


Next Main Window: NEW-WINDOW

Each page can consist of up to 99 main windows. Each main window is assigned a consecutive identifying number (0..98), and the windows are filled in this order. This feature enables SAPscript to print labels and to output multi-column text. When one main window fills up, the next main window on that page is taken, if there is a next one. A page break is inserted after the last main window.


You can use the NEW-WINDOW command to call the next main window explicitly, even if the current main window is not yet full. If you are in the last main window of the page, the command has the same effect as the NEW-PAGE command.
Syntax:
/: NEW-WINDOW


Assigning a Value to a Text Symbol: DEFINE

Text symbols acquire their values as a result of explicit assignment. This assignment can be performed interactively in the text editor via the menu option Include -> Symbols -> Text. This method is available for all text symbols belonging to a text module as well as those of the associated layout set.


Values defined in this way are lost when the transaction is left. If the text module is to be printed again then the symbol values must all be entered again. The purpose of the DEFINE command is to provide a means of making this value assignment a permanent part of the text, so that the values are available again when the text module is called again. This command can also be used to re-assign a new value to a text symbol part way through the text.


Syntax:
/: DEFINE &symbol_name& = 'value'

/: DEFINE &subject& = 'Your letter of 7/3/95'


The value assigned can have a maximal length of 60 characters. It may itself contain other symbols. A symbol contained within the value assigned to another symbol is not replaced with its own value at the point at which the DEFINE command is executed. Rather, this replacement is made when the symbol defined in the DEFINE command is called in the text.

/: DEFINE &symbol1& = 'mail'
/: DEFINE &symbol2& = 'SAP&symbol1&'
/: DEFINE &symbol1& = 'script'
&symbol2& -> SAPscript


If, however, the DEFINE command is written using the ':=' character rather than the '=' character, then any symbol contained within the value being assigned will be replaced immediately with its current value.

The assignment to the target symbol will only be made after all symbols in the value string have been replaced with their values. The total length of the value string may not exceed 80 characters. The target symbol must be a text symbol, as before.

/: DEFINE &symbol1& = 'mail'
/: DEFINE &symbol2& := 'SAP&symbol1&'
/: DEFINE &symbol1& = 'script'
&symbol2& -> SAPmail


RELATED POSTS

SAP SCRIPT CONTROLS 6
SAP SCRIPT CONTROLS 5
SAP SCRIPT CONTROLS 4
SAP SCRIPT CONTROLS 3
SAP SCRIPT CONTROLS 2

No comments :

Post a Comment