Free SAP Training & Tutorial A Free SAP Functional And Technical Tutorial And Training For ABAP, SAP QUERY, ALV, SMARTFORMS, SD, PP, MM, QM, FICO
15.12.2009 | Author: | Posted in SmartForms 

Today I want to teach you how to create a simple SmartForms. SmartForms  it’s a very robust program which I think is far much better than the good old SAP script, it’s very recommended to use SmartForms when creating print out form such as Invoice, Sales Order, Delivery Order, etc. Okay now let’s start our training today.

1. First execute TCODE smartforms

2. Create a new smartform program, just name it as ZSFEXERCISE and click CREATE.

smartforms 1

3. On Global Settings, click Form Interface and on your right select the TABLES tab. Here you can define internal table to use for the report fields structure, you can define more than 1 table depending on your program requirements. In this example let’s create 1 internal table named ITAB using table SPFLI field structure.

smart forms

4. Next go to Pages and Windows section (Below Global Settings), open the %PAGE1 New Page folder until you find MAIN Main Window folder, after that Right click > Create > Table This will create an internal table that can get the query result from the report interface.

3

5. In this next screen, you will see an empty box that will act as the main body of your report to display the report data.

But first we need to define how many columns we want to have on this report, to do this just click Draw Lines And Columns (Pencil button) button and draw a vertical lines on the box to create the report columns. In this example, I drew 3 vertical lines that will create 4 report columns.

5

6. Now go to Main Area (below the header), right click the Main Area > Create > Table Line. This will one new line 1 just below the main area section, on the right screen you can see the Output Table section, now select the Line Type selection box and click on %LTYP1. After that, you can see that all 4 columns we created earlier in step 5.

7

7. Now we need to attach internal table columns to display on this smartforms columns, right click the first column > Create > Text this will create a new text icon just below the first CELL Column.
8

8. Click on the TEXT1 icon we just created earlier, and click on the General Attributes tab.

31082010-inserfield-04

9. Click on the insert field button.
31082010-inserfield-01

10. Now this is very important, to define internal table field column on smartforms, you must type &itab-columnname& (begin and ended with a &).

In this example I want this first column to display the carrid column in the SPFLI table, then I will write &itab-carrid&
31082010-inserfield-02

11.  Now  repeat step 8 and 9 to display these other 3 columns.

  • &itab-connid&   (on Cell2)
  • &itab-cityfrom&  (on Cell3)
  • &itab-cityto& (on Cell4)

12. On the Main Window, click on the TABLE section. In this part you have to define the internal table name used to display the data. In this example we’re using ITAB.

12

See picture below for a clearer view.

15

13. After that Click Activate

Now the last step would be to create a program that will be the interface to call this smartform.

14.  Execute SE38, create a program ZRPTEXERCISE

13

15.  Now copy and paste this code below.

REPORT  ZRPTEXERCISE.

DATA T_SPFLI TYPE TABLE OF SPFLI WITH HEADER LINE.
DATA FUNC_NAME TYPE RS38L_FNAM.
DATA ITAB LIKE STANDARD TABLE OF SPFLI WITH HEADER LINE.

START-OF-SELECTION.

SELECT * INTO TABLE ITAB FROM SPFLI.

CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
  EXPORTING
    formname                 = 'ZSFEXERCISE'
*   VARIANT                  = ' '
*   DIRECT_CALL              = ' '
 IMPORTING
   FM_NAME                  = FUNC_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 FUNC_NAME
* EXPORTING
*   ARCHIVE_INDEX              =
*   ARCHIVE_INDEX_TAB          =
*   ARCHIVE_PARAMETERS         =
*   CONTROL_PARAMETERS         =
*   MAIL_APPL_OBJ              =
*   MAIL_RECIPIENT             =
*   MAIL_SENDER                =
*   OUTPUT_OPTIONS             =
*   USER_SETTINGS              = 'X'
* IMPORTING
*   DOCUMENT_OUTPUT_INFO       =
*   JOB_OUTPUT_INFO            =
*   JOB_OUTPUT_OPTIONS         =
  TABLES
    itab                       = ITAB
* 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.

16. Now run the program. Here’s the Smartforms beautiful report display.

14

Popularity: 98% [?]

 


 
 

Related Tutorial " SmartForms" 

  •  
     
    Recent Tutorials
    Create Table Maintenance Display In SAP Create table display to maintain tables values using SM30
    Create Table Maintenance Generator In SAP Maintaining SAP Transparent table values using maintenance generator
    Table Relationship In SAP Learn How To Find Tables Relationships in SAP
    Convert Number To words Using ABAP Find out how to convert numbers into words Using ABAP
    How To Maintain Long Text Object in SAP Maintain long text object in SAP
    How To Know What TCODE Used In ABAP Program Find TCODE For your ABAP Program Report
    How does CRM Work? Learn how CRM system works to run your business
    Why SAP CRM is the Best Choice? The reasons why CRM application is the best choice
    Difference Between CRM System and CRM Strategy What's the difference between CRM system and its strategy
    CRM for a Better Customer Service Learn how CRM could make your customer service much better
    Costs of Implementing CRM Software Learn the how much cost you need to prepare when implementing CRM
     
    Popular Tutorials
  • (none)
  •  
    Categories
    ABAP   Basis & Configuration  
    ALV SAP BW (Business Warehouse)
    BAPI   SAP Interview Questions
    SAP Tables   SAP Overview
    Transaction Codes FI SAP Query
      MM SAP Script  
      PP SAP Tutorial FI Module
      QM   MM Module
      SD   PM Module
    SAP Functional MM   PP Module
      SD   QM Module
    White Papers     SD Module
    Uncategorized   SmartForms  
      User-Exits  
     
     

     

    Home | About | Contribute | Privacy

    Copyright 2011 freesaptutorial.com.

    Free SAP Tutorial is not associated with SAP AG in Germany or in any other country.

    SAP is a registered trade mark of SAP AG.