Anda di halaman 1dari 6

REPORTS

About reports
Reports, in the R/3 system are online programs whose function is to retrieve data from database and display it or print it for the user. An end user often needs some information to look up, depending upon which various management decisions are taken, or to just see business results or simply to continue work. As R/3 is collection of all business applications, it has provided a very powerful feature to satisfy this crucial business need i.e., reports are involved at each and every step of business. This type of extracting, collecting and formatting data that is stored in database is done by REPORT program. The program that is written to retrieve and display data is REPORT program and the data that is displayed on the screen when you execute the program is called as LIST (output of the report). When you display data, you need to display the data, user needs. For example, user wants to see the all the employee, who has joined after 12th December 1997. In this case user has to pass this information, to the system, that he needs only those employee records where joining data is greater than 12th December 1997. For user, it is passing information to the system but for the system it is input from the user. System takes input from the user before it retrieves the data from the database. This is very common requirement of any report as the need of any business is to display data, which is required by user. Reports are ABAP/4 programs. You use reports to evaluation data from database tables. The results of such an evaluation can be displayed on the screen or printed form. Reports are stand-alone programs. The user can execute reports directly via the program name, for example, by choosing System Utilities Reporting. A report program contains a collection of processing blocks for different events that are always triggered externally. In a report, you can react on events by programming the corresponding processing blocks or ignore the events by not writing the corresponding processing blocks. A report itself never creates events. Reports can use logical databases or select statements defined by developer. For each application, SAP supplies logical databases. Or you can easily create logical database yourself. Event control of a report corresponds to a certain scheme: When a report is executed, the ABAP/4 processor creates together with the logical database used (if any) a sequence of certain events for which you can program processing blocks. The chronology of the events is (more or less)

Steps involved in creating a Report: 1. Processing the selection screen After starting a report, the selection screen allows the user to enter limits or control values for further report processing. The report can contain several processing blocks for events during selection screen processing, for example, for checking the input values. 2. Reading the database After selection screen processing come the events for reading the database. Either the report reads data from relational databases it using the corresponding ABAP/4 statements (open SQL) or leaves this task to a logical database. In the latter case, the logical database creates a sequence of events to allow the report to copy the data. 3. Evaluating data and creating lists During or after reading the database the report creates the output list. During list creation, several events allow you to layout the output list (for example, layout the page header). 4. Outputting a list The last part of the processing sequence controlled by the ABAP/4 processor is the list output on the screen or printer. When displaying the list on the screen, user can trigger other reports, that are interactive and are event driven. For example, by clicking the mouse. By programming processing blocks for these events, you change a normal report to a so-called Interactive report. If a report does not contain event keywords, the entire coding of the report belongs to a single processing block, which is called by a standard event. This standard event is triggered directly after processing the selection screen.

Selection criteria System accepts inputs from user through SELECTION CRITERIA. Selection criteria are nothing but input fields which allows the user to restrict information given to program for processing further data. If you dont specify any criteria for selection, your report program produces a long list of data, which might not be needed by the user. Basically, selection criteria are the fields where user enters some value for which he needs information. Through

selection criteria user can enter discrete value or ranges. For example, user wants to see all the records of the employees, who have joined between 12th December 1997 and 12th May 1998. This range can be entered in selection criteria. As the user becomes more specific for mentioning the criteria, the list will be smaller and more specific. Syntax:

SELECT-OPTIONS <field> for <table field>.


Field is the variable, which you declare for accepting input from the user. Table field is reference field. SELECT-OPTIONS: fld1 for sflight-fldate, carrid1 for sflight-carrid. Maximum length of the name Select-Options variable is 8. When system executes this statement, the selection screen is displayed and is like this.

When you enter the desired information and click on execute button, rest of the program is executed, that is retrieval of data from database, which matches this information and the list is displayed. Behavior of SELECT-OPTIONS When the Select-Options statement is executed the system creates the internal table with the same variable name (in this case it will be carrid1). This table is also called as selection table.

The main purpose of selection table is to store selection criteria. The table has four standard fields, which are as follows: SIGN is a variable, which denotes the system whether the result should be included with those particular criteria. It can contain either I or E. I denotes Inclusion. The criteria are included. E denotes Exclusion. The criteria are excluded from the result. LOW the data type of LOW is the same as the field type of the database table, for which you are using selection criteria. This acts as lower limit of the selection. HIGH the data type of HIGH is the same field type of the database table, for which you are using the selection criteria. This acts as higher limit. If you dont enter HIGH value then the LOW value defines a single value selection. OPTION is two-character field, which contains operators like EQ, GT, LT, GE, and LE. When the user enters both the values i.e., high and low then this field acts as BT (between). If you dont enter high value then all other operators can be Applicable. For each Select-Options statement system creates internal table. Default values for select-options If you want to display default values for the selection criteria before your screen is displayed, give default values for the selection table fields i.e., low or high. SELECT-OPTIONS: CARRID1 FOR SFLIGHT-CARRID DEFAULT CARRID1-LOW = LH AND CARRID1-HIGH = SQ. In this case selection screen is displayed with default values LH for lower range and SQ for higher range. User can use same values or overwrite these values with new values, whichever he needs.

Parameters
Parameter statement is used to accept input from user. PARAMETER statement is used when you want user to enter data and depending upon what he enters you need to take action. The parameter statement declares the variable and also allows system to accept data into that variable.

Syntax. Parameters: num type I. Here parameter statement declares the variable and creates the selection screen on which user enters the data i.e., in this case num is declared of type I and user can enter any number. Entered value is stored in the same variable and can be used in program. Data: m type I Parameters: num type I M = num 5 Write: / The number is, m. You can define default values with parameter statement for example Parameter: num type I default 12. In this case when selection screen is displayed the default value is displayed. User can either use same value or overwrite the value. Parameter of type character and length = 1, can be displayed as Checkbox and Radiobutton. Parameter: C1 as Checkbox, C2 as Checkbox. Parameter: R1 Radiobutton group g1, R2 Radiobutton group g1. When parameter is defined as Radiobutton, it needs to be attached to one group. Only one Radiobutton of one group can be clicked. Every parameter can be associated with language dependent text that is displayed on the selection screen. This can be done with the help of text elements.

WRITE Statement The basic APAB/4 statement for outputting data on the screen is WRITE. Syntax: WRITE <field> <option>. This statement outputs the field <f> to the current list in its standard output format. By default, the list is displayed on the screen. The field <field>can be any variable or table field or just literal. PROGRAM ZDEMO WRITE: /HELLO.

When you start this program, the system leaves the current screen i.e., your editor screen and branches to the output screen, which is also called as list screen: The list screen has the same name as the title of the program specified in the program attributes. First line on the screen contains the list header. By default, the list header is the same as the title of the program. The current page number (1) appears on the right. The list header is followed by one line and then the output is displayed. Write : HELLO. Write : WORK HARD On the screen, the output is normally left justified. But in above case, because we have used two WRITE statements, the output fields are displayed one after the other, each separated by one column (i.e., one blank). If there is not enough space for an output field on the current line, a new line is started. Almost all system-defined fields are right justified except FLOAT, INTEGER, and PACKED i.e., number field. The numeric data types F, P, and I are right justified and padded with blanks on the left. If there is sufficient space, thousands of separators are also output. If a type P field contains decimal places, the default output length is increased by one. With the data type D, the internal format of a date differs from its output format. When you use the WRITE statement for outputting data, the system automatically outputs dates of type D in the format specified in the users master record (e.g. DD/MM/YYYY or MM/DD/YYYY).

Anda mungkin juga menyukai