Ansicht
Dokumentation

RSS_TEMPLATE_INSTANTIATE -

RSS_TEMPLATE_INSTANTIATE -

ROGBILLS - Synchronize billing plans   BAL Application Log Documentation  
This documentation is copyright by SAP AG.
SAP E-Book

Functionality

This function module is used to instantiate templates. A program is generated from the template rows contained in the template. This process is carried out for any given meta-object, and is controlled by meta-statements in the template.

Meta-statements control, for example, whether a template row is replaced 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 (all the other rows).

Valid ABAP/4-statements are permitted as meta-statements. The following restrictions 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 not be declared a second time.

The template rows can contain parameters. Parameters are enclosed in backslashes, and can be valid actual parameters in a meta-program (for example, \sy-datum\, \sy-repid+5(3)\).

The function module RSS_TEMPLATE_INSTANTIATE is called to generate the program. The name of the template, the name of the program that is going to be generated, and the meta-object, are transferred to the module. The meta-object is transferred untyped, and can be a simple name, or a complex data structure. You access the meta-object using the formal parameter I_META_OBJECT in the meta-program of the template. The meta-object also controls the replacement of the template rows.

Example

The following example demonstrates how a primitive table display is generated from a template (stored as a program-include with the name name 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\).

The Generation Process

The function module RSS_TEMPLATE_INSTANTIATE is called. The following information 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.

The Generated Program

The template described above generates the program ZZTRDIR for the meta- 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).

Notes

Further information





Parameters

C_TX_TEXTPOOL
E_ERROR_LINE
E_ERROR_MESSAGE
E_RX_EXCEPTION
E_TH_PDIRSUB
E_T_CODE
E_T_PROGRAM_SOURCE
E_T_TEMPLATE_REF
E_T_VARCODE
E_UCCHECK
I_BUFFERED
I_CLIENT
I_DB_COMMIT
I_DEBUG_LEVEL
I_FORCE_COMPILATION
I_GLOBAL_CHECK
I_GLOBAL_PROGRAM
I_META_OBJECT
I_NO_COMMENT_LINE_SPLIT
I_NO_PROGRAM_CHECK
I_NO_RDIR_CHECK
I_PROGRAM_CLASS
I_PROGRAM_NAME
I_PROGRAM_TYPE
I_RDIR_FIXPT
I_SECONDS_TO_WAIT
I_TEMPLATE
I_UNI_IDC25
I_USE_METACLASS
O_ERROR_LINE
O_ERROR_MESSAGE

Exceptions

GENERATION_ERROR
INTERNAL_ERROR
INVALID_INPUT
PROGRAM_SYNTAX_ERROR
TEMPLATE_NOT_FOUND
TEMPLATE_SYNTAX_ERROR

Function Group

RSSG

General Material Data   RFUMSV00 - Advance Return for Tax on Sales/Purchases  
This documentation is copyright by SAP AG.

Length: 7761 Date: 20240605 Time: 202328     sap01-206 ( 92 ms )