Escolar Documentos
Profissional Documentos
Cultura Documentos
In this example, we will print a simple text using our form. To create a text, expand Pages and
Windows New Page. Select Main Window and Right click on that. Select Create Text
Test the smart form by clicking on Test. You would be navigated to the function builder with the
function module defaulting to the one that is generated earlier.
Click on execute.
Expand Pages and Windows and click on %PAGE1. Rename the page to your needs and add a
short description to the same.
To display the address on the form, right click on Main Window, select Create Address
Enter a name to the Address and add a short description for the same.
You all might be aware that Addresses are stored in the table ADRC. Now pick an address number
from that table, add provide the same in the Address Number as shown below:
Double-click on GRAPHICS node and click on Import (F5) to import the image.
Select the file name by using the F4 functionality available. Name your graphic and enter a short
description. If you have color image, select the radio button Color Bitmap image. Click on tick mark
to proceed.
Create a new form and give a short description for the same.
Scenario: Let us take a simple scenario of passing Material Number and Material description from
Driver program to the Smart Form.
Go to transaction SMARTFORMS and create a Smart Form.
To pass the values from the driver program to Smart Form, we need to define the form interface with
the parameters to be passed on.
Click on Global Settings Form Interface.
Now define the import parameters for MATNR and MAKTX (From table MAKT)
Now create a Text in the Main window to display the above two parameters.
Enter the field names between the & (Ampersand) as shown below:
Save and Activate the Smart Form. Test run the Smart Form by clicking on Execute.
Now to calculate Seats Available, select Main Window Create Flow Logic Program Lines
Now mention the input parameters as SEATS_MAX and SEATS_OCC and the output parameter as
SEATS_AVAIL. Write the code to calculate SEATS_AVAIL.
Now to print these values on the layout, create a text by selecting Main Window Create Text:
To position the secondary window to meet our needs, click on Form Painter.
Save and activate the Smart Form. Test run the Smart Form; you would get the following output:
Scenario: To print three copies of a particular document and the first copy
should mention as Customer copy, second one as Bank copy and the third one
say College copy.
Create a Smart Form using the transaction SMARTFORMS.
In this demo, we would print in the Copies window whether it is bank copy, company copy or others.
Create a secondary window as shown below:
Also name your window and give it a proper description. Do not change any other settings.
Adjust the window size using the Form Painter available on the application toolbar.
The variable SFSY-COPYCOUNT would provide us count of the copy whether it is a first copy, second
copy and others. We would use this field to print the owner of the copy.
We would define a string, which would hold the name of the copy (bank copy and others) depending
on the value of SFSY-COPYCOUNT. Define a variable in the global definition as shown below:
Now select your Copies window, right click Select Create Flow Logic Program Lines
Now include a text in the Main window as well with some content.
By Swathi, Wipro
Scenario: In this demo, we would create a small text as shown below with outline numbering as
shown below
Go to transaction SmartStyles
To create a paragraph, click on folder Paragraph Formats and click on Create (as shown in the
above screenshot).
Following pop-up appears: Enter a paragraph format name.
Enter a suitable description for your graph and enter the left margin value as 2 CH.
Also, in the same window, check the Number Chaining Box. If this is selected, the parent value
would be displayed (like 1.1, 1.2, 2.1,2.2..). If this is not checked, only numbering would appear like 1,
2,3 without the parent number prefixing.
Save and activate your Smart Style.
Now go to transaction SmartForms.
Create a Smart Form and create a text in the Main Window:
Select the tab Output Options to mention the Smart Style to be used.
Return to the main screen of the Text. The screen would appear as follows:
Save and activate the Smart Form. Test run the Smart Form. Following would be the output:
By Venkat
Step1: Provide the name of the smart form is YDEMO_LOOP on the initial screen of the smart form
and meaningful description.
Step2: Now go to Global definitions where we can define the Global data, Types, Initialization and etc.
Define Structure using Types Parameter as shown below. In Types parameters we usually define user
defined data types.
Step3: Now define the internal table and work area in Global Data parameter.
Step4: In Initialization parameter, we can write a code as shown below. We have to mention the
output result in the output parameter so that we can use it further. Here in this case we are outputting
IT_TAB and we are going to use this IT_TAB further in the LOOP in the Flow Logic.
Step7: To create the character, paragraph formats and Tabs, we use the smart style. The transaction
for create smart style is SMARTSTYLE or we can be created the initial screen of SMARTFORMS.
Here SMART STYLE is created to define Tab positions for the columns.
Step10: Now Import SMART STYLE in to the SMART FORM as shown below.
Step12: Save and activate the smart form. The output is as shown below.
By Venkat
Step1: T-code for smart forms is SMARTFORMS. Provide the name of the smart form.
And provide the short text for this smart form YDEMO_TABLE.
Step2: Now go to Global definitions where we can define the Global data, Types, Initialization and etc.
Define Structure using Types Parameter as shown below. In Types parameters we usually define user
defined data types.
Step3: Now define the internal table and work area in Global Data parameter.
Step4: In Initialization parameter, we can write a code as shown below. We have to mention the
output result in the output parameter so that we can use it further. Here in this case we are outputting
IT_TAB and we are going to use this IT_TAB further in the Table painter.
Step6: Now we define number of table columns in %LTYPE1. Here, %LTYPE1 is renamed as LINE
as shown below.
Here, in this scenario we have to divide the LINE area into 4 columns as we have to display 5
columns. To draw a line we have to select Draw lines and columns button as shown above.
Step7: Now we have to create Table line for Header and Main area of Table painter as shown
below.
Here we have to provide line type. Here, the line type is LINE.
Step8: Provide the text for all columns.
Step11: Save and activate the smart form. Execute the smart form now. The output is as shown
below.
Step 5:In the text box general attributes TAB select Text module from the drop down list
Step 6: Give the name of the Text Module created and click on COPY button.
Step 7: The text in the text Module will be copied into the Text Editor.
Step 9: Save and activate. Execute and check the print preview.
By Surekha
This document details the procedure in using Microsoft Word as editor in SAP Script / Smart Forms.
In normal case, when you try opening the editor in Smart Forms, the following editor would appear:
If you would like to use MS Word Editor in both Script and Smartforms, then check the both
checkboxes as shown below:
Click on Activate.
The following popup appears (related to SAPScript Editor):
Click on Yes. Now the following popup appears (related to Smartforms Editor):
In SAP Script:
You can anytime revert to old editor by deactivation MS Word editor option using the transaction I18N.
Step2: we can define user-defined structure in TYPES tab in the Global Definitions.
Step3: Define the field string, internal table and global variables in Global Data tab.
Step8: suppose, if we want to know the item details sales document wise. To achieve this, we have to
write the events in the loop as shown below.
Step10: Now the requirement is to sum the net price of all items of sales document. To achieve this,
In program lines,
Assigning a transport request for the translations related to the text in Smart
Forms
Now let us maintain a translation for the above text in French. To do the same, go to translation
SE63.
Click on Translation -> ABAP Objects -> Other Long Texts
In the following screen, enter the name of the Smart Form created earlier. Also provide the source
language and Target Language to be maintained:
Now to assign a transport request for the above transaction, execute the program
RS_LXE_RECORD_TORDER.
Enter the target language, Short Description for the transport request, object type as SSF.
Click on Execute.
As shown in the above screen shot, a transport request is created for the required translations. To
check the same, go to transaction SE09 and provide the transport request number:
REPORT zsuresh_test.
* Variable declarations
DATA:
w_form_name TYPE tdsfname VALUE 'ZSURESH_TEST',
w_fmodule TYPE rs38l_fnam,
w_cparam TYPE ssfctrlop,
w_outoptions TYPE ssfcompop,
W_bin_filesize TYPE i, " Binary File Size
w_FILE_NAME type string,
w_File_path type string,
w_FULL_PATH type string.
* Internal tables declaration
* Internal table to hold the OTF data
DATA:
t_otf TYPE itcoo OCCURS 0 WITH HEADER LINE,
* Internal table to hold OTF data recd from the SMARTFORM
t_otf_from_fm TYPE ssfcrescl,
* Internal table to hold the data from the FM CONVERT_OTF
T_pdf_tab LIKE tline OCCURS 0 WITH HEADER LINE.
* This function module call is used to retrieve the name of the Function
* module generated when the SMARTFORM is activated
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = w_form_name
* VARIANT = ' '
* DIRECT_CALL = ' '
IMPORTING
fm_name = w_fmodule
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.
w_cparam-no_dialog = 'X'.
w_cparam-preview = space. " Suppressing the dialog box
" for print preview
w_cparam-getotf = 'X'.
* Printer name to be used is provided in the export parameter
* OUTPUT_OPTIONS
w_outoptions-tddest = 'LP01'.
CALL FUNCTION w_fmodule
EXPORTING
* ARCHIVE_INDEX =
* ARCHIVE_INDEX_TAB =
* ARCHIVE_PARAMETERS =
control_parameters = w_cparam
* MAIL_APPL_OBJ =
* MAIL_RECIPIENT =
* MAIL_SENDER =
output_options = w_outoptions
* USER_SETTINGS = 'X'
IMPORTING
* DOCUMENT_OUTPUT_INFO =
job_output_info = t_otf_from_fm
* JOB_OUTPUT_OPTIONS =
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.
t_otf[] = t_otf_from_fm-otfdata[].
* Function Module CONVERT_OTF is used to convert the OTF format to PDF
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
FORMAT = 'PDF'
MAX_LINEWIDTH = 132
* ARCHIVE_INDEX = ' '
* COPYNUMBER = 0
* ASCII_BIDI_VIS2LOG = ' '
* PDF_DELETE_OTFTAB = ' '
IMPORTING
BIN_FILESIZE = W_bin_filesize
* BIN_FILE =
TABLES
otf = T_OTF
lines = T_pdf_tab
EXCEPTIONS
ERR_MAX_LINEWIDTH = 1
ERR_FORMAT = 2
ERR_CONV_NOT_POSSIBLE = 3
ERR_BAD_OTF = 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.
* To display File SAVE dialog window
CALL METHOD cl_gui_frontend_services=>file_save_dialog
* EXPORTING
* WINDOW_TITLE =
* DEFAULT_EXTENSION =
* DEFAULT_FILE_NAME =
* FILE_FILTER =
* INITIAL_DIRECTORY =
* WITH_ENCODING =
* PROMPT_ON_OVERWRITE = 'X'
CHANGING
filename = w_FILE_NAME
path = w_FILE_PATH
fullpath = w_FULL_PATH
* USER_ACTION =
* FILE_ENCODING =
EXCEPTIONS
CNTL_ERROR = 1
ERROR_NO_GUI = 2
NOT_SUPPORTED_BY_GUI = 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.
* Use the FM GUI_DOWNLOAD to download the generated PDF file onto the
* presentation server
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
BIN_FILESIZE = W_bin_filesize
filename = w_FULL_PATH
FILETYPE = 'BIN'
* APPEND = ' '
* WRITE_FIELD_SEPARATOR = ' '
* HEADER = '00'
* TRUNC_TRAILING_BLANKS = ' '
* WRITE_LF = 'X'
* COL_SELECT = ' '
* COL_SELECT_MASK = ' '
* DAT_MODE = ' '
* CONFIRM_OVERWRITE = ' '
* NO_AUTH_CHECK = ' '
* CODEPAGE = ' '
* IGNORE_CERR = ABAP_TRUE
* REPLACEMENT = '#'
* WRITE_BOM = ' '
* TRUNC_TRAILING_BLANKS_EOL = 'X'
* WK1_N_FORMAT = ' '
* WK1_N_SIZE = ' '
* WK1_T_FORMAT = ' '
* WK1_T_SIZE = ' '
* IMPORTING
* FILELENGTH =
tables
data_tab = T_pdf_tab
* FIELDNAMES =
* EXCEPTIONS
* FILE_WRITE_ERROR = 1
* NO_BATCH = 2
* GUI_REFUSE_FILETRANSFER = 3
* INVALID_TYPE = 4
* NO_AUTHORITY = 5
* UNKNOWN_ERROR = 6
* HEADER_NOT_ALLOWED = 7
* SEPARATOR_NOT_ALLOWED = 8
* FILESIZE_NOT_ALLOWED = 9
* HEADER_TOO_LONG = 10
* DP_ERROR_CREATE = 11
* DP_ERROR_SEND = 12
* DP_ERROR_WRITE = 13
* UNKNOWN_DP_ERROR = 14
* ACCESS_DENIED = 15
* DP_OUT_OF_MEMORY = 16
* DISK_FULL = 17
* DP_TIMEOUT = 18
* FILE_NOT_FOUND = 19
* DATAPROVIDER_EXCEPTION = 20
* CONTROL_FLUSH_ERROR = 21
* OTHERS = 22
.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Passing Select-Options to Smart Forms
By Venkat
Step1: Create a Structure ZSELECTION in SE11 with following fields.
Step6: The PERNRS given in the select-option in the driver program is captured in T_SELECT. In
program lines, T_SELECT is input to SELECT query and the results are captured in internal table
T_0002. We have to mention resulted internal table T_0002 in output parameters for further use.
Step8: Create driver program ZSELECT_FORM_REP. Write the following code in report.