Sie sind auf Seite 1von 3

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 (by using the generated XML output). 

According to SAP, you need neither have any programming knowledge nor use a Script
language to adapt standard forms. However, basic ABAP programming skills are
required only in special cases (for example, to call a function module you created or for
complex and extensive conditions).

1. Create a new smartforms


 Transaction code SMARTFORMS
 Create new smartforms call ZSMART

2. Define looping process for internal table

Pages and windows

 First Page -> Header Window (Cursor at First Page then click Edit ->
Node -> Create)
Here, you can specify your title and page numbering
&SFSY-PAGE& (Page 1) of &SFSY-FORMPAGES(Z4.0)& (Total
Page)
 Main windows -> TABLE -> DATA
 In the Loop section, tick Internal table and fill in
 ITAB1 (table in ABAP SMARTFORM calling function) INTO ITAB2

3. Define table in smartforms


Global settings :
Form interface
Variable name    Type assignment   Reference type
ITAB1               TYPE                  Table Structure
 
Global definitions
Variable name    Type assignment   Reference type
ITAB2               TYPE                  Table Structure

4. To display the data in the form


Make used of the Table Painter and declare the Line Type in Tabstrips Table
e.g.  HD_GEN for printing header details,
        IT_GEN  for printing data details.
You have to specify the Line Type in your Text elements in the Tabstrips
Output options.
Tick the New Line and specify the Line Type for outputting the data.
Declare your output fields in Text elements
Tabstrips - Output Options
For different fonts use this Style : IDWTCERTSTYLE
For Quantity or Amout you can used this variable &GS_ITAB-
AMOUNT(12.2)&
5. Calling SMARTFORMS from your ABAP program

REPORT ZSMARTFORM.

* Calling SMARTFORMS from your ABAP program.


* Collecting all the table data in your program, and pass once to
SMARTFORMS
* SMARTFORMS
* Declare your table type in :-
* Global Settings -> Form Interface
* Global Definintions -> Global Data
* Main Window -> Table -> DATA
*
* Written by :  SAP Hints and Tips on Configuration and ABAP/4 Programming
*                     http://sapr3.tripod.com
*

TABLES: MKPF.

DATA: FM_NAME TYPE RS38L_FNAM.

DATA: BEGIN OF INT_MKPF OCCURS 0.


        INCLUDE STRUCTURE MKPF.
DATA: END OF INT_MKPF.

SELECT-OPTIONS S_MBLNR FOR MKPF-MBLNR MEMORY ID 001.

SELECT * FROM MKPF WHERE MBLNR IN S_MBLNR.


   MOVE-CORRESPONDING MKPF TO INT_MKPF.
   APPEND INT_MKPF.

ENDSELECT.

* At the end of your program.


* Passing data to SMARTFORMS

call function 'SSF_FUNCTION_MODULE_NAME'


  exporting
    formname                 = 'ZSMARTFORM'
*   VARIANT                  = ' '
*   DIRECT_CALL              = ' '
  IMPORTING
    FM_NAME                  = FM_NAME
  EXCEPTIONS
    NO_FORM                  = 1
    NO_FUNCTION_MODULE       = 2
    OTHERS                   = 3.

if sy-subrc <> 0.
   WRITE: / 'ERROR 1'.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.

call function FM_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
    GS_MKPF                    = INT_MKPF
  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.

Das könnte Ihnen auch gefallen