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

write form and Control form

Former Member
0 Likes
2,239

Hi SAP Gurus,

In scripts what is the difference between write form and Control form .

plz tell me.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
888

Hi Durga,

Write form is manditory for scripts. You have to pass the window like main or address or signature etc....

Control form is for pass the control parameters like

suppose if you want to print the paragraph with out any seperated by page break then we will use PROTECT and ENDPROTECT.

These command we have to pass to control form.

HOPE THIS WILL HELP YOU..

Regards,

Kumar

3 REPLIES 3
Read only

Former Member
0 Likes
889

Hi Durga,

Write form is manditory for scripts. You have to pass the window like main or address or signature etc....

Control form is for pass the control parameters like

suppose if you want to print the paragraph with out any seperated by page break then we will use PROTECT and ENDPROTECT.

These command we have to pass to control form.

HOPE THIS WILL HELP YOU..

Regards,

Kumar

Read only

Former Member
0 Likes
888

hi,

Please see ..

CONTROL_FORM

Use CONTROL_FORM to pass SAPscript control statements to the layout set.

Function call:

CALL FUNCTION 'CONTROL_FORM'

EXPORTING COMMAND = ?...

EXCEPTIONS UNOPENED =

UNSTARTED =

Export parameters:

COMMAND Enter the SAPscript statement you want to execute in ITF format, but without the statement paragraph attribute '/:'.

Exceptions:

UNOPENED The current layout set function could not be executed, since the layout set output was no yet initialized using OPEN_FORM.

UNSTARTED No layout set was opened yet.Possible reasons:

• The layout set processing was started using OPEN_FORM without specifying a layout set name, but no layout set was opened yet using START_FORM.

• The last used layout set was closed using END_FORM, but no new layout set was opened using START_FORM.

• The last filled page of the current layout set has no subsequent page. In this case, the system automatically terminates layout set printing after this page. You need no explicit END_FORM call.

• In the current layout set, no page contains a main window, but a text element shall be output in the main window.

***************************************************

SAPscript Control Commands

The functionality of the SAPscript editor is made available through a set of commands which the user selects either from the menu or via the function (F-) keys. These commands give you full editing control over your text. They are executed immediately when called.

There is, however, another kind of SAPscript command, namely the control commands. The purpose of these is to allow control of the output formatting. These commands are not interpreted by the SAPscript editor, but are passed through to the SAPscript Composer for processing.

The Composer is the program that converts text from the form displayed in the editor to the form used for printing. This includes, for example, line and page formatting, the replacement of symbols with their current values and the formatting of text according to the paragraph and character formats specified.

The SAPscript control commands are described in the following sections.

The Syntax of Control Commands

Explicit Page Break: NEW-PAGE

Preventing Page Breaks: PROTECT

Next Main Window: NEW-WINDOW

Assigning a Value to a Text Symbol: DEFINE

Formatting Date Fields: SET DATE MASK

Formatting Time Fields: SET TIME MASK

Country-Dependent Formatting: SET COUNTRY

Position of the Leading Sign: SET SIGN

Initializing Numbered Paragraphs: RESET

Including Other Texts: INCLUDE

Changing the Style: STYLE

Formatting Addresses: ADDRESS

Setting a Header Text in the Main Window: TOP

Setting a Footer Text in the Main Window: BOTTOM

Conditional Text: IF

The CASE command

Calling ABAP/4 Subroutines: PERFORM

Inserting Print Controls: PRINT-CONTROL

Boxes, Lines, Shading: BOX, POSITION, SIZE

Hexadecimal Data: HEX, ENDHEX

Summing a Program Symbol: SUMMING

The Syntax of Control Commands

SAPscript control commands are entered and edited in the text editor in the same way as a normal line of text. They do, however, differ from normal lines of text in respect to the following points:

• The paragraph format /: must be entered in the format column to identify a control command.

• You enter the command itself in the text line. You will notice that all key words and other parts of the specification not given as literal values enclosed in apostrophe characters are automatically converted to capital letters.

• A control command, together with any parameters it requires, may not occupy more than a single line.

• A maximum of one control command may appear in each line.

• The editor formatting has no effect on lines containing control commands.

Syntax:

/: NEW-PAGE [page_name]

/: NEW-PAGE

The current page will be completed and the text in the following lines will be written to the page specified in the layout set.

/: NEW-PAGE S1

As above, except that the page S1 will taken as the next page.

• If a page not contained in the layout set is specified in a NEW-PAGE command then this specification is ignored.

• You should take care that there is not an blank line immediately before a NEW-PAGE command. This would serve no useful purpose and may lead to an unexpected blank page being printed. This would happen if an implicit page break would normally occur within the blank line.

***********************

Here is the sample code for write_form

REPORT ZPSAPSCRIPT.

TABLES : EKKO,

EKPO,

KNA1,

USR01,

MARA,

MAKT.

DATA : BEGIN OF ZOPTION.

INCLUDE STRUCTURE ITCPO.

DATA : END OF ZOPTION.

PARAMETERS: P_EBELN LIKE EKKO-EBELN,

P_EBELP LIKE EKPO-EBELP.

CLEAR EKPO.

SELECT SINGLE * FROM EKPO

WHERE EBELN = P_EBELN AND

EBELP = P_EBELP.

CLEAR KNA1.

SELECT SINGLE NAME1 FROM KNA1

INTO KNA1-NAME1

WHERE KUNNR = EKPO-KUNNR.

CLEAR MAKT.

SELECT SINGLE MAKTX FROM MAKT

INTO MAKT-MAKTX

WHERE MATNR = EKPO-MATNR AND

SPRAS = SY-LANGU.

CLEAR USR01.

SELECT SINGLE * FROM USR01 WHERE BNAME = SY-UNAME.

ZOPTION-TDDEST = USR01-SPLD. "Output device (printer)

ZOPTION-TDIMMED = 'X'. "Print immediately

ZOPTION-TDDELETE = 'X'. "Delete after printing

ZOPTION-TDPROGRAM = 'ZPQRPRNT'. "Program Name

CALL FUNCTION 'OPEN_FORM'

EXPORTING

APPLICATION = 'TX'

  • ARCHIVE_INDEX = ' '

  • ARCHIVE_PARAMS = ' '

DEVICE = 'PRINTER'

DIALOG = ' '

FORM = 'Z_TESTSCRIPT'

LANGUAGE = SY-LANGU

OPTIONS = ZOPTION

IMPORTING

LANGUAGE = SY-LANGU

EXCEPTIONS

OTHERS = 1.

CALL FUNCTION 'WRITE_FORM'

EXPORTING

ELEMENT = 'HEADER'

  • FUNCTION = 'SET'

  • TYPE = 'BODY'

WINDOW = 'HEADER'

EXCEPTIONS

ELEMENT = 1.

CALL FUNCTION 'WRITE_FORM'

EXPORTING

ELEMENT = 'MAIN'

  • FUNCTION = 'SET'

  • TYPE = 'BODY'

WINDOW = 'MAIN'

EXCEPTIONS

ELEMENT = 1.

CALL FUNCTION 'WRITE_FORM'

EXPORTING

ELEMENT = 'FOOTER'

  • FUNCTION = 'SET'

  • TYPE = 'BODY'

WINDOW = 'FOOTER'

EXCEPTIONS

ELEMENT = 1.

CALL FUNCTION 'CLOSE_FORM'

EXCEPTIONS

UNOPENED = 1

OTHERS = 2.

*********************************

Form functions

OPEN_FORM Opens the form output

WRITE_FORM Calls a form element

CLOSE_FORM Ends the form output

START_FORM Starts a new form

Regds

Sivaparvathi

Please reward points if helpful......

Read only

Former Member
0 Likes
888

Hi,

Control form output directly using a Smart Form, you can pass other parameters at the interface of the Smart Form, depending on the output format. SAP Smart Forms then forwards these parameters to the appropriate output interface (for example, for e-mail).

Output Depending on the Output Format

OTF

Passed to spool processing (default)

Sent as fax or in an e-mail

Archiving the form

Returned as table in the application program

XSF

Passed to spool processing (default)

Returned as table in the application program (see also: Dynamically Activating XSF Output)

HTML

Returned as table in the application program

XDF

Passed to spool processing

Best Regards,

Rajesh

Please reward points if found helpful.