SAP ABAP Data Element RSSG_TEMPL (BW Generation Tool: Template for Code Generation)
Hierarchy
SAP_BASIS (Software Component) SAP Basis Component
   BC-BW (Application Component) BW Service API
     SBIG (Package) Business Information Warehouse: Generation Tool
Basic Data
Data Element RSSG_TEMPL
Short Description BW Generation Tool: Template for Code Generation  
Data Type
Category of Dictionary Type D   Domain
Type of Object Referenced     No Information
Domain / Name of Reference Type PROGNAME    
Data Type CHAR   Character String 
Length 40    
Decimal Places 0    
Output Length 40    
Value Table      
Further Characteristics
Search Help: Name    
Search Help: Parameters    
Parameter ID   
Default Component name    
Change document    
No Input History    
Basic direction is set to LTR    
No BIDI Filtering    
Field Label
  Length  Field Label  
Short 10 Template 
Medium 15 Template 
Long 20 Template 
Heading 30 Template 
Documentation

Definition

A template is an Include program (type 'I') that is used for the program code to be generated. Status management of the generation tool detects changes to the template and can trigger the regeneration of a program.

If the application itself creates the program code, it can itself define the syntax of the template. However, if the code is generated by the generation tool (function module RSS_PROGRAM_GENERATE or RSS_TEMPLATE_INSTANTIATE), the template must satisfy a given syntax:

A template for the BI generation tool consists of template rows and meta commands that control how parameters are replaced in the template rows.

Meta commands are inserted as special comment lines and must begin with '*@'. ABAP is used as language for the meta commands. All meta commands must satisfy the syntax requirements for implementating a FORM routine. For example, the commands PROGRAM ..., FORM ..., TYPE-POOLS ..., etc. are not allowed. A special solution for using type groups in meta coding is described below.

Meta commands may not be interrupted with template rows. This must be taken into consideration, especially when writing instructions for corrections and when including corrections in a template using the modification assistant. Event interrupting a meta command with normal comment lines that are normally inserted with the modification assistant results in syntax errors in the template.

Because of the internal limitations of ABAP objects (branch limit), templates cannot be of unlimited size. The actual limit depends on the complexity of the meta code commands and the number of replacements in the template rows. Normally this limit is reached with a few thousand template rows. This is described in Note 998705; for this reason you should avoid creating templates with more than 10,000 rows.

Within the meta code, the following namespaces are reserved for internal use by the generation tool. They may not be used in declarations in the meta code.

_RSSG...    Objects in this namespace (data objects, routines, parameters,...) are only for internal processing in the generation tool.

I_...    Data objects in this namespace are used for passing parameters from the generation tool to the meta program (= importing).

E_...    Data objects in this namespace are used to return parameters from the meta program to the generation tool (= exporting) and possibly to the application. This namespace is not currently used.

C_...    Data objects in this namespace are used for passing parameters both to and from the meta program (= changing).

The reservation in this form is valid as of Basis 6.20.

The following predefined data objects can be read in the meta code:

I_UNI_IDC25    25-place GUID as a reference to the application object

I_CLIENT    Client of the applciation object if the program class is marked as client-dependent.

I_TEMPLATE    Template name

I_PROGRAM    Name of the program to be generated

I_META_OBJECT    This parameter is obsolete and should only be used if generation used the function module RSS_TEMPLATE_INSTANTIATE and a 25-digit GUID can be eliminated as reference to the meta object.

I_DEBUG_LEVEL    Debug level from the parameter with the same name in function module RSS_PROGRAM_GENERATE or RSS_TEMPLATE_INSTANTIATE. The parameter is only available with Basis 6.30.

C_TX_TEXTPOOL    Text pool of the program (new with Release 6.10). The template provides the text elements in the current logon language. The texts can be changed in the meta code of the template and rows for additional languages can be appended to the table. The data object is a standard table in the row structure RSSG_SX_TP.

When you call the generation with function module RSS_PROGRAM_GENERATE, the variables I_UNI_IDC25 and I_CLIENT in the meta program contain the values of the import parameters of this module having the same name.

Within the meta code, generation can be terminated at any time with the predefined exception GENERATION_ERROR, if possible with a meaningful error message. As a result, the call of function module RSS_PROGRAM_GENERATE or RSS_TEMPLATE_INSTANTIATE is terminated with an exception having the same name.

The template rows can contain parameters. Parameters are delimited with backslashes and can be valid actual parameters in the meta code (for example, \sy-datum\, \sy-repid+4(*)\ or variables declared in the meta code). A single backslash must be defined with \\. With Basis Release 6.10, parameters may no longer be structured data types, not even if they only contain characterlike components.

With Basis 6.40, you can set a tab in a template row with \+\. The tab aligns the following expressions at the same absolute column position in the generated code. A tab can also be set together with a variable by putting a + between the first backslash and the parameter name. For example, in a template you can use the rows

\var_name1\            \+\= \var_value1\.
\var_name2\            \+\= \var_value2\.

to generate value assignments so that the equals signs are aligned under one another, irrespective of the character lengths of the values of parameters var_name1 and var_name2.

You can use type groups in meta coding between the two special commands

    *@@global.

and

    *@@endglobal.

as a normal meta command. Both special commands should be in a separate row. All objects that are declared in the meta code between these two special commands are treated as though they were in the global part of a subroutine pool, that is variables defined in this way maintain their value if there is another generation with the same template within the same internal mode. This could be of advantage in a mass generation.

With Basis Release 6.40, the two meta commands

    *@@SECTION secname.

and

    *@@INSTANTIATE pclass [guid25 [section]].

are supported. The command *@@section defines the start of a section in a template. secname is a name with a maximum of 20 places, consisting of the ten digits, the 26 Latin uppercase letters, and an underline. The meta command *@@INSTANTIATE is used to include generated code from another program class. You must define the program class in parameter pclass. Parameter guid25 is optional. If it is not specified, the current GUID is passed to the called program class. guid25 can be a literal or a valid variable in the meta code having the type RSSGUID25. Parameter section is also optional and defines a section in the template. If this parameter is specified, only the generated code from this section is passed to the current location of the template. The command *@@INSTANTIATE results in an internal call of function module RSS_TEMPLATE_INSTANTIATE. The other parameters for calling this module are passed from the current call if needed.

An example is the template RSSG_BROWSER_TEMPLATE.

With Basis Release 6.10 you can use the program class maintenance (transaction RSSGPCLA) to find and correct syntax errors in the meta code: To check this, execute the function 'Check Template' at the appropriate row. If the check detects a syntax error in the template, you automatically go to the corresponding location in the editor. You can correct the error there and activate the template again. A new check is triggered when you leave the editor. You can repeat this process approximately 36 times (= maximum number of temporary subroutine pools in the roll area).

The meta code in the template should be designed so that it can perform the generation without an external context (that is, it should at least be able to build this context on its own from the GUID. In this way, a program can be generated at any time from the test environment of the Workbench by calling the function module RSS_PROGRAM_GENERATE and passing the program class and GUID.

History
Last changed by/on SAP  20110908 
SAP Release Created in 50A