SMARTFORM Development in Ten Easy Steps

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 25

SMARTFORM DEVELOPMENT IN TEN EASY STEPS

Graphics, Barcode, Standard Texts, Driver Program, Converting smartforms to PDF

SMARTFORM development in ten easy steps


SAP Smartforms can be used for creating and maintaining forms for mass printing in SAP Systems. The output medium for Smartforms support printer, fax, e-mail, or the Internet. The transaction to create smartform is SMARTFORMS. The smartform I am going to design is of the following format.

Header Logo Barcode Date & Time Shop Address Customer Address

Item Details

Total amount after tax Terms & Conditions

Note Page No

Step 1. Go to transaction smartforms. Give a name for the smartform and press create. By default the generated form has 2 sections (Global settings & Page and Windows). Global settings have 3 sections such as form attributes (Page format, style), form interface (variables to get values from program), global definitions (global variables). In pages and Windows section create a page. Inside page one can design windows. Use Form Painter to place the windows properly.

By Debesh

Page 1

SMARTFORM development in ten easy steps

Create 2 pages one MAIN and a NEXT page. After the end of main page next page is called. On first page general attributes provide Next page as next page.

Design the windows in the main page. Right click on page and create the windows. Click on form painter to place them properly.

By Debesh

Page 2

SMARTFORM development in ten easy steps


Step2. Graphics Image For Logo and background logo use transaction SE78(Admin Graphics). To use logo from desktop use Import button. Give a name and save it. The logo which is going to be uploaded should be of Bitmap Type.

Two Logos are maintained ( For Company logo on left hand corner, background Logo).

By Debesh

Page 3

SMARTFORM development in ten easy steps


Step3. Barcode For Barcode creation use transaction SE73(Font maintenance).

Choose a barcode format. By Debesh Page 4

SMARTFORM development in ten easy steps

The alignment is to provide scan direction of the barcode.

Choose the barcode parameters.

By Debesh

Page 5

SMARTFORM development in ten easy steps

Test It.

Step 4. Style Create a style. Style handles how the characters appear on the screen. The paragraph format is also made by this. The page margin, character spacing, font are handled here. To use the Barcode, the same needs to be integrated to a character format here. The transaction is Smartforms.

Step5. Text maintenance. The global texts which can be used in many smartforms or needs to be translated to different languages can be declared in Text Modules (Transaction smartforms) or in Standard Text( Transaction SO10).

By Debesh

Page 6

SMARTFORM development in ten easy steps

Three Standard texts are maintained ( For company address, For Terms & Conditions , For Attention Note). Step6. Variable declaration. Declare the variables which are obtained from the system/print program in Form Interface. Declare Global variables in Global definition section.

By Debesh

Page 7

SMARTFORM development in ten easy steps

Step 7.First Page Windows Design. 1. Header Section Insert a text in header.

Create a text in header. By Debesh Page 8

SMARTFORM development in ten easy steps

Choose a style.

2. Logo Insert a graphics for the logo window.

By Debesh

Page 9

SMARTFORM development in ten easy steps

3. Bar Code Insert Barcode in barcode window.

By Debesh

Page 10

SMARTFORM development in ten easy steps

4. Address Insert a standard text for address window.

5. Bill To Party Insert program lines for bill to party where program code can be written.

By Debesh

Page 11

SMARTFORM development in ten easy steps

DATA : LV_KUNNR TYPE KNA1-KUNNR, LV_KUNN2 TYPE KNA1-KUNNR. SELECT SINGLE KUNNR FROM VBPA INTO LV_KUNNR WHERE VBELN = BILL_DOC. IF SY-SUBRC IS INITIAL. SELECT SINGLE KUNN2 FROM KNVP INTO LV_KUNN2 WHERE KUNNR = LV_KUNNR AND PARVW = 'RE'. IF SY-SUBRC IS INITIAL. SELECT SINGLE NAME1 ORT01 STRAS PSTLZ TELF1 INTO LS_BILLTO FROM KNA1 WHERE KUNNR = LV_KUNN2.

By Debesh

Page 12

SMARTFORM development in ten easy steps


6. Date & Time For date and time insert a text and use system variable for that. SMARTFORM provides certain system parameters like SFSY-DATE, SFSY-TIME, SFSY-PAGE, SFSYFORMPAGES.

7. Main Create a program line in main window to write the logic for item details.

By Debesh

Page 13

SMARTFORM development in ten easy steps


Create a table to display the item details. Create a line type.

Loop the item table in data segment.

Give the line type in header and write the labels for the header using text element.

By Debesh

Page 14

SMARTFORM development in ten easy steps

In main area use the line type and provide the workarea.

For the total use program lines in respective variables in main section.

By Debesh

Page 15

SMARTFORM development in ten easy steps

Write the total, tax, net in proper position.

Use standard text for terms and conditions.

By Debesh

Page 16

SMARTFORM development in ten easy steps

For note to get displayed only in last page give the condition as follows.

Use a standard text for note.

By Debesh

Page 17

SMARTFORM development in ten easy steps


8. Page For page number use text element and system variable.

. Step 8. Next page Windows design Copy the main window, page no, Note window and paste in the next window.

Step 9. Directly test it or write a driver program. Write a program to convert the smart form to PDF and download the same to the local system. First download the Open Text Format and convert the same to PDF. The sample code is written at the end.

By Debesh

Page 18

SMARTFORM development in ten easy steps


Step 10. Output. 1. First page

By Debesh

Page 19

SMARTFORM development in ten easy steps


2. Second page

3. Third page

By Debesh

Page 20

SMARTFORM development in ten easy steps

Sample Program code : *&---------------------------------------------------------------------* *& Report YTEST_SMART_DRIVER *& Driver Program for Invoice Smart Form *&---------------------------------------------------------------------* *& Developed By Debesh *& Date 25/05/2013 *&---------------------------------------------------------------------*

REPORT ytest_smart_driver. PARAMETERS : p_bill TYPE vbrk-vbeln. DATA : lv_fname TYPE rs38l_fnam, lv_control TYPE ssfctrlop, lv_out lv_job TYPE ssfcompop, TYPE ssfcrescl."Smart Forms: Return value at end of form printing

lv_control-no_dialog = 'X'."SAP Smart Forms: General Indicator lv_control-preview = space."Print preview lv_control-getotf = 'X'."Return of OTF table. No printing, display, or faxing lv_out-tddest = 'LP01'."Spool: Output device

CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME' EXPORTING formname IMPORTING fm_name = lv_fname = 'YTEST_INVOICE'

By Debesh

Page 21

SMARTFORM development in ten easy steps


EXCEPTIONS no_form =1

no_function_module = 2 OTHERS 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 lv_fname EXPORTING control_parameters output_options bill_doc IMPORTING job_output_info EXCEPTIONS formatting_error internal_error send_error user_canceled OTHERS . IF sy-subrc <> 0. MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. ENDIF. DATA: L_PDF_LEN TYPE I. =1 =2 =3 =4 =5 = lv_job = lv_control = lv_out = p_bill = 3.

By Debesh

Page 22

SMARTFORM development in ten easy steps

DATA: output_data LIKE ITCOO OCCURS 0 WITH HEADER LINE, IT_LINES LIKE TLINE OCCURS 0 WITH HEADER LINE.

*--CONVERTING IT TO PDF CONTENT

CALL FUNCTION 'CONVERT_OTF' EXPORTING format IMPORTING bin_filesize TABLES otf lines EXCEPTIONS err_max_linewidth err_format =2 =1 = LV_JOB-OTFDATA = It_lines = l_pdf_len = 'PDF'

err_conv_not_possible = 3 err_bad_otf OTHERS =4 = 5.

*--DOWNLOADING PDF FILE CALL FUNCTION 'WS_DOWNLOAD' EXPORTING BIN_FILESIZE FILENAME FILETYPE TABLES = l_pdf_len = 'C:\FILE.PDF' = 'BIN'

By Debesh

Page 23

SMARTFORM development in ten easy steps


DATA_TAB EXCEPTIONS FILE_OPEN_ERROR FILE_WRITE_ERROR INVALID_FILESIZE INVALID_TYPE NO_BATCH UNKNOWN_ERROR INVALID_TABLE_WIDTH GUI_REFUSE_FILETRANSFER CUSTOMER_ERROR OTHERS = 10. =9 =1 =2 =3 =4 =5 =6 =7 =8 = IT_LINES

IF SY-SUBRC <> 0. MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. ELSE. MESSAGE I004(Ztest) . ENDIF.

NOTE : In smartform only one main window possible. In all the pages the main window should have the same width ,height may differ.

By Debesh

Page 24

You might also like