Sie sind auf Seite 1von 19

ECC 6.

0
Solutions: Smart Forms SAP Development ABAP Training

Exercise 1
Output Program name - YSPXXOUTPROG_2
Smart Form Name – YSPXXFORM_2

Steps To Create the Smart Form:

 Go to Transaction SMARTFORMS.
 Type the Form name and press the create button.
 The Header Section of the Smart Form will appear.

 Give a Description of the program and click the save button to save the program in the
appropriate package and CTS.
 Now click on the Pages button and go to the Pages section of the form.
 Change the name of the new page as PAGE1. Specify the next page as PAGE1 itself
because we will use only one page. Leave rest of the fields to their default values.
 Now save the Smart Form once again.

Dec-2008
Page 1
ECC 6.0
Solutions: Smart Forms SAP Development ABAP Training

 Now create a database structure YSTRUCT thorough transaction SE11 for the internal table
I_TAB that is coming from the driver program.

Dec-2008
Page 2
ECC 6.0
Solutions: Smart Forms SAP Development ABAP Training

 Now Go to Transaction SMARTFORMS again to create Smart Style YSPXXSTYLE_2. Then


Right Click on the Paragraph formats node and Character format node to create the
necessary paragraph formats and character format. In our case, we will use 2 paragraph
formats P1, P2 and 3 Character formats C1, C2 and C3 for the Header, Footer and Main
window. Give appropriate values to the attributes of the paragraph formats like Font family,
Font size, Bold/Italic/Underline, Tab positions etc.Click the save button to save the Style in
the appropriate package and CTS.

Dec-2008
Page 3
ECC 6.0
Solutions: Smart Forms SAP Development ABAP Training

 Now assign the Smart Style and give the table’s parameter as I_TAB into the Smart Form.

Dec-2008
Page 4
ECC 6.0
Solutions: Smart Forms SAP Development ABAP Training

Dec-2008
Page 5
ECC 6.0
Solutions: Smart Forms SAP Development ABAP Training

 Now create the windows necessary to the Smart Form. Create 3 windows LOGO (Logo
window), HDR (Header Window), MAIN (Main Window) and FTR (Footer Window). To create
the windows and give them appropriate sizes, use the Graphical Form Painter. You can
change the name, description, type, size, and position etc of the window from the left hand
side of the screen.

 Use the menu path Settings -> Form Painter. On clicking the menu, you will get one popup
screen in which you have to check the Graphical Form Painter Checkbox and uncheck the
Graphical PC Editor checkbox and press ‘Enter’. Now you will get the Graphical Form Painter.
A screenshot is shown below with all the windows created.

Dec-2008
Page 6
ECC 6.0
Solutions: Smart Forms SAP Development ABAP Training

 Now save the Smart Form once again.


 First we have to create one Graphics object for the IBM logo. To create this, use transaction
SE78.
 After creating IBM logo, right click on LOGO window and choose the menu path Create ->
Graphic and then give the IBMLOGO as graphic object name.

Dec-2008
Page 7
ECC 6.0
Solutions: Smart Forms SAP Development ABAP Training

 Now right click on HDR window and click on the menu path create->Text to create Text
Module. Create two-text module one for ‘Date’ and another for ‘Invoice Print’.

Dec-2008
Page 8
ECC 6.0
Solutions: Smart Forms SAP Development ABAP Training

 The screen shot below shows the code added to the HDR window. The hard coded text
“Date:” is enclosed within default paragraph format. We have to show the date, that’s why we
have used the SAP system field &SY-DATUM&. The text “Invoice Print” is embedded default
paragraph format.

Dec-2008
Page 9
ECC 6.0
Solutions: Smart Forms SAP Development ABAP Training

 Follow the same path for the Footer window to go to their corresponding editors and add code
there.
 In the FTR window, we have added some hard coded texts. The page number in ‘Page x of x’
format is printed using two Smart Form symbols &SFSY-PAGE& and &SFSY-FORMPAGES&.

Dec-2008
Page 10
ECC 6.0
Solutions: Smart Forms SAP Development ABAP Training

 In the MAIN window, we have printed the invoice number, which is coming from the selection
screen of the output program. We are using &SY-UNAME& system field for printing the name
of the person. Now to print line item data, create a table where we have to put internal table
name that is coming from the driver program.

Dec-2008
Page 11
ECC 6.0
Solutions: Smart Forms SAP Development ABAP Training

 Now create line type to form pattern (i.e. item field) of each row of table and then assign the
line type into the row type.

Dec-2008
Page 12
ECC 6.0
Solutions: Smart Forms SAP Development ABAP Training

Dec-2008
Page 13
ECC 6.0
Solutions: Smart Forms SAP Development ABAP Training

 Now put the entire column heading in header section of the table and all the item variables
will reside under the main area section.

Dec-2008
Page 14
ECC 6.0
Solutions: Smart Forms SAP Development ABAP Training

 For unit price, creating a Program lines node to write the code by using the menu path
Create->Flow Logic->Program Lines and pass those variables that required within the
program logic.

Dec-2008
Page 15
ECC 6.0
Solutions: Smart Forms SAP Development ABAP Training

Dec-2008
Page 16
ECC 6.0
Solutions: Smart Forms SAP Development ABAP Training

The Output Program:

 The output program first gets the value of invoice number from the user through a
selection screen. Now it uses that value to retrieve data from the database and stores it
in an internal table. The code snippet is given below-

TYPES: BEGIN OF TAB,


POSNR LIKE VBRP-POSNR,
MATNR LIKE VBRP-MATNR,
FKIMG LIKE VBRP-FKIMG,
VRKME LIKE VBRP-VRKME,
NETWR LIKE VBRP-NETWR,
END OF TAB.

PARAMETERS: INVOICE LIKE VBRP-VBELN.

Dec-2008
Page 17
ECC 6.0
Solutions: Smart Forms SAP Development ABAP Training

DATA: FM_NAME TYPE RS38L_FNAM. "NAME OF THE


"FUNCTION MODULE
"FOR CALLING
"SMARTFORM

DATA: I_TAB TYPE STANDARD TABLE OF TAB INITIAL SIZE 0 WITH HEADER LINE,
UP TYPE P DECIMALS 2 VALUE 0.

SELECT POSNR MATNR FKIMG VRKME NETWR FROM VBRP INTO TABLE I_TAB WHERE
VBELN = INVOICE.

IF SY-SUBRC <> 0.

MESSAGE I000(YTRABAPMSG) WITH 'INVOICE NO. DOES NOT EXIST'.


LEAVE LIST-PROCESSING.

ENDIF.

 Find the name of the function module by providing the name of the Smart Forms.

CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'


EXPORTING formname = 'YSPXXFORM_2'
* variant =''
* direct_call =''
IMPORTING fm_name = fm_name
EXCEPTIONS no_form =1
no_function_module = 2
OTHERS = 3.

IF sy-subrc <> 0.
* Error handling
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
EXIT.
ENDIF.

 Now call the generated function module

CALL FUNCTION fm_name


EXPORTING
inv_no = invoice
TABLES:
i_tab = i_tab

EXCEPTIONS
formatting error = 1
internal_error =2

Dec-2008
Page 18
ECC 6.0
Solutions: Smart Forms SAP Development ABAP Training

send_error =3
user_cancelled =4
OTHERS =5.

IF sy-subrc <> 0.
* Error handling
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.

 Run the Output Program and check the output in “Print Preview”.

Dec-2008
Page 19

Das könnte Ihnen auch gefallen