Skip to end of metadata
Go to start of metadata

Definition of basic elements

How can I insert symbols in Smart Forms?

Select the Text node.
Change Editor (Click the button above Check near the Editor)
Go to menu Include->Characters->SAP Symbols
Choose the SAP symbol that you want to insert.

How can I display the total number of pages in Smart Forms?

Use SFSY-FORMPAGES to display the total number of pages in the Smart Forms

&SFSY-PAGE&

Current page number

&SFSY-FORMPAGES&

Total number of pages in the currently formatted layout set

&SFSY-JOBPAGES&

Total number of pages in the currently formatted print request

What SFSY system fields are available?

Within a form you can use the field string SFSY with its system fields. During form processing the system replaces these fields with the corresponding values. The field values come from the SAP System or are results of the processing.

See SAP Library - Smart Forms - System Fields

&SFSY-COPYCOUNT&

Original-1, first copy-2

&SFSY-DATE&

Displays the date, you determine the display format in the user master record

&SFSY-TIME&

Displays the time of day in the form HH:MM:SS

&SFSY-USERNAME&

Username

&SFSY-WINDOWNAME&

Contains the name of the current window (string in the Window field)

&SFSY-PAGE&

Inserts the number of the current print page into the text. You determine the format of the page number (for example, Arabic, numeric) in the page node

&SFSY-FORMPAGES&

Displays the total number of pages for the currently processed form. This allows you to include texts such as' Page x of y' into your output

&SFSY-JOBPAGES&

Contains the total page number of all forms in the currently processed print request

&SFSY-PAGENAME&

Contains the name of the current page (string in the Page field)

&SFSY-PAGEBREAK&

Is set to 'X' after a page break

&SFSY-MAINEND&

Is set as soon as processing of the main window on the current page ends

&SFSY-EXCEPTION&

Contains the name of the raised exception. You must trigger your own exceptions, which you defined in the form interface, using the user exception macro (syntax: user exception <exception name >)

etc.

Why SFSY-FORMPAGES is output as a star "*" instead of the total number of pages?

There may not be enough space in the window to display the variable, either increase the window dimensions or condense the spaces using &SFSY-FORMPAGES(3CZ)&, or change the window type to Final.

What are the various text formatting options in Smart Forms?

It's using the SAPscript technology so it's unchanged. For more information, see sap library - sapscript - formatting options.

&symbol(Z)&

Omit Leading Zeros

&symbol(S)&

Omit Leading Sign

&symbol(<)&

Display Leading Sign to the Left

&symbol(>)&

Display Leading Sign to the Right

&symbol(C)&

Compress Spaces

&symbol(.N)&

Display upto N decimal places

&symbol(T)&

Omit thousands separator

&symbol(R)&

Right justified

&symbol(I)&

Suppress output of the initial value

How can I provide a background shading to the table?

In the Table Painter, you can specify the color and shading for the table lines.

How to avoid an element to be printed on 2 pages?

To define Page Protect for a node go to the Output options and check the Page Protection checkbox.

What is the difference between Template and Table in Smart Forms?

The Template contains a fixed number of rows and columns, where the output is fixed.
The Table can have variable number of rows.

Where can I define the paragraph and character format for the Smart Forms?

The paragraph and character format for the Smart Forms can be defined in the transaction SMARTSTYLES

How to print a watermark?

See Background pictures in Smart Forms.

How to print barcodes?

You may use either the old barcode technology which works exactly the same way as for SAPscript forms, or the new barcode technology which is only available for Smart Forms.

How is a currency code variable associated to an amount variable?

See How currency code is determined in Smart Forms for a given amount field

How to draw a single line?

  • Either you can use a window that takes up the width of your page and only has a height of 1 mm. Then you put a frame around it (in window output options). Thus you have drawn a box but it looks like a line.
  • Or you can just draw "__" across the page and play with the fonts so that it joins each UNDER_SCORE.

How to print Double sided?

Your customer wants your PO Smart Form to be able to print "Terms and Conditions" on the back side of each page. They don't want to purchase pre-printed forms with the company's logo on the front and terms & conditions on the back.
If for example there was a 3 page PO to be printed, they want 3 pieces of paper, the front side of each to contains the PO information (page 1, 2, and 3) and the back side of each piece of paper to containing the static "Terms & Conditions" information.
This can be done by this method: - page FRONT lists page CONTACTS as next page and CONTACTS lists FRONT as next page. Since CONTACTS does not contain a MAIN window, it will print the contacts info and then continue on to FRONT for the rest of the main items. Additionally, set print mode on FRONT to D (duplex) and set CONTACTS to 'blank' (for both resource name and print mode - this is the only way to get to the back of the page).

Definition of the logic

Where can I provide the input parameters to the Smart Form?

The input parameters for the Smart Form can be defined in Global Settings->Form Interface.
(warning) The Associated Type must be defined in the ABAP Dictionary.

Where can I define my own global types for the Smart Form?

The global types (within the Smart Form) can be defined in Global Settings->Global Definitions->Types
The types defined here will be global through the entire Smart Form.
Also the form routines can be defined Global Settings->Global Definitions->Form Routines

Though I declared a global variable, why do I get error variable is not defined?

Whenever using the global variables in the Program Lines, you must enter the variable name in Input Parameters of the if you are going to use/read the variable. If you are going to both read/write the variable, enter the same in Output Parameters.

I have created a table node for display. Where can I check the condition which must satisfy to display the table?

The conditions can be defined in the Conditions tab. In Smart Forms all the nodes have a condition tab where you can specify the condition to be satisfied to access the node.

How to force a page break within a table?

Put a Command node inside the table that forces a NEWPAGE on whatever condition you want.

How to protect lines against page break?

  • You can protect a table line type
    • Double-click on the Table node and choose the Table tab page, then switch to the Detail view by choosing the Details pushbutton.
    • Set the Protection against page break checkbox in the table for the relevant line type. Table lines that use this line type are output on one page.
  • You can protect several table line types
    • Expand the main area of your table node in the navigation tree.
    • Insert a Folder node for the table lines to be protected in the main area.
    • If you have already created table lines in the main area, you can put the lines that you want to protect again page break under the Folder using Drag Drop. Otherwise, create the table lines as sub nodes of the Folder.
    • Choose the Output Options tab page of the Folder node and set the Page Protection option. All table lines that are in the Folder with the Page Protection option set are output on one page.
  • The "protection" checkbox can be checked in a Text node which is inside a window or folder, but it can't be checked if it's inside a table node (only possible to protect at line type level, see above) or inside a template node (a template is always protected)
  • The "protection" checkbox can be checked in any Folder node except the ones inside a Table Line Type node (but you can define a protected folder node in a table above table line type nodes)
  • alternatively in a paragraph format use the Page protection attribute to determine whether or not to display a paragraph completely on one page. Mark it if you want to avoid that a paragraph is split up by a page break. If on the current page (only in the main window) there is not enough space left for the paragraph, the entire paragraph appears on the next page.

Execution of Smart forms

How can I make the Smart Forms to choose a printer name by default?

In the CALL FUNCTION of the Smart Form Function Module, set the output options parameter to set the printer name.

The output options is of the type SSFCOMPOP which contains the field TDDEST. Set the TDDEST field to your default printer name.

How can I make the Smart Forms to display a print preview by default without displaying the popup for print parameters?

In the SSF_OPEN function module,
Set the OUTPUT OPTIONS paramter TDDEST to your printer name.
Set the CONTROL PARAMETERS and control parameters as shown below,

control-preview = 'X'.
control-no_open = 'X'.
control-no_close = 'X'.
control-no_dialog = 'X'.
control-device = 'PRINTER'.
control_parameters-no_dialog = 'X'.
control_parameters-no_open = 'X'.
control_parameters-no_close = 'X'.
OUTPUT_OPTIONS-TDDEST = 'PRINTER NAME'.
OUTPUT_OPTIONS-TDNOPRINT = 'X'.

CALL FUNCTION 'SSF_OPEN'
  EXPORTING
    output_options     = output_options
    control_parameters = control
    user_settings      = ' '
  EXCEPTIONS
    formatting_error   = 1
    internal_error     = 2
    send_error         = 3
    user_canceled      = 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.

How to debug Smart Forms?

  • By executing the Smart Form in test mode, the function module editor is displayed, and then you may set break-points (do not add neither BREAK-POINT statement nor BREAK as it pollutes the code, and sometimes it is forgotten to be removed).
    • If you want to debug a particular Smart Form node, insert a "Program Line" node just above, where you enter BREAK yourUserName statement.
  • You may also run SFTRACE transaction (or SMARTFORM_TRACE in releases before 6.10) to generate a log and activate break-points when abnormal events occur. For more information, see SAP Library - Smart Form Trace.
  • If you don't know the smart form name, you may add a break point in SSF_FUNCTION_MODULE_NAME function module to get the name.
  • In some situations, break-points many not be reached, in that case read this wiki: ABAP Debugger.

How to get the Smart Form as a PDF?

If you don't want to generate the spool, When you call the smart form, you can request to get the OTF data (GETOTF field of CONTROL_PARAMETERS parameter), then you convert the OTF data using CONVERT_OTF function module.
Or you can call RSTXPDFT4 and enter the spool number.

Why there seem to be a difference in the output of characters per inch?

(the distance between characters - text in two lines instead of one)

It happens when the two printers having different Printer Controls' if you go to SPAD Menu (Spool Administrator Menu) you can see the difference in the Printer Control and if you make the Printer control setting for both the printers as same.

Administration, transport, migration, ...

Why my Smart Form dumps after transporting it to PROD?

It works fine in DEV. After transporting it to PROD, there is no Function module generated for this Smart Form.

The Smart Form that is created in the Development may not have the same name in the Production server. So it is always advised to use the Function Module SSF_FUNCTION_MODULE_NAME to get the Function Module name by passing the Smart Form name.

DATA: fm_name TYPE rs38l_fnam.

CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
  EXPORTING
    formname           = 'ZSMARTFORM'
  IMPORTING
    fm_name            = fm_name
  EXCEPTIONS
    no_form            = 1
    no_function_module = 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.

CALL FUNCTION fm_name
 EXCEPTIONS
    formatting_error = 1
    internal_error   = 2
    send_error       = 3
    user_canceled    = 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.

What are the differences between SAPscripts and Smart Forms?

See this wiki: Differences between Smart forms and Sap scripts

Is it possible to migrate SAPscript to Smart Form?

  • That's a big effort to migrate a SAPscript to Smart Form, so it's better to analyze and create it from scratch
  • Nethertheless, there's a tool to migrate the layout, it can be accessed from SMARTFORMS transaction. See SAP Library - Smart Forms - Migrating SAPscript Forms
  • You may also migrate SAPscript style to Smart Style without loss from SMARTSTYLES transaction
  • You may mass migrate using SF_MIGRATE program
  • There is also FB_MIGRATE_FORM function module

Are there demo Smart Forms delivered in SAP system?

SF_EXAMPLE_01

Simple example; invoice with table output of flight booking for one customer

SF_EXAMPLE_02

Similar to SF_EXAMPLE_01 but with subtotals

SF_EXAMPLE_03

Similar to SF_EXAMPLE_02, whereby several customers are selected in the application program; the form is called for each customer and all form outputs are included in an output request

4 Comments

  1. Unknown User (w756kav)

    When i try  to set the as above it gives error that control-preview not known control-nno_open not know and so on how do it rectify this

  2. Unknown User (w756kav)

    Hi all,

    after i decleared DATA: output_options type SSFCOMPOP,
          control type SSFCTRLOP. and put in the printer name  in OUTPUT_OPTIONS-TDDEST and when i give a range it now gives an error that previous output request was not finished and gives a blank page and does not display the form.

  3. Official name is "Smart Form" (see SAP Library), do not use smartform

  4. Former Member

    Very good one ..