You are on page 1of 49

Day 4

SAP Scripts I

Agenda
About Forms
Header
Page Layout
Windows
Pages
Page Windows

Paragraph Format
Character Format
Documentation

Different Forms
Form 1

Invoice

Form 2
Document

Form 3

Dear

Processing Sequence

SAP DB
Form

Document
Invoice

Application transaction
Print program

Invoice

Composer

SAP Script
A form of the graphical
Form Painter consists of
Header data
Page layout
Paragraph format
Character format
Documentation

SE71

Header Data: Organization


:

Header
ata
Header
ddata
Administrative data
Administration information
Language attributes

Basicsettings
Set up page
Default values fortext
formatting

Header Data: Basic Settings


Basic Settings

Set uppage

Spool

z Page format
z First page
z Orientation

Default values for


text formatting
z Tab stop

z Font family
Font
maintenance zFont size

Portrait format
Landscape format
z Lines/inch
z Characters/inch

z Default paragraph
z Bold
z Italic

Form
definition

z Underlined
z Spacing
z Thickness
z Intensity

Editing Forms: The Form Painter

alphanumeric

Form Painter

Header data

graphical

Header data

Windows
Pages

Layout

Page windows
Paragraph formats

Paragraph formats

Character formats

Character formats

Structuring Pages Using Windows

Pages
Windows

Form Components - Windows

They represent areas that are


positioned on pages as page
windows and in which at a later
time text is printed. You must
define at least one window for
each form

Window Types

Windows

Sender

Date

Adressee

Window type
:
VAR

Types of windows
Main Window

Window with
body text

Window type
:
MAIN

Variable Window
Footer

Const Window
SAP AG 1999

Window type
: VAR

Page Windows

Window names are linked


to page names. The
position and size of the
window on the assigned
page should be specified

Topedge
Topedge
Left edge

Left margin
Upper margin

Page window

Window width
Window height

Width

Page

Height

Windows and Page Windows


Windows

Sender

and

Form:

Page windows

Date

Adressee

Window with
body text

Page 2
Page 1

Footer

Pages
Define at least one page for every form
Designate a "first" page in the form header
Inform the system which page is to be used after
reaching the end of the first page

Pages - Attributes
Mode
INC
Increases the counter by 1
HOLD Counter remains unchanged
START Sets the counter to 1
NUMBERING TYPES
ARABICArabicnumerals
CHAR Fixed character
LETTERLetters
ROMAN Romannumerals
Papertray choice

S
S
D
D
TT

Simplex
Simplex mode
mode
Duplex
Duplex mode
mode
Tumble
Tumble mode
mode

Character formats

Allows to format entire blocks of


text within a paragraph

Character attribute groups can be:


Font
Standard

Font attributes - attributes such as


font family, size, bold, italic etc.
Standard attributes

Marker
Bar code
Protected
Hidden
Superscript/subscript

Paragraph formats

In SAPScript, paragraphs are


formatted using formats and
their corresponding attributes

Helps simplifying the text


processing

Attributes
Standard
Font
Tabs
Outline

Paragraph formats

Standard attributes

Description
Left or right margin
Indent first line
Space before and space after
Alignment
Line spacing
No blank lines
Page protection
Next paragraph same page

Alignment:
Alignment:
Standard attributes
Paragraph

HD

Left margin

1.00

CM

Alignment

LEFT

Right margin 1.50


Indent 1st line 2.00

CM

Line spacing

1.00

CM

No blank lines

Space before

CM

Page protection

Space after

Left margin

1.50

Header 1

Description

Right margin

Space before

Window

LN

Next paragraph same page

Space after
Indentation

BLOCK
BLOCK justified
justified
CENTER
CENTERcentered
centered
LEFT
LEFT aligned
alignedleft
left
RIGHT
RIGHT aligned
alignedright
right

Units
Unitsof
of
measurement:
measurement:
LN
LN Lines
Lines
CM
CM Centimeters
Centimeters
MM
MM Millimeters
Millimeters
IN
IN Inches
Inches
PT
PT Points
Points
TW
TW Twips
Twips

Paragraph formats

Font attributes - attributes such as font family, size, bold, italic etc.

Tabs - tab position (different units of measure)

Outline - Outline, outline level, Number margin, left/right delimiter,


Number chaining, character string, Numbering type.

Paragraph Formats: Metric Sizes


Paragraph Formats:
MetricSizes

Right margin

Left margin
Dear Mr.
. Smythe
,

Space after
Space before
Indent

Thank you for your


reservation
. We are pleased to
confirm the following bookings

Window

Graphical Form Painter: Page Layout


Form ...

Page
FIRST

Address page

WINDOW1*

WINDOW2*

Window Graphic
Window
ADDRESS
Description Address
Main window Administrative window
Default paragraph
1,60

CM

Upper margin 1,60


Window width 9,00

CM

Window height 6,00

CM

Left margin

Design / Text

CM

Options

MAIN*

Design window

Form Elements: Documentation

List ofall pages


PAGE_1
PAGE_2
...

Editor
Enter longtexts

List ofallwindows
WINDOW_1
MAIN
...

Listofall text elements


MAIN-ITEM_HEADER
MAIN-ITEM_LINE
...

Day 4

SAP Scripts II

Agenda

Text Elements
Control Commands
Symbols System, Program, Standard, Text
Function Modules

Text Elements
Text elements are defined for each window. On the
Form: choose Edit Text elements.
In the layout of a text element, we can use the paragraph
and character formats defined in the form.
Example
/E ITEM_LINE
IL &VBDPA-POSNR&,,&VBDPA-MATNR
/

&'Customerarticlenumber 'VBDPA-IDNKD'

SAP Script - Control commands


IF Command
Syntax
/: IF condition
:
ELSEIF condition
:
/:ELSE
:
/:ENDIF
IF + the condition must not extend more than a line

SAP Script - Control commands


CASE command
Syntax
/: CASE symbol
/: WHEN value1
:
/: WHEN value 2
:
/: WHEN value n
:
/: WHEN OTHERS.
:
/:ENDCASE

SAP Script - Control commands


PERFORM Command
To Call an ABAP subroutine (form) from any program
Syntax
/: PERFORM <form> IN PROGRAM <prog>
/: USING &VAR1&

/: CHANGING &VAR2&

/: ENDPERFORM

SAP Script - Control commands

ADDRESS Command

Formatting Addresses
/: ADDRESS [DELIVERY] [TYPE t] [PARAGRAPH a]
[PRIORITY p] [LINES l]
/: TITLE title
.
/: STREET street name HOUSE house number
.
/: ENDADDRESS

SAP Script - Control commands


INCLUDE Command
To include the contents of another text into the current text
Syntax
/: INCLUDE name [OBJECT o] [ID i] [LANGUAGE l]
[PARAGRAPH p] [NEW-PARAGRAPH np]
Example
/: INCLUDE MYTEXT LANGUAGE 'E' PARAGRAPH 'A1'

SAP Script - Symbols


Text in the SAP system contains a reference to some
other stored object
We can create flexible text modules by using the
placeholders at all points where the text needs to be
variable. These placeholders are symbols
Data is added to the text normally at the point at which
output is formatted

SAP Script - Symbols - Types


System symbols
Standard symbols
Program symbols
Text symbols

System Symbols

DATE
DAY
NAME_OF_DAY
MONTH
NAME_OF_MONTH
YEAR
TIME
HOURS
MINUTES
SECONDS
PAGE
NEXTPAGE
DEVICE
SPACE
ULINE
VLINE

Date
Day
Name of day
Month
Name of month
Year
Time
Hours
Minutes
Seconds
Page number
Number of next page
Output device
Blank space
Underline
Vertical line

Standard Symbols

Table TTDTG

Symbols are user-defined

Symbols are language-dependent

Name: max. 22 characters

Value: max. 60 characters

Text Symbols

Value is defined in the text module

DEFINE &symbol& =

Name: max. 32 characters

Value: max. 60 characters

value

Program Symbols
KNA1
ABAP
TABLES KNA1.
DATA:
COUNTRY LIKE ...
* Data selection
...
* Start of form printing
...

Form

&KNA1 - NAME1&
&KNA1 - STRAS&
&KNA1 - PSTLZ&&KNA1 - ORT01&
&COUNTRY&

NAME1

Jane Smith

PSTLZ

80801

ORT01

Capital City, CA

STRAS

81 Third Ave

Jane Smith
81 Third Ave.
Capital City, CA 80801
USA

Program Symbol and Symbol Definition


Text Edit Goto Format Include System Help

Text Edit Goto Format Insert System Help

Program symbols
.....
SPFLI
SFLIGHT
CRTX

Programm symbols
Program
Symbolsymbols
definition

.....

Symbol definition
Print programfor form
Print
for formDescription
Printprograms
programm
Print report
RIPRAT01
RIPRAT01
.....

DDIC fields

Short description
.....
.....
Global data

Symbol definition
REPORT riprat01.
TABLES: spfli, sflight, ...
DATA: sums LIKE ...

.....

Defining Text Symbols

Form:

RVINVOICE01

Window: FOOTER

/ : DEFINE &SYMBOL& = 'String1 String2 String3'


...

Time, Date Format

/: SET TIME MASK = .........


/: SET DATE MASK = ........
/: SET COUNTRY ........

Example :
/: SET TIME MASK = HH : MM
/: SET DATE MASK = DD.MMMM YYYY
/: SET COUNTRY US

Frames, Lines and Shading


Window1

Form
Window1

[/ : POSITION WINDOW]
[/ : SIZE WIDTH 2 CMHEIGHT +40 TW]
/ : BOX FRAME 10 TW

Window2

Window2
/ : BOX INTENSITY 10
Window3

Window3
/ : BOX HEIGHT 0 CMFRAME 20 TW
/ : BOX WIDTH 0 CMFRAME 20 TW

Calling ABAP Subroutines


Form
/: PERFORM <form> IN PROGRAM <prog>
/: USING &invar1&
/: USING &invar2&
.
/: CHANGING &outvar1&
..
/: ENDPERFORM

IN_TAB
structure ITCSY
NAME

VALUE

invar1

...

invar2

...

REPORT <prog>.
FORM <form> TABLES in_tab STRUCTURE itcsy
out_tab STRUCTURE itcsy.
...
ENDFORM.
ABAP
report

ABAP
Dictionary

Function Modules in SAP Script


Form functions
OPEN_FORM

Opens the form output

WRITE_FORM

Calls a form element

CLOSE_FORM

Ends the form output

START_FORM

Starts a new form

Database
READ_TEXT

Reads a text module and passes


it to the specified work areas

Print Program and Composer

Print program
report jh_form_01.

Application

DB

data

Form
ABAP
program

tables: scustom.
select * from scustom...
......
call function 'OPEN_FORM'
......
call function 'START_FORM'
......
call function 'WRITE_FORM'
......

J. Smith
7 Second Ave.
47110 XYZ City

Composer

Place, Date
Invoice No.4
123-45-556-678

Art.No.
00345
00379
02378
00458
Total

Price
200.150.50.300.700.XYZ Bank
Acct. No.: 0815 4711
Bank No.: 000000000

Structure of Print Program

Retrieves data
Opens form
printing

Closes form
printing

program rstxexp1.
tables: scustom, sbook, ...
select * from ...
...
call function 'OPEN_FORM'
exporting form = ...
...
call function 'START_FORM' ...
...
call function 'WRITE_FORM'
exporting element = ...
window = ...
...
call function 'END_FORM' ...
...
call function 'START_FORM' ...
...
call function 'END_FORM' ...
...
call function 'CLOSE_FORM' ...

Changes to
another form
Prints output
on form

Main Windows

TOP

BODY
MAIN

BOTTOM

Outputting Text Elements in the Main Window

CALL FUNCTION 'WRITE_FORM'


EXPORTING
ELEMENT
= ...
EXCEPTIONS ...
= ...

Art.No.
00345

MAIN

Price
200.-

WRITE_FORM
element = 'ITEM_LINE'
window= 'MAIN'

/E ITEM_HEADER
Art.No.,,Price
/E ITEM_LINE
&vbdpa-matnr&,,
&vbdpa-netpr&

Art.No.
00345
00379
MAIN

Price
200.150.-

Creating and Deleting Headings

Output heading to
current page

Write heading in
TOParea

Delete heading from


TOParea
for next page

call function 'START_FORM' ...


...
call function 'WRITE_FORM'
exporting element = 'ITEM_HEADER'
type
= 'BODY'
window = 'MAIN'
call function 'WRITE_FORM'
exporting element = 'ITEM_HEADER'
function = 'SET'
type
= 'TOP'
window = 'MAIN'
...
call function 'WRITE_FORM'
exporting element = 'ITEM_HEADER'
function = 'DELETE'
type
= 'TOP'
window = 'MAIN'
...
call function 'END_FORM' ...

Adding Text Elements to Non-main Windows

CALL FUNCTION 'WRITE_FORM'


EXPORTING
ELEMENT
= ...
FUNCTION
= 'APPEND'
WINDOW
= 'INFO'
EXCEPTIONS ...
= ...

Art.No.
00345
00379
02378
00458
Total

INFO

INFO

INFOTEXT1

INFOTEXT1
INFOTEXT2

Price
200.150.50.300.700.-

WRITE_FORM
element = 'INFOTEXT2'
function = 'APPEND'
window = 'INFO'

Art.No.
00345
00379
02378
00458
Total

Price
200.150.50.300.700.-

Style : A Formatting Aid

. . . . +. . . . 1. . . . +. . . . 2. . . . +. . . . 3. . . . +. . . . 4. . . . +. . . . 5. . . . +. . . . 6. . . . +

You have assigned a style to this


text.

You have assigned a STYLE to this text.

CU This is an outline:
G1 First level

Format column(1) 6 En...

G2 Second level
G3 Third level

F.... Description
G3

Outline level 3

AS Standard paragraph
B

Bold

----------MYSTYLE---------System-------------Lines
1 - 1/ 1 ----------CU Italic, underlined

F4

G1

Outline level 1

G2

Outline level 2

G3

Outline level 3

This is an outline:
=> First level
=> Second level
=> Third level

Thank You

You might also like