******************************************************************************** ****************************************** Symbols and Control commands

******************************************************************************** ****************************************** Symbols are placeholders for values that are inserted during print formatting. Symbols are indentified by name surrounded by "&" and are not case sensitive Types of symbols Formatting Control commands Types of symbols System symbols DATE DAY NAME_OF_DAY MONTH YEAR TIME HOURS MINUTES SECONDS PAGE NEXTPAGE DEVICE SPACE ULINE VLINE Date Day Name of day Month Year Time Hours Minutes Seconds Page number Number of next pagre Output device Blank space Underline Vertical line

Standard symbols Standard symbols are user defined and are maintained in table TTDG. You use tran saction SM30 to change or display standard symbols. An examples of standard symbols is &MFG& fot "Yours faithfully" Standard text Se also Using Graphics Standard texts is predifined texts that can be used in more than one form. Stand ard texts are can be created, changed and displayed using transaction SO10. The text ID is used to classify texts. To include a standard text in a form, use the INCLUDE command: /: INCLUDE Z_BC460_EX4_HF OBJECT TEXT ID SDVD When formatting the standard text the PARAGRAPH parameter is used. To center the text use:

Offset refers to formatt ed value &SYMBOL(5)& Length .The data length is defined by th e ABAP dictionary &SYMBOL(8. Language. In the form: &KNA1-NAME1& Formatting &SYMBOL& No formatting &SYMBOL+4& Offset .If the field has been initi alized. Leading spacesare suppressed. Paragraph Example: /: INCLUDE Z_BC460_EX4_HF OBJECT TEXT ID SDVD LANGUAGE EN PARAGRAPH C. nothing is output &SYMBOL(Z)& Suppress leading zeros &SYMBOL(C)& Compress blank spaces . data from the database tables are printed isntead of the symbols. W hen you print the form.2)& Decimal format. &SYMBOL(R)& Right align output &SYMBOL(S)& Operators are suppressed &SYMBOL(*)& Dictionary length ./: INCLUDE <name> <Parameter> <parameter> = Object. ID.Consecutice spaces are compr essed into a single space. Length 8 decimals 2 &'text1'SYMBOL'text2'& Text can be inserted before and after the symbol .Output begins here. In the print program: TABLES: kna1.Output data in the specified length &SYMBOL(I)& Suppress initial value . Name: Z_BC460_EX4_HF Object: Text Text id: SDVD (Text id from SO10) Language: EN Paragraph: C (Centered) Tip: You can use menu Insert->Text->Standard to make it easier to insert the tex t Program symbols Program symbols are for contents of database fields or global program symbols.

..Control commands Control command are used to modify text output. DOKU (Document). /: /: /: /: /: /: /: INCLUDE DEFINE ADDRESS.ENDADDRESS PROTECT..ENDCASE Examples of control commands INCLUDE INCLUDE name <parameter> Parameters: OBJECT E. ID Text ID -Text ID is a way to group texts ... Note that a text with the name in the variable &SCUSTOM-NAME& name must be created in SO10. The PA RAGRAPH parameter can be used to redefine the standard paragraph for this style for the current call.g. TEXT. All *-paragraphs in the included text will then be formatted using the paragraph specified here. DSYS (Hypertext). Object ID Language Paragraph Standard texts are maintained in transaction SO10.. Depending on the name in the variable &SCUSTOM-NAME& different texts will be sho wn. Example 1: You have created a standard text in SO10 Named MYTEXT and with Text Id ST /: INCLUDE MYTEXT OBJECT text ID st Example 2: You can also use a dynamic name so that you can retreive a ext depeding of the n ame variable: /: INCLUDE &SCUSTOM-NAME& text ID st...ENDPROTECT NEW-PAGE IF.Se transaction SO10 LANGUAGE If the parameter is not specefied.ENDIF CASE.... DEFINE .. the logon language will be used PARAGRAPH The text to be included is formatted using the style allocated. Use format key /: in the format column.

ADDRESS-ENDDRESS The ADDRESS-ENDADDRESS command formats addresses according to the postal norms o f the recipient's country.ENDIF and CASE . Conditonal text ouput IF . the PROTECT command acts as a NEW-PAGE command and inserts a page b reak.ENDCASE You can use IF/ENDIF and CASE/ENDCASE like in a normal ABAP program /: IF condition : : /: ENDIF and /: IF condition : /: ELSE : /: ENDIF .YYYY' /: SET COUNTRY 'USA' PROTECT-ENDPROTECT Is used to avoid pagebreaks in a paragraph.MMMM. /: /: /: /: /: /: /: /: ADDRESS DELIVERY PARAGRAPH AD NAME &KNA1-NAME& STREET &KNA1-STRAS& POSTCODE &KNA1-PSTLZ& CITY &KNA1-ORT01& COUNTRY &KNA1-LAND1& FROMCOUNTRY 'DE' ENDADDRESS Time Date and decimal format Examples: /: SET TIME MASK = 'HH:MM' /: SET DATE MASK = 'DD. /: PROTECT : : /: ENDPROTECT 5. The text lines to be protected are e nclosed between the two commands./: DEFINE &SYMBOL& = 'String1 String2' /: DEFINE &CUST& = '00000021'. as defined in the country parameter. If there is not enough room on the page.

Lines and shading ******************************************************************************** ****************************************** BOX Draws a box Syntax: /: BOX <xpos> <ypos> <width> <height> <frame> <intensity> The intensity is the grey scale of the box as %.5 P T). Default is 0.. xpos..31' MM HEIGHT '10' MM WIDTH '20' MM INTENSITY 10 FRAME 0 TW /: BOX FRAME 10 TW Draws a frame around the current window with a frame thickness of 10 TW (= 0. put some text here /: ENDIF /: CASE <something> /: WHEN <.. width.Example: /: IF &SPFLI-CITYTO& = "BERLIN" * . height and frame muts be followed of the measurement unit: TW (twip) PT (point) IN (inch) MM (millimeter) CM (centimeter) LN (line) CH (character). /: BOX WIDTH 0 TW FRAME 10 TW Draws a vertical line along the complete height of the left hand edge of the win dow. Examples: /: BOX XPOS '11. /: BOX INTENSITY 10 Fills the window background with shading having a gray scale of 10 %. The frame parameters is the thi ckness of the frame.. /: BOX HEIGHT 0 TW FRAME 10 TW Draws a horizontal line across the complete top edge of the window.21' MM YPOS '5. Each of the paramteters ypos.> /: ENDCASE ******************************************************************************** ****************************************** Frames. ...

5 cm to the left and 1 cm up. Drawing a line You can draw a line by setting the Height or Width of a box to 0 and add a frame .5' CM WIDTH 0 TW HEIGHT '13.21' YORIGIN '5.5' CM FRAME 10 TW /: BOX XPOS '13.5' CM FRAME 10 TW Draws two rectangles and two lines to construct a table of three columns with a highlighted heading section. Note that you uses "+" or "-" in the ORIGIN position to the set the position relatively.5' CM HEIGHT '13. Example: /: POSITION XORIGIN '11. /: POSITION XORIGIN 2 CM YORIGIN '2. /: POSITION XORIGIN '-1.5' CM HEIGHT 1 CM FRAME 10 TW INTENSITY 15 /: BOX WIDTH '17. /: POSITION WINDOW /: POSITION XORIGIN '+5' MM YORIGIN '+10' MM the position is now 5 MM from the left and 10 MM from the top of the window. NOTE: After using the position command you can move the current position realtiv ely to the last used position /: POSITION XORIGIN '+10' MM YORIGIN '+20' MM Now the position will be X = 15 and Y = 30 More examples: /: POSITION WINDOW Sets the origin for the coordinate system to the upper left corner of the window .5 CM' Sets the origin for the coordinate system to a point 2 cm from the left edge and 2.0' CM WIDTH 0 TW HEIGHT '13. T his can be usefull if you have several boxes that share the same parameters.5 cm from the upper edge of the output page. POSITION and SIZE You can use the POSITION and SIZE commands to set default parmeters for a box.5' CM YORIGIN -1 CM Shifts the origin for the coordinates 1.5' CM FRAME 10 TW /: BOX XPOS '10./: BOX WIDTH '17. Then use POSITION to set the current position relatively to the start of the Window.31' MM /: SIZE HEIGHT '2' MM WIDTH '76' MM /: BOX FRAME 10 TW INTENSITY 10 If you want to set the position realtively to the window use POSITION WINDOW to set the position to the top/left start of the window.

E. Dear &NAME& The ABAP routine The ABAP routine could be defined as follows: IMPORTANT: The structure itcsy must be used for the parameters. /:PERFORM GET_NAME IN PROGRAM Z_BC460_EX4_HF /: USING &CUST& /: CHANGING &NAME& /:ENDPERFORM. TABLES scustom. /: SIZE WIDTH '3. FORM get_name tables in_tab structure itcsy out_tab structure itcsy. PAGE Sets the values for the width and height to the values of the current outpu t page. Examples: /: SIZE WINDOW Sets WIDTH and HEIGHT to the current window dimensions. REPORT Z_HENRIKF_SCRIPT_FORM . The edges of the frame extend beyond the edges of the window itself.21' MM YPOS '14.81' MM INTENSITY 100 Window and Page WINDOW sets the values for the width and height to the values of the current win dow (default setting).6 cm. read table in_tab index 1. You c an use this to get data without havning to cnahge the print program.. SapScript /:DEFINE &CUST& = '00000021'.g. /: POSITION WINDOW /: POSITION XORIGIN -20 TW YORIGIN -20 TW /: SIZE WIDTH +40 TW HEIGHT +40 TW /: BOX FRAME 10 TW A frame is added to the current window. In the examole below NAME is retrei ved from table SCUSTOM.5 cm and HEIGHT to 7. Calling ABAP subroutines You can call an ABAP subroutine from SapScript using the PERFORM statment.5' CM HEIGHT '7. . so as to avoid obscuring the leading and trailing text characters. a horizontal line: /: SIZE HEIGHT '0' MM WIDTH '200' MM /: BOX FRAME 10 TW XPOS '11.6' CM Sets WIDTH to 3.

.. * out_par-value = l_name1. move 'No name' to out_tab-value. The program retieves the necesary data from datbase tables. move scustom-name to out_tab-value.. modify out_tab index sy-tabix. modify out_tab index sy-tabix... read table out_tab index 1. ** You could also fill the ouput parameter table this way * READ TABLE out_par WITH KEY 'NAME1'. ENDFORM.select single * from scustom where id = in_tab-value. /: CHANGING &OUTVAR1& /: CHANGING &OUTVAR2& . if sy-subrc = 0. Note that if you use more than one parameter you must use Using or Changing befo re every parameter ! /: PERFORM <form> IN PROGRAM <prog> /: USING &INVAR1& /: USING &INVAR2& . * MODIFY out_par INDEX sy-tabix. chooses a form for printing and selects an output device and print options. read table out_tab index 1. /: ENDPERFORM ******************************************************************************** ******************************************** The Print Program ******************************************************************************** ******************************************** Structure of a print program OPEN_FORM function CLOSE_FORM function WRITE_FORM START_FORM function END_FORM function CONTROL_FORM function The print program is used to print forms.. else. Function modules in a printprogram: .... defines the order of in which text elements are printed.. endif.

. Note: for printing line s in the body.. SELECT * FROM xxx. The order in which the texteleme nts are printed. you can also use the WRITE_FORM_LINES function module. * Ends spool request started with START_FORM call funtion 'END_FORM'. begin each form using START_FORM..Must be called before working with any of the other form function modules... is determined by the order of the WRITE_FORM statements..When you print a form you must used the staments OPEN_FORM and CLOSE_FORM. OPEN_FORM function Syntax: CALL FUNCTION 'OPEN_FORM' * EXPORTING * APPLICATION * ARCHIVE_INDEX * ARCHIVE_PARAMS * DEVICE * DIALOG * FORM * LANGUAGE * OPTIONS * MAIL_SENDER * MAIL_RECIPIENT * MAIL_APPL_OBJECT * RAW_DATA_INTERFACE * IMPORTING = = = = = = = = = = = = 'TX' 'PRINTER' 'X' ' ' SY-LANGU '*' .. To transfer control command to a form use CONTROL_FORM... To co mbine forms into a single spool request use START_FORM and END_FORM... Structure of a print program * Read data Tables: xxx. * To begin several indentical forms containing different data within a single sp ool request. and end it using END_FORM call funtion 'START_FORM'.. * Write text elements to a window of the form call function 'WRITE_FORM'.... * Must be ended with function module CLOSE FORM call function 'OPEN_FORM'... * Open form printing . To print textelements in a form use WRITE_FORM. * Closes form printing call function 'CLOSE_FORM'..

* LANGUAGE = * NEW_ARCHIVE_PARAMS = * RESULT = * EXCEPTIONS * CANCELED = 1 * DEVICE = 2 * FORM = 3 * OPTIONS = 4 * UNCLOSED = 5 * MAIL_OPTIONS = 6 * ARCHIVE_ERROR = 7 * INVALID_FAX_NUMBER = 8 * MORE_PARAMS_NEEDED_IN_BATCH = 9 * SPOOL_ERROR = 10 * OTHERS = 11 . IF sy-subrc <> 0. * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO * WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO * WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. ENDIF. ... The input for the parameter is structure ITCPO. Paramerters: RESULT Returns status information and print/fax parameters after the form has be en printed. Some important parameters: FORM Name of the form DEVICE PRINTER : Print output using spool TELEFAX: Fax output SCREEN: Output to screen OPTIONS Used to control attrubutes for printing or faxing (Number of copies.. ENDIF. CLOSE_FORM function CALL FUNCTION 'CLOSE_FORM' * IMPORTING * RESULT = * RDI_RESULT = * TABLES * OTFDATA = * EXCEPTIONS * UNOPENED = 1 * BAD_PAGEFORMAT_FOR_PRINT = 2 * SEND_ERROR = 3 * SPOOL_ERROR = 4 * OTHERS = 5 . RESULT is of structure ITCPP. imm ediate output. IF sy-subrc <> 0.

. Some important parameters: ELEMENT Specifies which textelement is printed WINDOW Specifies which window is printed TYPE Specifies the output area of the main window. ENDIF...Used for headers BODY BOTTOM .WRITE_FORM function CALL FUNCTION 'WRITE_FORM' * EXPORTING * ELEMENT = ' ' * FUNCTION = 'SET' * TYPE = 'BODY' * WINDOW = 'MAIN' * IMPORTING * PENDING_LINES = * EXCEPTIONS * ELEMENT = 1 * FUNCTION = 2 * TYPE = 3 * UNOPENED = 4 * UNSTARTED = 5 * WINDOW = 6 * BAD_PAGEFORMAT_FOR_PRINT = 7 * SPOOL_ERROR = 8 * OTHERS = 9 . /E ITEM_HEADER IH Carrier.. This can be: TOP .......... IF sy-subrc <> 0. replaced or added Example of how to use the WRITE_FORM function module together with a script.....Used for footers FUNCTION Specifies whether text is to be appended.. &SPFLI-DEPTIME& /E CLOSING_REMARK The print program * Writing INTRODUCTION CALL FUNCTION 'WRITE_FORM' EXPORTING ... Form layout of the MAIN window /E INTRODUCTION * Dear Customer . Departure /E ITEM_LINE IL &SBOOK-CARRID&.. * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO * WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4......

.ELEMENT FUNCTION TYPE WINDOW EXCEPTIONS OTHERS . CALL FUNCTION 'WRITE_FORM' EXPORTING ELEMENT = 'ITEM_LINE' FUNCTION = 'SET' TYPE = 'BODY' WINDOW = 'MAIN' EXCEPTIONS OTHERS = 8.. ENDLOOP... = = = = 'INTRODUCTION' 'SET' 'BODY' 'MAIN' = 8 * Writing ITEM_HEADER CALL FUNCTION 'WRITE_FORM' EXPORTING ELEMENT FUNCTION TYPE WINDOW EXCEPTIONS OTHERS . * Delete ITEM_HEADER from TOP area of main window CALL FUNCTION 'WRITE_FORM' EXPORTING ELEMENT = 'ITEM_HEADER' FUNCTION = 'DELETE' TYPE = 'TOP' WINDOW = 'MAIN' EXCEPTIONS OTHERS = 8 * Print CLOSING_REMARK CALL FUNCTION 'WRITE_FORM' EXPORTING ELEMENT = 'CLOSING_REMARK' . = = = = 'ITEM_HEADER' 'SET' 'BODY' 'MAIN' = 8 area of main window for subsequent pages 'ITEM_HEADER' 'SET' 'TOP' 'MAIN' 8 * Set ITEM_HEADER into TOP CALL FUNCTION 'WRITE_FORM' EXPORTING ELEMENT = FUNCTION = TYPE = WINDOW = EXCEPTIONS OTHERS = * Write ITEM_LINE LOOP AT .

Syntax: CALL FUNCTION 'CONTROL_FORM' EXPORTING command = * EXCEPTIONS * UNOPENED = 1 * UNSTARTED = 2 . * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO * WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. ENDIF.FUNCTION TYPE WINDOW EXCEPTIONS OTHERS = 'SET' = 'BODY' = 'MAIN' = 8 START_FORM function CALL FUNCTION 'START_FORM' * EXPORTING * ARCHIVE_INDEX = * FORM = ' ' * LANGUAGE = ' ' * STARTPAGE = ' ' * PROGRAM = ' ' * MAIL_APPL_OBJECT = * IMPORTING * LANGUAGE = * EXCEPTIONS * FORM = 1 * FORMAT = 2 * UNENDED = 3 * UNOPENED = 4 * UNUSED = 5 * SPOOL_ERROR = 6 * OTHERS = 7 . ENDIF. IF sy-subrc <> 0. CONTROL_FORM function The CONTROL_FORM function module alows you to create SapScript control statement s from within an APAB program. END_FORM function CALL FUNCTION 'END_FORM' * RESULT = * EXCEPTIONS * UNOPENED = 1 * BAD_PAGEFORMAT_FOR_PRINT = 2 * SPOOL_ERROR = 3 * OTHERS = 4 . IF sy-subrc <> 0. * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO * WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

There can be the following reasons to change the print program: Structureal changes New text eloements are needed Print program to be used to print additional forms Determine/change which forms and printprograms that are used for printing The forms and print programs for a given output type and application can be foun d in table TNAPR Processing programs for output Use view V_TNAPR in (Transaction SE30) to change entries. Example: Protecting the text element ITEM_LINE CALL FUNCTION 'CONTROL_FORM' EXPORTING COMMAND = 'PROTECT'. create styles and maintainse styles. use transaction SE72. CALL FUNCTION 'WRITE_FORM' EXPORTING TEXELEMENT = 'ITEM_LINE'. SAP prov ides several standard styles e. You assign style to a text by using menu Format -> Style You can make temporary style changes using the control command /: STYLE Modifications Considerations in connection with modifications The standard SAP print program should only be changed when it is absolutely nece ssary. If additional data is needed. To find styles. on-line documentation and so on. ******************************************************************************** ********************************************* Styles ******************************************************************************** ********************************************* Styles are used to predefine paragraph and character formats for forms. these can in many cases be retrieved using a a PERFORM statement in the form instead of changing the print program. . for Address includes.. You can define your own s tyles. ENDIF. IF sy-subrc <> 0. * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO * WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.* OTHERS = 3 .g. CALL FUNCTION 'CONTROL_FORM' EXPORTING COMMAND = 'ENDPROTECT'.

To use an INCLUDE stanment. there is an option in Utilities as COPY ffrom Source client (000). MEDRUCK is the form used to print a PO that has been created. Look at MEDRUCK form and it would have a print program. 5. you can find in tcode NA CE. In the form painter. Co py the from MEDRUCK into a Zname form. goto into the woindow script editor and use menu Inc lude->Graphic. Please send me the one examples in full length. 3.. Generally. I want to know the procedure to create a purchase order using MEDRUCK. 4. MEDRUCK is the form for PO. you can either include directly to the form using menu Edit ->Graphic->Create or using the INCLUDE statement in a window.Using Graphics See also Standard Text Use transaction SE78 to inmport graphics to SAP. Th ese structures are used to get data from Database. 2. etc. Unless you have to do something new for your client like Labels or Packaging card. using Std text for Terms and Conditions. You don't create a PO using MEDRUCK. The include can look like this for a bitmap: /: BITMAP MYLOGO OBJECT GRAPHICS ID BMAP TYPE BMON ******************************************************************************** ********************************************* Questions on PO SapScripts MEDRUCK ******************************************************************************** ********************************************* 1. How can I access my data from DB to SCRIPTS? There are structures used in Scripts which hold the data entered by the user. When do you modified MEDRUCK? ( IF I SAID I HAVE WORKED ON SCRIPTS). The common changes wud b inserting a logo . ******************************************************************************** ********************************************* SapScript Question ******************************************************************************** ********************************************* 1) How do you backup script layout sets? 2) What type of variables normally used in script to o/p data? 3) How do you use tabsets in layouts? . get xtra data if client is asking for somethign more. What are the usual changes to be done on MEDRUCK? Goto SE71. alignment of windows as per client re quirement. we modify existing sap scripts provided by SAP rather than creating o ne.

TIF Resolution for Tiff file Absolute X-position Absolute Y-position Absolute positioning Reserved height Shift to right UOM = CM Text title Line width for text = 132 Text name ZHEX-MACRO-COMPLOGO Text ID ST Text language = E Postscript scaling Width & Height according to PS scaling Number of Tiff gray levels (2.doc). If there are fewer tabs in the paragraph f ormats than in the header data. Those are defined in Driver progr am. 1) First Export to Presentation file(. 2) Normally we call them as Program symbols. We do not want the number of pages as in duplex printing. &itab-matnr& Other variables ---System symbols : ex &page& ---Std symbols : ---Text symbols :We define them in script editor itself. Q: Can I Print a logo on an Invoice? A: Save a Logo using Paintshop Pro or Corel Draw as Tiff file.00 LN .00 CH Upper margin LN window height 8. Process could be like the following: Run RSTXLDMC Enter file name C:\MAIL\COMPLOGO.1) Use this Std program RSTXSCRP. the tab stops of the header data are used for th e rest of the line. In our case duplex case is always 'Terms & Conditions'.9) 2 Then Create a new window 'COMP' with attributes. 2) Whenever you need that Export into SAP. the path and file name have to be correctly specified. Ex : /: Define &mysymbol& = 'XX' 3) We can control the tab feed in a paragraph with tab positions. What is the best possible s olution? A: On the Terms & Conditions page. Change the Page counter mode to 'HOLD' to kee p the page counter from incrementing when you print the Term & Conditions. The tab stops us define in the paragraph format replace the tab spacing we defined in the hea der data of the form.00 CH window width 10. Window COMP description Company Logo Window type CONST Left margin 7. Use RSTXLDMC to c onvert the logo to standard text in SapScript. SAPscripts Tips by : Venkat O Q: We get the total number of pages as expected by using 'SAPSCRIPT-FORMPAGES' i n a duplex layout. We can use in Script as for exp. this depends on the extent to which we have defin ed tab stops in the paragraph format. However. When the program is executed.4.

'. 18045. Say 'ZHEX-MACRO-LOGO1' and 'ZHEX-MACRO-LOGO2'.. 39031 for some inputs. The same will be printed i n actual printout. . the names of the logos should be unique. the logo may not be printed! You will not be able to see the logo in a test print. Else all the information will be overwritten.0. Please note that if object name is not indicated as 'ZHEX. mention /: INCLUDE 'ZHEX-MACRO-COMPLOGO' OBJECT TEXT ID ST LANGUAGE 'E'. the same will not be printed. If the logo is not EXACTLY TIFF 6.Finally in the text element .. See OSS notes 5995. If you are using two logos in the same layout.