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

Composer

Invoice

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 d Header ata d Administrative data


Administration information Language attributes

Basic settings
Set up page Default values fortext formatting

Header Data: Basic Settings


Basic Settings

Set uppage
Page format First page Orientation Portrait format Landscape format Lines/inch Characters/inch

Spool

Default values for text formatting


Tab stop Font family Font size Default paragraph Bold Italic Underlined
Spacing Thickness Intensity

Font maintenance

Form definition

Editing Forms: The Form Painter

alphanumeric
Header data Windows Pages

Form Painter
Header data

graphical

Layout

Page windows Paragraph formats Character formats Paragraph 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 Types of windows Main Window Variable Window
Footer Window with body text

Window Types

Windows
Date

Sender Adressee

Window type VAR :

Window type MAIN :

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
Left margin Upper margin Window width Window height
Topedge Topedge Left edge

Page window

Height

Width

Page

Windows and Page Windows


Windows
and

Form:

Page windows

Sender

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 ARABICArabic numerals CHAR Fixed character LETTERLetters ROMAN Roman numerals Papertray choice

S S D D T T

Simplex mode Simplex mode Duplex mode Duplex mode Tumble mode Tumble 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
Standard attributes Paragraph Left margin HD 1.00 Description CM CM CM CM Alignment Line spacing Header 1 LEFT 1.00 LN

Alignment: Alignment:
BLOCK justified BLOCK justified CENTER centered CENTER centered LEFT LEFT aligned left aligned left RIGHT aligned right RIGHT aligned right

Right margin 1.50 Indent 1st line 2.00 Space before Space after 1.50

No blank lines Page protection Next paragraph same page Right margin Space after Space before

Units of Units of measurement: measurement:


LN Lines LN Lines CM Centimeters CM Centimeters MM Millimeters MM Millimeters IN Inches IN Inches PT Points PT Points TW Twips TW Twips

Left margin

Indentation Window

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: Sizes Metric

Left margin
Dear Mr. Smythe . ,

Right margin

Space after Space before Indent


Thank you for your reservation We are pleased to . confirm the following bookings

Window

Graphical Form Painter: Page Layout


Page FIRST Address page Form ...
WINDOW1*

WINDOW2*

Window Graphic Window ADDRESS Description Address Main window Administrative window Default paragraph Left margin 1,60 CM CM CM CM Upper margin 1,60 Window width 9,00 Window height 6,00
MAIN*

Design window

Design / Text

Options

Form Elements: Documentation

L o p es ist fall ag P G _1 AE P G _2 AE ...

E ditor
E ter lo gtexts n n

L o ist fallw d w in o s W D W1 IN O _ M IN A ...

L fall text elem ts isto en M IN-IT M E D R A E _H A E M IN-IT M IN A E _L E ...

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& =

value

Name: max. 32 characters

Value: max. 60 characters

Program Symbols
KNA1 ABAP
TABLES KNA1. DATA: COUNTRY LIKE ... * Data selection ... * Start of form printing ...
NAME1 PSTLZ ORT01 STRAS Jane Smith 80801 Capital City, CA 81 Third Ave

Form

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

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

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 symbols Symbol definition Symbol definition Print programfor form Print programs for formDescription Print 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

W indow: 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


Form
W indow1

W indow1 [/ : POSITION W INDO W] [/ : SIZE W IDTH 2 CMHEIGHT +40 TW ] / : BOX FRA 10 TW ME W indow2 / : BOX INTENSITY 10

W indow2

W indow3

W indow3 / : BOX HEIGHT 0 CMFRA 20 TW ME / : BOX W IDTH 0 CMFRA 20 TW ME

Calling ABAP Subroutines


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

IN_TAB structure ITCSY NAME invar1 invar2 VALUE ... ...

ABAP Dictionary

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

Function Modules in SAP Script


Form functions OPEN_FORM WRITE_FORM CLOSE_FORM START_FORM Database READ_TEXT Reads a text module and passes it to the specified work areas Opens the form output Calls a form element Ends the form output Starts a new form

Print Program and Composer

Print program
report jh_form_01.

Form ABAP program

Application

DB

data

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

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

Composer

Art.No. 00345 00379 02378 00458 Total


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

Price 200.150.50.300.700.-

Structure of Print Program


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' ...

Retrieves data Opens form printing

Changes to another form Prints output on form

Closes form printing

Main Windows

TOP

BODY
MAIN

BOTTOM

Outputting Text Elements in the Main Window

CALL FUNCTION 'WRITE_FORM' EXPORTING ELEMENT = ... EXCEPTIONS ... = ...

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

Art.No. 00345

Price 200.-

WRITE_FORM element = 'ITEM_LINE' window= 'MAIN'

Art.No. 00345 00379


MAIN

Price 200.150.-

MAIN

Creating and Deleting Headings


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' ...

Output heading to current page

Write heading in TOParea

Delete heading from TOParea for next page

Adding Text Elements to Non-main Windows

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

INFO INFOTEXT1

INFO INFOTEXT1 INFOTEXT2

Art.No. 00345 00379 02378 00458 Total

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 G2 Second level G3 Third level

Format column(1) 6 En...


F.... Description G3 B Outline level 3 AS Standard paragraph Bold

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

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


G1 Outline level 1 Outline level 2 Outline level 3

F4

G2 G3

Thank You

You might also like