Show TOC

Program SymbolsLocate this document in the navigation structure

Procedure

The integration of SAPscript allows you to link data that is stored in various applications of the SAP system in text modules; for example a form letter to be sent to multiple customers. The address information of these customers is in the SAP database and must be incorporated into the letter. SAPscript cannot read this data from the SAP database itself, but has to call another program to do this. The data is then copied into work areas declared with TABLES.

Note

Starting with Release 3.1G, you are no longer restricted to the TABLES statement. You can address any global variable using a program symbol. The system can evaluate the ABAP Dictionary information (output length, number of decimal places, and so on) not only for TABLES fields, but also for INFOTYPES fields and variables with a LIKE reference.

  • Example:

    DATA: MYCOUNTRY LIKE USR03-LAND1.

The system considers all output characteristics that can be retrieved using the ABAP statement DESCRIBE.

If SAPscript is now called from this program to format a text, it can copy the data out of these work areas.

Symbols that obtain their values from this kind of data area are called program symbols. The value of a program symbol is limited to a maximum of 255 characters. The name of a program symbol, when using TABLES statements, consists of the table name and the field name, separated by a hyphen. Examples of customer address fields are: &KNA1-NAME1&, &KNA1-ORT01&, &KNA1-PFACH&. Otherwise, the symbol is used in the way it is defined in the print program (for example, &MYCOUNTRY&). When SAPscript encounters a symbol, it first checks whether the symbol is a system symbol. If it finds no corresponding entry, it tries to find a table or structure in the calling ABAP program (declared with TABLES:....). If it finds one, the symbol is a program symbol and SAPscript next checks in the Dictionary to see whether this table contains the specified field.

If there is no table or structure in the calling ABAP program, SAPscript checks whether the symbol is a standard symbol. If no entry is found in table TTDTG, the system checks the calling program for global definitions (DATA, CONSTANTS, INFOTYPE, PARAMETER). If it finds any definitions, SAPscript processes the symbol as program symbol.

Only if no global symbol definitions are found, does SAPscript process the symbol as text symbol.

Basically, a defined text symbol remains a text symbol even if in the print program, for example, a DATA statement with the same name is used.

Note

For replacing the variables, the sequence of the variables in the corresponding text is decisive.

Example
  • Form/text:

    ....

    /: DEFINE &mysymbol& = 'abc'

    * &mysymbol&

    ....

  • Print program:

    ....

    Data: mysymbol(5) value 'xyz'.

    ....

In this example, in the form/text instead of &mysymbol&, the value of the text symbol defined with DEFINE is printed: abc.

Example
  • Form/text:

    ....

    * &mysymbol&

    /: DEFINE &mysymbol& = 'abc'

    ....

  • Print program:

    ....

    Data: mysymbol(5) value 'xyz'.

    ....

In this example, in the form/text instead of &mysymbol&, the value of the program symbol defined in the print program is printed: xyz.

Usually, SAPscript looks for the table work areas and the global variables in the main part of the ABAP program that was started. For example, if you want to use the table work areas of called function modules, enter the name of the corresponding program in the field TDPROGRAM of the structure you can enter in the OPTIONS parameter at OPEN_FORM. This definition is then valid for all program symbols up to the next CLOSE_FORM. However, you can also specify the name of the program in the PROGRAM parameter of the START_FORM function module. If you do this, it is valid up to the next END_FORM. If this parameter is not set in START_FORM, then the setting in OPEN_FORM applies.

For formatting a program symbol, SAPscript uses the specifications found in the Dictionary (output length, formatting routine, and so on). Certain data types require additional information out of other fields to format a value. For example, the contents of a currency field can be formatted correctly only when the information from the currency field key is also available. SAPscript itself is responsible for obtaining the necessary information from the Dictionary.

Note

For printing the program symbols, SAPscript uses the WRITE statement of the ABAP programming language. The effect of this statement is controlled externally via parameters (such as specifications in the user master record, table T005X), depending on the data type. If a program symbol is not printed in the way you expected it, first check whether the control parameters stated above are set correctly.

In all SAPscript text modules, you can refer to fields of the table work areas shown below:

ยท SYST: System Fields in the ABAP Programming Environment