Sie sind auf Seite 1von 8

Print Report with Logo (Utility Program to print any report with Logo)

Applies To:
This Utility Program is developed in SAP R/3 Enterprise. Function modules in Function group STXD & SLST are invoked.

Summary
This article provides a solution to print any simple report with a logo. By: Bala JK Company: Yash Technologies, Inc Date: 30 January 2006

Table of Contents
Applies To:........................................................................................................................................1 Summary ..........................................................................................................................................1 Table of Contents .............................................................................................................................1 Utility Program to Print Report with Logo .........................................................................................1 Requirement...........................................................................................................................1 Solution...................................................................................................................................1 Solution Code .........................................................................................................................1 Author Bio.........................................................................................................................................8

Utility Program to Print Report with Logo


Requirement Requirement arises in a financial institution with lots of Reports to be displayed, downloaded and printed. The twist is that the client doesnt want to go for a pre-printed stationary (with Logo) and on the other hand the client wants the report with color-coding. So the doors are closed for Smart forms & SAP Scripts. Solution Create a standard text (SO10) and insert your logo. In the utility program invoke the logo using function module READ_TEXT. Provide the option of entering the Report & Variant in the selection screen of utility program. Submit the Report with addition EXPORTING LIST TO MEMORY. Get the list from memory using function module LIST_FROM_MEMORY and convert to ASCI format using function module LIST_TO_ASCI. Combine the Output of LIST_TO_ASCI with the standard text returned by READ_TEXT. Populate the combined internal table to function module PRINT_TEXT to print your report with logo.

2006 SAP AG

The SAP Developer Network: http://sdn.sap.com 1

Print Report with Logo (Utility Program to print any report with Logo)
Solution Code Below is the source code of the utility program to print any simple Report with Logo.

REPORT Z_PRINT_REPORT_WITH_LOGO. *----------------------------------------------------------------------* * PROGRAM * TITLE * AUTHOR Z_PRINT_REPORT_WITH_LOGO Utility program to print any simple Report with Logo Bala * * *

*----------------------------------------------------------------------* * DESCRIPTION: * * * * * * * * * * Step 1: Create a standard text and Insert your Logo Step 2: Get the standard text to Int. table T_LINE Step 3: Submit the report and export the list to memory Step 4: Get the List from memory Step 5: Convert the list to ASCI format Step 6: Format the List and Append to Int. table T_LINE Step 7: Print your List with Logo This Program is used to Print Any Simple Report with Logo. * * * * * * * * * * *

*----------------------------------------------------------------------*

*----------------------------------------------------------------------* * INTERNAL TABLE DECLARATION *----------------------------------------------------------------------* DATA: T_LIST T_SOLI TYPE STANDARD TABLE OF ABAPLIST WITH HEADER LINE, TYPE STANDARD TABLE OF SOLI WITH HEADER LINE,

2006 SAP AG

The SAP Developer Network: http://sdn.sap.com 2

Print Report with Logo (Utility Program to print any report with Logo)
T_LINE T_HEAD TYPE STANDARD TABLE OF TLINE TYPE STANDARD TABLE OF THEAD WITH HEADER LINE, WITH HEADER LINE, WITH HEADER LINE, WITH HEADER LINE.

T_ITCPO TYPE STANDARD TABLE OF ITCPO T_ITCPP TYPE STANDARD TABLE OF ITCPP

*----------------------------------------------------------------------* * SELECTION SCREEN *

*----------------------------------------------------------------------* SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001. PARAMETERS: P_PROG TYPE RS38M-PROGRAMM OBLIGATORY, P_VART TYPE RSVAR-VARIANT. SELECTION-SCREEN END OF BLOCK B1. "Your Report Name

"Your Variant Name

*----------------------------------------------------------------------* * GET YOUR LOGO FROM STANDARD TEXT *

*----------------------------------------------------------------------* * Make sure you have created a standard text in SO10 & Insert your Logo * In this example standard text "ZLOGO" is used. CALL FUNCTION 'READ_TEXT' EXPORTING CLIENT ID LANGUAGE NAME OBJECT IMPORTING = SY-MANDT = 'ST' = SY-LANGU = 'ZLOGO' = 'TEXT' "Your standard Text Name

2006 SAP AG

The SAP Developer Network: http://sdn.sap.com 3

Print Report with Logo (Utility Program to print any report with Logo)
HEADER TABLES LINES EXCEPTIONS ID LANGUAGE NAME NOT_FOUND OBJECT REFERENCE_CHECK = 1 = 2 = 3 = 4 = 5 = 6 = T_LINE = T_HEAD

WRONG_ACCESS_TO_ARCHIVE = 7 OTHERS = 8.

IF SY-SUBRC NE 0. * Pop a Message ENDIF.

*----------------------------------------------------------------------* * SUBMIT THE REPORT & EXPORTING THE LIST TO MEMORY *

*----------------------------------------------------------------------* * Program Name & Variant Name from Selection screen SUBMIT (P_PROG) USING SELECTION-SET P_VART EXPORTING LIST TO MEMORY AND RETURN. WAIT UP TO 1 SECONDS.

2006 SAP AG

The SAP Developer Network: http://sdn.sap.com 4

Print Report with Logo (Utility Program to print any report with Logo)
*----------------------------------------------------------------------* * GET THE LIST FROM MEMORY & CONVERT TO ASCI *

*----------------------------------------------------------------------* * Get the List from Memory CALL FUNCTION 'LIST_FROM_MEMORY' TABLES LISTOBJECT = T_LIST EXCEPTIONS NOT_FOUND OTHERS = 1 = 2.

IF SY-SUBRC NE 0. * Pop a Message ENDIF.

* Get ASCI of List CALL FUNCTION 'LIST_TO_ASCI' TABLES LISTASCI LISTOBJECT EXCEPTIONS EMPTY_LIST = 1 = T_SOLI = T_LIST

LIST_INDEX_INVALID = 2 OTHERS IF SY-SUBRC NE 0. * Pop a Message ENDIF. = 3.

* Clear Int. table

2006 SAP AG

The SAP Developer Network: http://sdn.sap.com 5

Print Report with Logo (Utility Program to print any report with Logo)
CLEAR T_LIST.

REFRESH T_LIST.

*----------------------------------------------------------------------* * FORMAT THE LIST BEFORE PRINTING *

*----------------------------------------------------------------------* * Int. table T_LINE already having the Logo (Standard text) * Set Tag Column to List LOOP AT T_SOLI. MOVE: '/=' TO T_LINE-TDFORMAT,

T_SOLI-LINE TO T_LINE-TDLINE. APPEND T_LINE. CLEAR T_LINE. ENDLOOP.

* Clear Int. table CLEAR T_SOLI.

REFRESH T_SOLI.

*----------------------------------------------------------------------* * PRINT YOUR LIST *

*----------------------------------------------------------------------* * Print Your Report with Logo * Note: Form SYSTEM is defaulted to T_HEAD-TDFORM and its Orientation * * is Portrait Format. If your Report Width is more, make a copy of Form SYSTEM and change the Orientation to Landscape Format

2006 SAP AG

The SAP Developer Network: http://sdn.sap.com 6

Print Report with Logo (Utility Program to print any report with Logo)
CALL FUNCTION 'PRINT_TEXT' EXPORTING DEVICE DIALOG HEADER OPTIONS IMPORTING RESULT TABLES LINES EXCEPTIONS CANCELED DEVICE FORM OPTIONS UNCLOSED UNKNOWN FORMAT TEXTFORMAT COMMUNICATION = 1 = 2 = 3 = 4 = 5 = 6 = 7 = 8 = 9 = T_LINE = T_ITCPP = 'PRINTER' = 'X' = T_HEAD = T_ITCPO

BAD_PAGEFORMAT_FOR_PRINT = 10 OTHERS IF SY-SUBRC NE 0. * Pop a Message ENDIF. * --------------------------- End of Program --------------------------* = 11.

2006 SAP AG

The SAP Developer Network: http://sdn.sap.com 7

Print Report with Logo (Utility Program to print any report with Logo)
Executing the Utility Program: Enter your Report name and Variant Name in the selection screen.

Author Bio

Bala, working as a Technical Consultant for the last 6 years. Designing interfaces between SAP and 3rd party systems is his area of interest. Expertise in Cross-Applications, Web service and Enhancement frame work. Currently working as a technical consultant in an IS-Retail implementation Project.

Disclaimer & Liability Notice


This document may discuss sample coding or other information that does not include SAP official interfaces and therefore is not supported by SAP. Changes made based on this information are not supported and can be overwritten during an upgrade. SAP will not be held liable for any damages caused by using or misusing the information, code or methods suggested in this document, and anyone using these methods does so at his/her own risk. SAP offers no guarantees and assumes no responsibility or liability of any type with respect to the content of this technical article or code sample, including any liability resulting from incompatibility between the content within this document and the materials and services offered by SAP. You agree that you will not hold, or seek to hold, SAP responsible or liable with respect to the content of this document.

2006 SAP AG

The SAP Developer Network: http://sdn.sap.com 8

Das könnte Ihnen auch gefallen