Sap Script
-
Upload
playboy117 -
Category
Documents
-
view
628 -
download
5
Transcript of Sap Script
Chapter TitleElectronic Name.1
SAP Script
Chapter 1: Introduction
Chapter 2: Printing
Chapter 3: Layout Set
Chapter 4: Output Program
Chapter 5: Configuration
Chapter TitleElectronic Name.2
IntroductionWhat is SAP Script ?
• SAP Script is used to print forms.
• Form Vs. Reports Forms look “nicer”. Forms can have graphic elements. Forms can be event-triggered.
• Examples of forms:SD Inquiry
Order confirmationDelivery noteInvoice
PU Purchasing req.Purchase orderContract
IM Goods receiptGoods issue
FI Customer statementChecks
WM Picking listPacking listLabels
Chapter TitleElectronic Name.3
IntroductionHow SAP Script Works (Big Picture)
• SAP documents are printed using forms.
• Forms are defined and formatted using layout sets.
• SAP script is a tool that SAP provides for creating layout sets.
SAPDocument
SAPDocument
Form
(Output)
Layout set
(Template)
Layout set
(Template)Read DataRead Data PrintPrint
SAP Script
DefineDefine• Sales order• Billing document• Purchase order• etc
• Sales order• Billing document• Purchase order• etc
• Order confirmation• Invoice• Purchase order• etc
• Order confirmation• Invoice• Purchase order• etc
Chapter TitleElectronic Name.4
IntroductionCreating Report Vs. Form
SAPDocument
SAPDocument
OutputProgram(ABAP)
OutputProgram(ABAP)
Report
SAPDocument
SAPDocument
OutputProgram(ABAP)
OutputProgram(ABAP)
Layout setLayout set Form
Creating ReportsCreating Reports
Creating FormsCreating Forms
Chapter TitleElectronic Name.5
Introduction Components of SAP Script
SAPDocument
SAPDocument
OutputProgramOutput
Program Layout setLayout set Form
Output determination configurationOutput determination configuration
Printer / Font ConfigurationPrinter / Font Configuration
• Output program: Extracts data from SAP data dictionary
• Layout set: Formats the extracted data
• Output determination configuration: Configures triggering event, timing / destination
• Printer / Font configuration: Configures impact / laser printer, bar code, logo
Chapter TitleElectronic Name.6
IntroductionSAP Script Development
Component Resource
Output program ABAP resource
Layout set ABAP resource
Output determinationconfiguration
Functional resource
Printer configuration(Impact, Thermal, Laser)
Basis / ABAP
Font configuraiton Basis / ABAP
Testing End-user / Functional /ABAP resrouce
Chapter TitleElectronic Name.7
Printing SAP Script FormsWhat? Where? When? How?
• Where should it be printed?
• How many copied should be printed?
• When should it be printed?
• What medium should it be “printed” on?
• What types of status should be captured?
Chapter TitleElectronic Name.8
Printing SAP Script FormsOutput Type
• Menu: Sales order > Header > Output
• Output Type defines “when” and to “where” to print the form.
• “When” - Communication method
• “Where” - Further data
• “How” - Medium
Chapter TitleElectronic Name.9
Printing SAP Script FormsOutput Type - “When”
• Click on “Communication method” button
• Send time
– 1 Send with next selection run• Batch printing using program
RSNAST00
– 2 Send with time specification• Batch printing using program
RSNAST00 in the background job
– 3 Explicit request• On demand
– 4 Immediately• After an update
Chapter TitleElectronic Name.10
Printing SAP Script FormsOutput Type - “Where”
• Click on “Further data” button
• Printer name - Physical output device name
• Number of messages - Number of copies to be printed
Chapter TitleElectronic Name.11
Printing SAP Script Forms
• Output medium:– 1 Printout– 2 Fax– 3 Teletex– 4 Telex– 6 EDI– 7 SAP Office– 8 Special function– 9 Workflow events– A Distribution (ALE)– T Workflow: Task
• Processing status:– 0 Not processed– 1 Successfully processed– 2 Incorrectly processed– 3 Not active
Chapter TitleElectronic Name.12
Printing SAP Script FormsScreen Vs. Printer
• Menu: Issue Output To > Screen
– Works with all timing as long as there exists an output type
– Ignores the output device specification
– Best for debugging
• Menu: Issue Output To > Printer
– Works only if Send time = 3 (On demand)
Chapter TitleElectronic Name.13
Printing SAP Script FormsPrint Preview
• On screen display of print preview
Chapter TitleElectronic Name.14
Printing SAP Script FormsCollective Printing (Send time = 1)
Execute Program RSNAST00 using Transaction SA38. Transaction OVNN.
• Can define and use variants.
• Only the output types with timing = 1 will be detected
• Only the output type with status = 0 will be detected unless Send Again field is checked
• Object key = Document number
Chapter TitleElectronic Name.15
Printing SAP Script FormsRepeating Output
1. Enter the document in change mode.
2. Select an output type that has already been successfully
processed (Status = 1).3. Click on “Repeat output”
button.4. Select the new entry. (Status
= 0) and change any data if necessary
5. Trigger printing as before.
Chapter TitleElectronic Name.16
Layout SetSome Facts
Client specific (client-dependent)
Language specific
• Note: If the layout set is not available in the client in which the document is being printed, then the SAPscript checks for the style or layout set in client 000.
• Recommendation: Keep only one copy of the layout set in one client.
Chapter TitleElectronic Name.17
Layout Set ElementsInitial Screen
• Header
• Paragraphs
• Character strings
• Windows
• Pages
• Page windows
IMG
Menu: Tools > Word processing > Layout set
Chapter TitleElectronic Name.18
Layout Set ElementsComponents
• Header: General info and default settings• Paragraphs: Font and tab info• Character strings: Font info within a paragraph• Windows: Description of areas on the pages• Pages: Name of the pages with page flow info• Page windows: Position and size of the windows on the pages
Item Material # Price
Item Material # PriceSold-to Ship-to
S.O. #P.O. #Date
S.O. #P.O. #Date
10 Part A $50020 Part B $35030 Part C $800
40 Part D $25050 Part E $40060 Part F $35070 Part G $150
Total $2,800
Chapter TitleElectronic Name.19
Layout Set ElementsPage Windows
• List of all the windows on the page with coordinates.
• The coordinates are given by the upper left-hand corner and the width and length.
• Note: A window which should appear on a page must first be defined under ”Windows” and then be added to the page windows.
Chapter TitleElectronic Name.20
Layout Set ElementsWindows
• Type of windows:
– Main - Special– VAR - Variable– CONST - Constant
• Shows list of all windows defined for the layout set.
• A window can contain hard-coded texts and the variables to be printed in the window.
Chapter TitleElectronic Name.21
Layout Set ElementsWindows - Text element
• A window can contain hard-coded texts and the variables to be printed in the window.
• Tag column: Specifies format of the text
• Text line column: Contains the actual content of the window.
• Special characters
– * Default paragraph– /: Command line– /* Comment line– /E Text element
Chapter TitleElectronic Name.22
Layout Set ElementsWindows - Text element
• Text element always starts with the line /E and continues to the next text element (/E).
• It is the output program (not the layout set) that controls whether or not to print a text element (I.e. block of texts surrounded by /E) and the order in which they are printed.
• ‘,,’ Tabs in a paragraph
• ‘&&’ Variables
Chapter TitleElectronic Name.23
Layout Set ElementsPages
• Shows the page flow information.
• Must define at least two pages.
• The first page specifies the next page.
• The last page recursively defines the next page as itself.
Chapter TitleElectronic Name.24
Layout Set ElementsParagraphs
• Contains all information needed to format a paragraph of text
• Font
• Tabs
Chapter TitleElectronic Name.25
Layout Set ElementsParagraphs
• Specify tabs to create columns for line items
• If no font is specified, default font from the layout set header will be used
TabsTabs
FontFont
Chapter TitleElectronic Name.26
Layout Set ElementsCharacter Strings
• A default character style is specified at the paragraph level.
• Can be used within paragraph to override the default settings for a few words within the paragraph.
Chapter TitleElectronic Name.27
Layout Set ElementsHeader
• Administrative info
• Default settings
• Page format: different for different countries / applications
• Never change ‘Lines per inch’ & ‘Characters/inch’
Chapter TitleElectronic Name.28
Layout SetTest Print
• Menu: Utility > Test print
• Shows the layout design of the layout set.
• Test printing does not trigger the output program to interface with the layout set.
• It simply shows the maximum length of each of the fields being printed.
Chapter TitleElectronic Name.29
Layout SetActivating Layout Set
• Menu: Layout set > Activate
• Must activate the layout set any time a change has been made
Chapter TitleElectronic Name.30
Layout SetSymbol
• Symbols are placeholders for values during print formatting.
• Symbols are identified by a name which is included in ‘&’ characters. Example : &VBAK-VBELN&. Symbols are case sensitive.
• Depending on the source, the value of a symbol comes from, they can be categorized as follows:
• SYSTEM symbols• PROGRAM symbols• STANDARD symbols• TEXT symbols
Chapter TitleElectronic Name.31
Layout SetSymbol
• SYSTEM symbols are supplied by SAPscripts. They can be used in all texts. Following are list of frequently used system symbols.
&DATE& = Current date &DAY& = Day &MONTH& = Month &YEAR& = Year &TIME& = Time of day &HOURS& = Hours &MINUTES& = Minutes &SECONDS& = Seconds &PAGE& = Page &NEXTPAGE& = Page number of next page &SPACE& = Blanks &ULINE& = Underline &VLINE& = Vertical line &NAME_OF_MONTH& = Name of month
Chapter TitleElectronic Name.32
Layout Set Symbol
• PROGRAM symbols are placeholders for values which come from the program that calls the layout set. The symbol has to be defined in the Data Dictionary and filled with values by the output program.
• Example: &KNA1-NAME1& in the layout set will output the Customer’s name.
• STANDARD symbol are maintained centrally in one table (TTDTG) for all SAPscript users.
• Values of TEXT symbol are created by assignment via DEFINE statement.
Example : /: DEFINE &CASENUM& = ‘1234’.
Chapter TitleElectronic Name.33
Layout Set Symbol
• FORMATTING of the symbol can be done in following different ways:
&SYMBOL+ 4& = Off set &SYMBOL(5)& = Length &SYMBOL(I)& = If the symbol is initial, output nothing &SYMBOL(Z)& = Suppress leading zeros &SYMBOL(C)& = Compress blanks &SYMBOL(R)& = Right-justified output &SYMBOL(S)& = Suppress +/- sign &SYMBOL(5,2)& = Decimal place formatting &SYMBOL(E3)& = Exponential notation &’text1’SYMBOL’text2’& = Concatenation of symbol and text
Examples :
&VBDPR-MATNR+2(4)& &VBDKL-BRGEW(I13)& &’Currency : ’VBDKA-WAERK& &’Case # &PREFIX&’VBDPR-BSTNK+2(8)’00’&
Chapter TitleElectronic Name.34
Layout SetCommands
• IF..ELSE..ENDIF can be used within the layout set to control the flow of logic.
Example :
/: IF &VBRK-VKORG(2)& EQ ‘HG’. /: DEFINE &PREFIX& = ‘Mr.’. /: ELSE. /: DEFINE &PREFIX& = ‘Mrs.’. /: ENDIF. . / &PREFIX&
Chapter TitleElectronic Name.35
Layout SetCommands
• CASE ..ENDCASE command can also be used in the layout set to control the flow of logic.
Example :
/: CASE &VBDKL-VKORG(2)& /: WHEN ‘HG’ / Case # &‘934’VBDPL-SORTKRI& /: WHEN OTHERS / Case # &‘999’VBDPL-SORTKRI& /: ENDCASE
Chapter TitleElectronic Name.36
Layout Set Commands
• Using the command NEW-PAGE, a page -break can be made in SAPscript at any position before the end of the page defined in the layout set. The next page can be specified explicitly.
Syntax: /: NEW-PAGE [PAGE]
• A page break within a paragraph can be prevented by using this command PROTECT..ENDPROTECT.
Syntax : /: PROTECT
text text text
/: ENDPROTECT
Chapter TitleElectronic Name.37
Layout SetCommands
• The command ADDRESS…ENDADDRES formats an address according to the postal standards of the country of destination which is defined in the parameter COUNTRY.
Syntax :
/: ADDRESS DELIVERY PARAGRAPH paragraph [ PRIORITY prio LINES lines ] /: TITLE form of address /: NAME name1[, name2[, name3[,name4]]] /: STREET strno /: POBOX pobox [CODE code] /: POSTCODE postal code /: CITY city1[,city2] /: REGION district /: COUNTRY recipient country /: FORMCOUNTRY sender country /: ENDADDRESS
Chapter TitleElectronic Name.38
Layout Set Commands
• Parameter PRIORITY defines which address lines may be omitted, if necessary. The possible values are as follows :
A Form of address B Mandatory blank line 1 C Mandatory blank line 2 2 Name2 3 Name3 4 Name4 L Country name S Street line O City line
• The parameter LINES are available for formatting the address. Possible values are from 1 to n. If it is not possible to format all address data due to a lack of lines, the data which is entered in the parameter PRIORITY is omitted.
Chapter TitleElectronic Name.39
Layout SetCommands
• The date can be formatted using the command SET
DATE MASK = ‘…’. After formatting all date fields are output as specified. The available formats for day, month and year are following.
DD Day MM Month in figures MMMM Month in words YY Year (2 digits) YYYY Year (4 digits)
Example : /: SET DATE MASK = ‘MM/DD/YYYY’
• The formatting can be reset at any point of time by /: SET DATE MASK = ‘’. Formatting is then carried out
as defined by the System.
Chapter TitleElectronic Name.40
Layout Set Commands
• The time can be formatted using the command SET TIME MASK = ‘…’. After formatting all time fields are output as specified. The available formats for hours, minutes and seconds are following.
HH Hours MM Minutes SS Seconds
Example /: SET TIME MASK = ‘HH:MM:SS’
• The formatting can be reset at any point of time by /: SET TIME MASK = ‘’. Formatting is then carried out
as defined by the System.
Chapter TitleElectronic Name.41
Layout SetCommands
• In SAPscript, any text can be included at a certain position in the document using INCLUDE command.
Syntax :
INCLUDE name OBJECT object ID identifier PARAGRAPH paragraph LANGUAGE language
Example :
INCLUDE &VBDPL-TDNAME& OBJECT VBBP ID 0001 PARAGRAPH IT
INCLUDE ‘SD_TEXT’ OBJECT TEXT ID SDVD PARAGRAPH HT
• There are two different types of text handled in SAPscript. One is APPLICATION TEXT and other one is STANDARD TEXT.
Chapter TitleElectronic Name.42
Layout SetCommands
• The ‘name’ in the include command is always the document no for APPLICATION TEXT and the name of standard text for STANDARD TEXT.
• Example : vbdka-tdname, vbdkl-tdname, vbdkr-tdname.
• The text ‘object’ specifies the environment to which a text belongs.
TEXT NAME TEXT ORIGIN
VBBK Sales document Header Text
KNVV Customer Master SD Text
VBKA Contacts General Text
VTTK Shipment Header Text
The ‘object’ is always ‘TEXT’ for STANDARD TEXT.
Chapter TitleElectronic Name.43
Layout Set Commands
• Several different text IDs can belong to one object .
• TEXT ID
0002 Sales document header note1.
0003 Sales document header note2.
Chapter TitleElectronic Name.44
Output ProgramOverview
• Program retrieves the data to be printed in a Layout set.
• Structure of Programs Stand alone . Transaction Triggered.
• Communication in between program and layout set is done via execution of function calls and communication structures.
• Execution sequence of function calls• A layout set must be opened before being able to output
data.• Data can be transfer as often as required.• At end layout set has to be closed.
Chapter TitleElectronic Name.45
Output ProgramFunction Call
• General Function calls
• CALL FUNCTION ‘ OPEN_FORM ’.
• CALL FUNCTION ‘ WRITE_FORM ’.
• CALL FUNCTION ‘ CLOSE_FORM ’.
• CALL FUNCTION ‘ CONTROL_FORM ’.
• CALL FUNCTION ‘ READ_TEXT ’.
Chapter TitleElectronic Name.46
Output Program Function Call
• CALL FUNCTION ‘ OPEN_FORM ’ = ..
EXPORTING FORM = .. LANGUAGE = .. DEVICE = .. OPTIONS = .. DIALOG = .. APPLICATION = ..
IMPORTING LANGUAGE = .. EXCEPTIONS …..
Chapter TitleElectronic Name.47
Output Program Function Call
• OPEN_FORM opens layout set for Printing .
• Parameters
• LANGUAGE defines the layout set language version .
• DEVICE specifies the output device type .
( Example : PRINTER, SCREEN, TELEX, TELEFAX)
• OPTIONS can be used to specify the print preview.
• DIALOG can request a pop-up screen on which user can enter spool information such as printer name.
Chapter TitleElectronic Name.48
Output Program Function Call
• Possible Exceptions :
• DEVICE = Device type invalid
• FORM = Layout set does not exist
• OPTIONS = Options invalid
• UNCLOSED = A layout set is still active
Chapter TitleElectronic Name.49
Output Program Function Call
• CALL FUNCTION ‘ WRITE_FORM ’ = ..
EXPORTING ELEMENT = .. TYPE = .. FUNCTION = .. WINDOW = .. EXCEPTIONS …..
Chapter TitleElectronic Name.50
Output Program Function Call
• WRITE_FORM transfer the data to layout.
• Parameters
• Explicitly specify ELEMENT and WINDOW name to output data from a specific ELEMENT.
• No specification of WINDOW name is necessary for MAIN window.
• TYPE defines area of the MAIN window, where data need to written. Possible values :
• TOP = MAIN window header.
• BOTTOM = MAIN window footer.
• BODY = MAIN window normal output area (Default).
Chapter TitleElectronic Name.51
Output Program Function Call
• FUNCTION defines how the data specified in the text element is to be written in the respective WINDOW.
• MAIN window• SET = Append to preceding output. • APPEND = Identical with SET.• DELETE = Ineffective.
• OTHER window• SET = Delete old contents and output new text.• APPEND = Append to preceding output.• DELETE = Delete the specified text element.
• Default is SET
Chapter TitleElectronic Name.52
Output Program Function Call
• Possible Exceptions :
• ELEMENT = Text does not exist.
• FUNCTION = Function is invalid.
• TYPE = Window area is invalid.
• WINDOW = Window does not exist.
• UNOPENED = Layout set printing not opened.
Chapter TitleElectronic Name.53
Output Program Function Call
• CALL FUNCTION ‘ CLOSE_FORM ’ = .. EXPORTING RESULT = ..
EXCEPTIONS…..
• Layout set opened with function ‘OPEN_FORM’ is closed.
• Layout set must be closed before being able to output the data on the screen or printer.
• Possible exceptions :
• UNOPENED = No open layout set.
Chapter TitleElectronic Name.54
Output Program Function Call
• CALL FUNCTION ‘ CONTROL_FORM ’ = .. EXPORTING COMMAND = ..
EXCEPTIONS…..
• ‘CONTROL_FORM’ can execute SAPscript control commands.
• Example : PROTECT … ENDPROTECT.
• Parameter COMMAND accept the SAPscript command.
• Possible exceptions :
• UNOPENED = Layout set printing has not been opened.
• UNSTARTED = No layout set opened
Chapter TitleElectronic Name.55
Output Program Function Call
• CALL FUNCTION ‘ READ_TEXT ’ = ..
EXPORTING OBJECT = .. NAME = .. ID = .. LANGUAGE = .. IMPORTING HEADER = .. TABLES LINES = .. EXCEPTIONS …..
Chapter TitleElectronic Name.56
Output Program Function Call
• An application text can be read from text file. HEADER and LINES contain header and text information after successful execution.
• Work area for header must be defined as a field string.
DATA BEGIN OF HEADER INCLUDE STRUCTURE THEAD
DATA END OF HEADER
• Work area for text lines must be defined as an internal table.
DATA BEGIN OF LINES OCCURS ... INCLUDE STRUCTURE TLINE
DATA END OF HEADER
Chapter TitleElectronic Name.57
Output Program Function Call
• Possible Exceptions :• ID = Text ID invalid.
• LANGUAGE = Language invalid.
• NAME = Text name invalid.
• NOT_FOUND = Text not found.
• OBJECT = Text object invalid.
• REFERENCE_CHECK = Reference sequence interrupted.
Chapter TitleElectronic Name.58
Output Program Function Call
• Document ( e.g. Sales Order ) generation programs can also be triggered via business transaction.
• Sources of data :
Document Header Item
SO VDBKA VBDPA
Delivery Note VDBKL VBDPL
Picking VDLKK VBLKP
Invoice VDBKR VBDPR
Purchase Order EKKO EKPO
Payment REGUH REGUP
Chapter TitleElectronic Name.59
Configuration Output Determination
Linking a layout set to the printing program
Proposing the output type for the documents Output time Output device Print parameters
Chapter TitleElectronic Name.60
Configuration Linking Layout set to Program: SD Module
• SD Menu: SD > Basic functions > Output > Output determination > Process output and forms > Assign forms and programs > Allocate to sales documents
• Output type / Medium determines
– Printing program– Layout set– Form routine
• Good screen to check initially to see which programs and the layout sets the standard system uses to print standard forms
Chapter TitleElectronic Name.61
Configuration Linking Layout set to Program
• By using the “FORM Routine” field you can indicate different “entry point” to the printing program.
• All output type can be associated with the same program / layout set combination but to different “FORM Routines”.
• Helps to consolidate logic variation in one program
Internt’l = XInternt’l = X Interco = XInterco = X internal = Xinternal = X
FORM EntryAFORM EntryA FORM EntryBFORM EntryB FORM EntryCFORM EntryC
If Internt’l = X….elseif Interco = X…elseif Internal = X….Endif
If Internt’l = X….elseif Interco = X…elseif Internal = X….Endif
ProgramProgram Layout setLayout set
Open_FormOpen_FormFORM Entry
Chapter TitleElectronic Name.62
Configuration Linking Layout set to Program: MM Module
• Purchasing Menu: MM > Purchasing > Messages > Output control > Output control > Define output control for the purchase order
• Inventory Management Menu: MM > IM > Output determination > Assign layout sets and programs
• Warehouse Management Menu: MM > WM > Activities > Define print control
Chapter TitleElectronic Name.63
Configuration Linking Layout set to Program: FI Module
• Finance Menu: FI > AR & AP > Customer (Vendor) accounts > Line items > Correspondence > Carry out check or correspondence settings >Define form names for printing correspondence
• Check Printing Menu: FI > AR & AP > Business transaction > Outgoing payments > Automatic outgoing payments > Payment method / Bank selection > Configure payment program > Payment method > In company code > “Double click on the country” > “Double click on check” > Environment > Form data
Chapter TitleElectronic Name.64
Barcode Printing
• To print barcode , follow the steps below :
• Select / Create a barcode font in SAP.
• Create a character string and include the barcode with it.
• The data need to printed as barcode should be attributed via the character string.
• e.g. / <BC> * &VBAKA-WERKS& * </>
Chapter TitleElectronic Name.65
Logo Printing
• To print a Logo, follow the steps below :
• Built a Logo. This file can be a bit map or windows meta file.
• Convert the Logo to a TIFF ( extension TIF ) file.
• Use program RSTXLDMC to convert the TIF file to a standard text.
• Print this standard text via SAPscript INCLUDE command.• e.g. /: INCLUDE ZHEX-IBMLOGO-PCL OBJECT TEXT ID
ST