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 . 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 : .Windows • They represent areas that are positioned on pages – as page windows – and in which at a later time text is printed.

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 .Page Windows • Window names are linked to page names.

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 .

attributes such as font family. size. italic etc. Standard attributes – – – – – Marker Bar code Protected Hidden Superscript/subscript . bold.Character formats • • Allows to format entire blocks of text within a paragraph Character attribute groups can be: – Font – Standard Font attributes .

Paragraph formats • In SAPScript. paragraphs are formatted using formats and their corresponding attributes Helps simplifying the text processing • Attributes – Standard – Font – Tabs – Outline .

50 Indent 1st line 2.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.00 Space before Space after 1.00 Description CM CM CM CM Alignment Line spacing Header 1 LEFT 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 • 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.

. character string.Paragraph formats • Font attributes . left/right delimiter. Number margin. bold. Numbering type.attributes such as font family.Outline. Number chaining.tab position (different units of measure) • Outline . italic etc. • Tabs . outline level. size.

Right margin Space after Space before Indent Thank you for your reservation We are pleased to . Smythe .Paragraph Formats: Metric Sizes Paragraph Formats: Sizes Metric Left margin Dear Mr. . confirm the following bookings Window .

00 MAIN* Design window Design / Text Options .00 Window height 6.60 Window width 9.Graphical Form Painter: Page Layout Page FIRST Address page Form ..60 CM CM CM CM Upper margin 1. WINDOW1* WINDOW2* Window Graphic Window ADDRESS Description Address Main window Administrative window Default paragraph Left margin 1..

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 .

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

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

SAP Script .Control commands • IF Command Syntax /: IF condition : ELSEIF condition : /:ELSE : /:ENDIF IF + the condition must not extend more than a line .

: /:ENDCASE .SAP Script .Control commands • CASE command Syntax /: CASE symbol /: WHEN value1 : /: WHEN value 2 : /: WHEN value n : /: WHEN OTHERS.

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 .

Control commands • ADDRESS Command Formatting Addresses /: ADDRESS [DELIVERY] [TYPE t] [PARAGRAPH a] [PRIORITY p] [LINES l] /: TITLE title …. /: STREET street name HOUSE house number ….SAP Script . /: 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' .

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.SAP Script . These placeholders are symbols • Data is added to the text normally at the point at which output is formatted .

Types • System symbols • Standard symbols • Program symbols • Text symbols .Symbols .SAP Script .

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. 60 characters . 22 characters Value: max.

32 characters Value: max. 60 characters .Text Symbols Value is defined in the text module DEFINE &symbol& = ’ value ’ Name: max.

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

... sflight....... Symbol definition REPORT riprat01.. .. .. Global data . DATA: sums LIKE ......... Programm symbols Program symbols Symbol definition Symbol definition Print programfor form Print programs for formDescription Print programm Print report RIPRAT01 RIPRAT01 .... SPFLI SFLIGHT CRTX ... DDIC fields Short description ...Program Symbol and Symbol Definition Text Edit Goto Format Include System Help Text Edit Goto Format Insert System Help Program symbols . .. TABLES: spfli.

..Defining Text Symbols Form : RVINVOICE01 W indow: FOOTER / : DEFINE &SYMBOL& = 'String1 String2 String3' . .

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

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

.. . FORM <form> TABLES in_tab STRUCTURE itcsy out_tab STRUCTURE itcsy. ENDFORM. /: ENDPERFORM IN_TAB structure ITCSY NAME invar1 invar2 VALUE . ABAP report .... /: CHANGING &outvar1& ……...Calling ABAP Subroutines Form /: PERFORM <form> IN PROGRAM <prog> /: USING &invar1& /: USING &invar2& ………. ABAP Dictionary REPORT <prog>..

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 .

150... 47110 XYZ City Place.Print Program and Composer Print program report jh_form_01... No.- . call function 'OPEN_FORM' ...No. ..4 123-45-556-678 Composer Art.. call function 'START_FORM' ... 00345 00379 02378 00458 Total XYZ Bank Acct... Smith 7 Second Ave....: 000000000 Price 200. J... Date Invoice No... select * from scustom. Form ABAP program Application DB data tables: scustom..50...: 0815 4711 Bank No.700. call function 'WRITE_FORM' .300.

select * from . .. call function 'START_FORM' .. sbook... tables: scustom.. call function 'OPEN_FORM' exporting form = ... .... call function 'END_FORM' .... ..... call function 'START_FORM' .. . . call function 'WRITE_FORM' exporting element = .... window = .. . Retrieves data Opens form printing Changes to another form Prints output on form Closes form printing .. .. ..Structure of Print Program program rstxexp1... call function 'CLOSE_FORM' ...... call function 'END_FORM' ...

Main Windows TOP BODY MAIN BOTTOM .

..Outputting Text Elements in the Main Window CALL FUNCTION 'WRITE_FORM' EXPORTING ELEMENT = ... = .- WRITE_FORM element = 'ITEM_LINE' window= 'MAIN' Art. 00345 00379 MAIN Price 200. &vbdpa-netpr& Art..Price /E ITEM_LINE &vbdpa-matnr&.150...- MAIN . /E ITEM_HEADER Art..No. EXCEPTIONS .No. 00345 Price 200.No..

.........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' .. Output heading to current page Write heading in TOParea Delete heading from TOParea for next page . call function 'WRITE_FORM' exporting element = 'ITEM_HEADER' function = 'DELETE' type = 'TOP' window = 'MAIN' . call function 'END_FORM' .

FUNCTION = 'APPEND' WINDOW = 'INFO' EXCEPTIONS .50. 00345 00379 02378 00458 Total Price 200.- .700.300.150. = .. INFO INFOTEXT1 INFO INFOTEXT1 INFOTEXT2 Art.No.150..50.300..700.No.. 00345 00379 02378 00458 Total Price 200.Adding Text Elements to Non-main Windows CALL FUNCTION 'WRITE_FORM' EXPORTING ELEMENT = ...- WRITE_FORM element = 'INFOTEXT2' function = 'APPEND' window = 'INFO' Art.

+. .1/ 1 ----------CU Italic. 1. . . . .. . B You have assigned a STYLE to this text. . . F. . 4. .Style : A Formatting Aid . . 3. +. . .. . . CU This is an outline: G1 First level G2 Second level G3 Third level Format column(1) 6 En. . +. +. . . . ... 6. . . . underlined G1 Outline level 1 Outline level 2 Outline level 3 F4 G2 G3 . +. . 2. . . . + You have assigned a style to this text.. . . . . . . . . +. . . 5. Description G3 B Outline level 3 AS Standard paragraph Bold This is an outline: => First level => Second level => Third level ----------MYSTYLE---------System-------------Lines 1 . . .

Thank You .