3.12.10

SAP Note 20040 - SAPscript: Wrong symbol values in form windows .

Symptom

Variable symbols are used in SAPscript layout sets in windows of type VAR or CONST. During the printout or test display on the screen, incorrect values are sometimes displayed for these symbols.

Cause and prerequisites

The windows of type VAR and CONST only processed at the end of the page, unlike window type MAIN, that is, the text elements of the VAR or CONST type windows are only processed when a page break is reached when filling the main window. Typ VAR oder CONST prozessiert. Especially the variables symbols are only expanded at this time and replaced by their actual value from the print program.
However, if the print program expects that the variables are replaced immediately when calling a text elements and internally sets its variable differently, this other value is displayed, for example:
Assume the form text element for window HEADER is:
/E ELEM1
* Item indicator: &REGUP-POKEN&
..........

and the print program is:

TABLES REGUP.

REGUP-POKEN = 'XYZ'.
CALL FUNCTION 'WRITE_FORM'
EXPORTING ELEMENT = 'ELEM1'
WINDOW = 'HEADER'.
REGUP-POKEN = 'ABC'.
..........

The printout would then be:
Item indicator: ABC

That is, the value set after WRITE_FORM is displayed.

Solution
Three solution are principally possible:

1. Try to move the corresponding text elements into the MAIN window because the display or porcessing in windows of type MAIN is done immediately, that is, with the corresponding function module call.

2. You have to create another variable symbol for each text element. In the above example, you could enhance the Dictionary structure REGUP by field REGUP-POKEN1 which is addressed after WRITE_FORM. Thus:

REGUP-POKEN1 = 'ABC'.

3. For repeatedly used variables, you have to replace the variables in the print program itself to get the desired current value. You can do this with the following function modules for the above example:
Layout set text element for window HEADER is:
/E ELEM1
* Item indicator: &REGUP-POKEN&
..........

The print program is:

TABLES REGUP.

DATA BEGIN OF TEXT_HEADER.
INCLUDE STRUCTURE THEAD.
DATA END OF TEXT_HEADER.

DATA BEGIN OF FORM_LINES OCCURS 0.
INCLUDE STRUCTURE TLINE.
DATA END OF FORM_LINES.


REGUP-POKEN = 'XYZ'.
CALL FUNCTION 'READ_FORM_LINES'
EXPORTING ELEMENT = 'ELEM1'
WINDOW = 'HEADER'
TABLES LINES = FORM_LINES.

"Formatierbreite für Variablenersetzung setzen
TEXT_HEADER-TDLINESIZE = 132.
CALL FUNCTION 'TEXT_SYMBOL_REPLACE'
EXPOPTING HEADER = TEXT_HEADER
TABLES LINES = FORM_LINES.

CALL FUNCTION 'WRITE_FORM_LINES'
EXPORTRING HEADER = TEXT_HEADER
WINDOW = 'HEADER'
TABLES LINES = FORM_LINES.

REGUP-POKEN = 'ABC'.
..........

The printout would then be:
Item indicator: XYZ

Additional key words

SAPscript, Form, se71

No comments:

Post a Comment