Program Symbols

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.

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.

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.

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