abap report templates

18

Click here to load reader

Upload: aniruddha-jha

Post on 05-Nov-2015

11 views

Category:

Documents


3 download

DESCRIPTION

ABAP Report Templates

TRANSCRIPT

  • 12

    How to build an interactive report using the report template

    Useful tips and tricks on ABAP report development

    How to build a traditional report using the report template

    The difference between traditional and interactive reports

    The basic structure of an ABAP report

    In this chapter you will learn:

    Chapter 12: ABAP Report Templates

    Contents

    First Things First ..................................................................................................122

    ABAP Reporting Basics.......................................................................................123

    Template Approach to Report Development .....................................................127

    Working With Report Templates .........................................................................128

    Getting the Most from ABAP Report Development: Tips & Tricks................1217

    Where to Learn More..........................................................................................1218

    Report Development Tools 121

  • Chapter 12: ABAP Report Templates First Things First

    First Things First

    In the preceding chapters you learned about the different report development tools available in the R/3 environment. This chapter introduces the basics of SAPs programming language, Advanced Business Application Program (ABAP), which can be used to build custom reports. This chapter is structured differently than the others. It does not present all the features of ABAPwe leave that to the online documentation. Instead, we focus on helping you build an ABAP report using templates.

    Before You Consider ABAP The decision to use ABAP to create custom reports requires careful consideration. Writing reports in ABAP can be costly, time-consuming, and in many cases unnecessary. While ABAP provides numerous features to create excellent programs, it is not geared solely toward report creation, as are the reporting tools outlined in the previous chapters. Thus, the robust functionality of ABAP (combined with the programming styles of many programmers) may make it cumbersome. The tactical approach to reporting (see chapter 2 in book 1, Fundamentals of Reporting of this guidebook series) recommends that you use ABAP only after you have explored all other options.

    Ideally, you should consider ABAP development only after you can answer yes to all of the following questions: < Did you do a thorough search of the standard reports to find the report you need? < Did you survey available standard report development tools to determine if a certain

    tool fits your report needs? < Did you check other report resources (such as user groups and/or OSSSAPs Online

    Support Service)?

    Fundamentals of Reporting, the first book in the Reporting Made Easy series, outlines how to approach the questions listed above. However, if you still do not have a solution for your reporting requirement, it may be time to consider ABAP for custom development.

    Before You Start If you are an ABAP programmer, you should be aware of the following prerequisites and assumptions: < Your user account is registered as a developer in OSS. If your account is not classified as

    a developer, then contact your system administrator to modify your account classification.

    < You need to be authorized to develop programs. Contact your system or security administrator for the required authorization.

    < You should have a basic understanding of ABAP. If you have prior programming experience, you should be able to learn reporting-related ABAP commands.

    Reporting Made Easy 122

  • Chapter 12: ABAP Report Templates ABAP Reporting Basics

    < You should have a basic knowledge of Structured Query Language (SQL). ABAP uses its

    own set of SQL statements called Open SQL which are simplified but similar versions of SQL.

    < You should be familiar with ABAP event-triggering. Understanding which event statement is relevant to which building block of a report helps speed up report development.

    < You should know how to create function modules in ABAP. < ABAP report development must always be done in the development system . Do not use

    the production (or any other) system to write ABAP reports.

    ABAP Reporting Basics

    Writing reports in ABAP is a matter of understanding the various commands relevant to each basic block, and using them appropriately in the program to make the report produce the desired results in an output list.

    Basic Structure An ABAP report consists of the following basic blocks (or sections):

    1. Get the required data from the database.

    2. Process the read-data as required.

    3. Output the processed data as a formatted list on the screen or the printer.

    ABAP code is written to perform certain functions that typically fall under one of the three blocks listed above.

    As shown in the graphic on the following page, these functions are performed in a linear sequence and are dependent on each other. Think of these functions as the basic building blocks of any report. Each block contains the necessary ABAP code to do its task. The ABAP code within each block can be further modularized to perform the steps required for a given block to function.

    Report Development Tools 123

  • Chapter 12: ABAP Report Templates ABAP Reporting Basics

    Get required data

    Process theread data

    Output processeddata as a list

    Define data containers to store and output data

    Define selection parameters as a basis for data retrieval

    Read relevant data into selection parameters

    Refine retrieved data (sorting, grouping, etc.)

    Refine authorization filters

    Perform desired calculations against the data

    Prepare a list page layout (header, footer, comments, etc.)

    Write and format the fields data (header, size, icon, color, indentation, etc.)

    Basic Block TasksBasic Report Blocks

    Types of ABAP Reports As shown in the graphic below, there are two types of ABAP reports:

    TraditionalReport

    TraditionalReport

    Interactive Report

    < Traditional reports < Interactive reports Both report types share the same basic structure and functionality. An interactive report is an extension of a traditional report.

    With a traditional report, the execution of the report is finished as soon as the output list is displayed. An interactive report allows the user to interact with the report list.

    Traditional Reports

    A traditional report, also called a classic report, allows the user to enter selection parameters as key input for retrieving the data from the database. Then, the report processes the read-data, and displays a list for output. Once the report list is displayed on the screen or sent to a print spool, the report program execution concludes and no further interaction or user input is possible. If the output is sent to the screen, a traditional report sends all output data to a single list called a basic list.

    Reporting Made Easy 124

  • Chapter 12: ABAP Report Templates ABAP Reporting Basics

    Basic report list is generatedBasic report list is generated

    Read data is processedRead data is processed

    User enters selection parametersUser enters selection parameters

    Displayon screen

    Traditional Report

    OR Send toprint spool

    Basic report list is generatedBasic report list is generated

    Read data is processedRead data is processed

    User enters selection parametersUser enters selection parameters

    Displayon screen

    Interactive Report

    OR Send toprint spool

    Download to desktop applications Control number of fields displayed Call up another report Jump to a system transaction Display summarized results or

    totals in a new window Print selected fields Interactive sorting of fields

    Plus

    Seco

    ndar

    y lis

    t

    TraditionalReport

    TraditionalReport

    Interactive Report

    Interactive Reports

    Interactive reporting builds on the standard functionality of a traditional report. An interactive report performs all the functions of a traditional report and provides the user with the means to interact with the report even after the list is displayed on the screen.

    As shown in the graphic above, this expanded functionality is particularly useful for reports that require: < Controlling the number of displayed fields on the screen < Interactively sorting in any order of any field on the screen < Calling up another report, or jumping to system transaction < Displaying summarized results or totals in a new window < Downloading to desktop applications < Printing of selected fields on the displayed list The first time an interactive report issues output, it sends data to the basic list just like a traditional report. Any additional information is presented as a secondary list, which may either completely replace the previous basic or secondary list, or appear in a secondary window on the same screen.

    To program the output list, a set of available ABAP commands is used. Typically, an interactive report is written so that for every user input, an event is triggered, some source code is executed, and the report responds back with either a new secondary list, or jumps to a new screen.

    Report Development Tools 125

  • Chapter 12: ABAP Report Templates ABAP Reporting Basics

    In Release 4.0 you can use a new tool called the ABAP List Viewer (ALV) and a set of function modules to build interactive reporting functionality without having to program. The ALV can help save time on display formatting. It also handles many basic interactive features such as sorting, detailed line information, and total calculation. For more information on ALV, refer to appendix A.

    Traditional Versus Interactive Reports We suggest using the following guidelines to decide whether to develop a traditional report (basic list display) or an interactive report (interactive data retrieval).

    Criteria Recommended Report Type

    Frequency of report use

    If the report is run quarterly or annually, then a traditional report is recommended. Even if the report is complex in nature, or requires a multilayered output list, writing an interactive report is probably not worth the development effort. If the report is to be run more frequently, an interactive report (which allows further analysis) is probably preferable.

    Background processing only

    A traditional report is recommended since user interaction is irrelevant in this case.

    Ease of programming Traditional reports are typically easier to program, and faster to develop and maintain. If needed, a traditional report can always be enhanced to become an interactive report without significant source code changes.

    User interaction If the specifications require some form of user interaction, then choose interactive reporting style.

    Width of data fields If the report requires the simultaneous display of many large data fields, an interactive report is useful. You can enhance the displayed list visually by suppressing the output of lengthy fields, and provide a menu button to view detailed line item information as a secondary list in a new window.

    Number of calculations

    If the report uses numerous mathematical calculations and displays multitotaled field results, consider an interactive report.

    Number of users Choose the interactive reporting style for any report that is used by many users and is normally executed online for tracking purposes on a daily, weekly, or monthly basis.

    Presentation If the report is used for frequent presentation purposes, or for an online demonstration of a successful project (such as employee achievements), an interactive report carries a stronger impact.

    Reporting Made Easy 126

  • Chapter 12: ABAP Report Templates Template Approach to Report Development

    Template Approach to Report Development

    A report template is a generic program that contains all the necessary report elements common to any report. It includes the ABAP statements and events, as they would typically be placed in a report. The programmer then completes the detail.

    Because each report has its own requirements, a template is not specific to any report. It only serves as a roadmap for starting a report development project. It consists of many empty placeholders for which custom source code is programmed.

    The template itself cannot be generated. Consequently you cannot execute a template. You must have basic ABAP knowledge to convert the template to executable code.

    Why Use a Report Template? Report templates offer the following advantages: < Modular structure: Reports in general are modular, which allows a template to be well

    structured and highly customizable. A template can be easily expanded to include new subroutines and new program code relevant to the report requirements.

    < Eliminates cumbersome copying: For instance, templates eliminate the process of copying an existing report, deleting many lines of source code, or modifying source code that is relevant but uses different field names. These processes are awkward, and may end up taking more time than starting a report from scratch.

    < Saves time: A report template is a good way to jumpstart the development effort and save time. Once the programmer identifies the database tables to work with, the selection criteria, and the report functionality, the template can be instantly used to insert the necessary source code in the various program sections.

    < Consistency: Using templates ensures consistency of source code and structural uniformity across many reports. This is especially helpful when other programmers have to maintain the report in the future. (However, to help future programmers understand report code, few things take the place of well-integrated comments.)

    < Syntax: Even experienced programmers sometimes forget the exact syntax of a command and have to look it up. Templates include frequently used program statements in their correct syntax form. Any statement can have its parameter names changed while still keeping it syntactically correct.

    Note: A template approach to report development is a convenient and effective way to start writing reports. We recommend that customers adopt a template approach for all of their custom report development. If your company does not use templates, we suggest designing a company standard report template for use by all programmers who write reports. If needed, you can create your templates by refining the ones supplied with this guidebook.

    Report Development Tools 127

  • Chapter 12: ABAP Report Templates Working With Report Templates

    Working With Report Templates

    In this section you learn to work with the following types of report templates when writing a report: < Traditional report template < Interactive report template To work with a template, follow the steps and hints shown, and try to apply them according to your report needs. Sections that are common to both templates have been described only once in the traditional report template.

    In addition, parameters for the ABAP statements included in this template are shown in italics. To illustrate in where particular report section parameters would be found, the descriptive names of the parameters have also been included. Change the words in italics and insert new ABAP commands similar in functionality under those sections.

    Note: A ready-to-use template containing the necessary source code for an interactive and traditional report is included in the CD supplied with this guidebook.

    You can also download the templates from our website at: http://www.saplabs.com/rme.

    Report Specification Form and Report Templates

    A report specification form serves as the starting point for ABAP report development. It provides the developer with vital information about the reporting project. A detailed and complete specification is important for efficient report development.

    To help customers and consultants streamline the process of developing reports, a sample report specification form is shown in book 1, Fundamentals of Reporting, of this guidebook series. You can use the report specification form as is, or modify it to suit your requirements.

    Additionally, an electronic version (Microsoft Word document) of the specification form is included on the companion CD supplied with this guidebook series. You can also download the specification form from www.saplabs.com/rme.

    We suggest making use of the report specification form to supply the information for some of the blocks (for example, report name, database tables, etc.) in the report template. As shown in the table on the next page, a developer can fill many of the placeholders in the report template simply by pulling related information blocks from the specification form.

    Reporting Made Easy 128

  • Chapter 12: ABAP Report Templates Working With Report Templates

    Information a Developer Needs for the ABAP Report Blocks

    Where Found on the Report Specification Form (Filled out by the person requesting the report)

    Title Item 1: What is the suggested name of the desired report (Page 2)?

    Documentation Item 2: Give a short description of the desired report (Page 2).

    Attributes or Application Item 4: Name the application(s) or data area(s) for the report (Page 2).

    Data declarations (Tables statement)

    Item 5: Please indicate any known tables or fields desired in the report (Page 2).

    Traditional Report Template

    To work with this template, enter the relevant information in each section as described here. This template uses a prefix convention for each program object. You could use subroutine names that are different from the ones shown in italics. Also, modularize the source code using several subroutines if necessary.

    Guided Tour

    1. From the SAP main menu, choose Tools ABAP Workbench, then Development ABAP editor.

    2. In the Program field, enter a name for your report.

    3. Choose Create.

    If your user account does not have developer status, the system will not let you create an ABAP report. Contact your system administrator for more information.

    Note: Although you will enter the source code in the ABAP Editor, the actual screens are not included here. Instead, only the source code you would enter in ABAP Editor is shown.

    32

    Report Development Tools 129

  • Chapter 12: ABAP Report Templates Working With Report Templates

    Enter: < Report name and

    width of the list. < Report attributes

    such as program name and title when the report is first saved.

    < Change history including date, name of person changing the report, and the change description.

    REPORT REPORTNAME. LINE-SIZE XX LINE-COUNT YY *************************************************************** * Program Info: (information IN ADDITION to what is already * captured in program ATTRIBUTES and DOCUMENTATION) * ************************************************************** * * Change History: (in addition to what is found in Version * Management) * * Date/Author: * Reason/Description of Change: * * Date/Author: * Reason/Description of Change: * **************************************************************

    < Enter all include program names used by the report (for example, system icons, symbols, or the names of include programs that contain source code the report uses)

    ************************************************************** * DATA DECLARATIONS - BEGIN ************************************************************** ************************************************************** * INCLUDES ************************************************************** Include . Include . Include . Include ProgramName.

    < Define report tables, views, or structures in this section, and include the text description of each object. Object names are not always descriptive.

    ************************************************************** * PROGRAM TABLES / STRUCTURES / VIEWS ************************************************************** TABLES: DDIC_tab1, Table description DDIC_tab2. Table description DDIC_View1. Table view description

    DDIC_Structure1. Structure description

    < Define all the necessary internal tables where the program needs to store the data.

    ************************************************************** * DATA - INTERNAL TABLES (ITAB_tablename) ************************************************************** DATA: BEGIN OF ITAB_tab1 OCCURS n, Field1 LIKE table-field1, Field2 LIKE table-field2, END OF ITAB_tab1.

    Reporting Made Easy 1210

  • Chapter 12: ABAP Report Templates Working With Report Templates

    < Define the internal structures or work areas the program uses to store and work with temporary header data.

    ************************************************************** * DATA - STRUCTURES (WA_structurename) ************************************************************** DATA: BEGIN OF WA_structure1. INCLUDE STRUCTURE DDIC_tab2. D ATA: END OF WA_structure1.

    < Global data fields are declared in this section with a G_ prefix for ease of recognition in the program code.

    ************************************************************** * DATA Global Work Fields (G_fieldname) ************************************************************** DATA: G_field3 TYPE C value is initial, G_field4 like DDIC_tab1-field1 value value, G_header1 TYPE C value is initial, G_header2 TYPE C value is initial. ************************************************************** * DATA DECLARATIONS - END **************************************************************

    < In this section you define the selection criteria of the report. You use the parameters or the select-options statement with various options to draw the selection screen interface.

    ************************************************************** * SELECTION-SCREEN / PARAMETERS (P_parametername, * SEL_fieldname) ************************************************************** SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE T1. PARAMETERS: P_RB000 RADIOBUTTON GROUP G1 DEFAULT 'X', P_RB001 RADIOBUTTON GROUP G1. SELECT-OPTIONS: SEL_field1 FOR DDIC_tab1-field1 [options]. SELECT-OPTIONS: SEL_field2 FOR DDIC_tab2-field1 [options]. SELECTION-SCREEN END OF BLOCK B1.

    < This event is used to control the display of the selection screen interface.

    ************************************************************** * AT SELECTION SCREEN OUTPUT (ATSelOutxxx Events) ************************************************************** AT SELECTION-SCREEN OUTPUT. PERFORM ATSelOut100_MODIFY_SCREEN

    < All initialization occurs once at the beginning of the report. You usually initialize any data fields or structures before working with them.

    ************************************************************** * INITIALIZATION (INITxxx Events) ************************************************************** INITIALIZATION. PERFORM INIT100_Program_Variables.

    Report Development Tools 1211

  • Chapter 12: ABAP Report Templates Working With Report Templates

    < At this point, the report starts reading data from the database based on the selection criteria entered. All data selection and processing source code is programmed under this event, and preferably placed in one subroutine

    < Depending on your authorization requirements, insert appropriate authorization checks

    ************************************************************** * START-OF-SELECTION (StartSelxxx Events) ************************************************************** START-OF-SELECTION. CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR' EXPORTING TEXT = T2 EXCEPTIONS OTHERS = 1. PERFORM StartSe100_Main_Processing.

    < This section is used to output the data as a list. You program the display of the data fields under this event. The WRITE statement is used with various options to format the list output.

    ************************************************************** * END-OF-SELECTION (EndSelxxx Events) ************************************************************** END-OF-SELECTION. PERFORM EndSel100_Output_Processing.

    < Each output list has a top-of-page. You program the page headers, information lines, and text headers for data fields in this section.

    ************************************************************** * TOP-OF-PAGE (TopPagexxx Events) ************************************************************** TOP-OF-PAGE. PERFORM TopPage100_Print_Report_Headers.

    < Each output list also has an end-of-page. Page footers are programmed in this section.

    ************************************************************** * END-OF-PAGE (EndPagexxx Events) ************************************************************** END-OF-PAGE. PERFORM EndPage100_Print_Report_Footers.

    Reporting Made Easy 1212

  • Chapter 12: ABAP Report Templates Working With Report Templates

    < This section contains the source code of the subroutines used.

    < This subroutine is used to initialize the data structures of the report. It could also be used to fill internal tables with data that is not part of the report data processing.

    < Data selection occurs in this form. SQL statements are programmed to retrieve data from the database according to the entered selection criteria, and store them in the internal tables.

    < Remember: The source code found here and elsewhere is only to illustrate the logic. The actual source code of your report is likely to vary.

    ************************************************************** * FORMS / (SUBROUTINES) ************************************************************** FORM Init100_program_variables REFRESH: ITAB_tab1, ITAB_tab2. CLEAR: G_field3, G_field4, WA_Structure1. T1 = TEXT-100. text element T2 = TEXT-200. text element T3 = TEXT-300. text element G_header1 = Text-400. G_header2 = Text-500. ENDFORM. INIT100_PROGRAM_VARIABLES ************************************************************** FORM StartSel100_Main_Processing. DATA: L_field1 TYPE I VALUE is INITIAL. SELECT field3 field4 field5 FROM DDIC_tab1 WHERE Key_field1 IN SEL_field1 AND Key_field2 = P_field2. ITAB_tab1-field1 = DDIC_tab1-field3 + L_field1. ITAB_tab1-field2 = DDIC_tab1-field4. ITAB_tab1-field3 = DDIC_tab1-field5. APPEND ITAB_tab1. L_field1 = L_field1 + SY-TABIX. ENDSELECT. ENDFORM.

    < List display is programmed at this point. Each output data field is sent to the screen with the WRITE statement along with the formatting options.

    ************************************************************** FORM EndSel100_Output_Processing. FORMAT INTENSIFIED OFF COLOR COL_KEY. LOOP at ITAB_tab1. WRITE:/ SY-VLINE NO-GAP. WRITE:(5) ITAB_tab1-field1 NO-GAP CENTERED, SY-VLINE NO-GAP. WRITE:(6) ITAB_tab1-field2 NO-GAP, SY-VLINE NO-GAP. WRITE:(7) ITAB_tab1-field3 NO-GAP CENTERED, SY-VLINE NO-GAP. ENDLOOP. ENDFORM.

    Report Development Tools 1213

  • Chapter 12: ABAP Report Templates Working With Report Templates

    < A list can have several pages. At the top of each page, a report header and text description of data fields are displayed. We recommend you use a company standard header, with a subroutine to handle the centering of the text.

    < At the bottom of each page, the report footer information is displayed. Use this form to program any footer information the report uses.

    < This helper subroutine centers any text string according to the width-size of the list.

    ************************************************************** FORM TopPage100_Print_Report_Headers. CALL FUNCTION 'Z_COMPANY_REPORT_HEADER' EXCEPTIONS OTHERS = 1. PERFORM TopPage200_print_centered using T3. WRITE: /000 G_header1, 020 G_header2. ULINE. ENDFORM. ************************************************************** FORM EndPage100_Print_Report_Footers. CALL FUNCTION 'Z_COMPANY_REPORT_FOOTER' EXCEPTIONS OTHERS = 1. ENDFORM. ************************************************************** FORM TopPage200_print_centered using p_string type c. DATA: L_LENGTH TYPE I, L_STARTPOS TYPE I. L_LENGTH = STRLEN( P_STRING ). L_STARTPOS = CEIL( ( SY-LINSZ - L_LENGTH ) / 2 ). WRITE: /L_STARTPOS P_STRING, AT SY-LINSZ SPACE. ENDFORM. **************************************************************

    Reporting Made Easy 1214

  • Chapter 12: ABAP Report Templates Working With Report Templates

    Interactive Report Template

    To work with the interactive template:

    1. Start with the traditional template illustrated in the previous section.

    2. Append the sections described below to the traditional template.

    3. Modify the existing source code.

    Guided Tour

    < This event is

    triggered when the user pushes a button on the screen. Each button will have a function code Fcode to execute the necessary steps.

    **************************************************************** * AT USER-COMMAND (AtUsrCmdxxx Events) **************************************************************** AT USER-COMMAND. PERFORM AtUsrCmd100_USER_COMMAND.

    < This event is used to control screen list events that occur when the user selects or double-clicks on a list line.

    **************************************************************** * AT LINE-SELECTION (AtLineSelxxx Events) **************************************************************** AT LINE-SELECTION. PERFORM AtLineSel100_LINE_SELECTION.

    < Interactive reporting uses a secondary list that in turn uses pages for output. This event is used to reexecute the top-of-page code.

    **************************************************************** * TOP-OF-PAGE DURING LINE-SELECTION ( TopLinSelxxx Events) **************************************************************** TOP-OF-PAGE DURING LINE-SELECTION. PERFORM TopPage100_Print_Report_Headers.

    Report Development Tools 1215

  • Chapter 12: ABAP Report Templates Working With Report Templates

    < User input from the menu or pushbuttons is usually handled in a subroutine using a case statement for each possible function code, which ends up executing some steps, and regenerating the list display.

    GET recognizes global fields only. < User line input on a

    particular line of the displayed list is handled in a similar way as user commands. This event is triggered when the user double-clicks on a line, or selects a hotspot area. The line contents are usually used to execute further program steps.

    < This subroutine is used to demonstrate the sorting of the list when the user pushes a sort button on the menu.

    **************************************************************** * FORMS / (SUBROUTINES) **************************************************************** FORM AtUsrCmd100_USER_COMMAND. DATA: L_LINE1 LIKE SY-LILLI, L_FIELD1(40) TYPE C, L_VALUE1 LIKE SY-LISEL. GET CURSOR FIELD L_FIELD1 VALUE L_VALUE1 LINE L_LINE1. CASE SY-UCOMM. WHEN 'Fcode1'. MODIFY CURRENT LINE L_LINE1 FORMAT INTENSIFIED ON. WHEN 'Fcode2'. PERFORM AtUsrCmd200_Sort_List. ENDCASE. ENDFORM. **************************************************************** FORM AtLineSel100_LINE_SELECTION. DATA: L_FIELD1(40) TYPE C, L_VALUE1(44) TYPE C. GET CURSOR FIELD L_FIELD1 VALUE L_VALUE1. CASE L_FIELD1. WHEN 'ITAB_tab1-field1'. Call transaction TRAN and skip first screen. WHEN 'G_header1'. Submit report ReportName and return. ENDCASE. SUBTRACT 1 FROM SY-LSIND. PERFORM EndSel100_Output_Processing. ENDFORM. **************************************************************** FORM AtUsrCmd200_Sort_List. SORT ITAB_tab1 ascending by field1 ENDFORM.

    Reporting Made Easy 1216

  • Chapter 12: ABAP Report Templates Getting the Most from ABAP Report Development: Tips & Tricks

    Getting the Most from ABAP Report Development: Tips & Tricks

    < Assess the complexity and size of your report based on: Report specifications SAP application areas involved Number of database tables the report uses Complexity of data selection and processing Various display formats or so-called report flavors requested for output

    < Start building your report from an empty template. Some reports can be created with reference to other reports, but programmers should be very careful, and aware of the functions of the original report.

    < Use descriptive colors for field display, for example, red for negative quantities, or yellow for totals. In addition, you can use color stripes, or alternate line color to make the list easier to read.

    < Icons and symbols in lists enhance the visual appeal of a list. Include icons where they help a user better understand the meaning of the data. For example, a green traffic light usually means that the data is valid or has been updated.

    < When creating interactive reports, provide helpful line functions such as multiple row and column highlighting, sort sequencing, and detailed field information.

    < Use a standard report header and footer for all custom reports. Use existing function modules, or create new ones for use.

    < If many output fields need to be displayed, use dynamic field offset and size for the output of data fields. Just like text elements, use of dynamic field offset and size for the output of data fields helps when programming interactive scrolling or hiding fields from the display.

    < Use OLE (Object Linking and Embedding) to enable reports to be downloaded into desktop applications such as Microsoft Excel or Word. OLE allows automatic transfer of list data to an Excel spreadsheet without having to format the data as a delimiter file. Note: If the primary objective is to download data to another application, it is important to note that the use of OLE increases the processing time.

    < Modularize data selection and processing. Use the include programs and function modules if the program is too large, or to group common source code together. Report specifications and requirements will often change throughout the project and before the report is complete.

    < Researching and finding the report specifications along the way does not fall under report writing. Rather, report writing should include researching tables, key fields involved in data selection, processing, and display. It is important to discover omitted data fields to include in the program for instance, or as part of the selection screen interface. However, the focus should be on developing the report and not on setting specifications.

    Report Development Tools 1217

  • Chapter 12: ABAP Report Templates Where to Learn More

    < A good approach for testing reports is to use dummy data to test the logic and the report display. Often, the data in the development system is unavailable, is incorrect, or changes frequently, and the report does not run as expected. Check the data in the system before modifying the report source code.

    < Use the debugger and set break points when testing the report. This is a standard procedure to fix or change the logic or the list format.

    General Programming Hints < Use text elements instead of typed text in the program. Remember that text elements can

    be changed without having to change the source code. < Future maintenance of any program is essential during the life of the report. Think of

    ways you can make your report easily modifiable. < Use a consistent naming convention for all program objects. < Attach comments to your source code as much as possible. Do not mix comments and

    source code on the same line unless necessary. < Always document changes at the top of the report.

    Where to Learn More

    < R/3 Library (Online help): In Release 4.0B, you will find more information on ABAP. Go to R/3 Library BC Basis Components ABAP Workbench.

    < ABAP/4 Development Workbench, a comprehensive documentation set published by SAP AG. To order printed copies use product number 50014371. You can also purchase this book from www.computerliteracy.com

    < BC405: ABAP/4 Development WorkbenchReporting, a five-day training course offered by SAP Education and Training.

    Reporting Made Easy 1218

    ABAP Report Templates First Things First Before You Consider ABAP Before You Start ABAP Reporting Basics Basic Structure Types of ABAP Reports Traditional Reports Interactive Reports

    Traditional Versus Interactive Reports

    Template Approach to Report Development Why Use a Report Template?

    Working With Report Templates Report Specification Form and Report Templates Traditional Report Template Interactive Report Template

    Getting the Most from ABAP Report Development: Tips & Tricks General Programming Hints

    Where to Learn More