• No results found

Symbols and Control Commands

In document BC460 SAP Script (Page 93-127)

Symbols and Control Commands

Unit Overview

This unit starts with the introduction of various symbols and then discusses the control commands. Finally, the unit highlights the various uses of the control commands.

Unit Objectives

After completing this unit, you will be able to: • Use symbols

• Identify formatting options • Use control commands

Unit Contents

Lesson: Symbols... 86 Lesson: Control Commands... 96 Exercise 2: Using Control Commands...105

Lesson: Symbols

Lesson Overview

This lesson introduces you to the various types of symbols. It also describes the various formatting options available with symbols.

Lesson Objectives

After completing this lesson, you will be able to: • Use symbols

• Identify formatting options

Business Example

You are working with a garment export house that exports a large variety of readymade garments to various distributors across the world. The export house uses SAPscripts to create and print invoices generated by the Sales and Distribution department. The information about the invoices created by the Sales and Distribution department is stored in tables. As a sales executive of this export house, you need to use symbols with these tables. Symbols enable you to display the most current values from SAP tables in the form of text modules. You can use these text modules for further analysis.

Introduction to Symbols

Figure 57: Using Symbols

Symbols are placeholders for values that are inserted during print formatting. The use of symbols allows you to output the most current values from SAP tables in the form of text modules.

Symbols are identified by names surrounded by ampersand characters at the beginning and end of the symbol. Symbol names are not case-sensitive.

Symbol names may not contain a blank space.

Symbols must always completely fit on one text line; symbols cannot wrap to the next line of text.

Types of Symbols

Figure 58: Types of Symbols

SAPscript uses four types of symbols: • System

• Standard • Program • Text

These symbol types differ in the way in which values are assigned to them. You can select symbols by selecting Include → Symbols.

Figure 59: System Symbols

SAPscript provides standard system symbols that are automatically replaced with data from SAP R/3 Enterprise when a document is printed.

You can use system symbols in any document.

To choose a system symbol, select Include → Symbols → System.

From Release 4.5 A, the table TTXSY, which contains system symbols, is also available to users.

• Table TTDTG

• Symbols are user-defined. • Symbols are language-dependent. • Name: max. 22 characters. • Value: max. 60 characters.

Standard symbols are application-defined and stored in table TTDTG.

You can display or change standard symbols by selectingSystem → Services →

Tablemaintenance → Extended table maint. , or by selectingTools → SAPscript → Administration → Settings.

You can use standard symbols in any document. Standard symbols are language-specific.

Examples of standard symbols are:

• &SGDH& for the opening salutation: “Dear Sir/Madam:” • &MFG& for the closing salutation: “Yours faithfully” • Value is defined in the text module

• DEFINE &symbol& = “value” • Name: max. 32 characters • Value: max. 60 characters

You can define a text symbol for any text module. This symbol is valid only in the text module for which you have defined the symbol.

You can assign values to a symbol in the following ways: • Use DEFINE.

– The value assigned to the symbol is saved when you save the text module. – To assign several values to the same symbol, use DEFINE every time you

assign a new value.

Use a standard text symbol. To do so, select Include → Symbols → Text symbols

...

– The system displays all the text symbols in the current text and form. – You can assign any value to the symbols.

– The value assigned to a text symbol is only temporary and is not saved with the text.

Figure 60: Program Symbols

Program symbols are substitute symbols for values, which originate from the ABAP program.

Program symbols represent the contents of database fields or global program symbols. The database fields must be defined in a table or a structure in the ABAP Dictionary with a TABLES statement. Global program symbols can be defined in the print program over DATA or SELECT OPTION.

The data objects must be filled with values by the print program. You can edit the values using SAPscript according to the ABAP Dictionary or using the program-defined characteristics.

Figure 61: Program Symbols and Symbol Definition

Click the Program symbols button or select Insert → Symbols → Program symbols to display a detailed list of program symbols for your print program. You can add these symbols to the text by clicking the symbols.

Click the Symbol definition button or select Go to → Print program → Symbol

definition to branch to a specific data object’s definition screen in the print program.

Select Go to → Print program → Symbol definition with dialog to jump to various print programs using the dialog box that this function calls.

To assign additional print programs to a form, selectInsert → Symbols → Program

symbols. A dialog box called Print program for form appears. Choose Append print program.

Figure 62: Creating Additional Information in the PC Editor

You can insert commands, symbols, and text elements in the PC editor by using Edit

→ Insert command.

The structures you insert appear in fields on the screen.

These structures can be deleted or changed by placing your cursor on the appropriate line and choosing either Edit → Delete command or Edit → Change command. Those commands and symbols inserted using the dialog box undergo a syntax check before they are inserted into your text.

You can also check syntax manually using Text → Check. From 4.5A you can also check unknown symbols in form texts.

Formatting Options

Figure 63: Formatting Options

The value of a symbol is displayed in full but blank spaces at the end of the value are cut off. To change the symbol display, use the following options:

• Offset: Output begins here. Offset always refers to the formatted value. • Length: Data of a specified length is displayed.

• I: If the field has an initial value, nothing is displayed at the output. • Z: Leading zeros are suppressed.

• C: Several consecutive blank spaces are compressed into one blank space. Leading blank spaces are suppressed.

• R: The output is right-aligned. • S: The sign is hidden.

• (x,y) Decimal notation: the data has length x with y decimal places. Text can also be inserted before or after a symbol, for example,

&’text1’SYMBOL’text2’&.

Lesson Summary

You should now be able to: • Use symbols

Lesson: Control Commands

Lesson Overview

This lesson provides you with an overview of control commands. It also describes how to use control commands for various purposes, such as to include text modules and define text symbols.

Lesson Objectives

After completing this lesson, you will be able to: • Use control commands

Business Example

You are working with a garment export house that exports a large variety of readymade garments to various distributors across the world. The export house uses SAPscripts to create and print invoices generated by the Sales and Distribution department. You have created text modules for the SAPscript tables that are used to store the details of invoices. Now, you need to include these text modules to the Windows in a form. You also need to use the data from these tables. But the print program cannot read the data assigned to it. To enable the print program to read the data, you need to use control commands in SAPscript.

You can use control commands to modify the output text. Control commands allow you to:

• Include text in a document. • Assign values to text symbols. • Start or suppress a page break. • Reset outline paragraphs. • Evaluate conditions.

To enter a control command, use the format key /: in the format column. The length of a control command must not exceed one line.

Using Control Commands

Figure 65: Text Modules

A form contains predefined text modules, such as material lists, customer description, a company footer, bank account numbers, and the names of the executive board members.

You can enter and store these text modules separately.

To identify the text, specify the client, name, language, text object, and text ID. The text object and text ID are used to classify the text.

A text object describes the context of a document, such as Item Text, which contains Purchasing Document, Materials Text, or Standard Text. Such text can be used for more than one application.

Text objects are divided into text IDs to permit a more precise classification of text types. For example, the category, Sales and Distribution Text, is a subcategory of Materials Text.

To work on any standard document, that is, to work with all the text allocated to Object TEXT, select Tools → SAPscript → Standard text.

Figure 66: Including Text Modules

You can include text modules from the current client in any window in a form. You can also include text modules in other text modules. In both the cases, you need to use INCLUDE to add the text modules.

You must specify the name of the text you want to include.

You can specify additional key fields for the text using the OBJECT, ID, and LANGUAGE parameters.

Use Insert → Text → Standard ... to include standard text. Enter the name of the text that you want to include in the dialog box that appears.

Figure 67: Defining Text Symbols

You must specify values for text symbols explicitly. The DEFINE command allows you to anchor the value you assign in a text.

To assign values to text symbols, you need to use DEFINE before the text symbol is displayed for the first time.

Text symbols are retained in the document. This means that the text symbol remains in the text module till you use the text symbol again.

In addition, you can change the value of a text symbol that appears repeatedly in your text.

The ADDRESS-ENDADDRESS command formats addresses according to the postal norms of the recipient’s country, as defined in the COUNTRY parameter. The corresponding references fields are described in structure, ADRS. You can assign both literals and symbols to the parameter.

The composer calls the function module, ADDRESS_INTO_PRINTFORM, when formatting addresses and transfers the appropriate format parameter from the text to the function module.

For additional information, refer to the online documentation for the function module, ADDRESS_INTO_PRINTFORM.

You should always include the FROMCOUNTRY parameter when formatting addresses; otherwise, the sender’s address will be formatted according to the COUNTRY parameter. For example, with postal codes, if the value of COUNTRY is Germany and the FROMCOUNTRY parameter is not included, the sender’s postal code will be displayed as D-80801.

Figure 69: Time, Date, and Decimal Formats

To modify the format of program and system symbols of this type, use the following control commands:

• SET TIME MASK: Controls the time field format. • SET DATE MASK: Controls the date field format.

• SET COUNTRY: Provides a choice of country-specific date or decimal formats that differ from the user master data.

To define format masks, use command lines.

Figure 70: Page Break and Page Protection

SAPscript automatically inserts a page break when the main window (MAIN) is full. To override the automatic page break in the main window and insert a manual page break, you need to use the control command, NEW-PAGE.

You can specify the subsequent page explicitly. If you do not specify the next page, the page defined in the form is used as the next page.

To avoid unwanted page breaks, you need to use the PROTECT...ENDPROTECT commands. All the text enclosed within these commands is printed on one page. If the text fits onto the current page, the text is printed on that page as if the PROTECT command had not been used. If there is no space on the page, the PROTECT command functions as a NEW-PAGE command and inserts a page break.

Figure 71: Conditional Text Output: Case Distinction

You can specify that the text should be displayed only when certain conditions are met. To set such conditions, you need to use the IF...ENDIF command. If the logical expression within the IF command is evaluated as True, the text enclosed within IF ... ENDIF is printed. Otherwise, the text is ignored.

The following comparison operators can be used in the logical expression: • = EQ equal >= GE greater than or equal

• < LT less than <> NE not equal

• > GT greater than NOT, AND, OR comparison operators • <= LE less than or equal

These comparisons are text comparisons only.

To distinguish between dual-level and multilevel cases, use ELSE and ELSEIF within IF...ENDIF.

CASE is a special type of multilevel case distinction using IF commands. Only one symbol can be tested for equivalence with different values for various cases.

Figure 72: Frames, Lines, and Shading

The SAPscript commands, BOX, POSITION, and SIZE, allow you to display windows and individual text passages in a box, frame, or with a shaded background. Use the following syntax:

• /: BOX [XPOS] [YPOS] [WIDTH] [HEIGHT] [FRAME] [INTENSITY]: For a frame of size WIDTH and HEIGHT at position [XPOS, YPOS] (left upper corner of the frame in relation to the values contained in the POSITION command). The FRAME addition determines what line thickness the frame has. The INTENSITY addition shades the background area contained within the frame. Position, size, and frame thickness use appropriate units of measurement; shading should be entered in percent.

• /: POSITION [XORIGIN] [YORIGIN] [WINDOW] [PAGE]: To fix the source coordinates XORIGIN and YORIGIN for the XPOS and YPOS parameters in the BOX command. The WINDOW addition sets the values for the top and left margins to those of the current window. The PAGE addition sets the values for the top and left margins to those of the page currently being displayed.

• /: SIZE [WIDTH] [HEIGHT] [WINDOW] [PAGE]: To define the WIDTH and HEIGHT values for the BOX command for the current WINDOW or PAGE.

Figure 73: Calling ABAP Subroutines

Use the PERFORM command to transfer SAPscript data to programs and program data back to SAPscript without having to change your print program.

• Example: You want to use data from a SAPscript database table that cannot be read by the print program assigned to it. Have a program in customer namespace Z read the data and then use the PERFORM command in SAPscript to call the program.

The form routine called during this procedure uses an internal table based on the structure ITCSY.

The structure ITCSY is composed of two fields, NAME and VALUE. Text fields are transferred to the NAME field and text field contents are transferred to the VALUE field.

The variables listed under the PERFORM command are symbols.

All symbols, parameter names, and contents, which are transferred from SAPscript to the program being called are listed in the PERFORM command using the keyword, USING.

Parameters transferred back to SAPscript from the internal tables in programs are received by the PERFORM command as text symbols using the keyword,

Exercise 2: Using Control Commands

Exercise Objectives

After completing this exercise, you will be able to: • Make changes to SAP standard forms

• Understand the layout using the graphical Form Painter and the alphanumeric Form Painter

• Understand text changes

• Print preview using the print program

Business Example

In most cases, standard forms are altered to reflect the needs of individual customers.

Task 1:

Object Name / Description

Name of the form to be creates Z_BC460_EX4_## Name of the form to be used SAPBC460T_FM_04 Name of the print program to be used SAPBC460D_01 Name of the program to be created Z_BC460_EX4_##

Development class $TMP

Note: ## is your group number

Create a separate form called Z_BC460_EX4_xx to be used in this exercise.

1. Make a copy of the sample form SAPBC460T_FM_04. Choose Form → Copy (see Exercises: PC Editor and Line Editor).

Task 2:

Change the greeting in Element INTRODUCTION of Window MAIN to print the customer’s name. Use a text symbol which you fill using your own program. The print program does not have access to this information.

1. Use the DEFINE command to assign the value ‘00000022’ to a new symbol &CUST& in the MAIN window.

2. Read the name of this customer from table SCUSTOM in a form routine of an ABAP program. Use the PERFORM command in SAPscript to pass the date from your own program into the form. (The performed program will be created below.) Assign this value to the new symbol &NAME&.

3. Change the Greeting by using the symbol &NAME& now.

4. Write the ABAP program Z_BC460_EX4_xx. Remember, it must have a structure that looks like this:

REPORT Z_BC460_EX4_##.

FORM GET_NAME TABLES INTTAB STRUCTURE ITCSY OUTTAB STRUCTURE ITCSY.

* Read the entry of the imported internal table * Select the desired record from table SCUSTOM using * the customer ID in field inttab-value(8).

* Write the selected record back into the internal * table to be exported

ENDFORM.

5. Test your changes using program SAPBC460D_01.

6. You may want to use the DEBUG mode to check the values of INTTAB and OUTTAB.

Task 3:

Put a box around the SENDER window. This should be just a little larger than the window so that it will not touch any of the text inside the window.

1. Select the SENDER window and choose Text.

2. Use the POSITION command to set the x and y origin to ‘-.2’ cm. This positions the top left corner of the box .2 cm left and .2 cm up from the top left corner of the window.

3. Use the SIZE command to set the width and height at ‘+0.4’ cm. This makes up for the upper position and adds another 0.2 cm to the window width and height. 4. Use the BOX FRAME command to draw the box using a line width of 10 TW. 5. Test your changes using program SAPBC460D_01.

Task 4:

Create a standard text module with a name of Z_BC460_EX4_## and Text ID of SDVD. Include this text in your form. Print the text with an alignment of CENTER. 1. Create a standard text module using Tools → SAPscript → Standard text.

Change the Text ID to SDVD (Standard text for SD forms). 2. Enter a few lines of text and save.

Note: Do not select any paragraph format because you need to control

the paragraph formatting from the form.

3. Use the INCLUDE command to select the standard text to be printed in your form.

Note: To insert your newly created text module, select Insert → Text →

Standard.

4. Add the parameter PARAGRAPH to select the appropriate paragraph tag to use CENTER alignment to print the text.

Solution 2: Using Control Commands

Task 1:

Object Name / Description

Name of the form to be creates Z_BC460_EX4_##

In document BC460 SAP Script (Page 93-127)

Related documents