Application Development 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: 

how many types of forms are there in sap scripts

aarif_baig
Active Participant
1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

Script contains the following forms:

Open_Form

Close_Form

Start_Form

Write_Form

End_form

Control_Form

<u><b>In Addition:</b></u>

Write_Form_Lines

Read_Form_Elements

Read_Form_Lines

are available. Details of each one is in the following below:

<u><b>OPEN_FORM</b></u>

The function module OPEN_FORM opens form printing. You must call this function module before you can use any other form function (WRITE_FORM, START_FORM, CONTROL_FORM...).

You need not specify a form name. If you omit the name, you must use the function module START_FORM to open a form before starting the output.

You must end form printing by using the function module CLOSE_FORM. Otherwise, the system does not print or display anything.

Within a program, you can use several OPEN_FORM.. CLOSE_FORM pairs. This allows you to write output to several different spool requests from within one program.

<u><b>CLOSE_FORM</b></u>

The function module closes the form opened using OPEN_FORM. The system executes any terminating processing steps for the last opened form.

You must use this function module to close form printing. Otherwise, no output appears on printer or screen.

<u><b>START_FORM</b></u>

In-between the function modules OPEN_FORM and CLOSE_FORM, you can use different forms. This allows you to combine several different forms into one print output. However, you can combine only those forms that have the same page format.

To switch forms, use the function module START_FORM. If another form is still open, you must close it first using END_FORM.

If you specify no form name when calling START_FORM, the system restarts the last open form. If after OPEN_FORM no form was activated yet, the system leaves the function module with the exception UNUSED.

<u><b>WRITE_FORM</b></u>

The system outputs the form element specified in parameter ELEMENT into the currently opened form.

In the parameter WINDOW you can specify the name of a window for the output. Remember that the form 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.

<u><b>WRITE_FORM_LINES</b></u>

The function module outputs the text lines in table LINES into the specified form window. The text lines must have the SAPscript 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 form.

Use parameter WINDOW to specify into which of the windows defined in the form you want to output the text. You can specify any window used in the form. 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.

<u><b>END_FORM</b></u>

END_FORM ends the currently open form and executes the required termination processing. After calling this function module, no more form is active. For further output, you must start a new form using START_FORM.

<u><b>CONTROL_FORM</b></u>

Use CONTROL_FORM to pass SAPscript control statements to the form.

<u><b>READ_FORM_ELEMENTS</b></u>

The function module fills a table with all text elements that appear in one form.

If you specify no form name, the system includes all elements of the currently open form. If you specify a form, the system uses the information about the active version of the form, retrieved from the database.

<u><b>READ_FORM_LINES</b></u>

Use this function module to transfer the lines of a form element into an internal table.

If you specify no form name, the system transfers the text lines of the currently open form. If you specify a form, the system uses the text lines of the active version of the form from the database.

Regards,

Bhaskar

5 REPLIES 5

Former Member
0 Kudos

Could you please explain you question in detail...

Thanks

Srinivas

Former Member
0 Kudos

HI,

this is the sequence of the calls..

when you want to call a layout from your layout then use start_form/end_form to end.these calls should be in side open_form and close_form.

open_form.

start_form.

end_form.

close_form.

Regards

Former Member
0 Kudos

Hi,

These are the 3 function modules which are essential to print the output from a program related to Script

In the Open form we pass the Script name that should be called/triggered from the driver program

Write_form is used to write the data in the respective window and text element

Close_form is used to close the script form .

see the doc

Structure of a print program

OPEN_FORM function

CLOSE_FORM function

WRITE_FORM

START_FORM function

END_FORM function

CONTROL_FORM function

The print program is used to print forms. The program retieves the necesary data from datbase tables, defines the order of in which text elements are printed, chooses a form for printing and selects an output device and print options.

Function modules in a printprogram:

• When you print a form you must used the staments OPEN_FORM and CLOSE_FORM. To combine forms into a single spool request use START_FORM and END_FORM.

• To print textelements in a form use WRITE_FORM. The order in which the textelements are printed, is determined by the order of the WRITE_FORM statements. Note: for printing lines in the body, you can also use the WRITE_FORM_LINES function module.

• To transfer control command to a form use CONTROL_FORM.

Structure of a print program

  • Read data

Tables: xxx.

SELECT *

FROM xxx.

  • Open form printing - Must be called before working with any of the other form function modules.

  • Must be ended with function module CLOSE FORM

call function 'OPEN_FORM'.....

  • To begin several indentical forms containing different data within a single spool request, begin each form using START_FORM, and end it using END_FORM

call funtion 'START_FORM'.....

  • Write text elements to a window of the form

call function 'WRITE_FORM'.....

  • Ends spool request started with START_FORM

call funtion 'END_FORM'.....

  • Closes form printing

call function 'CLOSE_FORM'...

OPEN_FORM function

Syntax:

CALL FUNCTION 'OPEN_FORM'

  • EXPORTING

  • APPLICATION = 'TX'

  • ARCHIVE_INDEX =

  • ARCHIVE_PARAMS =

  • DEVICE = 'PRINTER'

  • DIALOG = 'X'

  • FORM = ' '

  • LANGUAGE = SY-LANGU

  • OPTIONS =

  • MAIL_SENDER =

  • MAIL_RECIPIENT =

  • MAIL_APPL_OBJECT =

  • RAW_DATA_INTERFACE = '*'

  • IMPORTING

  • LANGUAGE =

  • NEW_ARCHIVE_PARAMS =

  • RESULT =

  • EXCEPTIONS

  • CANCELED = 1

  • DEVICE = 2

  • FORM = 3

  • OPTIONS = 4

  • UNCLOSED = 5

  • MAIL_OPTIONS = 6

  • ARCHIVE_ERROR = 7

  • INVALID_FAX_NUMBER = 8

  • MORE_PARAMS_NEEDED_IN_BATCH = 9

  • SPOOL_ERROR = 10

  • OTHERS = 11

.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

Some important parameters:

FORM Name of the form

DEVICE • PRINTER : Print output using spool

• TELEFAX: Fax output

• SCREEN: Output to screen

OPTIONS Used to control attrubutes for printing or faxing (Number of copies, immediate output....

The input for the parameter is structure ITCPO.

CLOSE_FORM function

CALL FUNCTION 'CLOSE_FORM'

  • IMPORTING

  • RESULT =

  • RDI_RESULT =

  • TABLES

  • OTFDATA =

  • EXCEPTIONS

  • UNOPENED = 1

  • BAD_PAGEFORMAT_FOR_PRINT = 2

  • SEND_ERROR = 3

  • SPOOL_ERROR = 4

  • OTHERS = 5

.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

Paramerters:

RESULT Returns status information and print/fax parameters after the form has been printed. RESULT is of structure ITCPP.

WRITE_FORM function

CALL FUNCTION 'WRITE_FORM'

  • EXPORTING

  • ELEMENT = ' '

  • FUNCTION = 'SET'

  • TYPE = 'BODY'

  • WINDOW = 'MAIN'

  • IMPORTING

  • PENDING_LINES =

  • EXCEPTIONS

  • ELEMENT = 1

  • FUNCTION = 2

  • TYPE = 3

  • UNOPENED = 4

  • UNSTARTED = 5

  • WINDOW = 6

  • BAD_PAGEFORMAT_FOR_PRINT = 7

  • SPOOL_ERROR = 8

  • OTHERS = 9

.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

Some important parameters:

ELEMENT Specifies which textelement is printed

WINDOW Specifies which window is printed

TYPE Specifies the output area of the main window. This can be:

• TOP - Used for headers

• BODY

• BOTTOM - Used for footers

FUNCTION Specifies whether text is to be appended, replaced or added

Example of how to use the WRITE_FORM function module together with a script.

Form layout of the MAIN window

/E INTRODUCTION

  • Dear Customer

...........................

/E ITEM_HEADER

IH Carrier, Departure

/E ITEM_LINE

IL &SBOOK-CARRID&, &SPFLI-DEPTIME&

/E CLOSING_REMARK

The print program

  • Writing INTRODUCTION

CALL FUNCTION 'WRITE_FORM'

EXPORTING

ELEMENT = 'INTRODUCTION'

FUNCTION = 'SET'

TYPE = 'BODY'

WINDOW = 'MAIN'

EXCEPTIONS

OTHERS = 8

.

  • Writing ITEM_HEADER

CALL FUNCTION 'WRITE_FORM'

EXPORTING

ELEMENT = 'ITEM_HEADER'

FUNCTION = 'SET'

TYPE = 'BODY'

WINDOW = 'MAIN'

EXCEPTIONS

OTHERS = 8

.

  • Set ITEM_HEADER into TOP area of main window for subsequent pages

CALL FUNCTION 'WRITE_FORM'

EXPORTING

ELEMENT = 'ITEM_HEADER'

FUNCTION = 'SET'

TYPE = 'TOP'

WINDOW = 'MAIN'

EXCEPTIONS

OTHERS = 8

  • Write ITEM_LINE

LOOP AT .....

CALL FUNCTION 'WRITE_FORM'

EXPORTING

ELEMENT = 'ITEM_LINE'

FUNCTION = 'SET'

TYPE = 'BODY'

WINDOW = 'MAIN'

EXCEPTIONS

OTHERS = 8.

ENDLOOP.

  • Delete ITEM_HEADER from TOP area of main window

CALL FUNCTION 'WRITE_FORM'

EXPORTING

ELEMENT = 'ITEM_HEADER'

FUNCTION = 'DELETE'

TYPE = 'TOP'

WINDOW = 'MAIN'

EXCEPTIONS

OTHERS = 8

  • Print CLOSING_REMARK

CALL FUNCTION 'WRITE_FORM'

EXPORTING

ELEMENT = 'CLOSING_REMARK'

FUNCTION = 'SET'

TYPE = 'BODY'

WINDOW = 'MAIN'

EXCEPTIONS

OTHERS = 8

START_FORM function

CALL FUNCTION 'START_FORM'

  • EXPORTING

  • ARCHIVE_INDEX =

  • FORM = ' '

  • LANGUAGE = ' '

  • STARTPAGE = ' '

  • PROGRAM = ' '

  • MAIL_APPL_OBJECT =

  • IMPORTING

  • LANGUAGE =

  • EXCEPTIONS

  • FORM = 1

  • FORMAT = 2

  • UNENDED = 3

  • UNOPENED = 4

  • UNUSED = 5

  • SPOOL_ERROR = 6

  • OTHERS = 7

.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

END_FORM function

CALL FUNCTION 'END_FORM'

  • IMPORTING

  • RESULT =

  • EXCEPTIONS

  • UNOPENED = 1

  • BAD_PAGEFORMAT_FOR_PRINT = 2

  • SPOOL_ERROR = 3

  • OTHERS = 4

.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

CONTROL_FORM function

The CONTROL_FORM function module alows you to create SapScript control statements from within an APAB program.

Syntax:

CALL FUNCTION 'CONTROL_FORM'

EXPORTING

command =

  • EXCEPTIONS

  • UNOPENED = 1

  • UNSTARTED = 2

  • OTHERS = 3

.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

Example:

Protecting the text element ITEM_LINE

CALL FUNCTION 'CONTROL_FORM'

EXPORTING

COMMAND = 'PROTECT'.

CALL FUNCTION 'WRITE_FORM'

EXPORTING

TEXELEMENT = 'ITEM_LINE'.

CALL FUNCTION 'CONTROL_FORM'

EXPORTING

COMMAND = 'ENDPROTECT'.

Refer the threads-

Regards,

Priyanka.

Former Member
0 Kudos

Hi,

Open_form => It assign the form and printer, It should be first.

Start_form => It start Writing mode. You can use write_form in loop to write more than one lines befor End_form.

End_form => It end writing mode of current page and will require to start again through Start_form.

Close_form=> it end the Form. After this you can not start again for created file.

Write_form, write_form_lines.

Control_form => To output data( this can be used as many times between OPEN_FORM and CLOSE_FORM)

<b>Regards,

Jackie.</b>

Former Member
0 Kudos

Hi,

Script contains the following forms:

Open_Form

Close_Form

Start_Form

Write_Form

End_form

Control_Form

<u><b>In Addition:</b></u>

Write_Form_Lines

Read_Form_Elements

Read_Form_Lines

are available. Details of each one is in the following below:

<u><b>OPEN_FORM</b></u>

The function module OPEN_FORM opens form printing. You must call this function module before you can use any other form function (WRITE_FORM, START_FORM, CONTROL_FORM...).

You need not specify a form name. If you omit the name, you must use the function module START_FORM to open a form before starting the output.

You must end form printing by using the function module CLOSE_FORM. Otherwise, the system does not print or display anything.

Within a program, you can use several OPEN_FORM.. CLOSE_FORM pairs. This allows you to write output to several different spool requests from within one program.

<u><b>CLOSE_FORM</b></u>

The function module closes the form opened using OPEN_FORM. The system executes any terminating processing steps for the last opened form.

You must use this function module to close form printing. Otherwise, no output appears on printer or screen.

<u><b>START_FORM</b></u>

In-between the function modules OPEN_FORM and CLOSE_FORM, you can use different forms. This allows you to combine several different forms into one print output. However, you can combine only those forms that have the same page format.

To switch forms, use the function module START_FORM. If another form is still open, you must close it first using END_FORM.

If you specify no form name when calling START_FORM, the system restarts the last open form. If after OPEN_FORM no form was activated yet, the system leaves the function module with the exception UNUSED.

<u><b>WRITE_FORM</b></u>

The system outputs the form element specified in parameter ELEMENT into the currently opened form.

In the parameter WINDOW you can specify the name of a window for the output. Remember that the form 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.

<u><b>WRITE_FORM_LINES</b></u>

The function module outputs the text lines in table LINES into the specified form window. The text lines must have the SAPscript 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 form.

Use parameter WINDOW to specify into which of the windows defined in the form you want to output the text. You can specify any window used in the form. 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.

<u><b>END_FORM</b></u>

END_FORM ends the currently open form and executes the required termination processing. After calling this function module, no more form is active. For further output, you must start a new form using START_FORM.

<u><b>CONTROL_FORM</b></u>

Use CONTROL_FORM to pass SAPscript control statements to the form.

<u><b>READ_FORM_ELEMENTS</b></u>

The function module fills a table with all text elements that appear in one form.

If you specify no form name, the system includes all elements of the currently open form. If you specify a form, the system uses the information about the active version of the form, retrieved from the database.

<u><b>READ_FORM_LINES</b></u>

Use this function module to transfer the lines of a form element into an internal table.

If you specify no form name, the system transfers the text lines of the currently open form. If you specify a form, the system uses the text lines of the active version of the form from the database.

Regards,

Bhaskar