49
Day 4 SAP Scripts I

4 SAP Script

Embed Size (px)

Citation preview

Page 1: 4 SAP Script

Day 4

SAP Scripts I

Page 2: 4 SAP Script

Agenda

• About Forms• Header• Page Layout

– Windows– Pages– Page Windows

• Paragraph Format• Character Format• Documentation

Page 3: 4 SAP Script

Different Forms

Form 2

Form 1

Form 3

Dear

Invoice

Document

Page 4: 4 SAP Script

Processing Sequence

Invoice

Document

Print program

Application transaction

Form

Composer

SAP DBSAP DB

Invoice

Page 5: 4 SAP Script

SAP Script SE71

A form of the graphical

Form Painter consists of

Header data

Page layout

Paragraph format

Character format

Documentation

Page 6: 4 SAP Script

Header Data: Organization:

HeaderdataHeaderdata

Administrative data

Language attributes

Basic settings

Default values fortextformatting

Administration

Set up page

information

Page 7: 4 SAP Script

Header Data: Basic Settings

Basic SettingsBasic Settings

PageformatFirst pageOrientation

Portrait formatLandscape format

Lines/inchCharacters/inch

Set uppage

Tab stopFont familyFont sizeDefault paragraphBoldItalicUnderlined

SpacingThicknessIntensity

Default values for text formatting

Spool

FormFormdefinitiondefinition

Fontmaintenance

Page 8: 4 SAP Script

Editing Forms: The Form Painter

alphanumeric

Header data

Windows

Pages

Pagewindows

Paragraphformats

Character formats

Form Painter graphical

Layout

Header data

Paragraphformats

Character formats

Page 9: 4 SAP Script

Structuring Pages Using Windows

Windows

Pages

Page 10: 4 SAP Script

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

– Const Window© SAP AG 1999

SenderDate

Adressee

Footer

Window withbody text

Windows

Window type: MAIN

Window type: VAR

Window type: VAR

Window Types

Page 11: 4 SAP Script

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

Pagewindow

TopTopedgeedgeLeft edgeLeft edge

WidthWidth

HeightHeight

PagePage

Page 12: 4 SAP Script

Windows and Page Windows

SenderDate

Adressee

Footer

Window withbody text

Windows Form: Page windows

Page 1

Page 2

and

Page 13: 4 SAP Script

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

Page 14: 4 SAP Script

Pages - Attributes

ModeINC Increases the counter by 1HOLD Counter remains unchangedSTART Sets the counter to 1

NUMBERING TYPES ARABICArabicnumeralsCHAR Fixed characterLETTERLettersROMAN Romannumerals

Papertray choice

S Simplex modeD Duplex modeT Tumble mode

S Simplex modeD Duplex modeT Tumble mode

Page 15: 4 SAP Script

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

Page 16: 4 SAP Script

Paragraph formats

• In SAPScript, paragraphs are formatted using formats and their corresponding attributes

• Helps simplifying the text processing

Attributes– Standard

– Font

– Tabs

– Outline

Page 17: 4 SAP Script

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

Paragraph

Left marginRight marginIndent 1st lineSpace beforeSpace after

AlignmentLine spacing

Noblank linesPage protectionNext paragraph same page

Description

WindowWindow

IndentationIndentation

Space afterSpace after

Space beforeSpace before

Left marginLeft margin Right marginRight margin

HD Header 1

1.00 CM LEFT1.50 CM 1.00 LN2.00 CM1.50 CM

Alignment:BLOCK justifiedCENTER centeredLEFT aligned left RIGHT aligned right

Alignment:BLOCK justifiedCENTER centeredLEFT aligned left RIGHT aligned right

Units of measurement:LN LinesCM CentimetersMM MillimetersIN InchesPT PointsTW Twips

Units of measurement:LN LinesCM CentimetersMM MillimetersIN InchesPT PointsTW Twips

Standardattributes

Page 18: 4 SAP Script

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.

Page 19: 4 SAP Script

Paragraph Formats: Metric Sizes

Dear Mr.. Smythe,

reservation. We are pleased to

confirm the following bookings

Thank you for your

WindowWindow

IndentIndent

Space afterSpace after

Space beforeSpace before

Left marginLeft margin Right marginRight margin

Paragraph Formats: MetricSizes

Page 20: 4 SAP Script

Graphical Form Painter: Page Layout

OptionsDesign / Text

WindowWindowDescription

Left marginUpper marginWindow widthWindow height

Main window

Default paragraph1,60 CM1,60 CM9,00 CM6,00 CM

ADDRESSAddress

Page

FIRST Address page

Graphic

Form ...

MAIN*

WINDOW1*

WINDOW2*

Design windowAdministrative window

Page 21: 4 SAP Script

Form Elements: Documentation

List ofall pages PAGE_1PAGE_2. . .

List ofallwindows WINDOW_1MAIN. . .

Listofall text elements MAIN -ITEM_HEADERMAIN -ITEM_LINE. . .

EditorEditor

Enter long texts

Page 22: 4 SAP Script

Day 4

SAP Scripts II

Page 23: 4 SAP Script

Agenda

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

Page 24: 4 SAP Script

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_LINEIL &VBDPA-POSNR&,,&VBDPA-MATNR/ &'Customerarticlenumber 'VBDPA-IDNKD'

Page 25: 4 SAP Script

SAP Script - Control commands

• IF CommandSyntax/: IF condition:ELSEIF condition:/:ELSE:/:ENDIF

IF + the condition must not extend more than a line

Page 26: 4 SAP Script

SAP Script - Control commands

• CASE commandSyntax/: CASE symbol

/: WHEN value1

:

/: WHEN value 2

:

/: WHEN value n

:

/: WHEN OTHERS.

:

/:ENDCASE

Page 27: 4 SAP Script

SAP Script - Control commands

• PERFORM CommandTo Call an ABAP subroutine (form) from any program

Syntax/: PERFORM <form> IN PROGRAM <prog>

/: USING &VAR1&

/: CHANGING &VAR2&

/: ENDPERFORM

Page 28: 4 SAP Script

SAP Script - Control commands

• ADDRESS CommandFormatting Addresses/: ADDRESS [DELIVERY] [TYPE t] [PARAGRAPH a]

[PRIORITY p] [LINES l] /: TITLE title…./: STREET street name HOUSE house number….

/: ENDADDRESS

Page 29: 4 SAP Script

SAP Script - Control commands

• INCLUDE Command

To include the contents of another text into the current textSyntax

/: INCLUDE name [OBJECT o] [ID i] [LANGUAGE l] [PARAGRAPH p] [NEW-PARAGRAPH np]

Example/: INCLUDE MYTEXT LANGUAGE 'E' PARAGRAPH 'A1'

Page 30: 4 SAP Script

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

Page 31: 4 SAP Script

SAP Script - Symbols - Types

• System symbols

• Standard symbols

• Program symbols

• Text symbols

Page 32: 4 SAP Script

System Symbols

DATE DateDAY DayNAME_OF_DAY Name of dayMONTH MonthNAME_OF_MONTH Name of monthYEAR YearTIME TimeHOURS HoursMINUTES MinutesSECONDS SecondsPAGE Page numberNEXTPAGE Number of next pageDEVICE Output deviceSPACE Blank spaceULINE UnderlineVLINE Vertical line

Page 33: 4 SAP Script

Standard Symbols

Table TTDTG

Symbols are user-defined

Symbols are language-dependent

Name: max. 22 characters

Value: max. 60 characters

Page 34: 4 SAP Script

Text Symbols

Value is defined in the text module

DEFINE &symbol& = ’ value ’

Name: max. 32 characters

Value: max. 60 characters

Page 35: 4 SAP Script

Program SymbolsKNA1

TABLES KNA1.DATA: COUNTRY LIKE ...* Data selection

...* Start of form printing

...

Jane Smith81 Third Ave.Capital City, CA 80801USA

ABAP

Form

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

NAME1 Jane Smith

PSTLZ 80801ORT01 Capital City, CA

STRAS 81 Third Ave

Page 36: 4 SAP Script

Program Symbol and Symbol Definition

Text Edit Goto Format Insert System Help

Program symbols Symbol definition

Print programs for formPrint report Short description

RIPRAT01 .....

Program symbols

Symbol definition

SPFLISFLIGHTCRTX.....

.....

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

Text Edit Goto Format Include System Help

Programm symbolsSymbol definition

DDIC fields Global data

Print programfor form

..... .....

Print programm Description

RIPRAT01 .....

Page 37: 4 SAP Script

Defining Text Symbols

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

. . .

Form: RVINVOICE01

Window: FOOTER

Page 38: 4 SAP Script

Time, Date Format

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

/: SET DATE MASK = ’........’

/: SET COUNTRY ’........’

SET TIME MASK = ’HH : MM’ SET DATE MASK = ’DD.MMMM YYYY’

Example :

SET COUNTRY ’US’

/:/:/:

Page 39: 4 SAP Script

Frames, Lines and Shading

Window1

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

Window2

/ : BOX INTENSITY 10

Window3

/ : BOX HEIGHT 0 CM FRAME 20 TW/ : BOX WIDTH 0 CM FRAME 20 TW

FormWindow1

Window2

Window3

Page 40: 4 SAP Script

Calling ABAP Subroutines

/: PERFORM <form> IN PROGRAM <prog>/: USING &invar1&/: USING &invar2&

………./: CHANGING &outvar1&

……../: ENDPERFORM

FormIN_TAB structure ITCSY

NAME VALUEinvar1 . . .invar2 . . .

REPORT <prog>.FORM <form> TABLES in_tab STRUCTURE itcsy

out_tab STRUCTURE itcsy.

. . .

ENDFORM.ABAPreport

ABAPDictionary

Page 41: 4 SAP Script

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

Page 42: 4 SAP Script

Print Program and Composer

ComposerComposerXYZ Bank

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

J. Smith7 Second Ave.47110 XYZ City

Place, DateInvoice No.4 123-45-556-678

Art.No. Price 00345 200.-00379 150.-02378 50.-00458 300.-Total 700.-

Print programreport jh_form_01.

tables: scustom.select * from scustom...

......call function 'OPEN_FORM'

......call function 'START_FORM'

......call function 'WRITE_FORM'

......

ABAPprogramApplication

data

Form

DB

Page 43: 4 SAP Script

Structure of Print Program

programrstxexp1.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 formprinting

Closes formprinting

Prints output on form

Changes to another form

Page 44: 4 SAP Script

Main Windows

TOP

BODY

BOTTOM

MAIN

Page 45: 4 SAP Script

Outputting Text Elements in the Main Window

/E ITEM_HEADERArt.No.,,Price

/E ITEM_LINE&vbdpa-matnr&,,&vbdpa-netpr&

CALL FUNCTION 'WRITE_FORM'EXPORTING

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

Art.No. Price 00345 200.-

MAIN

Art.No. Price 00345 200.-00379 150.-

MAIN

WRITE_FORMelement = 'ITEM_LINE'window= 'MAIN'

Page 46: 4 SAP Script

Creating and Deleting Headings

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

Write headinginTOParea

Delete heading fromTOParea

for next page

Page 47: 4 SAP Script

Adding Text Elements to Non-main Windows

CALL FUNCTION 'WRITE_FORM'EXPORTING

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

EXCEPTIONS ... = . . .

INFO

Art.No. Price 00345 200.-00379 150.-02378 50.-00458 300.-Total 700.-

INFOTEXT1

Art.No. Price 00345 200.-00379 150.-02378 50.-00458 300.-Total 700.-

INFO

INFOTEXT1INFOTEXT2

WRITE_FORMelement = 'INFOTEXT2'function= 'APPEND'window = 'INFO'

Page 48: 4 SAP Script

Style : A Formatting Aid

You have assigned a style to this text.

This is an outline:

=> First level=> Second level

=> Third level

----------MYSTYLE---------System-------------Lines 1 - 1/ 1 -----------

You have assigned a STYLE to this text.This is an outline:First levelSecond levelThird level

B

CU

G1

G2

G3

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

G3 Outline level 3

G2 Outline level 2

G1 Outline level 1

CU Italic, underlined

B Bold

AS Standard paragraphOutline level 3G3

F.... Description

Format column(1) 6 En...

F4

Page 49: 4 SAP Script

Thank You