SMARTFORM Development in Ten Easy Steps
SMARTFORM Development in Ten Easy Steps
SMARTFORM Development in Ten Easy Steps
Header Logo Barcode Date & Time Shop Address Customer Address
Item Details
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
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
Two Logos are maintained ( For Company logo on left hand corner, background Logo).
By Debesh
Page 3
By Debesh
Page 5
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
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
Step 7.First Page Windows Design. 1. Header Section Insert a text in header.
Choose a style.
By Debesh
Page 9
By Debesh
Page 10
5. Bill To Party Insert program lines for bill to party where program code can be written.
By Debesh
Page 11
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
7. Main Create a program line in main window to write the logic for item details.
By Debesh
Page 13
Give the line type in header and write the labels for the header using text element.
By Debesh
Page 14
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
By Debesh
Page 16
For note to get displayed only in last page give the condition as follows.
By Debesh
Page 17
. 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
By Debesh
Page 19
3. Third page
By Debesh
Page 20
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
By Debesh
Page 21
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
DATA: output_data LIKE ITCOO OCCURS 0 WITH HEADER LINE, IT_LINES LIKE TLINE OCCURS 0 WITH HEADER LINE.
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'
*--DOWNLOADING PDF FILE CALL FUNCTION 'WS_DOWNLOAD' EXPORTING BIN_FILESIZE FILENAME FILETYPE TABLES = l_pdf_len = 'C:\FILE.PDF' = 'BIN'
By Debesh
Page 23
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