SAP Function RSS_TEMPLATE_INSTANTIATE -

Parameter Reference Type Length Default Optional Text
I_BUFFERED RSSG_BOOL C 1 RSSG_C_TRUE X
I_CLIENT RSSG_CLIENT 0 SY-MANDT X Client
I_DB_COMMIT RSSG_BOOL C 1 RSSG_C_FALSE X
I_DEBUG_LEVEL I I 4 X
I_FORCE_COMPILATION 0 X
I_GLOBAL_CHECK SYST-CALLD C 1 X
I_GLOBAL_PROGRAM SYST-REPID C 40 X Main program
I_META_OBJECT 0 X
I_NO_PROGRAM_CHECK RSSG_BOOL C 1 RSSG_C_FALSE X
I_NO_RDIR_CHECK RSSG_BOOL C 1 RSSG_C_TRUE X
I_PROGRAM_CLASS RSSG_PROGCLASS 0 X BW generation tool: Program class for generated programs
I_PROGRAM_NAME SYST-REPID C 40 X Program to be generated
I_PROGRAM_TYPE TRDIR-SUBC C 1 1 X Program Type
I_SECONDS_TO_WAIT I I 4 30 X
I_TEMPLATE SYST-REPID C 40 X Template
I_UNI_IDC25 RSSG_UNI_IDC25 0 X BW Generation tool: GUID in compressed form (CHAR25)
I_USE_METACLASS RSSG_BOOL C 1 RSSG_C_FALSE X

Parameter Reference Type Length Text
E_ERROR_LINE SYST-TABIX I 4
E_ERROR_MESSAGE RSSG_MESSAGE 0
E_RX_EXCEPTION REF TO CX_ROOT 0
E_TH_PDIRSUB RSSG_TH_PDIRSUB 0
E_T_CODE RSSG_T_CODELINE 0
E_T_TEMPLATE_REF RSSG_T_TEMPLREF 0 For internal use only
E_T_VARCODE RSSG_T_VARLINE 0
E_UCCHECK UCCHECK C 1 Flag, if unicode check was performed
O_ERROR_LINE SYST-TABIX I 4 Line number of syntax error
O_ERROR_MESSAGE C C 0 Error message

Parameter Reference Type Length Default Optional Text
C_TX_TEXTPOOL RSSG_TX_TP h 464 X BW Generation Tool: Text Pool

Parameter Reference Length Optional Text
E_T_PROGRAM_SOURCE ABAPSOURCE 72 X

Exception Text
GENERATION_ERROR
INTERNAL_ERROR Internal Error
INVALID_INPUT
PROGRAM_SYNTAX_ERROR
TEMPLATE_NOT_FOUND
TEMPLATE_SYNTAX_ERROR

Functionality
This function module is used to instantiate templates. A program isgenerated from the template rows contained in the template. Thisprocess is carried out for any given meta-object, and is controlled bymeta-statements in the template.
Meta-statements control, for example, whether a template row isreplaced conditionally, or several times (by various different values).
To check and instantiate the template, it is dismantled in the meta-statements (rows that start with '*@') and in the template rows (allthe other rows).
Valid ABAP/4-statements are permitted as meta-statements. The followingrestrictions apply:
Only those statements that can be used in a FORM routine are permitted(for example, no PROGRAM-statements, no FORM-statements).
The variables I_META_OBJECT and I_TEMPLATE are predefined, and must notbe declared a second time.
The template rows can contain parameters. Parameters are enclosed inbackslashes, and can be valid actual parameters in a meta-program (forexample, \sy-datum\, \sy-repid+5(3)\).
The function module RSS_TEMPLATE_INSTANTIATE is called to generate theprogram. The name of the template, the name of the program that isgoing to be generated, and the meta-object, are transferred to themodule. The meta-object is transferred untyped, and can be a simplename, or a complex data structure. You access the meta-object using theformal parameter I_META_OBJECT in the meta-program of the template. Themeta-object also controls the replacement of the template rows.
NEW-PAGE

Example
The following example demonstrates how a primitive table display isgenerated from a template (stored as a program-include with the namename TMPLSE16):
Template TMPLSE16
*@*-------------------------------------------------------------------*
*@* data declaration
*@*-------------------------------------------------------------------*
*@
*@data: tabname like dfies-tabname,
*@ x_init,
*@ max_columns type i,
*@ total_width type i,
*@ ft like dfies occurs 0 with header line.
*@
*@*-------------------------------------------------------------------*
*@* prepare meta data for generation
*@*-------------------------------------------------------------------*
*@
*@tabname = i_meta_object.
*@call function 'GET_FIELDTAB'
*@ exporting
*@ only = 'X'
*@ tabname = tabname
*@ withtext = ' '
*@ tables
*@ fieldtab = ft
*@ exceptions
*@ internal_error = 1
*@ no_texts_found = 2
*@ table_has_no_fields = 3
*@ table_not_activ = 4
*@ others = 5.
*@total_width = 1.
*@loop at ft.
*@ total_width = total_width + ft-outputlen + 1.
*@ if total_width > 255. exit. endif.
*@ max_columns = sy-tabix.
*@endloop.
*@
*@*-------------------------------------------------------------------*
*@* instantiate model lines
*@*-------------------------------------------------------------------*
*@
report zz\tabname\ line-size \total_width\.
*----------------------------------------------------------------------
* template....: \i_template\
* generated at: \sy-datum\ \sy-uzeit\
* generated by: \sy-uname\
*----------------------------------------------------------------------
tables \tabname\.
*@loop at ft where keyflag = 'X'.
select-options \ft-fieldname(8)\ for \tabname\-\ft-fieldname\.
*@endloop.
uline /(\total_width\).
new-line. write sy-vline no-gap.
*@loop at ft to max_columns.
write (\ft-outputlen\) '\ft-fieldname\' color col_heading no-gap.
write sy-vline no-gap.
*@endloop.
uline /(\total_width\).
select * from \tabname\
*@clear x_init.
*@loop at ft where keyflag = 'X'.
*@ if x_init is initial.
where \ft-fieldname\ in \ft-fieldname(8)\
*@ x_init = 'X'.
*@ else.
and \ft-fieldname\ in \ft-fieldname(8)\
*@ endif.
*@endloop.
.
new-line. write sy-vline no-gap.
*@loop at ft to max_columns.
*@ if not ft-keyflag is initial.
write \tabname\-\ft-fieldname\ color col_key no-gap.
*@ else.
write \tabname\-\ft-fieldname\ color col_normal no-gap.
*@ endif.
write sy-vline no-gap.
*@endloop.
endselect.
uline /(\total_width\).
NEW-PAGE
The Generation Process
The function module RSS_TEMPLATE_INSTANTIATE is called. The followinginformation has to be transferred to the module:
The name of the template.................: 'TMPLSE16',
the name of the program you want to generate: 'ZZTRDIR',
and the name of the table as a meta-object...: 'TRDIR'.
call function 'RSS_TEMPLATE_INSTANTIATE'
exporting
i_template = 'TMPLSE16'
i_program = 'ZZTRDIR'
i_meta_object = 'TRDIR'
exceptions
template_not_found = 1
template_syntax_error = 2
internal_error = 3.
NEW-PAGE
The Generated Program
The template described above generates the program ZZTRDIR for themeta- object TRDIR:
report zztrdir line-size 206.
*----------------------------------------------------------------------
* template....: TMPLSE16
* generated at: 04.03.1997 14:17:00
* generated by: SAPUSER
*----------------------------------------------------------------------
tables trdir.
select-options name for trdir-name.
uline /(206).
new-line. write sy-vline no-gap.
write (000040) 'NAME' color col_heading no-gap.
write sy-vline no-gap.
write (000001) 'SQLX' color col_heading no-gap.
write sy-vline no-gap.
...
write (000020) 'LDBNAME' color col_heading no-gap.
write sy-vline no-gap.
uline /(206).
select * from trdir
where name in name
.
new-line. write sy-vline no-gap.
write trdir-name color col_key no-gap.
write sy-vline no-gap.
write trdir-sqlx color col_normal no-gap.
write sy-vline no-gap.
...
write trdir-ldbname color col_normal no-gap.
write sy-vline no-gap.
endselect.
uline /(206).

765439Collection Note for Unicode - CRM Middleware
1363928P22:SDL: Syntax errors if hierarchy routine not sorted
998970The KEYGEN template cannot be generated
998705BI generation tool: Error RG 102 "Syntax error in GP_MET_"