The steps for including graphical elements in the layout set are as follows
- The graphical element (like company logo) should be in valid graphic file format like .bmp or .jpg
- Use appropriate software to convert the above file into a .TIFF file
- Use report RSTXLDMC to upload this file as a text module in SAP
- Execute the above program from the ABAP /4 editor
- Enter the location of the .TIFF file on the PC
- Specify BMON or BCOL as the raster image type
- The SAP system suggests a name for the file ( like ZHEX-MARCO-* ). The * indicates the type of file. For e.g. if the file contains a logo then the name can be ZHEX-MACRO-LOGO
- The ID should be ‘ST’ and give the logon language
- Running the program will convert this .TIFF file into a text element
- Incorporate this converted logo in the appropriate window under the appropriate text element by giving
The best way to explain the various steps in designing a SAP script is to visualize the creation of a document. The entire process is explained as a series of steps.
Let us assume that we need to design the document Invoice.doc for the ABC Company Limited.
- Understand the structure of the document that needs to be generated page by page.
- Find out the different pages that form the document.
- Decide the FIRST page of the document and the pages that are going to follow.
- Find out the various fonts and styles (bold, italics, etc) that are used in the document.
- Also try to group the data printed on the document into logical parts.
- Create all the character strings that have been used in the document
- Create all the paragraphs that have been used in the document
- Create all CONSTANT the windows that have been uniquely identified in the document
- Identify the MAIN window of the every page of the document
- Define the pages that form the parts of the document
- Assign the windows to each page
- Define the text elements within each window
- Use function module OPEN_FORM to open the layout set.
- Use function module WRITE_FORM to write the text elements in various windows
- Use function module CLOSE_FORM to close the layout set
Layout set Z_TESTSCRIPT Description Test SAP script Standard attributes First page FIRST Default paragraph P1 Tab-stop 1.00 CH Page format DINA4 Orientation Landscape Lines/inch 6.00 Characters/inch 10.00 Font attributes Font family COURIER Font size 12.0 Point Bold No Italic No Underlined No Characters Attributes B Character String Bold Standard attributes Marker No Font attributes Bold Yes Paragraphs Attributes P1 Default Paragraph Standard attributes Line spacing 1.00 LN Left margin 1.00 CM Alignment Left-aligned Font attributes Font family TIMES Font size 12.0 Point P2 Header Paragraph Standard attributes Line spacing 1.00 LN Left margin 4.50 CM Alignment Left-aligned Font attributes Font family TIMES Font size 18.0 Point Bold Yes P3 Undelined paragraph Standard attributes Line spacing 1.00 LN Alignment Left-aligned Font attributes Font family TIMES Font size 12.0 Point Underlined Yes Windows Attributes MAIN Main window Window type MAIN HEADER Main window Window type CONSTANT FOOTER Main window Window type CONSTANT Pages Attributes FIRST First Page Standard attributes Next page FIRST Page counter Mode START Numbering type Arabic numerals Page window HEADER Left margin 00.00 CM Upper margin 00.00 CM Window width 20.00 CM Window height 04.00 CM MAIN Left margin 00.00 CM Upper margin 05.00 CM Window width 20.00 CM Window height 20.00 CM FOOTER Left margin 00.00 CM Upper margin 25.00 CM Window width 20.00 CM Window height 04.00 CM Text elements for following windows: HEADER Element HEADER /: POSITION XORIGIN 2 CM YORIGIN '-0.5 CM' /: BOX XPOS 1 CM YPOS 1 CM WIDTH 18 CM HEIGHT 1 CM FRAME 10 TW INTENSITY 10 / / / P2 ,,<B>TEST PURCHASE ORDER</> / / MAIN Element MAIN P1 <B>Customer/Supplier:</>,,&KNA1-NAME1& / P1 <B>PO No:</>,,&EKPO-EBELN& / P1 <B>Part No:</>,,&MAKT-MATNR& / P1 <B>Description:</>,,&MAKT-MAKTX& / P1 <B>Quantity:,,</>&EKPO-MENGE& / P1 <B>Sign:</>&uline(81)& / P1 <B>Date:</>&EKKO-AEDAT& FOOTER Element FOOTER /: POSITION XORIGIN 2 CM YORIGIN '-0.5 CM' /: BOX XPOS 1 CM YPOS 1 CM WIDTH 18 CM HEIGHT 1 CM FRAME 10 TW INTENSITY 10 / / / P2 ,,<B>PLEASE SIGN THE PO BEFORE DISPATCH</> / /
REPORT ZPSAPSCRIPT.
TABLES : EKKO,
EKPO,
KNA1,
USR01,
MARA,
MAKT.
DATA : BEGIN OF ZOPTION.
INCLUDE STRUCTURE ITCPO.
DATA : END OF ZOPTION.
PARAMETERS: P_EBELN LIKE EKKO-EBELN,
P_EBELP LIKE EKPO-EBELP.
CLEAR EKPO.
SELECT SINGLE * FROM EKPO
WHERE EBELN = P_EBELN AND
EBELP = P_EBELP.
CLEAR KNA1.
SELECT SINGLE NAME1 FROM KNA1
INTO KNA1-NAME1
WHERE KUNNR = EKPO-KUNNR.
CLEAR MAKT.
SELECT SINGLE MAKTX FROM MAKT
INTO MAKT-MAKTX
WHERE MATNR = EKPO-MATNR AND
SPRAS = SY-LANGU.
CLEAR USR01.
SELECT SINGLE * FROM USR01 WHERE BNAME = SY-UNAME.
ZOPTION-TDDEST = USR01-SPLD. "Output device (printer)
ZOPTION-TDIMMED = 'X'. "Print immediately
ZOPTION-TDDELETE = 'X'. "Delete after printing
ZOPTION-TDPROGRAM = 'ZPQRPRNT'. "Program Name
CALL FUNCTION 'OPEN_FORM'
EXPORTING
APPLICATION = 'TX'
* ARCHIVE_INDEX = ' '
* ARCHIVE_PARAMS = ' '
DEVICE = 'PRINTER'
DIALOG = ' '
FORM = 'Z_TESTSCRIPT'
LANGUAGE = SY-LANGU
OPTIONS = ZOPTION
IMPORTING
LANGUAGE = SY-LANGU
EXCEPTIONS
OTHERS = 1.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT = 'HEADER'
* FUNCTION = 'SET'
* TYPE = 'BODY'
WINDOW = 'HEADER'
EXCEPTIONS
ELEMENT = 1.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT = 'MAIN'
* FUNCTION = 'SET'
* TYPE = 'BODY'
WINDOW = 'MAIN'
EXCEPTIONS
ELEMENT = 1.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT = 'FOOTER'
* FUNCTION = 'SET'
* TYPE = 'BODY'
WINDOW = 'FOOTER'
EXCEPTIONS
ELEMENT = 1.
CALL FUNCTION 'CLOSE_FORM'
EXCEPTIONS
UNOPENED = 1
OTHERS = 2.
No comments:
Post a Comment