6584234 creating a sapscriptestt form 3

Upload: bhattahcarjee-rupak

Post on 14-Apr-2018

216 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/27/2019 6584234 Creating a Sapscriptestt Form 3

    1/61

    1

    Sap Script

  • 7/27/2019 6584234 Creating a Sapscriptestt Form 3

    2/61

    2

    Objectives

    What is SAP Script ?

    How does a SAP Script work ?

    Standard TextObjects of Layout Set

    Header Paragraph and Character format Windows and Text Elements Pages Page WindowsComponents of Script

    Text ElementsStyleLayout setSymbols

    System symbolsStandard symbolsProgram symbolsText symbols (Contd. Next Page)

  • 7/27/2019 6584234 Creating a Sapscriptestt Form 3

    3/61

    3

    Objectives

    Style

    Layout SetControl Commands

    Incorporating Graphics

    Exercise Program

  • 7/27/2019 6584234 Creating a Sapscriptestt Form 3

    4/61

    4

    INTRODUCTION

    SAP Script is the SAP System's own text-processing system.Also calledas Word processing tool of SAP.

    SAP Script is tightly integrated into the SAP System

    Note:Entering and formatting text in SAP script is a little bit different than

    traditional text-processing programs on a PC.

    The main difference: the text that you enter is not in its final format.

    SAP script applies your formatting to text only when a document

    is printed, print-previewed, or displayed on-line in the SAP System

    Sap Script

  • 7/27/2019 6584234 Creating a Sapscriptestt Form 3

    5/61

    5

    How does a SAP Script work ?

    Every Script has a driver / print program attached or calling it.

    In case you are creating an entirely new script ,you also need to create

    the driver program.

    This program can be executed directly or attached to attached to certain

    events viz. Creation of Purchase Order , Sales Order , Hiring an Employee.

    Standard SAP scripts can be modified by copying them in the customer

    name space and making the required changes.

    Sap Script

  • 7/27/2019 6584234 Creating a Sapscriptestt Form 3

    6/61

    6

    Components of a SAP Scripts

    1. Standard TextThis is like a normal document.You can create letters , articles basically

    any static text.

    This can be created from transaction SO10.

    2. Layout Set

    This also called as Form created from Transaction SE71.

    3. Print Program

    This program retrieves desired data from the database , calls the Form,

    supplies data to the Form and finally closes the Layout Set ( Form ).

    Sap Script

  • 7/27/2019 6584234 Creating a Sapscriptestt Form 3

    7/61

    7

    Driver Program Layout set

    Forms

    Sap

    Script

    Gets printed

    Supplies

    data

    Defines

    Sap Script

  • 7/27/2019 6584234 Creating a Sapscriptestt Form 3

    8/61

    8

    Name

    House name

    Postal CodeCity

    WINDOW

    Name

    House namePostal Code

    City Page window

    Particular area in the

    page where the window

    is printed out

    Page

    Sap Script

  • 7/27/2019 6584234 Creating a Sapscriptestt Form 3

    9/61

    9

    Standard Text

    Transaction SO10

  • 7/27/2019 6584234 Creating a Sapscriptestt Form 3

    10/61

    10

    After creating a Standard Text assign it a Style.

    Standard Text

  • 7/27/2019 6584234 Creating a Sapscriptestt Form 3

    11/61

  • 7/27/2019 6584234 Creating a Sapscriptestt Form 3

    12/61

    12

    OBJECTS OF LAYOUT SET

    Header Paragraph and Character format Windows and Text Elements Pages Page Windows

    Layout Set

  • 7/27/2019 6584234 Creating a Sapscriptestt Form 3

    13/61

    13

    Header data is found both in style and layout set maintenance. In style

    maintenance, it is used primarily to present information designed to make

    it easier for the end user to select a style.

    The header data in layout set maintenance, on the other hand, is used for

    information and control purposes.

    Header

  • 7/27/2019 6584234 Creating a Sapscriptestt Form 3

    14/61

    14

    Header

    HEADERINFORMATION GLOBAL DATA

  • 7/27/2019 6584234 Creating a Sapscriptestt Form 3

    15/61

    15

    In SAP Script, paragraphs are formatted using formats and their

    corresponding attributes. Word processing is simplified by the use of

    different paragraph attribute groups:

    StandardFontTabsOutline

    Paragraph

  • 7/27/2019 6584234 Creating a Sapscriptestt Form 3

    16/61

    16

    Paragraph

    Paragraph Format

  • 7/27/2019 6584234 Creating a Sapscriptestt Form 3

    17/61

    17

    Character formats

    Allow you to format entire blocks of text within a paragraphWhich will override the paragraph formatCharacter formats are defined in character stringsE.g.: &VBDKA-TDNAME& ,, &VBDKA-TFGEU&

    Character Format

  • 7/27/2019 6584234 Creating a Sapscriptestt Form 3

    18/61

    18

    WINDOWS

    We can combine information contained in a document into certaingroups and make each group appear on the printed page in an individual

    area. SAP Scripts calls such a group a window

    To refer a window via program each window must have a unique name We can assign text to each windows via text elementsTEXT ELEMENTS

    Text elements can be defined in layout set maintenance for each window.

    The text elements are accessed by name by a print program, formatted,

    and output in the respective window. The /E in the tag column is used to

    identify the text as a text element

    Windows and Text Elements

  • 7/27/2019 6584234 Creating a Sapscriptestt Form 3

    19/61

    19

    Windows are defined in layout set maintenance. They represent areaswhich are positioned on pages -- as page windows -- and in which text

    is later output. At least one window must be defined for each layout set.

    If not, a text cannot be formatted by SAP Script.

    The following window types can be used:

    mainvariableconstant

    Windows

  • 7/27/2019 6584234 Creating a Sapscriptestt Form 3

    20/61

    20

    WINDOWS

    Windows

  • 7/27/2019 6584234 Creating a Sapscriptestt Form 3

    21/61

    21

    MAIN

    Main window in which continuous text is output. The text in the main

    window can extend over several pages. If the text fills one page, outputcontinues in the window of the next and subsequent pages, as long as

    MAIN has been defined for these pages.

    VAR

    Window with variable contents. The text can vary on each page in

    which the window is positioned. Variable windows are formatted foreach page.

    CONST

    Window with constant contents which is only formatted once.

    Windows

  • 7/27/2019 6584234 Creating a Sapscriptestt Form 3

    22/61

    22

    At least one page must be defined for every layout set. You must also

    designate a "first" page in the layout set header. Otherwise text

    formatting is not possible.

    Pages

  • 7/27/2019 6584234 Creating a Sapscriptestt Form 3

    23/61

    23

    PAGES

    Pages

  • 7/27/2019 6584234 Creating a Sapscriptestt Form 3

    24/61

    24

    When you define page windows, the window names are linked to page

    names. To do this, you need to specify the position and size of the

    window on the assigned page.

    Width of the main window must be the same on all pages.

    Page Windows

  • 7/27/2019 6584234 Creating a Sapscriptestt Form 3

    25/61

    25

    PAGE WINDOWS

    Page Windows

  • 7/27/2019 6584234 Creating a Sapscriptestt Form 3

    26/61

    26

    COMPONENTS OF SCRIPT

    Text ElementsStyleLayout set

    Sap Script

  • 7/27/2019 6584234 Creating a Sapscriptestt Form 3

    27/61

    27

    The text elements are related to a window .

    The print program calls the respective text elements of the window

    TYPES OF TEXT ELEMENTS

    TEXT ELEMENTS WITH OUT NAMESTEXT ELEMENTS WITH NAME

    Text Elements

  • 7/27/2019 6584234 Creating a Sapscriptestt Form 3

    28/61

    28

    NAMED TEXT ELEMENTS

    We recognize named text elements by paragraph format /EThe name can be up to 40 charactersThe different windows can have same named text elementsTo out put named text elements we have to call the function module

    WRITE_FORM

    Text Elements

  • 7/27/2019 6584234 Creating a Sapscriptestt Form 3

    29/61

    29

    A style defines the set of paragraph and character formats that are

    available for formatting a document.

    If a style is selected, then it provides the character and paragraph

    formats for your document. Any formats defined in the layout set

    selected for a document are then ignored.

    Style

  • 7/27/2019 6584234 Creating a Sapscriptestt Form 3

    30/61

    30

    Layout sets are used to control the page layout and also the textformatting in your documents.

    If a document is formatted for output to the screen or to a printer, then alayout set must be specified for it.

    If no other layout set is specified for a document, then the SYSTEMlayout set is assigned to the document by default.

    Layout Set

  • 7/27/2019 6584234 Creating a Sapscriptestt Form 3

    31/61

    31

    LAYOUT SET CONTROLOPEN_FORM - Initializes the SAP script composer and opens

    the specified layout set

    CLOSE_FORM - Closes the layout set ( if close_form is missing

    in the program nothing will be printed)

    WRITE_FORM ,

    WRITE_FORM_LINES,

    CONTROL_FORM - To output data( this can be used as many timesbetween OPEN_FORM and CLOSE_FORM)

    PAGE CONTROL IN LAYOUT SETS

    STATIC DEFINITION- Specify the starting page in header and for eachpage specify the subsequent page

    DYNAMIC DEFINITION - Specify START PAGE when you callSTART_FORM

    Layout Set

  • 7/27/2019 6584234 Creating a Sapscriptestt Form 3

    32/61

    32

    SYMBOLS

    Symbols are constants that can be inserted in a document. They save the

    user unnecessary work when replacing sections of text, phrases, etc.

    Possible symbol types are:

    System symbolsStandard symbolsProgram symbolsText symbols.

    Symbols

  • 7/27/2019 6584234 Creating a Sapscriptestt Form 3

    33/61

    33

    THE SYNTAX OF SYMBOLS

    The delimiter & must be used both immediately before and after thesymbol.

    The name of a symbol may not contain spaces. A SAP Script editor line break should not occur between the symbol

    delimiters.

    If additional formatting options are required, these should be enclosedin round brackets and inserted immediately after the symbol name.

    The code letters identifying these options must be given in capitals.

    Symbols

  • 7/27/2019 6584234 Creating a Sapscriptestt Form 3

    34/61

    34

    SYSTEM SYMBOLS

    SAP script provides values for the system symbolsExample &date& &time& &month& &year& &uline& &vline& &page&

    STANDARD SYMBOLS

    Standard symbols are defined in the TTDTG table. This table contains both the name of each symbol and its value. The value, which is language-dependent, can contain up to 60 chars. This table is delivered complete with standard entries supplied by SAP. It may be extended with customer-specific symbols

    Symbols

  • 7/27/2019 6584234 Creating a Sapscriptestt Form 3

    35/61

    35

    PROGRAM SYMBOL

    SAP Script cannot read this data out of the SAP database itself, but has to

    call on another program to do this. The data are then copied into work

    areas declared using TABLES. If SAP Script is now called from this

    program in order to format a text, it can copy the data out of these work

    areas.

    Symbols which obtain their values from this kind of data area are calledprogram symbols.

    Note

    The value of a program symbol is limited up to a maximum of 255 chars.The name of a program symbol consists of the table name and the field

    name separated by a hyphen.

    Symbols

  • 7/27/2019 6584234 Creating a Sapscriptestt Form 3

    36/61

    36

    TEXT SYMBOLS

    All symbols which do not correspond to one of the three types of symbol

    described above are text symbols. You define the value of a text symbolyourself in the text module.

    There are two ways of doing this:

    Use the menu entries in the text editorUse the control command DEFINEfor e.g

    /: DEFINE &mysymbol& = XXXX

    / &mysymbol&

    /: DEFINE &mysymbol& = YYYY

    / &mysymbol&

    would print XXXX

    YYYY

    Symbols

  • 7/27/2019 6584234 Creating a Sapscriptestt Form 3

    37/61

    37

    Control Command is a type of SAP script command which are used to

    control output formatting.

    The Syntax of Control Commands

    The paragraph format /: must be entered in the format column toidentify a control.

    You enter the command itself in the text line. A control command, together with any parameters it requires, may not

    occupy more than a single line

    A maximum of one control command may appear in each line

    Control Commands

  • 7/27/2019 6584234 Creating a Sapscriptestt Form 3

    38/61

    38

    SYNTAX OF CONTROL COMMANDS

    In tag column, indicate control commands with paragraph format /:Enter complete control commands and necessary parameters on one

    line

    Enter only one control command per lineEditor formatting does not affect lines with control commands

    Control Commands

  • 7/27/2019 6584234 Creating a Sapscriptestt Form 3

    39/61

    39

    SOME IMPORTANT CONTROL COMMANDS:

    /: NEW-PAGE

    /: PROTECT & /: ENDPROTECT

    /: SET DATE MASK = 'date_mask

    /: SET TIME MASK = 'time_mask

    /: RESET paragraph_format

    /: INCLUDE name [OBJECT o] [ID i] [LANGUAGE l ]

    [PARAGRAPH p] [NEW-PARAGRAPH np]

    (Cont.. Next page)

    Control Commands

  • 7/27/2019 6584234 Creating a Sapscriptestt Form 3

    40/61

    40

    /: TOP

    :

    /: ENDTOP

    /: BOTTOM

    :

    /: ENDBOTTOM

    /: IF condition:

    /: ENDIF

    Control Commands

  • 7/27/2019 6584234 Creating a Sapscriptestt Form 3

    41/61

    41

    SET DATE MASK command

    The formatting for date fields can be defined with the SAPscript SET

    DATE MASK command. Executing this command causes allsubsequent date fields to be output using the specified formatting.

    Syntax

    /: SET DATE MASK = 'date_mask'

    The following templates may be used in the date mask:For day : DD / DDD / DDDD

    For month : MM / MMM / MMMM

    For year : YY / YYYY

    Control Commands

  • 7/27/2019 6584234 Creating a Sapscriptestt Form 3

    42/61

    42

    SET TIME MASK command

    You can use the SAPscript SET TIME MASK command to format time

    fields in a way that differs from the standard setting. Executing thiscommand causes all subsequent time fields to be output using the

    specified formatting.

    Syntax:

    /: SET TIME MASK = 'time_mask'

    The following templates may be used in the time mask:

    HH hours (two digits)

    MM minutes (two digits)

    SS seconds (two digits)

    Control Commands

  • 7/27/2019 6584234 Creating a Sapscriptestt Form 3

    43/61

    43

    BOXES, LINES, SHADING: BOX, POSITION, SIZE

    The BOX, POSITION and SIZE commands for drawing boxes, lines andshadowing can be used for specifying that within a layout set particular

    windows or passages of text within a window are to be output in a frame

    or with shadowing.

    Syntax

    1. /: BOX [XPOS] [YPOS] [WIDTH] [HEIGHT] [FRAME] [INTENSITY]2. /: POSITION [XORIGIN] [YORIGIN] [WINDOW] [PAGE]3. /: SIZE [WIDTH] [HEIGHT] [WINDOW] [PAGE]

    .

    Control Commands

  • 7/27/2019 6584234 Creating a Sapscriptestt Form 3

    44/61

    44

    ADDRESS

    The command formats an address according to the postal standardsof the destination country defined in the parameter COUNTRY

    sap scripts calls function module ADDRESS_INTO_PRINTFORM

    to format the address

    /: ADDRESS[DELIVERY] [PARAGRAPH a] [PRIORITY p] [LINES l]

    /: TITLE title

    /: NAME name1[,name 2[,name 3[,name 4]]]/:STREET street

    /:POBOX po box[CODE zip code]

    /:CITY town1[,town 2]

    /:REGION region

    /:COUNTRY country

    /: FROMCOUNTRY from country/: ENDADDRESS

    Control Commands

  • 7/27/2019 6584234 Creating a Sapscriptestt Form 3

    45/61

    45

    BOTTOM /ENDBOTTOM

    /:BOTTOMThe text lines between the two commands are output at the bottom of

    MAIN window

    /:ENDBOTTOM

    /:DEFINE &symbolname& = value

    Text symbol receive their value through an explicit assignment. This

    assignment can be done interactively in the editor via include-symbols-

    text. The assigned value may have a maximum of 60 characters

    Control Commands

  • 7/27/2019 6584234 Creating a Sapscriptestt Form 3

    46/61

    46

    For e.g Company Logo

    1. .bmp / .jpg file has to be converted to .tiff file

    2. Upload the file as text module using ABAP/4 reportRSTXLDMC

    specify BMON or BCOL

    3. System generates a suggested name for the text

    e.g ZHEX-MACRO-LOGO Use ID ST and logon language.

    4. Include ZHEX-MACRO-LOGO object Text ID ST in the Layout.

    Incorporating Graphics

  • 7/27/2019 6584234 Creating a Sapscriptestt Form 3

    47/61

    47

    Example of Print ProgramCalling an Script from a program created in SE38

    REPORT ZSCRIPT .

    TABLES: SPFLI.DATA: I_SPFLI LIKE SPFLI OCCURS 0 WITH HEADER LINE.

    SELECT * FROM SPFLI INTO CORRESPONDING FIELDS OF TABLE

    I_SPFLI.

    CALL FUNCTION 'OPEN_FORM'

    EXPORTINGFORM = 'ZTEST11'.

    CALL FUNCTION 'WRITE_FORM'

    EXPORTING

    ELEMENT = 'HEADER_ITEM'

    * FUNCTION = 'SET'

    TYPE = 'BODY'WINDOW = 'MAIN'.

    (Contd.. Next Page)

  • 7/27/2019 6584234 Creating a Sapscriptestt Form 3

    48/61

    48

    CALL FUNCTION 'WRITE_FORM'

    EXPORTING

    ELEMENT = 'ADDRESS_LIST'

    * FUNCTION = 'SET'TYPE = 'BODY'

    WINDOW = 'WINDOW1'.

    LOOP AT I_SPFLI.

    CALL FUNCTION 'WRITE_FORM'EXPORTING

    ELEMENT = 'LINE_ITEM'

    * FUNCTION = 'SET'

    TYPE = 'BODY'

    WINDOW = 'MAIN'.

    ENDLOOP.

    CALL FUNCTION 'CLOSE_FORM'.

    Example of Print Program

  • 7/27/2019 6584234 Creating a Sapscriptestt Form 3

    49/61

    49

    Output of the program

    Example of Print Program

  • 7/27/2019 6584234 Creating a Sapscriptestt Form 3

    50/61

    50

    Details of Layout Set Header Data

    Example

  • 7/27/2019 6584234 Creating a Sapscriptestt Form 3

    51/61

    51

    Example

    Pages

  • 7/27/2019 6584234 Creating a Sapscriptestt Form 3

    52/61

    52

    Example

    Windows

  • 7/27/2019 6584234 Creating a Sapscriptestt Form 3

    53/61

    53

    Example

    Page Windows

  • 7/27/2019 6584234 Creating a Sapscriptestt Form 3

    54/61

    54

    Example

    Main Window Details

  • 7/27/2019 6584234 Creating a Sapscriptestt Form 3

    55/61

    55

    Formatting OptionsOffset - specifying an offset ofn , n left most characters are not displayed.E.g &symbol& ---> 1234576789

    &symbol+3& ----> 456789

    Output Length&symbol(3)& ----> 123

    &symbol(7)& ----> 1234567

    Time Mask

    &Time&

    Normally 10:08:12(hh) : (mm): (ss)

    /: Set Time Mask = HH:MM

    &Time& = 10:08

    /: Set Time Mask = HH hours MM minutes

    &Time& = 10 hours 08 minutes&Time(Z)& = 10 hours 8 minutes

  • 7/27/2019 6584234 Creating a Sapscriptestt Form 3

    56/61

    56

    ExampleDate Mask

    /: Set Date Mask = DDMMYY

    &Date& = 01 05 01/: Set Date Mask = MMMM DD,YYYY

    &Date& = May 01,2001

    Fill Character

    Leading spaces in a value can be replaced with a fill character.The F option is used and character to be filled is specified.

    E.g &KNA1-UMSAT& = 700.00

    &KNA1-UMSAT(F*)& = **700.00

    Space Compression&symbol(C)&

    It has a effect of replacing each string of space characters with a single space and

    shifting the words to left as necessary to close up gaps.Also Leading spaces are completely removed.

    Omitting Leading Zeros

    &symbol(Z)&

    &Day& = 01&DAY(Z)& = 1

    S

  • 7/27/2019 6584234 Creating a Sapscriptestt Form 3

    57/61

    57

    SummerySAP Script is the SAP System's own text-processing systemEvery Script has a driver / print program attached or calling it.The objects of layout set are to create Header, Paragraph & Character

    format, Windows &Text Elements, Pages and Page WindowsComponents of a SAP Script are Standard Text, Layout set and Driver

    Program

    The text elements are related to a window .We recognize named text elements by paragraph format /EA style defines the set of paragraph and character formats that are

    available for formatting a document.Layout sets are used to control the page layout and also the text

    formatting in your documents.

    Symbols are constants that can be inserted in a document.The four types of symbols are Text symbols, Program symbols,

    Standard symbols and System symbols

    Control Command is a type of SAP script command which are used tocontrol output formatting.

    Q ti d A

  • 7/27/2019 6584234 Creating a Sapscriptestt Form 3

    58/61

    58

    Question and Answers1. What is SAP Script and explain its purpose?

    Ans. SAP Script is the SAP's own text processing system. You'll find that

    it looks and feels a lot like other leading text-processing systems that you

    may use on your personal computer.Every company needs to output documents with a uniformly defined

    layout(for example, invoices,delivery notes etc..)

    These documents are often created automatically.

    The basic layout of the document is pre-defined, but in many cases other

    data has to be merged with it, such as addresses, line items etc. Instead

    of entering these items manually by an employee, can be retrieved from atable dynamically

    SAP Script has been developed to meet the above requirements. It is an

    integrated tool for text entry and form printing in R/3 applications.

    These documents are normally provided by SAP but every organization

    have their unique ways of presenting these documents. For customizing

    and creation of newer ones SAP Script is used.

    Q ti d A

  • 7/27/2019 6584234 Creating a Sapscriptestt Form 3

    59/61

    59

    Question and Answers

    2. What all are the components of SAP Script?

    Ans. Layout set, Sap script Text, Driver Program, Symbols etc.

    3 What is a layout set?

    Ans. The Layout of a document is defined in a Layout set. A layout set

    specifies the appearance and structure of a document. Layout sets

    contain predefined text modules with space reserved for variable data.

    You can use these different text modules for different applications.

    Every SAP Script document uses layout set. To make changes to your

    documents, such as moving a piece of text, or changing fonts, paragraphformats, and tabs you only need to change the layout set.

    4. What are the components of a layout set?

    Ans. Header, Pages, Windows, Page Windows, paragraph, text Elements

    & Character Strings.

    5. Where do we define Tab space for data in SAP script?

    Ans. When defining the paragraph for the text element we can define the

    TABS. The Parameter TABS to be defined in Paragraph definition.

    Q ti d A

  • 7/27/2019 6584234 Creating a Sapscriptestt Form 3

    60/61

    60

    Question and Answers6. What is the difference between Window and a Page Window?

    Ans. Window is an area predefined in the layout set. Windows are text

    modules, which are positioned on a document page. We define the

    Window type, Default paragraph,Text elements etc are included in theWindow component.

    Page Window in a page is known as Page Window. We define the

    parameters, of the earlier defined window such as left and right margins,

    width, height etc, based on that it will appear on a page.

    7. What are Symbols? Brief different types?Ans. You can use symbols to insert program and system data as well as

    existing texts into your document.SAP Script supports 4 types of symbols

    Text Symbols:- You define text symbols locally in your document.Program Symbols:- The values of program symbols come from the tablesof programs.

    Standard Symbols:- The standard symbols are globally available &maintained in the SAP script table TTDTG;

    System Symbols:- System symbols come from global system variables.

    Q ti d A

  • 7/27/2019 6584234 Creating a Sapscriptestt Form 3

    61/61

    Question and Answers8. What are control commands? Give example.

    Ans. Control Command is a type of SAP script command which are used

    to control output formatting

    E.g. BOTTOM /END BOTTOM./: BOTTOM

    The text lines between the two commands are output at the bottom of

    MAIN window

    /: ENDBOTTOM

    9. What is the purpose ofPROTECT and END PROTECT?Ans. You can avoid splitting your paragraph either in the style or in the

    layout set by the usage of the command group PROTECT and END

    PROTECT. Thus PROTECT..END PROTECT command pair may be

    regarded as conditional New-Page command.

    10. How do we set the date, time format.Ans. SET TIME MASK: controls the time field format.

    SET DATE MASK: controls the date field format.

    E.g. /: SET TIME MASK = HH: MM