Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

SAP SCRIPT ???????

Former Member
0 Likes
452

HOW MANY TYPES OF FUNCION MODULES R USED IN SAP SCRIPT ............AND WHAT R THE USES OF THEM ALL

3 REPLIES 3
Read only

Former Member
0 Likes
399

Hi,

in script, we use these function moduleS frequently.

OPEN_FORM

START_FORM

WRITE_FORM

END_FORM

CLOSE_FORM.

open_form

this FM open's the form printing and initialses the layout.

call function 'open_form'

exporting

form = ' ' ' here specifies the form name. default value is SPACE

language = sy-langu "here specifies the language in which form existing

device = 'printer' " here pass o/p device type.

close_form

this FM close the form printing, we must close the opened form with close-form.

call function 'close_form'

**this FM has no parameters

start_form

this FM is used for printing the form specified page, not from starting page.

call function 'start_form'

exporting

form = ' ' "name of the form

language = sy-langu " exisisting language

startpage = < > ' here specifies the page number from which printing is started.

end_form

this FM is used for end the form printing whish was started by start_form.

start_form must end with end_form FM.

call function 'end_form'

**has no mandatiry parameters

write_form

this FM outputs the form elements specified in the parameter element.

call function 'write_form'

exporting

element = < > "pass the element to output

window = <> " specifies the output location

type = < > "specifies the position onn window

control_form

this FM is used for inserting script control command from program into script editor.

call function 'control_form'

exporting

command = < > 'here pass the control command.

Reward if it helps..

Regards,

Omkar.

Read only

Former Member
0 Likes
399

Hi

Function Modules Used in Script:

In the Driver Program we must use all or some of the function modules that are listed below to transfer the data.

• Open_Form

• Close_Form

• Start_Form

• Write_Form

• Write_Form_Lines

• End_Form

• Control_Form

• Read_Form_elements

• Read_Form_Lines

Any driver program must contain Open_Form, Close_Form and Write_Form. Other function modules are optional.

OPEN_FORM: This function module opens layout set printing. One must call this function module before he uses any of other layout set function modules like Write_Form, Start_Form, Control_Form etc., You need specify a layout set name in the export parameters of this function module. If nothing is passed to Open_Form then one should use Start_Form function module to open layout set before starting the output. The layout set opened by Open_Form should be closed by Close_Form function module, other wise output doesn’t appear. We can use any number of Open_Form, Close_Form functions in one single program. But Close_Form must be there for every Open_Form in the program.

Some of the important export parameters we have to pass to Open_Form function module.

Form: Enter the Layout set name here, which then controls the output formatting. If nothing is specified then we must use Start_Form for opening layout set.

Language: Layout sets are Language dependent. Enter the desired language here. If the entered layout set is not in that language, then the function tries to open the Form entered in its original language. The default value is SY-LANGU.

Device: SAP Script can format a text on different device types. The device can be ‘PRINTER’ or ‘TELEX’, ‘TELEFAX’, ’ABAP’ and ‘SCREEN’.

Dialog: Use parameter DIALOG to determine whether to display a dialog box before printing, in which the user can set several spool parameters for print formatting. Possible values: SPACE displays no print parameter screen. 'X' display print parameter screen. Default value: 'X'

Options: Use parameter OPTIONS to set several options for print formatting. The parameter has the structure ITCPO. The user can change some of the defined settings on the print control screen. The default value for Options is ‘ ‘. We will discuss about ITCPO structure in detail later.

Other Export, Import and Exceptions are self-explanatory.

Close_Form: The function module closes the layout set opened using OPEN_FORM. The system executes any terminating processing steps for the last opened layout set. No Export parameters for this Function Module.

Start_Form: In-between the function modules OPEN_FORM and CLOSE_FORM, we can use different layout sets. This allows us to combine several different layout sets into one print output. However, we can combine only those layout sets that have the same page format. To switch layout sets, use the function module START_FORM. If another layout set is still open, we must close it first using END_FORM. If we specify no layout set name when calling START_FORM, the system restarts the last open layout set. If after OPEN_FORM no layout set was activated yet, the system leaves the function module with the exception UNUSED. Some of the important export parameters for this function module are

Form: The parameter contains the name of the layout set you want to use for printing. If you specify no layout set here, the system restarts the last active layout set.

Language: Layout sets are language-dependent. Enter the desired language here. If the layout set does not exist in this language, the system tries to call the layout set in its original language. If the parameter LANGUAGE is empty, the system uses the language of the last active layout set.

Startpage: Usually, SAP script starts with the page specified as start page in the layout set definition. If we want to start output with another layout set page, enter the name of the desired layout set page here. If the desired page is not defined, the system uses the start page defined in the layout set.

Program: To replace program symbols, SAP script must know which active program contains the work areas for the values to be passed. If we omit the parameter, the system searches for the field values in the program that was specified in the parameter OPTIONS (field TDPROGRAM) of OPEN_FORM. If we enter a program name, the system replaces the program symbols with the values from this program up to the next END_FORM.

Exceptions and other Export, Import parameters are self-explanatory.

Write_Form: The system outputs the layout set element specified in parameter ELEMENT into the currently opened layout set. In the parameter WINDOW we can specify the name of a window for the output. Remember that the layout set element must be defined in this window. The parameter FUNCTION specifies how to merge the text lines to be output with any existing contents in the window. In this case, there are differences between the different window types or areas. Some of the important export parameters used in Write_Form.

Element: Specify the name of the text element you want to output into the layout set window specified in the parameter WINDOW. The element must be defined in that layout set window. If you specify no element, the system uses the default element, if one is defined in the layout set.

Window: Specify the name of the window into which you want to output the layout set element specified in the parameter ELEMENT. Default value for Window is ‘MAIN’.

Function: The parameter determines how to output the text element into the respective window. The output type depends on the window type and area:

Window Type: MAIN Area: BODY

SET/APPEND: Appends to previous output.

Window Type: Main Area: Top/Bottom and

Window Type: Other than Main and all areas

SET : Delete the old element contents and prints the new elements

APPEND: Appends the new content to existing elements.

Type: The system interprets this parameter only for output to the main window. The parameter determines the area of the main window into which we want to output the element. Possible values: 'TOP' header area

'BODY' main area

'BOTTOM' footer area

Default value: 'BODY'

Write_Form_Lines: This function module outputs the text lines in table LINES into the specified layout set window. The text lines must have the SAP script ITF format. From the data in the text header, the system uses only the field TDSTYLE to apply the formatting attributes defined in the specified style for this text. If the field is empty, the system uses the identically named formatting attributes (character and paragraph formats) of the layout set.

Use parameter WINDOW to specify into which of the windows defined in the layout set we want to output the text. We can specify any window used in the layout set. The parameter FUNCTION determines how to merge the text lines to be output with any existing contents in the window. There are differences between the different window types or areas.

Header: This parameter contains the header of the text module we want to output in the current layout set. For the formatting process, the system uses only the entries in the header fields TDSTYLE and TDFORM. Structure: THEAD

WINDOW: Enter the name of the window into which we want to output the layout set element specified in parameter ELEMENT. Default value: 'MAIN'

FUNCTION: This parameter determines how to output the text element into the respective window. The output type depends on the window type and area: Window type MAIN, area BODY: 'SET' append to previous output 'APPEND' same as SET. DELETE' no effect. Window type MAIN, areas TOP and BOTTOM; all other windows: 'SET' delete old window or area contents and output the element 'APPEND' append the element to the existing elements 'DELETE' no effect Default value: 'SET'

TYPE: The system interprets this parameter only for output to the main window. The parameter determines the area of the main window into which you want to output the element. Possible values: 'TOP' header area 'BODY' main area 'BOTTOM' footer area Default value: 'BODY'

END_FORM: END_FORM ends the currently open layout set and executes the required termination processing. After calling this function module, no more layout set is active. For further output, we must start a new layout set using START_FORM. No Export parameters.

CONTROL_FORM: Use this function module to pass SAP Script Control Commands to the layout set. The Control command is passed through the export parameter ‘COMMAND’ in quotes.

READ_FORM_ELEMENTS: This function module fills a table with all text elements that appear in one layout set. If we specify no layout set name, the system includes all elements of the currently open layout set. If we specify a layout set, the system uses the information about the active version of the layout set, retrieved from the database. Here we have two export parameters, Form and Language and a table parameter Elements.

READ_FORM_LINES: Use this function module to transfer the lines of a layout set element into an internal table. If we specify no layout set name, the system transfers the text lines of the currently open layout set. If we specify a layout set, the system uses the text lines of the active version of the layout set from the database. The Export parameters are Form, Language, Window and Element. If we pass these 4 parameters the function module returns a table with the lines from layout set.

<b>Reward points for useful Answers</b>

Regards

Anji

Read only

Former Member
0 Likes
399

Hi,

There are so many function modules involved for vrious activities.

Function Modules Used in Script:

In the Driver we must use all or some of the function modules that are listed below to transfer the data.

• Open_Form

• Close_Form

• Start_Form

• Write_Form

• Write_Form_Lines

• End_Form

• Control_Form

• Read_Form_elements

• Read_Form_Lines

Any driver program must contain Open_Form, Close_Form and Write_Form. Other function modules are optional.

OPEN_FORM: This function module opens layout set printing. One must call this function module before he uses any of other layout set function modules like Write_Form, Start_Form, Control_Form etc., You need specify a layout set name in the export parameters of this function module. If nothing is passed to Open_Form then one should use Start_Form function module to open layout set before starting the output. The layout set opened by Open_Form should be closed by Close_Form function module, other wise output doesn’t appear. We can use any number of Open_Form, Close_Form functions in one single program. But Close_Form must be there for every Open_Form in the program.

Some of the important export parameters we have to pass to Open_Form function module.

Form: Enter the Layout set name here, which then controls the output formatting. If nothing is specified then we must use Start_Form for opening layout set.

Language: Layout sets are Language dependent. Enter the desired language here. If the entered layout set is not in that language, then the function tries to open the Form entered in its original language. The default value is SY-LANGU.

Device: SAP Script can format a text on different device types. The device can be ‘PRINTER’ or ‘TELEX’, ‘TELEFAX’, ’ABAP’ and ‘SCREEN’.

Dialog: Use parameter DIALOG to determine whether to display a dialog box before printing, in which the user can set several spool parameters for print formatting. Possible values: SPACE displays no print parameter screen. 'X' display print parameter screen. Default value: 'X'

Options: Use parameter OPTIONS to set several options for print formatting. The parameter has the structure ITCPO. The user can change some of the defined settings on the print control screen. The default value for Options is ‘ ‘. We will discuss about ITCPO structure in detail later.

Other Export, Import and Exceptions are self-explanatory.

Close_Form: The function module closes the layout set opened using OPEN_FORM. The system executes any terminating processing steps for the last opened layout set. No Export parameters for this Function Module.

Start_Form: In-between the function modules OPEN_FORM and CLOSE_FORM, we can use different layout sets. This allows us to combine several different layout sets into one print output. However, we can combine only those layout sets that have the same page format. To switch layout sets, use the function module START_FORM. If another layout set is still open, we must close it first using END_FORM. If we specify no layout set name when calling START_FORM, the system restarts the last open layout set. If after OPEN_FORM no layout set was activated yet, the system leaves the function module with the exception UNUSED. Some of the important export parameters for this function module are

Form: The parameter contains the name of the layout set you want to use for printing. If you specify no layout set here, the system restarts the last active layout set.

Language: Layout sets are language-dependent. Enter the desired language here. If the layout set does not exist in this language, the system tries to call the layout set in its original language. If the parameter LANGUAGE is empty, the system uses the language of the last active layout set.

Startpage: Usually, SAP script starts with the page specified as start page in the layout set definition. If we want to start output with another layout set page, enter the name of the desired layout set page here. If the desired page is not defined, the system uses the start page defined in the layout set.

Program: To replace program symbols, SAP script must know which active program contains the work areas for the values to be passed. If we omit the parameter, the system searches for the field values in the program that was specified in the parameter OPTIONS (field TDPROGRAM) of OPEN_FORM. If we enter a program name, the system replaces the program symbols with the values from this program up to the next END_FORM.

Exceptions and other Export, Import parameters are self-explanatory.

Write_Form: The system outputs the layout set element specified in parameter ELEMENT into the currently opened layout set. In the parameter WINDOW we can specify the name of a window for the output. Remember that the layout set element must be defined in this window. The parameter FUNCTION specifies how to merge the text lines to be output with any existing contents in the window. In this case, there are differences between the different window types or areas. Some of the important export parameters used in Write_Form.

Element: Specify the name of the text element you want to output into the layout set window specified in the parameter WINDOW. The element must be defined in that layout set window. If you specify no element, the system uses the default element, if one is defined in the layout set.

Window: Specify the name of the window into which you want to output the layout set element specified in the parameter ELEMENT. Default value for Window is ‘MAIN’.

Function: The parameter determines how to output the text element into the respective window. The output type depends on the window type and area:

Window Type: MAIN Area: BODY

SET/APPEND: Appends to previous output.

Window Type: Main Area: Top/Bottom and

Window Type: Other than Main and all areas

SET : Delete the old element contents and prints the new elements

APPEND: Appends the new content to existing elements.

Type: The system interprets this parameter only for output to the main window. The parameter determines the area of the main window into which we want to output the element. Possible values: 'TOP' header area

'BODY' main area

'BOTTOM' footer area

Default value: 'BODY'

Write_Form_Lines: This function module outputs the text lines in table LINES into the specified layout set window. The text lines must have the SAP script ITF format. From the data in the text header, the system uses only the field TDSTYLE to apply the formatting attributes defined in the specified style for this text. If the field is empty, the system uses the identically named formatting attributes (character and paragraph formats) of the layout set.

Use parameter WINDOW to specify into which of the windows defined in the layout set we want to output the text. We can specify any window used in the layout set. The parameter FUNCTION determines how to merge the text lines to be output with any existing contents in the window. There are differences between the different window types or areas.

Header: This parameter contains the header of the text module we want to output in the current layout set. For the formatting process, the system uses only the entries in the header fields TDSTYLE and TDFORM. Structure: THEAD

WINDOW: Enter the name of the window into which we want to output the layout set element specified in parameter ELEMENT. Default value: 'MAIN'

FUNCTION: This parameter determines how to output the text element into the respective window. The output type depends on the window type and area: Window type MAIN, area BODY: 'SET' append to previous output 'APPEND' same as SET. DELETE' no effect. Window type MAIN, areas TOP and BOTTOM; all other windows: 'SET' delete old window or area contents and output the element 'APPEND' append the element to the existing elements 'DELETE' no effect Default value: 'SET'

TYPE: The system interprets this parameter only for output to the main window. The parameter determines the area of the main window into which you want to output the element. Possible values: 'TOP' header area 'BODY' main area 'BOTTOM' footer area Default value: 'BODY'

END_FORM: END_FORM ends the currently open layout set and executes the required termination processing. After calling this function module, no more layout set is active. For further output, we must start a new layout set using START_FORM. No Export parameters.

CONTROL_FORM: Use this function module to pass SAP Script Control Commands to the layout set. The Control command is passed through the export parameter ‘COMMAND’ in quotes.

READ_FORM_ELEMENTS: This function module fills a table with all text elements that appear in one layout set. If we specify no layout set name, the system includes all elements of the currently open layout set. If we specify a layout set, the system uses the information about the active version of the layout set, retrieved from the database. Here we have two export parameters, Form and Language and a table parameter Elements.

READ_FORM_LINES: Use this function module to transfer the lines of a layout set element into an internal table. If we specify no layout set name, the system transfers the text lines of the currently open layout set. If we specify a layout set, the system uses the text lines of the active version of the layout set from the database. The Export parameters are Form, Language, Window and Element. If we pass these 4 parameters the function module returns a table with the lines from layout set.

Lookat http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCSRVSCRPROG/BCSRVSCRPROG.pdf

SAPscript Function Modules...................................................................................................153

READ_TEXT..............................................................................................................................156

READ_TEXT_INLINE.................................................................................................................159

READ_REFERENCE_LINES.....................................................................................................162

SAVE_TEXT...............................................................................................................................164

DELETE_TEXT...........................................................................................................................167

COPY_TEXTS............................................................................................................................169

SELECT_TEXT...........................................................................................................................171

REFER_TEXT............................................................................................................................174

RENAME_TEXT..........................................................................................................................177

COMMIT_TEXT...........................................................................................................................178

INIT_TEXT..................................................................................................................................180

EDIT_TEXT................................................................................................................................182

EDIT_TEXT_INLINE...................................................................................................................186

CHECK_TEXT_AUTHORITY.....................................................................................................190

CHECK_TEXT_ID.......................................................................................................................192

CHECK_TEXT_LANGUAGE......................................................................................................193

CHECK_TEXT_OBJECT............................................................................................................194

CHECK_TEXT_NAME................................................................................................................195

TEXT_SYMBOL_COLLECT.......................................................................................................196

TEXT_SYMBOL_PARSE...........................................................................................................197

TEXT_SYMBOL_REPLACE.......................................................................................................202

TEXT_SYMBOL_SETVALUE.....................................................................................................205

TEXT_CONTROL_REPLACE....................................................................................................206

TEXT_INCLUDE_REPLACE......................................................................................................208

PRINT_TEXT.............................................................................................................................210

PRINT_TEXT_ITF.......................................................................................................................215

OPEN_FORM.............................................................................................................................217

CLOSE_FORM...........................................................................................................................221

START_FORM...........................................................................................................................223

WRITE_FORM...........................................................................................................................226

WRITE_FORM_LINES................................................................................................................230

END_FORM...............................................................................................................................233

CONTROL_FORM......................................................................................................................234

READ_FORM_ELEMENTS........................................................................................................235

READ_FORM_LINES.................................................................................................................237

CONVERT_TEXT........................................................................................................................239

EXCHANGE_ITF.........................................................................................................................243

IMPORT_TEXT...........................................................................................................................245

EXPORT_TEXT..........................................................................................................................248

TRANSFER_TEXT......................................................................................................................252

CONVERT_TEXT_R2.................................................................................................................254

CONVERT_OTF_MEMORY.......................................................................................................

Regards,

Padmam.