Sunteți pe pagina 1din 98

*SMARTFORMS*

BY ----Arjun
Overview

SMART FORM

Smart form is a GUI Tool which is used to design


the business legal documents such as Delivery
note,Purchase order,Invoice etc.

The transcation code is SMARTFORMS

Smartforms are client independent

It is advanced version of scripts

It is basically a GUI tool for user friendly maintenance

 SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 2
SAP Smart Forms - Architecture

 SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 3
SAP Smart Forms - Architecture

Smart Form Web Browser

Printer
ABAP
Application Function
program module
(generated)

Fax

Database

Data retrieval Form logic Output device

 SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 4
Differences b/w scripts & smartforms

 SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 5
Differences b/w scripts & smartforms

Sapscripts
Sapscripts are clinet dependent.

main window is compulsary.

No function Module will be generated.

sapscripts allows only black and white texts.

Sapscripts has repeated transfer of control.

Only single PageFormat is possible

Windows are: main, var, graphical windows in sapscripts.

 SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 6
Differences b/w scripts & smartforms

Smartforms
Smartforms are client independent.

main window is not compulsary.

Smartforms generates a function module when activated.

Smartforms texts can be written in various colors.

There is no transfer of control b/w prg. and form in smartforms.

Once the control is transferred to FMOD, it will not come back to


driver prg.

Multiple PageFormats are possible

Windows are: main, secondary, copies and final windows in


smartforms.

 SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 7
FINDING SMARTFORM FUN.MOD NAME

 SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 8
SAP Smart Forms

 WHY SMARTFORMS ARE CLIENT INDEPENDENT?

Whenever a smartform is activated a function module will be


generated which contains the entire source code of the smartform.

Since function modules are client independent ,SAP Smartforms


are also client independent.

 HOW DO YOU FIND SMARTFORM FUN.MOD NAME STATICALLY?

Create a Smartform.

SAVE AND ACTIVATE.

Click on Environment
Function module name.

 SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 9
SAP Smart Forms

HOW DO YOU FIND SMARTFORM FUN.MOD NAME DYNAMICALLY FROM


PRG?

 USING FM: SSF_FUNCTION_MODULE_NAME

It is a function module which is used to find out the dynamically


generated fuction module of a smartform.

Note: Whenever we move the smartform from one server to another


server with in a system landscape ,The smartform function module
name will change dynamically.

So use,SF_FUNCTION_MODULE_NAME and find the dynamically


generated fuction module of a smartform.

 SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 10
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
FORMNAME = 'ZINVOICE‘(Formname)
IMPORTING
FM_NAME = FM_NAME.(dynamically generated FM)

CALL FUNCTION FM_NAME

 SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 11
SMART STYLES

 SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 12
SMART STYLES
These are used to create the paragraph formats and character
formats

The main advantage of using smartstyles is ‘REUSABILITY’

That means, Once you create a smartstyle, we can reuse the same

Smartstyle in multiple smartforms.

The Tcode is SMARTSTYLES

 SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 13
COMPONENTS OF SMARTFORMS

 SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 14
SAP Smart Forms Components

COMPONENTS OF SMARTFORMS:-

There are two main nodes in Smartforms.

1.Global Settings

Form Attribute

Form Interface

Global Definition

2.Pages and Windows

 SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 15
Global settings:

It is used to provide the basic settings for the smartform.

Form Attributes: It specifies the general attributes like

who created,Date,time,

package,translate options,

default smartstyle,

Page format (DINA4/DINA5)

 SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 16
Form interface: it acts as a mediator between a driver program and a
smart form.

The main functionality of form interface is, it will import the


parameters which are exported by driver program..

The parameters can be variables, work areas, internal tables..etc.

Global definition: it will contain the variables to be used within the


smart form.

We can define variables, user defined data types, field symbols,


initialization code,Subroutine, currency/quantity fields.

It is mainly used for declaring or defining the above variables.

 SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 17
COMPONENTS OF SMARTFORMS
Pages and Windows

page

Window

Graphic

Address

Text

Table

-- Header

-- Body

 SAP AG 2001, Smart Forms - the Form Printing Solution,


-- Footer
Claudia Binder / Jens Stumpe 18
COMPONENTS OF SMARTFORMS

 Template

Folder

 Program Lines

Alternative

Command

Loop

 SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 19
Pages and windows

This will contain all the pages and the windows, which are used in
the smartform.

By default, a page will be created by name %page1.

By default, a window will be created by name ‘MAIN’ under the


page1.

For each page, we need to specify the next page

Eg: page = %page1

Next page = %page1 or %page2

 SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 20
Nodes under pages

Page : It is used to define the layout of a smartform.

We can have different pages with different layouts.

Window : it is used to display information or text at a particular place


on a page.

Graphic : it is used to display logos or images on the smartforms.

Address : it is used to display the address of customer or vendor or


employe, organization address , workplace address etc.

Just provide address no, it will automatically display the address as


per the country formats.

 SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 21
Nodes under the window

Text : it is used to display the information or text in a window.

Table : it is used to display the information in the form of table.

When ever we create table by default HEADER, MAIN AREA,


FOOTER will be displayed.

The main functionality of a table is, it expands automatically


depending on the internal table data.

We need to provide the name of the internal table for a table.

 SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 22
Template : template is also like a table which does not expand. That
means it will have fixed number of rows and columns.

Program lines : it is used to write some lines of abap code.

Alternative : it is used to provide alternative conditions like true or


false.

It is like IF…..ELSE……ENDIF in abap.

Loop : it is used to loop an internal table.

Command : it is used to trigger an external event to call a new page.

Folder : it is a container which is used to group all the subnodes.It is


like a folder in normal language

 SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 23
Window Types

 SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 24
Window Types

Various window types

 Main window: For continuous output .


 Secondary window: For output with a fixed length
 Final window: Special type of secondary window for
outputting the information that is not known until the
end of form processing
 Copies window: Special type of secondary window for
marking pages as copy or original.

 SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 25
Example on SmartForm

Selected node

Attributes
Navigation tree Form Painter
(of selected node)

 SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 26
Steps To Create SmartForm

 SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 27
Steps To Create SmartForm

 Goto ‘SMARTFORMS’ Tcode.

Give the form name as ‘ zsmartform’.

Click on Create.

Expand Pages and Windows

Right Click on Main Window.


Create
Text
Write the Text as ‘ This is Smartform Demo’.

SAVE ,ACTIVATE AND TEST IT.

 SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 28
CREATING DRIVER PROGRAM FOR
 SMARTFORMS

 SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 29
CREATING DRIVER PROGRAM FOR SMARTFORMS

Goto SE38 TCODE.

Create a program by name ‘ZDP_SMARTFORM’.

Write below code in the program.

DATA: LV_FNAME TYPE RS38L_FNAM.

CALL FUNCTION ‘SSF_FUNCTION_MODULE_NAME’


EXPORTING
FORMNAME = ‘ZSMARTFORM’
IMPORTING
FM_NAME = LV_FNAME.
Call function LV_FNAME.

 SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 30
Passing data between Driver program and
smartform

 SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 31
Passing data between Driver program and smartform

 Create a variable in the Driver program as below.


DATA : V_NAME(20) TYPE C.
V_NAME = ‘INVOICE’.

Import the variable in the smart form.


i.e., Goto Form interface and declare the variable as below

 SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 32
Passing data between Driver program and smartform

 Create a Text and Display the Variable

Name is &V_NAME&.
Date is &SFSY-DATE&
Time is &SFSY-TIME&

Save & Activate the Smartform .

Change the Driver Program as Below.

CALL FUNCTION ‘LV_FNAME’


EXPORTING
V_NAME = V_NAME.

 SAVE,ACTIVATE AND TEST IT.

 SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 33
USING IMAGES IN SMARTFORM

 SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 34
USING IMAGES IN SMARTFORM

STEP1: Upload the image through SE78 Tcode


STEP2: Open the smartform
Right Click On Page1 Create Graphic
Provide the details as below.

Adjust the size in Form Painter.


Save,Activate and Test it.

 SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 35
DISPLAYING ADDRESS IN SMARTFORM

 SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 36
DISPLAYING ADDRESS IN SMARTFORM
 Open the smartform

Right Click On Page1


Create
Address
 Provide the details as below.

Adjust the size in FormPainter.


Save,Activate and Test it.

 SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 37
USING SECONDARY/TITLE WINDOW

 SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 38
USING SECONDARY/TITLE WINDOW

Right Click on Page1

Create

 Window

 Specify the window name and discription

Right Click on Window

Create

Text

Give some text like ‘PURCHASE ORDER’


Adjust the size in FormPainter.

Save,Activate and Test it.

 SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 39
USING TEMPLATES IN SMARTFORM

 SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 40
USING TEMPLATES IN SMARTFORM

Template is a node which has a fixed layout i.e. fixed no. of rows
and columns.

Templates are same as table i.e. Templates will not expand whereas
Tables expand dynamically with no. of records.

Right Click on WINDOW

Create

 Template

A icon will be displayed as below.

%Template

Similarly, line type %C1 is also displayed

Specify the no. of Rows and Columns for line type%C1

 SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 41
USING TEMPLATES IN SMARTFORM

Click on Pencil Icon and Divide %c1 into 3 Columns and 2 rows

Provide the Frame for the Template as below.

Select all Cells or Boxes

Click on select pattern Icon

A Popup is displayed .

 SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 42
Click on display framed patterns button.

Now the template gets border

Right Click on Template

Create

Text

 Give the Text as ‘SNO’.

 Click on Ouput Options tab

Specify Row/Line no as 1 ,Column Number as 1.

Similarly Repeat and Create Texts.

 SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 43
Give the Text as ‘SNAME’.

Specify Row/Line no as 1 ,Column Number as 2.

Give the Text as ‘CITY’.

Specify Row/Line no as 1 ,Column Number as 3.

Save ,Activate & Test the Driver program.

 SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 44
USING GLOBAL DEFINITION AND
PROGRAM LINES

 SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 45
USING GLOBAL DEFINITION AND PROGRAM LINES

Double click on global definitions in a smartform.

Declare a variable as below.

Right click on main window


Create
 flow logicProgram lines

 SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 46
USING GLOBAL DEFINITION AND PROGRAM LINES

Write the below ABAP Code in program lines

Write the below abap code.

V_NAME = ‘INVOICE SMARTFORM’.

Right Click on Programlines


Create
 Text.
Customer name is : &v_name&

Save, Activate and Test it.

 SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 47
USING ALTERNATIVE IN SAMRTFORMS

 SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 48
USING ALTERNATIVE IN SAMRTFORMS

ALTERNATIVE is similar to IF….ELSE….ENDIF(i.e. Condition).

Double click on Global definition and declare a variable.

Right Click on Main window.

Create
 Programlines

Write the Below Code.

 SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 49
USING ALTERNATIVE IN SAMRTFORMS

V_NAME = ‘DEL’.

Right Click on programlines


Create
FlowLogic
 Alternative.

A Condition node will be appeared.

Double Click on Condition node and specify the condition as


below.

 SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 50
USING ALTERNATIVE IN SAMRTFORMS

Right Click on TRUE node


Create
Text
Write the below Text
“DELIVERY NOTE”.
Right Click on FALSE node
Create
 Text
Write the below Text
“INVOICE”.
SAVE,ACTIVATE &TEST IT.

 SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 51
USING FOLDERS IN SMARTFORMS

 SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 52
USING FOLDERS IN SMARTFORMS

Right Click on MAIN Window


Create
 Folder

Drag and Drop a Text or ProgramLines or Condition on to the


folder.

SAVE,ACTIVATE .

 SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 53
USING TABLE,TYPES AND CODE
INITIALIZATION

 SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 54
USING TABLE,TYPES AND CODE INITIALIZATION
TABLE::
 It is a node which displays data in form of a table,
 The table expands dynamically depending upon the data.
 Whenever we create a table HEADER,MAINAREA,FOOTER will
be created automatically.
 We need to specify the columns for
HEADER,MAINAREA,FOOTER.
LINETYPE::
 It is an option which is available in the table to specify the
number of Columns in a line.

 SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 55
USING TABLE,TYPES AND CODE INITIALIZATION

Click on pencil button and divide the linetype into 4 columns


Right Click on a header
CreateTable line
Specify the LINE TYPE as ‘%LINETYPE1’.
Automatically 4 Columns(Cells) will be displayed.
Right Click on each cell
Create
Text and specify text as below
Cell1  Customer Number
Cell2 Land1
Cell3 City
Cell4  Pincode
Smilarly assign the LINE TYPE for MAIN AREA and FOOTER.

 SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 56
USING TABLE,TYPES AND CODE INITIALIZATION

Specifying Inernal Table and Work Area.

 Double Click on the Table


 Goto Data Tab

 SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 57
USING LOOP IN SMARTFORMS

 SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 58
USING LOOP IN SMARTFORMS
LOOP:
 LOOP is a node which is used to loop an internal table.

 SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 59
DEBUGGING OF SMARTFORMS

 SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 60
DEBUGGING OF SMARTFORMS

There are two ways to Debug the smartforms

By putting the static breakpoint in programlines of a


smartform.

By putting a dynamic break point ina function module.

 SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 61
CONFIGURATION OF SMARTFORM

 SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 62
CONFIGURATION OF SMARTFORM

These Configuration settings is done by BASIS consultant.

TextModules In Smarforms:-

 Text modules are used display text depending on logon


language.

 SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 63
Text formatting options

 SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 64
Text formatting options

What are the various text formatting options in Smart forms?

&symbol(Z)& Omit Leading Zeros


&symbol(S)& Omit Leading Sign
&symbol(<)& Display Leading Sign to the Left
&symbol(>)& Display Leading Sign to the Right
&symbol(C)& Compress Spaces
&symbol(.N)& Display upto N decimal places
&symbol(T)& Omit thousands separator
&symbol(R)& Right justified
&symbol(I)& Suppress output of the initial value

 SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 65
Review

-- Please Ask Questions!

 SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 66
ALV Reports By ARJUN

Function modules for developing ALV Reports

REUSE_ALV_GRID_DISPLAY  Display ALV data in GRID format

REUSE_ALV_LIST_DISPLAY  Display ALV data in LIST format

REUSE_ALV_COMMENTARY_WRITE  Display TOP-OF-PAGE,


LOGO,END-OF-LIST.

REUSE_ALV_FIELDCATELOG_MERGE Generate field catalog


automatically

REUSE_ALV_EVENTS_GET  Display ALV Events

REUSE_ALV_HIERSEQ_LIST_DISPLAY Display hierarchical ALV

REUSE_ALV_BLOCKED_LIST_DISPLAY  Display blocked ALV

 SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 67
List of ALV’s

ALV with structure

ALV with field category options

ALV with layout options

ALV with field catalog merge

ALV with totals and sub totals

ALV with LOGO/ TOP OF PAGE / END OF LIST

Interactive ALV

Interactive ALV by calling a transaction

hierarchical ALV

Blocked ALV
 SAP AG 2001, Smart Forms - the Form Printing Solution,
Claudia Binder / Jens Stumpe 68
» ALV with Structures
Business Requirement

Develop a material master Report which displays all the fields

STEPS

Declare an internal table and work area for MARA table

Write an select statement to fetch the data

Call the function module REUSE_ALV_GRID_DISPLAY and specify


the Below parameters

Structure Name

Program Name

Itab Name
 SAP AG 2001, Smart Forms - the Form Printing Solution,
Claudia Binder / Jens Stumpe 69
FieldCatelog: It is an int.Table which contains the list o the fields to
be displayed in ALV Report

It is also used to set various properties for each field.

The properties/options are:

1. COL_POS = 1.

2. FIELD NAME Specifies the name of the field

3. TABLE NAME Specifies the name of the internal table

4. SELTEXT_S  Specifies short

SELTEXT_L  Specifies Long

SELTEXT_M  Specifies medium

 SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 70
5. DO_SUM = ‘X’  For grand totals

6. SUBTOT = ‘X’  Sub totals to be calculated

7. EDIT = ‘X’  Field can be editable

8. EMPHASIZE = ‘CXYZ’  Specifies the Color to the fields

C – Indicates color

X – Color Numbers

Y – Backgroundcolor – 1 On BG color

0 off BG color

Z – Font color 1 OnFont color

0 Off font color

 SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 71
9. REFERENCE TABLENAME

REFERENCE FIELDNAME  To copy all the properties


from data dictionary to a
field catalog field.

10. KEY  Specify the key field

11. HOTSPOT  For selection.

Generation of Fieldcatelog :

It is generated using 2 ways.

1)Manually

2)Automatically by using FM

 SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 72
Steps for Example Program on field catalog

Declare the internal table and work area for the field catalog

DATA : i_fcat TYPE slis_t_fieldcat_alv.


*DATA : wa_fcat TYPE slis_fieldcat_alv.
DATA : wa_fcat like LINE OF i_fcat.

Fill the fieldcatelog Itab with all fields and their corresponding
properties.

wa_fcat-col_pos = 1. "v_pos.
wa_fcat-fieldname = 'KUNNR'.
*wa_fcat-tabname = 'I_KNA1'.
WA_FCAT-SELTEXT_L = 'CUST_NUM'.
*WA_FCAT-EDIT = 'X'.
WA_FCAT-EMPHASIZE = 'C610'.
WA_FCAT-REF_TABNAME = 'KNA1'.

 SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 73
WA_FCAT-REF_FIELDNAME = 'KUNNR'.
*WA_FCAT-KEY = 'X'.

APPEND WA_FCAT TO I_FCAT.


CLEAR WA_FCAT.

Call the function module and Export the field catalog in internal table
as exporting parameters to IT_FCAT.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'


EXPORTING
I_CALLBACK_PROGRAM = 'SY-REPID'
IT_FIELDCAT = I_FCAT
TABLES
T_OUTTAB = I_KNA1.

 SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 74
ALV with Layout
Layout

It is a structure or work area which is used to decorate or embellish


the output of ALV Report

Layout contains the few properties to decorate the ALV output

The properties are,

1. ZEEBRA = ‘X’.  Displays ALV with alternative colors

2. COLWIDTH-OPTIMIZE = ‘X’.  Each column in ALV o/p


displayed with maximum length, to display the entire data.

3. EDIT= ‘X’. All the columns are displayed in editable mode.

 SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 75
4. NO_VLINE = ‘X’.  Vertical lines will not be displayed

5. NO_HLINE = ‘X’.  Horizontal lines will not be displayed

Steps:

Declare a work area for the Layout

DATA : wa_layout TYPE slis_layout_alv.

Fill the WA with various options.

wa_layout-zebra = 'X'.
wa_layout-colwidth_optimize = 'X'.
* wa_layout-edit = 'X'.
* wa_layout-no_vline = 'X'.
wa_layout-no_hline = 'X'.

 SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 76
Call the function module and send the WA as exporting parameter to
IS_LAYOUT.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'


EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
IS_LAYOUT = WA_LAYOUT
IT_FIELDCAT = I_FCAT
TABLES
T_OUTTAB = I_KNA1.

 SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 77
ALV Reports with Totals

The totals can be calculated in two ways

By clicking on ∑ ALV output field.

By programmatically setting the option

DO_SUM = ‘X’, for an currency/quantity field in FCAT

WA_FCAT-COL_POS = ’5’.
WA_FCAT-FIELDNAME = 'NETWR'.
WA_FCAT-SELTEXT_M = 'NETPRICE‘.
WA_FCAT-DO_SUM = 'X'.
APPEND WA_FCAT TO I_FCAT.

 SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 78
ALV Reports with and sub totals

To calculate sub totals, we need to find out on what basis (field


name) the sub totals need to be calculated.

We need to sort the field in ascending order.

Then we need to set the property

SUBTOT = ‘X’ in FCAT.

WA_SORT-FIELDNAME = 'VBELN'.
WA_SORT-UP = 'X'.
WA_SORT-SUBTOT = 'X'.
APPEND WA_SORT TO I_SORT.

 SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 79
Steps :

Declare the internal table and work area for the sorting

DATA : I_SORT TYPE SLIS_T_SORTINFO_ALV.


DATA : WA_SORT TYPE SLIS_SORTINFO_ALV.

Specify the field and subtot = ‘X’ .

WA_SORT-FIELDNAME = 'VBELN'.
WA_SORT-UP = 'X'.
WA_SORT-SUBTOT = 'X'.
APPEND WA_SORT TO I_SORT.

 SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 80
Call the function module and send the SORT internal table as
exporting parameters to IT_SORT

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'


EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
IT_FIELDCAT = I_FCAT
IT_SORT = I_SORT
TABLES
T_OUTTAB = I_VBAP.

 SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 81
ALV with field catalog merge

We can create a field catalog either manually or by automatically

REUSE_ALV_FIELDCATELOG_MERGE is the function module which


is used to create field catalog automatically

But this is obsolete because, the function module uses the old
syntax for declaring internal tables

I.e. the internal table should be created as below and all the
fields in the internal table must be declared using LIKE statement not
the TYPE statement.
DATA: BEGIN OF I_MARA OCCURS 0,
MATNR LIKE MARA-MATNR,
MTART LIKE MARA-MTART,
MEINS LIKE MARA-MEINS,
END OF I_MARA.

 SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 82
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE’
EXPORTING
I_PROGRAM_NAME = SY-REPID
I_INTERNAL_TABNAME = 'I_MARA'
I_INCLNAME = SY-REPID
CHANGING
CT_FIELDCAT = I_FCAT.

LOOP AT I_FCAT INTO WA_FCAT.


IF WA_FCAT-FIELDNAME = 'MEINS'.
WA_FCAT-NO_OUT = 'X'. "For hiding the field
ELSEIF WA_FCAT-FIELDNAME = 'MTART'.
WA_FCAT-KEY = 'X‘.
ENDIF.

MODIFY I_FCAT FROM WA_FCAT INDEX SY-TABIX.


ENDLOOP.

 SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 83
ALV Reports with top of page/ Events

There are totally 17 events available for ALV reporting

The function module REUSE_ALV_EVENTS_GET will display all the


list of ALV events

Below are some events

Top-Of-Page

End-Of-List

At User command

Set PF status

 SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 84
ALV with LOGO:

For Logo’s in the ALV , We have two steps.

1. Upload the Logo from our system into SAP.


2. Call the FM “Reuse_Alv_Commentary_Write” and Export the Logo
name.

STEP1: “OAER” is the T-Code for upload the Logo’s into SAP.
=> Go to OAER Tcode.
ClassName – Pictures
ClassType – OT
ObjectKey – ARJUN
Click on the Standard Document Types
Double Click on the SCREEN Option for browse the image.

Click on the Save Button.

 SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 85
STEP2:
Call Function ‘REUSE_ALV_COMMENTARY_WRITE’
Exporting
I_LOGO = ‘ARJUN’.

 SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 86
TOP-OF-PAGE

Call the function module REUSE_ALV_EVENTS_GET

Provide the sub routine name for top-of-page event

Write below down the code in sub routine

Call the function module REUSE_ALV_COMMENTARY_WRITE to


display top-of-page in ALV

Finally export the events into internal table to the


REUSE_ALV_GRID_DISPLAY

 SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 87
STEP1:Data Declarations for TOP-OF-PAGE.
TYPE-POOLS: SLIS.
Data: I_EVENTS type SLIS_T_EVENT.
Data: WA_EVENTS like line of I_EVENTS.
Data: I_HEADING type SLIS_T_LISTHEADER.
Data: WA_HEADING like line of I_HEADING.
STEP2:
Call Function ‘ REUSE_ALV_EVENTS_GET’
Importing
ET_EVENTS = I_EVENTS.

Read Table I_EVENTS into WA_EVENTS


with key NAME = ‘TOP-OF-PAGE’.
WA_EVENTS-FORM = ‘ FORM_TOP_OF_PAGE ’.
Modify I_EVENTS into WA_EVENTS index SY–TABIX.

 SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 88
Form FORM_TOP_OF_PAGE.
WA_HEADING - TYP = ‘H’.
WA_HEADING – INFO = ‘MATERIAL MASTER REPORT’ .
Append WA_HEADING to I_HEADING.

WA_HEADING - TYP = ‘S’.


WA_HEADING – KEY = ‘USERNAME’.
WA_HEADING – INFO = SY – UNAME.
Append WA_HEADING to I_HEADING.

WA_HEADING - TYP = ‘A’.


WA_HEADING – KEY = ‘DATE’.
WA_HEADING – INFO = SY – DATUM.
Append WA_HEADING to I_HEADING.

 SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 89
STEP3:
Call Function ‘REUSE_ALV_COMMENTARY_WRITE’
Exporting
IT_LIST_COMMENTARY = I_HEADING.
EndForm.

STEP4:
Call Function ‘REUSE_ALV_GRID_DISPLAY’
Exporting
I_Callback_Programme = SY – REPID
IT_Events = I_EVENTS
Tables
T_OutTab = I_MARA.

 SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 90
END -OF-LIST:

Call the function module REUSE_ALV_EVENTS_GET

Provide the sub routine name for End-of-List event

Write below down the code in sub routine

Call the function module REUSE_ALV_COMMENTARY_WRITE to


display End-of-List in ALV

Finally export the events into internal table to the


REUSE_ALV_GRID_DISPLAY

 SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 91
STEP1:Data Declarations for End-of-List.
TYPE-POOLS: SLIS.
Data: I_EVENTS type SLIS_T_EVENT.
Data: WA_EVENTS like line of I_EVENTS.
Data: I_HEADING type SLIS_T_LISTHEADER.
Data: WA_HEADING like line of I_HEADING.
STEP2:
Call Function ‘ REUSE_ALV_EVENTS_GET’
Importing
ET_EVENTS = I_EVENTS.

Read Table I_EVENTS into WA_EVENTS


with key NAME = ‘END_OF_LIST’.
WA_EVENTS-FORM = ‘ FORM_END_OF_LIST’.
Modify I_EVENTS into WA_EVENTS index SY–TABIX.

 SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 92
Form FORM_END_OF_LIST.
WA_HEADING - TYP = ‘S’.
WA_HEADING – INFO = ‘ALL RIGHTS RESERVED TO THE
COMPANY’ .
Append WA_HEADING to I_HEADING.
STEP3:
Call Function ‘REUSE_ALV_COMMENTARY_WRITE’
Exporting
IT_LIST_COMMENTARY = I_HEADING
I_END_OF_LIST_GRID = ‘X’.
EndForm.
STEP4:
Call Function ‘REUSE_ALV_GRID_DISPLAY’
Exporting
I_Callback_Programme = SY – REPID
IT_Events = I_EVENTS
Tables
T_OutTab = I_MARA.
 SAP AG 2001, Smart Forms - the Form Printing Solution,
Claudia Binder / Jens Stumpe 93
INTERACTIVE ALV’s:

Call the function module REUSE_ALV_EVENTS_GET

Provide the sub routine name for USER_COMMAND

Write below down the code in sub routine

In the Sub routine Call the function module


REUSE_ALV_GRID_DISPLAY to display Secondary ALV

Finally export the events into internal table to the


REUSE_ALV_GRID_DISPLAY

 SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 94
STEP1:Data Declarations .
Type-Pools: SLIS.
Data: I_Events type SLIS_T_EVENT.
Data: WA_Events like line of I_Events.
Data: V_VBELN type VBAK – VBELN.
STEP2:
Call Function ‘REUSE_ALV_EVENTS_GET’
importing
ET_EVENTS = I_EVENTS.
Read Table I_EVENTS into WA_EVENTS with key NAME =
‘USER_COMMAND’.
WA_EVENTS-FORM = ‘FORM_USER_COMMAND’.
MODIFY I_EVENTS from WA_EVENTS index SY-TABIX.
Form FORM_USER_COMMAND using UCOMM type SY-UCOMM
SELFIELD type SLIS_SELFIELD.
READ TABLE I_VBAK into WA_VBAK index SELFIELD-TABINDEX.

 SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 95
Select * from VBAP into corresponding fields of table I_VBAP
where VBELN = WA_VBAP-VBELN.
STEP3:
CALL FUNCTION ‘REUSE_ALV_GRID_DISPLAY’
Exporting
I_CALLBACK_PROGRAME = SY-REPID
I_STRUCTURE_NAME = ‘VBAP’
Tables
T_OUTTAB = I_VBAP.
STEP4:
Call Function ‘REUSE_ALV_GRID_DISPLAY’
Exporting
I_Callback_Programme = SY – REPID
I_StructureName = ‘VBAK’
IT_Events = I_EVENTS
Tables
T_OutTab = I_VBAK.

 SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 96
HIERARCHIAL ALV’s:

Create User-Defined Types for Header Data and Item Data.

Write the code in Subroutines for Header data and Item Data.

Create the Fieldcatalog .

Create subroutine for Hierarchy.


Form Create_Hierarchy.
Key – Header01 = ‘VBELN’.
Key – Item01 = ‘VBELN’.
EndForm.

Finally,For Display Exports Header Data, Item Data, and Fieldcatalog


to the function module REUSE_ALV_HIERSEQ_LIST_DISPLAY.

 SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 97
Call Function ‘REUSE_ALV_HIERSEQ_LIST_DISPLAY’
Exporting
I_Callback_Program = SY – REPID
IT_Fieldcat = I_FCAT
I_Tabname_Header = ‘I_VBAK’
I_Tabname_Item = ‘I_VBAP’
Is_KeyInfo = KEY
Tables
T_Outtab_Header = I_VBAK
T_Outtab_Item = I_VBAP.

 SAP AG 2001, Smart Forms - the Form Printing Solution,


Claudia Binder / Jens Stumpe 98

S-ar putea să vă placă și