SlideShare a Scribd company logo
1 of 107
Download to read offline
Created by Pavan Page 1 of 107
Mail: Praveen.srrec@gmail.com
Reports:
In ABAP, there are total of 7 types of reports. They are:
• Classical
• Interactive
• Logical Database
• ABAP query
• ALV Reports (ALV stands for ABAP List Viewer)
• Report Writer/Report Painter
• Views (There are different types of views also)
Classical Reports
These are the simplest reports. Programmers learn this one first. It is just an output
of data using the Write statement inside a loop.
• Classical reports are normal reports. These reports are not having any sub
reports. IT IS HAVING ONLY ONE SCREEN/LIST FOR OUTPUT.
Events In Classical Reports.
• INTIALIZATION: This event triggers before selection screen display.
• AT-SELECTION-SCREEN: This event triggers after processing user input
still selection screen is in active mode.
• START OF SELECTION: Start of selection screen triggers after processing
selection screen.
END-OF-SELECTION: It is for Logical Database Reporting.
Event blocks are introduced by an event keyword. They end when the next
processing block begins. The following processing block can either be an event
block or another processing block allowed in this context – for example, a
subroutine or a dialog module. Event keywords have the same name as the events
to which they react.
Created by Pavan Page 2 of 107
Mail: Praveen.srrec@gmail.com
Syntax:
DATA:...
INITIALIZATION.
...
AT SELECTION-SCREEN.
...
START-OF-SELECTION.
...
GET spfli...
..
...
END-OF-SELECTION.
...
FORM...
...
ENDFORM.
The sequence in which the processing blocks occur in the program is irrelevant.
The actual processing sequence is determined by the external events. However, to
make your programs easier to understand, you should include the event blocks in
your program in approximately the same order in which they will be called by the
system. Subroutines should be placed at the end of the program.
With only two exceptions (AT SELECTION-SCREEN and GET), event blocks
have no local data area. All declarative statements in event blocks are handled
with the global data declarations in the program. You should therefore include all
of your declarations at the start of the program.
Statements that are not assigned to a processing block are never executed. In
executable programs, all non-declarative statements between the REPORT or
PROGRAM statement and the first processing block are assigned to the default
event START-OF-SELECTION. if a program does not contain an explicit
Created by Pavan Page 3 of 107
Mail: Praveen.srrec@gmail.com
START-OF-SELECTION event block, these statements form the entire
START-OF-SELECTION block. If a program contains an explicitly defined
START-OF-SELECTION event block, these statements are inserted at the
beginning of this event block. If a program does not contain any explicit event
blocks, all non-declarative statements form the processing block START-OF-
SELECTION.
In ABAP Editor initial
screen give your program
name and then press F5 or
click on Create
Created by Pavan Page 4 of 107
Mail: Praveen.srrec@gmail.com
Fill all the attributes &
then save it
Created by Pavan Page 5 of 107
Mail: Praveen.srrec@gmail.com
Here Goes your coding check for
inconsistencies and then activate it
Created by Pavan Page 6 of 107
Mail: Praveen.srrec@gmail.com
*&---------------------------------------------------------------------*
*& Report ZCLASSICAL *
*& *
*&---------------------------------------------------------------------*
*& *
*& *
*&---------------------------------------------------------------------*
REPORT ZCLASSICAL .
TABLES: vbak,vbap.
DATA: v_flag TYPE i.
******INTERNAL TABLE USED TO HOLD DATA TEMPORARILY
DATA: BEGIN OF it_salesorder OCCURS 0,
kunnr LIKE vbak-kunnr, " Sold To Party.
vbeln LIKE vbak-vbeln, " Sales Document Number.
posnr LIKE vbap-posnr, " Sales Document Item.
matnr LIKE vbap-matnr, " Material Number.
bstnk LIKE vbak-bstnk, " Customer purchase order number.
bstdk LIKE vbak-bstdk, " Customer purchase order date.
kwmeng LIKE vbap-kwmeng, " Cumulative order quantity.
netpr LIKE vbap-netpr, " Net price.
netwr LIKE vbap-netwr, " Net value of the order item.
END OF it_salesorder.
***********INPUT THE DATA USING SELECT OPTIONS
SELECT-OPTIONS: s_kunnr FOR vbak-kunnr, " Sold To Party.
s_vbeln FOR vbak-vbeln. " Sales Document Number.
**********INITIALIZATION
INITIALIZATION.
PERFORM initialization.
*********FETCH THE DATA FROM TABLES AND PLACE THEM IN INTERNAL TABLE
START-OF-SELECTION.
PERFORM fetch_data.
**********DISPLAYING THE DATA FROM INTERNAL TABLE
END-OF-SELECTION.
**********PAGE HEADINGS
PERFORM Page_headings.
PERFORM display_data.
*&---------------------------------------------------------------------*
*& Form initialization
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM initialization .
Created by Pavan Page 7 of 107
Mail: Praveen.srrec@gmail.com
s_kunnr-sign = 'I'.
s_kunnr-option = 'BT'.
s_kunnr-low = '1033'.
s_kunnr-high = '1390'.
APPEND s_kunnr.
s_vbeln-sign = 'I'.
s_vbeln-option = 'BT'.
s_vbeln-low = '4969'.
s_vbeln-high = '5000'.
APPEND s_vbeln.
ENDFORM. " initialization
*&---------------------------------------------------------------------*
*& Form fetch_data
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM fetch_data .
REFRESH it_salesorder.
CLEAR it_salesorder.
SELECT kunnr
vbak~vbeln
posnr
matnr
bstnk
bstdk
kwmeng
netpr
vbap~netwr
FROM vbak
INNER JOIN vbap ON vbak~vbeln = vbap~vbeln
INTO TABLE IT_SALESORDER
WHERE kunnr IN s_kunnr
AND vbak~vbeln IN s_vbeln.
ENDFORM. " fetch_data
*&---------------------------------------------------------------------*
*& Form display_data
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM display_data .
SORT it_salesorder BY kunnr vbeln.
LOOP AT it_salesorder.
AT NEW vbeln.
format color 3 on. " COLOR START
WRITE: / 'CUSTOMER:',it_salesorder-kunnr.
format reset. "COLOR END
ULINE.
format color 4 on inverse on. "COLOR START
Created by Pavan Page 8 of 107
Mail: Praveen.srrec@gmail.com
WRITE:/ 'VBELN', "COLOR END
20 'POSNR',
35 'MATNR',
50 'BSTNK',
70 'BSTDK',
85 'KWMENG',
106 'NETPR',
121 'NETWR'.
format reset.
format color 4 on.
WRITE: / it_salesorder-vbeln.
format reset.
ENDAT.
format color 5 on inverse on.
WRITE: /20 it_salesorder-posnr,
35 it_salesorder-matnr,
50 it_salesorder-bstnk,
70 it_salesorder-bstdk,
85 it_salesorder-kwmeng LEFT-JUSTIFIED,
101 it_salesorder-netpr,
109 it_salesorder-netwr.
format reset.
AT END OF vbeln.
SKIP 2.
ENDAT.
ENDLOOP.
ENDFORM. " display_data
*&---------------------------------------------------------------------*
*& Form page_headings
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM page_headings .
format color 7 on inverse on.
WRITE:/40 'SALES ORDER DOCUMENT FOR A GIVEN CUSTOMER'.
SKIP.
WRITE:/ 'DATE:',sy-datum, 100 'TIME:',sy-uzeit.
format reset.
SKIP 2.
ENDFORM. " page_headings
Created by Pavan Page 9 of 107
Mail: Praveen.srrec@gmail.com
Created by Pavan Page 10 of 107
Mail: Praveen.srrec@gmail.com
Interactive Reports:
In simple Interactive reports are nothing but which were user interface the name
itself signifies that it interacts with the users
A classical non-interactive report consists of one program that creates a single list.
Instead of one extensive and detailed list, with interactive reporting you create
basic list from which the user can call detailed information by positioning the
cursor and entering commands. Interactive reporting thus reduces information
retrieval to the data actually required.
Uses of interactive reporting:
The user can actively control data retrieval and display during the session. Instead
of an extensive and detailed list, you create a basic list with condensed information
from which the user can switch to detailed displays by positioning the cursor and
entering commands. The detailed information appears in secondary lists.
Secondary list:
It allows you to enhance the information presented in the basic list. The user can,
for example, select a line of the basic list for which he wants to see more detailed
information. You display these details on a secondary list. Secondary lists may
either overlay the basic list completely or you can display them in an extra
window on the screen. The secondary lists can themselves be interactive again.
To prevent the user from selecting invalid lines, ABAP/4 offers several
possibilities. At the end of the processing block END-OF-SELECTION, delete the
contents of one or more fields you previously stored for valid lines using the HIDE
statement. At the event AT LINE-SELECTION, check whether the work area is
initial or whether the HIDE statement stored field contents there. After processing
the secondary list, clear the work area again. This prevents the user from trying to
create further secondary lists from the secondary list displayed.
Created by Pavan Page 11 of 107
Mail: Praveen.srrec@gmail.com
System fields for secondary lists:
SY-LSIND Index of the list created during the current event (basic list = 0)
SY-LISTI Index of the list level from which the event was triggered.
SY-LILLI Absolute number of the line from which the event was triggered.
SY-LISEL Contents of the line from which the event was triggered.
SY-CUROW Position of the line in the window from which the event was
triggered (counting starts with 1)
SY-CUCOL Position of the column in the window from which the event was
triggered (counting starts with 2).
SY-CPAGE Page number of the first displayed page of the list from which the
event was triggered.
SY-STARO Number of the first line of the first page displayed of the list from
which the event was triggered (counting starts with 1). Possibly, a page header
occupies this line.
SY-STACO Number of the first column displayed in the list from which the event
was triggered (counting starts with 1).
SY-UCOMM Function code that triggered the event.
SY-PFKEY Status of the displayed list.
Events for Interactive Reporting:
AT LINE-SELECTION Moment at which the user selects a line by double
clicking on it or by positioning the cursor on it and pressing F2.
AT USER-COMMAND Moment at which the user presses a function key.
TOP-OF-PAGE DURING Moment during list processing of a
LINE-SELECTION secondary list at which a new page starts.
Created by Pavan Page 12 of 107
Mail: Praveen.srrec@gmail.com
AT PF-FUNCTION KEY function key from F5 to F12 to perform interactive
action on the list.
Created by Pavan Page 13 of 107
Mail: Praveen.srrec@gmail.com
Created by Pavan Page 14 of 107
Mail: Praveen.srrec@gmail.com
*&---------------------------------------------------------------------*
*& Report ZSIMPLE_INTERACTIVE *
*& *
*&---------------------------------------------------------------------*
*& *
*& *
*&---------------------------------------------------------------------*
REPORT ZSIMPLE_INTERACTIVE .
TABLES: MARA,MARC,MARD.
SELECT-OPTIONS: SMATNR FOR MARA-MATNR.
***********************************************************
* INITIALIZATION.
***********************************************************
INITIALIZATION.
SMATNR-LOW = '1300-1400'.
SMATNR-HIGH = '1300-2000'.
SMATNR-SIGN = 'I'.
SMATNR-OPTION = 'BT'.
APPEND SMATNR.
***********************************************************
* START-OF-SELECTION.
***********************************************************
START-OF-SELECTION.
WRITE:/10 'MATERIAL NO',25 'PLANT LOCATION',45 'STORAGE LOCATION'.
ULINE.
SELECT * FROM MARA WHERE MATNR IN SMATNR.
WRITE:/10 MARA-MATNR,30 MARA-MBRSH,50 MARA-MTART.
HIDE MARA-MBRSH.
ENDSELECT.
***********************************************************
* AT LINE-SELECTION.
***********************************************************
AT LINE-SELECTION.
IF SY-LSIND EQ 1.
SELECT * FROM MARC WHERE MATNR EQ MARA-MATNR.
WRITE:/ MARC-MATNR,MARC-WERKS.
HIDE MARC-MATNR.
ENDSELECT.
ENDIF.
Created by Pavan Page 15 of 107
Mail: Praveen.srrec@gmail.com
IF SY-LSIND EQ 2.
SELECT * FROM MARD WHERE WERKS EQ MARC-WERKS.
WRITE:/10 MARD-MATNR, 25 MARD-WERKS,45 MARD-LGORT.
HIDE MARD-MATNR.
ENDSELECT.
ENDIF.
***********************************************************
* TOP-OF-PAGE DURING LINE-SELECTION.
***********************************************************
TOP-OF-PAGE DURING LINE-SELECTION.
IF SY-LSIND EQ 1.
WRITE:/1 'MATERIAL NO',15 'PLANT LOCATION'.
ULINE.
ENDIF.
TOP-OF-PAGE DURING LINE-SELECTION.
IF SY-LSIND EQ 2.
WRITE:/10 'MATERIAL NO',25 'PLANT LOCATION',45 'STORAGE LOCATION'.
ENDIF.
************************************************************************
Created by Pavan Page 16 of 107
Mail: Praveen.srrec@gmail.com
The AT LINE-SELECTION event is triggered by double-clicking on the output
value to get the drilldown report.
First create two tables for this report
How to create Table?
Created by Pavan Page 17 of 107
Mail: Praveen.srrec@gmail.com
Created by Pavan Page 20 of 107
Mail: Praveen.srrec@gmail.com
Create Data element
Created by Pavan Page 21 of 107
Mail: Praveen.srrec@gmail.com
Created by Pavan Page 22 of 107
Mail: Praveen.srrec@gmail.com
Create Domain
Created by Pavan Page 23 of 107
Mail: Praveen.srrec@gmail.com
Fill all the Attributes and save it
and activate it
Created by Pavan Page 26 of 107
Mail: Praveen.srrec@gmail.com
Created by Pavan Page 27 of 107
Mail: Praveen.srrec@gmail.com
Message Class:
This messages which we will set here will be displayed while executing a report.
We can set up 4 kind of messages.
1. S- status Message. (Will appear green in status bar)
2. E-Error message. (Will appear red in status bar)
3. W-Warning message. (Will appear yellow in the status bar)
4. I-Information message (will appear as information box)
Creating Message Class:
After creating your report then it will directly shows your report name as
REPORT ZSMALL_INTERACTIVE_REPORT.
Now to create a message class you have first declare your message class at the
start of the report as
REPORT ZSMALL_INTERACTIVE_REPORT MESSAGE-ID ZPA1.
Here ZPA1 is message class. Now double click on ZPA1
Created by Pavan Page 28 of 107
Mail: Praveen.srrec@gmail.com
Created by Pavan Page 29 of 107
Mail: Praveen.srrec@gmail.com
Created by Pavan Page 30 of 107
Mail: Praveen.srrec@gmail.com
Created by Pavan Page 33 of 107
Mail: Praveen.srrec@gmail.com
Created by Pavan Page 34 of 107
Mail: Praveen.srrec@gmail.com
In your report to call a table or to declare a table the syntax is
Tables: zemp_details1.
To declare an internal table this is the syntax
Data: itab like zemp_details1 occurs 0 with header line.
In internal table we declare in two types
1) Internal Table manipulations
2) with Header line &
3) without header line
Syntax for Table Manipulations:
1. READ:
READ TABLE <itab> WITH KEY < fieldname = ‘’>.
2. INSERT:
INSERT <itab> index <sy-tabix>.
3. MODIFY:
MODIFY <itab> index <sy-tabix>
4. DESCRIBE:
DESCRIBE TABLE <itab> lines <var1> OCCURS <var2>.
5. APPEND:
APPEND <itab>.
6. CLEAR
CLEAR <itab>.
7. REFRESH
REFRESH <itab>.
Created by Pavan Page 35 of 107
Mail: Praveen.srrec@gmail.com
Sample report for Internal Table with header manipulation:
*&---------------------------------------------------------------------*
*& Report ZITAB_WITH_HEADER_MANIPULATION *
*& *
*&---------------------------------------------------------------------*
*& *
*& *
*&---------------------------------------------------------------------*
REPORT ZITAB_WITH_HEADER_MANIPULATION .
DATA: BEGIN OF ITAB OCCURS 0,
BOOKNO(4) TYPE N,
BOOKNAME(5) TYPE C,
BOOKADD(10) TYPE C,
END OF ITAB.
ITAB-BOOKNO = '1234'.
ITAB-BOOKNAME = 'SAP'.
ITAB-BOOKADD = 'KOTI'.
APPEND ITAB.
CLEAR ITAB.
ITAB-BOOKNO = '1235'.
ITAB-BOOKNAME = 'ABAP'.
ITAB-BOOKADD = 'PUNJAGUTTA'.
APPEND ITAB.
CLEAR ITAB.
ITAB-BOOKNO = '1236'.
ITAB-BOOKNAME = 'ERP'.
ITAB-BOOKADD = 'BEGUMPET'.
APPEND ITAB.
CLEAR ITAB.
LOOP AT ITAB.
WRITE:/ ITAB-BOOKNO,ITAB-BOOKNAME,ITAB-BOOKADD.
ENDLOOP.
SKIP 2.
READ TABLE ITAB WITH KEY BOOKNO = '1235'.
WRITE:/ ITAB-BOOKNO,ITAB-BOOKNAME,ITAB-BOOKADD.
SKIP 2.
READ TABLE ITAB INDEX 3.
WRITE:/ ITAB-BOOKNO,ITAB-BOOKNAME,ITAB-BOOKADD.
SKIP 2.
ITAB-BOOKNO = '9876'.
ITAB-BOOKNAME = 'XI'.
ITAB-BOOKADD = 'CHENNAI'.
INSERT ITAB INDEX 2.
LOOP AT ITAB.
WRITE:/ ITAB-BOOKNO,ITAB-BOOKNAME,ITAB-BOOKADD.
ENDLOOP.
SKIP 2.
ITAB-BOOKNO = '4567'.
ITAB-BOOKNAME = 'BASIS'.
ITAB-BOOKADD = 'SR NAGAR'.
MODIFY ITAB INDEX 2.
LOOP AT ITAB.
WRITE:/ ITAB-BOOKNO,ITAB-BOOKNAME,ITAB-BOOKADD.
ENDLOOP.
SKIP 2.
Created by Pavan Page 36 of 107
Mail: Praveen.srrec@gmail.com
DELETE ITAB INDEX 2.
LOOP AT ITAB.
WRITE:/ ITAB-BOOKNO,ITAB-BOOKNAME,ITAB-BOOKADD.
ENDLOOP.
SKIP 2.
CLEAR ITAB.
WRITE:/ ITAB-BOOKNO,ITAB-BOOKNAME,ITAB-BOOKADD.
SKIP 2.
FREE ITAB.
WRITE:/ ITAB-BOOKNO,ITAB-BOOKNAME,ITAB-BOOKADD.
SKIP 2.
REFRESH ITAB.
LOOP AT ITAB.
WRITE:/ ITAB-BOOKNO,ITAB-BOOKNAME,ITAB-BOOKADD.
ENDLOOP.
Created by Pavan Page 37 of 107
Mail: Praveen.srrec@gmail.com
Sample report for Internal Table without header:
*&---------------------------------------------------------------------*
*& Report ZITAB_WITHOUT_HEADER *
*& *
*&---------------------------------------------------------------------*
*& *
*& *
*&---------------------------------------------------------------------*
REPORT ZITAB_WITHOUT_HEADER .
DATA: BEGIN OF HEADER,
BOOKNO(4) TYPE N,
BOOKNAME(5) TYPE C,
BOOKADD(10) TYPE C,
END OF HEADER.
DATA: BODY LIKE HEADER OCCURS 0.
HEADER-BOOKNO = '1209'.
HEADER-BOOKNAME = 'SAP'.
HEADER-BOOKADD = 'HYD'.
APPEND HEADER TO BODY.
CLEAR HEADER.
HEADER-BOOKNO = '1235'.
HEADER-BOOKNAME = 'ABAP'.
HEADER-BOOKADD = 'PUNJAGUTTA'.
APPEND HEADER TO BODY.
CLEAR HEADER.
HEADER-BOOKNO = '1236'.
HEADER-BOOKNAME = 'ERP'.
HEADER-BOOKADD = 'KOTI'.
APPEND HEADER TO BODY.
CLEAR HEADER.
LOOP AT BODY INTO HEADER.
WRITE:/ HEADER-BOOKNO,HEADER-BOOKNAME,HEADER-BOOKADD.
ENDLOOP.
Created by Pavan Page 38 of 107
Mail: Praveen.srrec@gmail.com
Sample report for Internal Table with header:
*&---------------------------------------------------------------------*
*& Report ZITAB_WITH_HEADER *
*& *
*&---------------------------------------------------------------------*
*& *
*& *
*&---------------------------------------------------------------------*
REPORT ZITAB_WITH_HEADER .
DATA: BEGIN OF ITAB OCCURS 0,
BOOKNO(4) TYPE N,
BOOKNAME(10) TYPE C,
BOOKADD(15) TYPE C,
END OF ITAB.
ITAB-BOOKNO = '1216'.
ITAB-BOOKNAME = 'SAP'.
ITAB-BOOKADD = 'GANDHINAGAR'.
APPEND ITAB.
CLEAR ITAB.
ITAB-BOOKNO = '1209'.
ITAB-BOOKNAME = 'PAVAN-ABAP'.
ITAB-BOOKADD = 'GANDHINAGAR'.
APPEND ITAB.
CLEAR ITAB.
ITAB-BOOKNO = '1236'.
ITAB-BOOKNAME = 'ERP'.
ITAB-BOOKADD = 'HYD'.
APPEND ITAB.
CLEAR ITAB.
LOOP AT ITAB.
WRITE:/ ITAB-BOOKNO,ITAB-BOOKNAME,ITAB-BOOKADD.
ENDLOOP.
SKIP 2.
READ TABLE ITAB WITH KEY BOOKNO = '1235'.
WRITE:/ ITAB-BOOKNO,ITAB-BOOKNAME,ITAB-BOOKADD.
SKIP 2.
READ TABLE ITAB INDEX 3.
WRITE:/ ITAB-BOOKNO,ITAB-BOOKNAME,ITAB-BOOKADD.
SKIP 2.
ITAB-BOOKNO = '9876'.
ITAB-BOOKNAME = 'HR'.
ITAB-BOOKADD = 'PUNJAGUTTA'.
INSERT ITAB INDEX 2.
LOOP AT ITAB.
WRITE:/ ITAB-BOOKNO,ITAB-BOOKNAME,ITAB-BOOKADD.
ENDLOOP.
SKIP 2.
ITAB-BOOKNO = '4567'.
ITAB-BOOKNAME = 'BASIS'.
ITAB-BOOKADD = 'KOTI'.
MODIFY ITAB INDEX 2.
LOOP AT ITAB.
WRITE:/ ITAB-BOOKNO,ITAB-BOOKNAME,ITAB-BOOKADD.
ENDLOOP.
SKIP 2.
DELETE ITAB INDEX 2.
LOOP AT ITAB.
WRITE:/ ITAB-BOOKNO,ITAB-BOOKNAME,ITAB-BOOKADD.
Created by Pavan Page 39 of 107
Mail: Praveen.srrec@gmail.com
ENDLOOP.
SKIP 2.
CLEAR ITAB.
WRITE:/ ITAB-BOOKNO,ITAB-BOOKNAME,ITAB-BOOKADD.
SKIP 2.
FREE ITAB.
WRITE:/ ITAB-BOOKNO,ITAB-BOOKNAME,ITAB-BOOKADD.
SKIP 2.
REFRESH ITAB.
LOOP AT ITAB.
WRITE:/ ITAB-BOOKNO,ITAB-BOOKNAME,ITAB-BOOKADD.
ENDLOOP.
Initialization event is to set the initial values for the output that we get for the
report.
Low value – here refers to the low value for the primary key.
High value – here refers to the highest value u need.
Sign – can be either ‘Inclusive’ or ‘exclusive’.
Option – can be ‘BT (between), GT(greater than), LT( lesser than).
Now after declaring your internal table declare these values in your report
SELECT-OPTIONS: EMP_NO FOR ZEMP_DETAILS1-EMPNO.
INITIALIZATION.
EMP_NO-LOW = '1000'.
EMP_NO-HIGH = '4000'.
EMP_NO-SIGN = 'I'. “ HERE ‘I’ REPRESENTS INTEGER
EMP_NO-OPTION = 'BT'.
APPEND EMP_NO.
CLEAR EMP_NO.
AT SELECTION-SCREEN is used to check the validity of the user input values
by setting the messages in the Message Class.
AT SELECTION-SCREEN.
IF EMP_NO-LOW < '1000'.
MESSAGE S000(ZPA1).
ELSEIF EMP_NO-HIGH > '4000'.
MESSAGE S001.
ENDIF.
Created by Pavan Page 40 of 107
Mail: Praveen.srrec@gmail.com
START-OF SELECTION event where exactly we use the SQL statements to
retrieve the output from the database table.
START-OF-SELECTION.
SELECT * FROM ZEMP_DETAILS1 INTO TABLE ITAB WHERE EMPNO IN EMP_NO.
WRITE:/5 SY-ULINE(35).
LOOP AT ITAB.
WRITE:/5 SY-VLINE, 6 ITAB-EMPNO, 17 SY-VLINE,18 ITAB-EMPNAME,28 SY-VLINE
, 39 SY-VLINE.
ENDLOOP.
To get the output in the table format we use 2 system variables such as SY-
ULINE to draw the horizontal line and SY-VLINE to draw the vertical line.
To get the header at the top of every page we use TOP-OF-PAGE event .
TOP-OF-PAGE.
WRITE:/5 SY-ULINE(35).
WRITE:/5 SY-VLINE,6 'EMPNO',17 SY-VLINE,18 'EMPNAME',28 SY-VLINE,
39 SY-VLINE.
WRITE:/5 SY-ULINE(35).
In order to set the LINE-SIZE and the LINE-COUNT ,
REPORT ZSMALL_INTERACTIVE_REPORT MESSAGE-ID ZPA1 LINE-SIZE 255
we need to declare In the first line of the program and at the end of each and every
page we can set the page no by using the END-OF PAGE event and at the end of
selection we can set some message telling that the output is closed in the END-
OF-SELECTION event.
END-OF-PAGE.
WRITE:/5 SY-ULINE(35).
WRITE:/ 'THE PAGE NO IS',SY-PAGNO.
END-OF-SELECTION.
WRITE:/ 'THE RECORD IS CLOSED'.
Up to here what we have performed is Classical report the events upto here same
as interactive
Some of the interactive events are:
1. At line Selection
2. At PFn.
Created by Pavan Page 41 of 107
Mail: Praveen.srrec@gmail.com
3. At User-command.
AT LINE-SELECTION event is triggered by double-clicking on the output value
to get the drilldown report.
AT LINE-SELECTION.
IF SY-LSIND = 1.
SELECT * FROM ZEMP_DETAILS1 INTO TABLE ITAB WHERE EMPNO = ITAB-EMPNO.
LOOP AT ITAB.
WRITE:/5 SY-VLINE,6 ITAB-EMPNO,17 SY-VLINE,18 ITAB-EMPNAME,28 SY-VLINE,
39 SY-VLINE.
ENDLOOP.
WRITE:/5 SY-ULINE(35).
ELSEIF SY-LSIND = 2.
SELECT * FROM ZCOMP_DETAILS INTO TABLE JTAB.
LOOP AT JTAB.
WRITE:/5 SY-VLINE,6 JTAB-COMP_NO,17 SY-VLINE,18 JTAB-COMP_NAME,28
SY-VLINE,
39 SY-VLINE.
ENDLOOP.
WRITE:/5 SY-ULINE(35).
ENDIF.
Complete Coding for Interactive report
*&---------------------------------------------------------------------*
*& Report ZSMALL_INTERACTIVE_REPORT *
*& *
*&---------------------------------------------------------------------*
*& *
*& *
*&---------------------------------------------------------------------*
REPORT ZSMALL_INTERACTIVE_REPORT MESSAGE-ID ZPA1 LINE-SIZE 255
LINE-COUNT 10(2).
Tables: zemp_details1, zcomp_details.
Data: itab like zemp_details1 occurs 0 with header line.
Data: Jtab like zCOMP_details occurs 0 with header line.
SELECT-OPTIONS: EMP_NO FOR ZEMP_DETAILS1-EMPNO.
INITIALIZATION.
EMP_NO-LOW = '1000'.
EMP_NO-HIGH = '4000'.
EMP_NO-SIGN = 'I'.
EMP_NO-OPTION = 'BT'.
APPEND EMP_NO.
CLEAR EMP_NO.
AT SELECTION-SCREEN.
IF EMP_NO-LOW < '1000'.
MESSAGE S000(ZPA1).
ELSEIF EMP_NO-HIGH > '4000'.
MESSAGE S001.
ENDIF.
START-OF-SELECTION.
Created by Pavan Page 42 of 107
Mail: Praveen.srrec@gmail.com
SELECT * FROM ZEMP_DETAILS1 INTO TABLE ITAB WHERE EMPNO IN EMP_NO.
WRITE:/5 SY-ULINE(35).
LOOP AT ITAB.
WRITE:/5 SY-VLINE, 6 ITAB-EMPNO, 17 SY-VLINE,18 ITAB-EMPNAME,28 SY-VLINE
, 39 SY-VLINE.
ENDLOOP.
TOP-OF-PAGE.
WRITE:/5 SY-ULINE(35).
WRITE:/5 SY-VLINE,6 'EMPNO',17 SY-VLINE,18 'EMPNAME',28 SY-VLINE,
39 SY-VLINE.
WRITE:/5 SY-ULINE(35).
END-OF-PAGE.
WRITE:/5 SY-ULINE(35).
WRITE:/ 'THE PAGE NO IS',SY-PAGNO.
END-OF-SELECTION.
WRITE:/ 'THE RECORD IS CLOSED'.
AT LINE-SELECTION.
IF SY-LSIND = 1.
SELECT * FROM ZEMP_DETAILS1 INTO TABLE ITAB WHERE EMPNO = ITAB-EMPNO.
LOOP AT ITAB.
WRITE:/5 SY-VLINE,6 ITAB-EMPNO,17 SY-VLINE,18 ITAB-EMPNAME,28 SY-VLINE,
39 SY-VLINE.
ENDLOOP.
WRITE:/5 SY-ULINE(35).
ELSEIF SY-LSIND = 2.
SELECT * FROM ZCOMP_DETAILS INTO TABLE JTAB.
LOOP AT JTAB.
WRITE:/5 SY-VLINE,6 JTAB-COMP_NO,17 SY-VLINE,18 JTAB-COMP_NAME,28
SY-VLINE,
39 SY-VLINE.
ENDLOOP.
WRITE:/5 SY-ULINE(35).
ENDIF.
After executing this report if you click on the output any name or number
then it will take you to the another line for which you have defined coding as
above
AT PF ’n’ event is triggered by clicking on the function key assigned at the n
value wherein n can vary from 5 to 9.
If we go to se41, we can get menus, items and different function keys, which we
are using for secondary list in interactive report.
AT PF7.
Created by Pavan Page 43 of 107
Mail: Praveen.srrec@gmail.com
Now to set an PF-STATUS we have to go to Menu Painter (Se41). This Pf status
is for GUI. Goto se 41 and create a menu list or just follow this
In your program write the following code
SET PF-STATUS 'ZPA1_MENU'.
And now double click on ZPA1_MENU
Created by Pavan Page 44 of 107
Mail: Praveen.srrec@gmail.com
Fill all the necessary fields and
then press enter
Created by Pavan Page 45 of 107
Mail: Praveen.srrec@gmail.com
Click on this to expand the menu
bar options
Created by Pavan Page 46 of 107
Mail: Praveen.srrec@gmail.com
Give any name to your object and
double click on the same line
Created by Pavan Page 47 of 107
Mail: Praveen.srrec@gmail.com
In the application tool bar it provides option in output such as open, back, exit,
folder etc,
Fill your required option here so that it
will be displayed in the output and then
press enter
Created by Pavan Page 48 of 107
Mail: Praveen.srrec@gmail.com
Select Static or Dynamic text and then
press enter
Created by Pavan Page 49 of 107
Mail: Praveen.srrec@gmail.com
Give your Function Text and in the
icon name press F4 and select relevant
icon to be displayed at output
Created by Pavan Page 50 of 107
Mail: Praveen.srrec@gmail.com
Created by Pavan Page 51 of 107
Mail: Praveen.srrec@gmail.com
Created by Pavan Page 52 of 107
Mail: Praveen.srrec@gmail.com
You have to assign any function
keys to the object for which u
have created and then press enter
Created by Pavan Page 53 of 107
Mail: Praveen.srrec@gmail.com
Created by Pavan Page 54 of 107
Mail: Praveen.srrec@gmail.com
Here you can see your added function keys
or else you can add from here also
Created by Pavan Page 55 of 107
Mail: Praveen.srrec@gmail.com
Complete code of present report
*&---------------------------------------------------------------------*
*& Report ZSMALL_INTERACTIVE_REPORT *
*& *
*&---------------------------------------------------------------------*
*& *
*& *
*&---------------------------------------------------------------------*
REPORT ZSMALL_INTERACTIVE_REPORT MESSAGE-ID ZPA1 LINE-SIZE 255
LINE-COUNT 10(2).
Tables: zemp_details1, zcomp_details.
Data: itab like zemp_details1 occurs 0 with header line.
Data: Jtab like zCOMP_details occurs 0 with header line.
SELECT-OPTIONS: EMP_NO FOR ZEMP_DETAILS1-EMPNO.
SET PF-STATUS 'ZPA1_MENU'.
INITIALIZATION.
EMP_NO-LOW = '1000'.
EMP_NO-HIGH = '4000'.
EMP_NO-SIGN = 'I'.
EMP_NO-OPTION = 'BT'.
APPEND EMP_NO.
CLEAR EMP_NO.
AT SELECTION-SCREEN.
IF EMP_NO-LOW < '1000'.
MESSAGE S000(ZPA1).
ELSEIF EMP_NO-HIGH > '4000'.
MESSAGE S001.
ENDIF.
START-OF-SELECTION.
SELECT * FROM ZEMP_DETAILS1 INTO TABLE ITAB WHERE EMPNO IN EMP_NO.
LOOP AT ITAB.
WRITE:/5 SY-VLINE,6 ITAB-EMPNO,17 SY-VLINE,18 ITAB-EMPNAME,28 SY-VLINE,
39 SY-VLINE.
HIDE: ITAB-EMPNO.
ENDLOOP.
WRITE:/5 SY-ULINE(35).
TOP-OF-PAGE.
WRITE:/5 SY-ULINE(35).
WRITE:/5 SY-VLINE,6 'EMPNO',17 SY-VLINE,18 'EMPNAME',28 SY-VLINE,
39 SY-VLINE.
WRITE:/5 SY-ULINE(35).
END-OF-PAGE.
WRITE:/5 SY-ULINE(35).
Created by Pavan Page 56 of 107
Mail: Praveen.srrec@gmail.com
WRITE:/ 'THE PAGE NO IS',SY-PAGNO.
END-OF-SELECTION.
WRITE:/ 'THE RECORD IS CLOSED'.
AT LINE-SELECTION.
IF SY-LSIND = 1.
SELECT * FROM ZEMP_DETAILS1 INTO TABLE ITAB WHERE EMPNO = ITAB-EMPNO.
LOOP AT ITAB.
WRITE:/5 SY-VLINE,6 ITAB-EMPNO,17 SY-VLINE,18 ITAB-EMPNAME,28 SY-VLINE,
39 SY-VLINE.
ENDLOOP.
WRITE:/5 SY-ULINE(35).
ELSEIF SY-LSIND = 2.
SELECT * FROM ZCOMP_DETAILS INTO TABLE JTAB.
LOOP AT JTAB.
WRITE:/5 SY-VLINE,6 JTAB-COMP_NO,17 SY-VLINE,18 JTAB-COMP_NAME,28
SY-VLINE,
39 SY-VLINE.
ENDLOOP.
WRITE:/5 SY-ULINE(35).
ENDIF.
AT PF7.
IF SY-LSIND = 1.
SELECT * FROM ZEMP_DETAILS1 INTO TABLE ITAB WHERE EMPNO = ITAB-EMPNO.
LOOP AT ITAB.
WRITE:/5 SY-VLINE,6 ITAB-EMPNO,17 SY-VLINE,18 ITAB-EMPNAME,28 SY-VLINE,
39 SY-VLINE.
ENDLOOP.
WRITE:/5 SY-ULINE(35).
ELSEIF SY-LSIND = 2.
SELECT * FROM ZCOMP_DETAILS INTO TABLE JTAB.
LOOP AT JTAB.
WRITE:/5 SY-VLINE,6 JTAB-COMP_NO,17 SY-VLINE,18 JTAB-COMP_NAME,28
SY-VLINE,
39 SY-VLINE.
ENDLOOP.
WRITE:/5 SY-ULINE(35).
ENDIF.
AT USER-COMMAND.
IF SY-UCOMM = '0001'.
Created by Pavan Page 57 of 107
Mail: Praveen.srrec@gmail.com
IF SY-LSIND = 1.
SELECT * FROM ZEMP_DETAILS1 INTO TABLE ITAB WHERE EMPNO = ITAB-EMPNO.
LOOP AT ITAB.
WRITE:/5 SY-VLINE,6 ITAB-EMPNO,17 SY-VLINE,18 ITAB-EMPNAME,28 SY-VLINE,
39 SY-VLINE.
ENDLOOP.
WRITE:/5 SY-ULINE(35).
ELSEIF SY-LSIND = 2.
SELECT * FROM ZCOMP_DETAILS INTO TABLE JTAB.
LOOP AT JTAB.
WRITE:/5 SY-VLINE,6 JTAB-COMP_NO,17 SY-VLINE,18 JTAB-COMP_NAME,28
SY-VLINE,
39 SY-VLINE.
ENDLOOP.
WRITE:/5 SY-ULINE(35).
ENDIF.
ENDIF.
Created by Pavan Page 58 of 107
Mail: Praveen.srrec@gmail.com
Logical Data Base Builder:
A logical database is a special ABAP/4 program which combines the contents of
certain database tables. You can link a logical database to an ABAP/4 report
program as an attribute. The logical database then supplies the report program
with a set of hierarchically structured table lines which can be taken from different
database tables.
If you need to find the logical database for a table name, you can used SE36 -
Logical Database Builder.
Steps:-
Go to transaction SE36
Click Extras -> Table usage
Supply the Table name and hit enter.
A Display Logical Database will be shown on a pop-up window.
More Information from help.sap.com
Logical databases are special ABAP programs that retrieve data and make it
available to application programs. The most common use of logical databases is
still to read data from database tables and linking them to executable ABAP
programs while setting the program contents. You edit logical databases using the
Logical Database Builder in the ABAP Workbench.
However, since Release 4.5A, it has also been possible to call logical databases
independently of this tool using the function module LDB_PROCESS. This allows
you to call several logical databases from any ABAP program, nested in any way.
It is also possible to call a logical database more than once in a program, if it has
been programmed to allow this. This is particularly useful for executable
programs, allowing them to use more than one logical database and process a
database more than once.
Logical databases contain Open SQL statements that read data from the database.
You do not therefore need to use SQL in your own programs. The logical database
reads the program, stores them in the program if necessary, and then passes them
Created by Pavan Page 59 of 107
Mail: Praveen.srrec@gmail.com
line by line to the application program or the function module LDB_PROCESS
using an interface work area.
Views of Data in Logical Databases
Logical databases provide a particular view of database tables. It is appropriate to
use logical databases if the database tables you want to read correspond largely to
the structure of the logical database and where the flow of the system program
(select - read - process - display) meets the requirements of the application.
The data structure in a logical database is hierarchical. Many tables in the R/3
System are linked to each other using foreign key relationships. Some of these
dependencies form tree-like hierarchical structures. Logical databases read data
from database tables that are part of these structures.
Created by Pavan Page 60 of 107
Mail: Praveen.srrec@gmail.com
A logical database can read the lines of these tables one after the other into an
executable program in a sequence which is normally defined by the hierarchical
structure. The term logical database is sometimes used to mean not only the
program itself, but also the data that it can procure.
Tasks of Logical Databases
Logical databases serve mainly to reuse predefined functionality for reading data
from database tables, but they can also be programmed for other tasks. To keep the
application logic of application programs free from technical details, logical
databases can perform the following tasks:
· Reading the same data for several programs.
The individual programs do not then need to know the exact structure of the
relevant database tables (and especially not their foreign key relationships).
Instead, they can rely on the logical database to read the database entries in the
right order during the GET event.
· Defining the same user interface for several programs.
Logical databases have a built-in selection screen. Therefore, all of the programs
that use the logical database have the same user interface.
· Central authorization checks
Authorization checks for central and sensitive data can be programmed centrally
in the database to prevent them from being bypassed by simple application
programs.
· Improving Performance
If you want to improve response times, logical databases permit you to take a
number of measures to achieve this (for example, using joins instead of nested
SELECT statements). These become immediately effective in all of the
application programs concerned and save you from having to modify their source
code.
Created by Pavan Page 61 of 107
Mail: Praveen.srrec@gmail.com
Goto Tcode SE36 to create logical Data base
Created by Pavan Page 62 of 107
Mail: Praveen.srrec@gmail.com
Give your short description and
then press enter
Created by Pavan Page 63 of 107
Mail: Praveen.srrec@gmail.com
Give your table name
here
Give the text same as in
declared in your table
Again Declare your Table
here
Created by Pavan Page 64 of 107
Mail: Praveen.srrec@gmail.com
Give the second node which should be hierarchically under the root node and enter
the short description with the database table Name
Created by Pavan Page 65 of 107
Mail: Praveen.srrec@gmail.com
Give your second table name and the short text
should be same as declared in your table for
this particular table
Created by Pavan Page 66 of 107
Mail: Praveen.srrec@gmail.com
Select your table and then click on
Selections Button
Created by Pavan Page 67 of 107
Mail: Praveen.srrec@gmail.com
Created by Pavan Page 68 of 107
Mail: Praveen.srrec@gmail.com
Created by Pavan Page 69 of 107
Mail: Praveen.srrec@gmail.com
Created by Pavan Page 70 of 107
Mail: Praveen.srrec@gmail.com
Now uncomment your select-options and give any name for your select option
Created by Pavan Page 71 of 107
Mail: Praveen.srrec@gmail.com
This is our complete code after uncommenting few lines
SELECT-OPTIONS : empno FOR ZEMP_DETAILS1-EMPNO.
* Parameter for search pattern selection (Type SY-LDB_SP):
* PARAMETERS p_sp AS SEARCH PATTERN FOR TABLE
ZEMP_DETAILS1.
SELECT-OPTIONS : compno FOR ZCOMP_DETAILS-COMP_NO.
* Enable DYNAMIC SELECTIONS for selected nodes :
SELECTION-SCREEN DYNAMIC SELECTIONS FOR TABLE
ZEMP_DETAILS1.
SELECTION-SCREEN DYNAMIC SELECTIONS FOR TABLE
ZCOMP_DETAILS.
* Enable FIELD SELECTION for selected nodes :
Created by Pavan Page 72 of 107
Mail: Praveen.srrec@gmail.com
Now go back to your initial screen and select your table and then Select Source
code
Created by Pavan Page 73 of 107
Mail: Praveen.srrec@gmail.com
Now double click on TOP Include which is used for Header.
Created by Pavan Page 74 of 107
Mail: Praveen.srrec@gmail.com
Now check whether the tables you have defined are uncommented or not??
Created by Pavan Page 75 of 107
Mail: Praveen.srrec@gmail.com
Now go back to your Program screen and double click on Routines
Created by Pavan Page 76 of 107
Mail: Praveen.srrec@gmail.com
Now click on the include
Double click on top include
BASEN001 for emp details
table here my table is
ZEMP_DETAILS1
Created by Pavan Page 77 of 107
Mail: Praveen.srrec@gmail.com
Now uncomment the SQL statement and enter the field and the database table
name according to the logical database builder.
Created by Pavan Page 78 of 107
Mail: Praveen.srrec@gmail.com
Now go back to includes screen and in the same way as done above for employee
details now double click on Company details and uncomment the SQL statements
then SAVE, CHECK and ACTIVATE the screen.
Click BACK and SAVE, CHECK & ACTIVATE the screen until u reach the
main screen and SAVE the logical database.
Thus the logical database is constructed.
In order to generate the query report, first construct the logical database and
generation of query report is as follows.
The transaction codes used in Query reports are:
1. SQ01 – For creating Query.
2. SQ02 – For creating Infoset.
3. SQ03 – For creating User.
First u need to create the USER and generate the INFOSET, in turn can produce
the Query report.
Created by Pavan Page 79 of 107
Mail: Praveen.srrec@gmail.com
Infoset:
An SAP Infoset (formerly known as a Functional Area) is crucial for ABAP query
usage (in SAP versions 4.6A - onward).
The reason for Info Sets being important is because many R/3 clients find
themselves faced with how to develop useful reports from an application using
20k+ tables. In addition, many clients desire to use third-party reporting tools; i.e.,
Crystal Reports. In this article, we will look at what an R/3 Infoset and how they
relate to Crystal Reports.
1. Knowledge learned in this article can be put to use when:
2. Users require an understanding of how InfoSets are used within SAP R/3
3. Users require an understanding of the various methods of developing
InfoSets
4. Users require an understanding of how InfoSets are used in concert with
Crystal Reports.
Report developers cannot be expected to cull through the thousands of tables and
fields R/3 presents - even from a single logical database. Therefore, some form of
technical shortcut is beneficial. InfoSets, when used with ABAP queries are an
example of an available shortcut. At its simplest definition, an InfoSet determines
which tables and/or fields within a table, queries may reference. To accomplish
this, InfoSets are typically based upon table joins or logical databases (LDBs).
Therefore, an Infoset is, for lack of a better term, a form of Ubber View (Super
View).
Created by Pavan Page 80 of 107
Mail: Praveen.srrec@gmail.com
Go to Transaction Code SQ01.
Now follow this path Environment Usergroups
Created by Pavan Page 81 of 107
Mail: Praveen.srrec@gmail.com
Give your Query name and Click on create button
Click on Create
Button
Created by Pavan Page 82 of 107
Mail: Praveen.srrec@gmail.com
Save or press Enter
Created by Pavan Page 83 of 107
Mail: Praveen.srrec@gmail.com
Go back to User Group initial screen and then click on Assign users and InfoSets
Click on Assign users
& InfoSets
Created by Pavan Page 84 of 107
Mail: Praveen.srrec@gmail.com
Assign any user existing in
SAP and press enter
Created by Pavan Page 85 of 107
Mail: Praveen.srrec@gmail.com
Now go back to your user screen from there follow this menu path
Environment InfoSets
Or go to Tcode SQ02
Created by Pavan Page 86 of 107
Mail: Praveen.srrec@gmail.com
Created by Pavan Page 87 of 107
Mail: Praveen.srrec@gmail.com
Give your InfoSet query name and
press Create button
Created by Pavan Page 88 of 107
Mail: Praveen.srrec@gmail.com
Give your InfoSet name
Select a logical data base
by pressing F4
Created by Pavan Page 89 of 107
Mail: Praveen.srrec@gmail.com
This is the logical database
which we had created in SE36
Created by Pavan Page 90 of 107
Mail: Praveen.srrec@gmail.com
Created by Pavan Page 91 of 107
Mail: Praveen.srrec@gmail.com
You can drag & drop your
fields on to the screen save it
and come back to main screen
Created by Pavan Page 92 of 107
Mail: Praveen.srrec@gmail.com
Now in SQ03 assign your Infoset
which u had created just above
Created by Pavan Page 93 of 107
Mail: Praveen.srrec@gmail.com
Now to create Query goto USER screen and click on the
ENVIRONMENT QUERIES
and the Query name and click on the CREATE button. It will ask for infoset.
Choose the corresponding Infoset.
Select your infoset query
and then save it
Created by Pavan Page 94 of 107
Mail: Praveen.srrec@gmail.com
Created by Pavan Page 95 of 107
Mail: Praveen.srrec@gmail.com
Created by Pavan Page 96 of 107
Mail: Praveen.srrec@gmail.com
Select your infoset
Created by Pavan Page 97 of 107
Mail: Praveen.srrec@gmail.com
Now on the left hand side u can find the fields in the dictionary and on the right
hand side the field required for the Query report. Drag and drop the field you want
for the Query report and click on the GENERATE button.
Created by Pavan Page 98 of 107
Mail: Praveen.srrec@gmail.com
After selecting your fields click on
generate
Created by Pavan Page 99 of 107
Mail: Praveen.srrec@gmail.com
In the Tcode SQ03 enter your
title
Select ABAP List
Created by Pavan Page 100 of 107
Mail: Praveen.srrec@gmail.com
Click on Next screen
Created by Pavan Page 101 of 107
Mail: Praveen.srrec@gmail.com
Check the Tables for which u
want to make a query
Created by Pavan Page 102 of 107
Mail: Praveen.srrec@gmail.com
Click on Next screen
Created by Pavan Page 103 of 107
Mail: Praveen.srrec@gmail.com
ABAP/4 Query can generate the following 3 simple reports:
Basic List: It is the simple reports.
Statistics: Reports with statistical functions like Average, Percentages.
Ranked Lists: For analytical reports. - For creating a ABAP/4 Query,
programmer has to create user group and a functional group. Functional group can
be created using with or without logical database table. Finally, assign user group
to functional group. Finally, create a query on the functional group generated.
Select the fields and click
next screen
Created by Pavan Page 104 of 107
Mail: Praveen.srrec@gmail.com
Now select the data fields that you want to appear in the query report and click on
the SAVE button. Then Click on the TEST button.
Click on Basic List
Created by Pavan Page 105 of 107
Mail: Praveen.srrec@gmail.com
Select the fields which u want to
display in the output
The fields which u have
selected will be displayed
here
Created by Pavan Page 106 of 107
Mail: Praveen.srrec@gmail.com
In Logical data base(SE36) maintain all fields
Such as Selection Texts, Documentation and then in query report SQ01 execute
your report
Execute the report
Created by Pavan Page 107 of 107
Mail: Praveen.srrec@gmail.com

More Related Content

What's hot

1000 solved questions
1000 solved questions1000 solved questions
1000 solved questions
Kranthi Kumar
 
Sap abap modularization interview questions
Sap abap modularization interview questionsSap abap modularization interview questions
Sap abap modularization interview questions
Pradipta Mohanty
 
Call transaction method
Call transaction methodCall transaction method
Call transaction method
Kranthi Kumar
 
Ooabap notes with_programs
Ooabap notes with_programsOoabap notes with_programs
Ooabap notes with_programs
Kranthi Kumar
 
BATCH DATA COMMUNICATION
BATCH DATA COMMUNICATIONBATCH DATA COMMUNICATION
BATCH DATA COMMUNICATION
Kranthi Kumar
 

What's hot (20)

Bapi step-by-step
Bapi step-by-stepBapi step-by-step
Bapi step-by-step
 
SAP ABAP - Needed Notes
SAP   ABAP - Needed NotesSAP   ABAP - Needed Notes
SAP ABAP - Needed Notes
 
1000 solved questions
1000 solved questions1000 solved questions
1000 solved questions
 
Module pool programming
Module pool programmingModule pool programming
Module pool programming
 
Sap abap
Sap abapSap abap
Sap abap
 
Sap abap modularization interview questions
Sap abap modularization interview questionsSap abap modularization interview questions
Sap abap modularization interview questions
 
List Processing in ABAP
List Processing in ABAPList Processing in ABAP
List Processing in ABAP
 
Call transaction method
Call transaction methodCall transaction method
Call transaction method
 
Ooabap notes with_programs
Ooabap notes with_programsOoabap notes with_programs
Ooabap notes with_programs
 
Sap abap material
Sap abap materialSap abap material
Sap abap material
 
ABAP Programming Overview
ABAP Programming OverviewABAP Programming Overview
ABAP Programming Overview
 
Ab1011 module pool programming
Ab1011   module pool programmingAb1011   module pool programming
Ab1011 module pool programming
 
Smartforms interview questions with answers
Smartforms interview questions with answersSmartforms interview questions with answers
Smartforms interview questions with answers
 
SAP Adobe forms
SAP Adobe formsSAP Adobe forms
SAP Adobe forms
 
ABAP for Beginners - www.sapdocs.info
ABAP for Beginners - www.sapdocs.infoABAP for Beginners - www.sapdocs.info
ABAP for Beginners - www.sapdocs.info
 
Sap scripts
Sap scriptsSap scripts
Sap scripts
 
ABAP Advanced List
ABAP Advanced ListABAP Advanced List
ABAP Advanced List
 
Field symbols
Field symbolsField symbols
Field symbols
 
SAP Modularization techniques
SAP Modularization techniquesSAP Modularization techniques
SAP Modularization techniques
 
BATCH DATA COMMUNICATION
BATCH DATA COMMUNICATIONBATCH DATA COMMUNICATION
BATCH DATA COMMUNICATION
 

Viewers also liked

Step by Step guide for creating first ABAP report in SAP
Step by Step guide for creating first ABAP report in SAPStep by Step guide for creating first ABAP report in SAP
Step by Step guide for creating first ABAP report in SAP
nityaabap
 
ASAP methodology overview
ASAP methodology overviewASAP methodology overview
ASAP methodology overview
Bogdan Gorka
 
Sap table relation
Sap table relationSap table relation
Sap table relation
Rameeza09
 
Pm tables
Pm tablesPm tables
Pm tables
vbpc
 

Viewers also liked (19)

Step by Step guide for creating first ABAP report in SAP
Step by Step guide for creating first ABAP report in SAPStep by Step guide for creating first ABAP report in SAP
Step by Step guide for creating first ABAP report in SAP
 
Abap hr programing
Abap hr programingAbap hr programing
Abap hr programing
 
SAP ABAP data dictionary
SAP ABAP data dictionarySAP ABAP data dictionary
SAP ABAP data dictionary
 
SAP Smart forms
SAP Smart formsSAP Smart forms
SAP Smart forms
 
Asap methodology
Asap methodologyAsap methodology
Asap methodology
 
ASAP methodology overview
ASAP methodology overviewASAP methodology overview
ASAP methodology overview
 
Comparison between abap & abap hr
Comparison between abap & abap hrComparison between abap & abap hr
Comparison between abap & abap hr
 
Sap table relation
Sap table relationSap table relation
Sap table relation
 
SAP ABAP Latest Interview Questions with Answers by Garuda Trainings
SAP ABAP Latest Interview Questions with Answers by Garuda TrainingsSAP ABAP Latest Interview Questions with Answers by Garuda Trainings
SAP ABAP Latest Interview Questions with Answers by Garuda Trainings
 
Introduction to ABAP
Introduction to ABAPIntroduction to ABAP
Introduction to ABAP
 
HR ABAP Technical Overview | http://sapdocs.info/
HR ABAP Technical Overview | http://sapdocs.info/HR ABAP Technical Overview | http://sapdocs.info/
HR ABAP Technical Overview | http://sapdocs.info/
 
HR ABAP Programming Training Material | http://sapdocs.info
HR ABAP Programming Training Material | http://sapdocs.infoHR ABAP Programming Training Material | http://sapdocs.info
HR ABAP Programming Training Material | http://sapdocs.info
 
Classical ABAP interactive report
Classical ABAP interactive reportClassical ABAP interactive report
Classical ABAP interactive report
 
smartforms training | SAP SMART FORMS online training
smartforms training | SAP SMART FORMS online trainingsmartforms training | SAP SMART FORMS online training
smartforms training | SAP SMART FORMS online training
 
Pm tables
Pm tablesPm tables
Pm tables
 
Abap performance tunning tips
Abap performance tunning tipsAbap performance tunning tips
Abap performance tunning tips
 
SAP over view
SAP over viewSAP over view
SAP over view
 
101 erp605 process_overview_en_in
101 erp605 process_overview_en_in101 erp605 process_overview_en_in
101 erp605 process_overview_en_in
 
Bdc BATCH DATA COMMUNICATION
Bdc BATCH DATA COMMUNICATIONBdc BATCH DATA COMMUNICATION
Bdc BATCH DATA COMMUNICATION
 

Similar to Sap Abap Reports

Complete reference to_abap_basics
Complete reference to_abap_basicsComplete reference to_abap_basics
Complete reference to_abap_basics
Abhishek Dixit
 
Alv object model simple 2 d table - event handling
Alv object model   simple 2 d table - event handlingAlv object model   simple 2 d table - event handling
Alv object model simple 2 d table - event handling
anil kumar
 
CASE STUDY InternetExcel Exercises, page 434, textRecord your.docx
CASE STUDY InternetExcel Exercises, page 434, textRecord your.docxCASE STUDY InternetExcel Exercises, page 434, textRecord your.docx
CASE STUDY InternetExcel Exercises, page 434, textRecord your.docx
keturahhazelhurst
 
Illustrated Access 2013 Unit A SAM Project 1aIllustrated .docx
Illustrated Access 2013  Unit A SAM Project 1aIllustrated .docxIllustrated Access 2013  Unit A SAM Project 1aIllustrated .docx
Illustrated Access 2013 Unit A SAM Project 1aIllustrated .docx
wilcockiris
 
Advanced tips of dbms statas
Advanced tips of dbms statasAdvanced tips of dbms statas
Advanced tips of dbms statas
Louis liu
 
Complete list of all sap abap keywords
Complete list of all sap abap keywordsComplete list of all sap abap keywords
Complete list of all sap abap keywords
Prakash Thirumoorthy
 
ApplicationTestPlan[1]
ApplicationTestPlan[1]ApplicationTestPlan[1]
ApplicationTestPlan[1]
Minu Mishra
 
ManageEngine ADAudit Plus - Active Directory audit software.
ManageEngine ADAudit Plus - Active Directory audit software.ManageEngine ADAudit Plus - Active Directory audit software.
ManageEngine ADAudit Plus - Active Directory audit software.
Ashok Kumar
 

Similar to Sap Abap Reports (20)

Automate sap security user audit
Automate sap security user auditAutomate sap security user audit
Automate sap security user audit
 
SAP-ABAP-List-Processing.ppt
SAP-ABAP-List-Processing.pptSAP-ABAP-List-Processing.ppt
SAP-ABAP-List-Processing.ppt
 
Complete reference to_abap_basics
Complete reference to_abap_basicsComplete reference to_abap_basics
Complete reference to_abap_basics
 
Re pr-co
Re pr-coRe pr-co
Re pr-co
 
SAP SD QUERY REPORT_GANESH
SAP SD QUERY REPORT_GANESHSAP SD QUERY REPORT_GANESH
SAP SD QUERY REPORT_GANESH
 
Alv object model simple 2 d table - event handling
Alv object model   simple 2 d table - event handlingAlv object model   simple 2 d table - event handling
Alv object model simple 2 d table - event handling
 
325546_adding fields in CJI3 & CJI5.pdf
325546_adding fields in CJI3 & CJI5.pdf325546_adding fields in CJI3 & CJI5.pdf
325546_adding fields in CJI3 & CJI5.pdf
 
Sap abap
Sap abapSap abap
Sap abap
 
CASE STUDY InternetExcel Exercises, page 434, textRecord your.docx
CASE STUDY InternetExcel Exercises, page 434, textRecord your.docxCASE STUDY InternetExcel Exercises, page 434, textRecord your.docx
CASE STUDY InternetExcel Exercises, page 434, textRecord your.docx
 
The ultimate-guide-to-sql
The ultimate-guide-to-sqlThe ultimate-guide-to-sql
The ultimate-guide-to-sql
 
how to create scada offline with comap applications
how to create scada offline with comap applicationshow to create scada offline with comap applications
how to create scada offline with comap applications
 
Illustrated Access 2013 Unit A SAM Project 1aIllustrated .docx
Illustrated Access 2013  Unit A SAM Project 1aIllustrated .docxIllustrated Access 2013  Unit A SAM Project 1aIllustrated .docx
Illustrated Access 2013 Unit A SAM Project 1aIllustrated .docx
 
Advanced tips of dbms statas
Advanced tips of dbms statasAdvanced tips of dbms statas
Advanced tips of dbms statas
 
Run report from menu Personalization كيفية تشغيل تقرير أو ما شابة من خلال شا...
Run report from menu  Personalization كيفية تشغيل تقرير أو ما شابة من خلال شا...Run report from menu  Personalization كيفية تشغيل تقرير أو ما شابة من خلال شا...
Run report from menu Personalization كيفية تشغيل تقرير أو ما شابة من خلال شا...
 
Complete list of all sap abap keywords
Complete list of all sap abap keywordsComplete list of all sap abap keywords
Complete list of all sap abap keywords
 
ApplicationTestPlan[1]
ApplicationTestPlan[1]ApplicationTestPlan[1]
ApplicationTestPlan[1]
 
Looking for best Sap abap training institute in Chennai
Looking for best Sap abap training institute in ChennaiLooking for best Sap abap training institute in Chennai
Looking for best Sap abap training institute in Chennai
 
How to write a routine for 0 calday in infopackage selection
How to write a routine for 0 calday in infopackage selectionHow to write a routine for 0 calday in infopackage selection
How to write a routine for 0 calday in infopackage selection
 
ManageEngine ADAudit Plus - Active Directory audit software.
ManageEngine ADAudit Plus - Active Directory audit software.ManageEngine ADAudit Plus - Active Directory audit software.
ManageEngine ADAudit Plus - Active Directory audit software.
 
Sap abap training Overview
Sap abap training OverviewSap abap training Overview
Sap abap training Overview
 

Recently uploaded

RT Nagar Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Bang...
RT Nagar Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Bang...RT Nagar Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Bang...
RT Nagar Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Bang...
amitlee9823
 
infant assessment fdbbdbdddinal ppt.pptx
infant assessment fdbbdbdddinal ppt.pptxinfant assessment fdbbdbdddinal ppt.pptx
infant assessment fdbbdbdddinal ppt.pptx
suhanimunjal27
 
DESIGN THINKING in architecture- Introduction
DESIGN THINKING in architecture- IntroductionDESIGN THINKING in architecture- Introduction
DESIGN THINKING in architecture- Introduction
sivagami49
 
Nisha Yadav Escorts Service Ernakulam ❣️ 7014168258 ❣️ High Cost Unlimited Ha...
Nisha Yadav Escorts Service Ernakulam ❣️ 7014168258 ❣️ High Cost Unlimited Ha...Nisha Yadav Escorts Service Ernakulam ❣️ 7014168258 ❣️ High Cost Unlimited Ha...
Nisha Yadav Escorts Service Ernakulam ❣️ 7014168258 ❣️ High Cost Unlimited Ha...
nirzagarg
 
Abortion pill for sale in Muscat (+918761049707)) Get Cytotec Cash on deliver...
Abortion pill for sale in Muscat (+918761049707)) Get Cytotec Cash on deliver...Abortion pill for sale in Muscat (+918761049707)) Get Cytotec Cash on deliver...
Abortion pill for sale in Muscat (+918761049707)) Get Cytotec Cash on deliver...
instagramfab782445
 
Recommendable # 971589162217 # philippine Young Call Girls in Dubai By Marina...
Recommendable # 971589162217 # philippine Young Call Girls in Dubai By Marina...Recommendable # 971589162217 # philippine Young Call Girls in Dubai By Marina...
Recommendable # 971589162217 # philippine Young Call Girls in Dubai By Marina...
home
 
Call Girls Basavanagudi Just Call 👗 7737669865 👗 Top Class Call Girl Service ...
Call Girls Basavanagudi Just Call 👗 7737669865 👗 Top Class Call Girl Service ...Call Girls Basavanagudi Just Call 👗 7737669865 👗 Top Class Call Girl Service ...
Call Girls Basavanagudi Just Call 👗 7737669865 👗 Top Class Call Girl Service ...
amitlee9823
 
Editorial design Magazine design project.pdf
Editorial design Magazine design project.pdfEditorial design Magazine design project.pdf
Editorial design Magazine design project.pdf
tbatkhuu1
 

Recently uploaded (20)

RT Nagar Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Bang...
RT Nagar Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Bang...RT Nagar Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Bang...
RT Nagar Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Bang...
 
Hire 💕 8617697112 Meerut Call Girls Service Call Girls Agency
Hire 💕 8617697112 Meerut Call Girls Service Call Girls AgencyHire 💕 8617697112 Meerut Call Girls Service Call Girls Agency
Hire 💕 8617697112 Meerut Call Girls Service Call Girls Agency
 
Case Study of Hotel Taj Vivanta, Pune
Case Study of Hotel Taj Vivanta, PuneCase Study of Hotel Taj Vivanta, Pune
Case Study of Hotel Taj Vivanta, Pune
 
call girls in Kaushambi (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝...
call girls in Kaushambi (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝...call girls in Kaushambi (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝...
call girls in Kaushambi (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝...
 
infant assessment fdbbdbdddinal ppt.pptx
infant assessment fdbbdbdddinal ppt.pptxinfant assessment fdbbdbdddinal ppt.pptx
infant assessment fdbbdbdddinal ppt.pptx
 
Pooja 9892124323, Call girls Services and Mumbai Escort Service Near Hotel Th...
Pooja 9892124323, Call girls Services and Mumbai Escort Service Near Hotel Th...Pooja 9892124323, Call girls Services and Mumbai Escort Service Near Hotel Th...
Pooja 9892124323, Call girls Services and Mumbai Escort Service Near Hotel Th...
 
❤Personal Whatsapp Number 8617697112 Samba Call Girls 💦✅.
❤Personal Whatsapp Number 8617697112 Samba Call Girls 💦✅.❤Personal Whatsapp Number 8617697112 Samba Call Girls 💦✅.
❤Personal Whatsapp Number 8617697112 Samba Call Girls 💦✅.
 
DESIGN THINKING in architecture- Introduction
DESIGN THINKING in architecture- IntroductionDESIGN THINKING in architecture- Introduction
DESIGN THINKING in architecture- Introduction
 
Nisha Yadav Escorts Service Ernakulam ❣️ 7014168258 ❣️ High Cost Unlimited Ha...
Nisha Yadav Escorts Service Ernakulam ❣️ 7014168258 ❣️ High Cost Unlimited Ha...Nisha Yadav Escorts Service Ernakulam ❣️ 7014168258 ❣️ High Cost Unlimited Ha...
Nisha Yadav Escorts Service Ernakulam ❣️ 7014168258 ❣️ High Cost Unlimited Ha...
 
8377087607, Door Step Call Girls In Kalkaji (Locanto) 24/7 Available
8377087607, Door Step Call Girls In Kalkaji (Locanto) 24/7 Available8377087607, Door Step Call Girls In Kalkaji (Locanto) 24/7 Available
8377087607, Door Step Call Girls In Kalkaji (Locanto) 24/7 Available
 
Abortion pill for sale in Muscat (+918761049707)) Get Cytotec Cash on deliver...
Abortion pill for sale in Muscat (+918761049707)) Get Cytotec Cash on deliver...Abortion pill for sale in Muscat (+918761049707)) Get Cytotec Cash on deliver...
Abortion pill for sale in Muscat (+918761049707)) Get Cytotec Cash on deliver...
 
Pooja 9892124323, Call girls Services and Mumbai Escort Service Near Hotel Gi...
Pooja 9892124323, Call girls Services and Mumbai Escort Service Near Hotel Gi...Pooja 9892124323, Call girls Services and Mumbai Escort Service Near Hotel Gi...
Pooja 9892124323, Call girls Services and Mumbai Escort Service Near Hotel Gi...
 
call girls in Vasundhra (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝...
call girls in Vasundhra (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝...call girls in Vasundhra (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝...
call girls in Vasundhra (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝...
 
HiFi Call Girl Service Delhi Phone ☞ 9899900591 ☜ Escorts Service at along wi...
HiFi Call Girl Service Delhi Phone ☞ 9899900591 ☜ Escorts Service at along wi...HiFi Call Girl Service Delhi Phone ☞ 9899900591 ☜ Escorts Service at along wi...
HiFi Call Girl Service Delhi Phone ☞ 9899900591 ☜ Escorts Service at along wi...
 
AMBER GRAIN EMBROIDERY | Growing folklore elements | Root-based materials, w...
AMBER GRAIN EMBROIDERY | Growing folklore elements |  Root-based materials, w...AMBER GRAIN EMBROIDERY | Growing folklore elements |  Root-based materials, w...
AMBER GRAIN EMBROIDERY | Growing folklore elements | Root-based materials, w...
 
Chapter 19_DDA_TOD Policy_First Draft 2012.pdf
Chapter 19_DDA_TOD Policy_First Draft 2012.pdfChapter 19_DDA_TOD Policy_First Draft 2012.pdf
Chapter 19_DDA_TOD Policy_First Draft 2012.pdf
 
VIP Model Call Girls Kalyani Nagar ( Pune ) Call ON 8005736733 Starting From ...
VIP Model Call Girls Kalyani Nagar ( Pune ) Call ON 8005736733 Starting From ...VIP Model Call Girls Kalyani Nagar ( Pune ) Call ON 8005736733 Starting From ...
VIP Model Call Girls Kalyani Nagar ( Pune ) Call ON 8005736733 Starting From ...
 
Recommendable # 971589162217 # philippine Young Call Girls in Dubai By Marina...
Recommendable # 971589162217 # philippine Young Call Girls in Dubai By Marina...Recommendable # 971589162217 # philippine Young Call Girls in Dubai By Marina...
Recommendable # 971589162217 # philippine Young Call Girls in Dubai By Marina...
 
Call Girls Basavanagudi Just Call 👗 7737669865 👗 Top Class Call Girl Service ...
Call Girls Basavanagudi Just Call 👗 7737669865 👗 Top Class Call Girl Service ...Call Girls Basavanagudi Just Call 👗 7737669865 👗 Top Class Call Girl Service ...
Call Girls Basavanagudi Just Call 👗 7737669865 👗 Top Class Call Girl Service ...
 
Editorial design Magazine design project.pdf
Editorial design Magazine design project.pdfEditorial design Magazine design project.pdf
Editorial design Magazine design project.pdf
 

Sap Abap Reports

  • 1. Created by Pavan Page 1 of 107 Mail: Praveen.srrec@gmail.com Reports: In ABAP, there are total of 7 types of reports. They are: • Classical • Interactive • Logical Database • ABAP query • ALV Reports (ALV stands for ABAP List Viewer) • Report Writer/Report Painter • Views (There are different types of views also) Classical Reports These are the simplest reports. Programmers learn this one first. It is just an output of data using the Write statement inside a loop. • Classical reports are normal reports. These reports are not having any sub reports. IT IS HAVING ONLY ONE SCREEN/LIST FOR OUTPUT. Events In Classical Reports. • INTIALIZATION: This event triggers before selection screen display. • AT-SELECTION-SCREEN: This event triggers after processing user input still selection screen is in active mode. • START OF SELECTION: Start of selection screen triggers after processing selection screen. END-OF-SELECTION: It is for Logical Database Reporting. Event blocks are introduced by an event keyword. They end when the next processing block begins. The following processing block can either be an event block or another processing block allowed in this context – for example, a subroutine or a dialog module. Event keywords have the same name as the events to which they react.
  • 2. Created by Pavan Page 2 of 107 Mail: Praveen.srrec@gmail.com Syntax: DATA:... INITIALIZATION. ... AT SELECTION-SCREEN. ... START-OF-SELECTION. ... GET spfli... .. ... END-OF-SELECTION. ... FORM... ... ENDFORM. The sequence in which the processing blocks occur in the program is irrelevant. The actual processing sequence is determined by the external events. However, to make your programs easier to understand, you should include the event blocks in your program in approximately the same order in which they will be called by the system. Subroutines should be placed at the end of the program. With only two exceptions (AT SELECTION-SCREEN and GET), event blocks have no local data area. All declarative statements in event blocks are handled with the global data declarations in the program. You should therefore include all of your declarations at the start of the program. Statements that are not assigned to a processing block are never executed. In executable programs, all non-declarative statements between the REPORT or PROGRAM statement and the first processing block are assigned to the default event START-OF-SELECTION. if a program does not contain an explicit
  • 3. Created by Pavan Page 3 of 107 Mail: Praveen.srrec@gmail.com START-OF-SELECTION event block, these statements form the entire START-OF-SELECTION block. If a program contains an explicitly defined START-OF-SELECTION event block, these statements are inserted at the beginning of this event block. If a program does not contain any explicit event blocks, all non-declarative statements form the processing block START-OF- SELECTION. In ABAP Editor initial screen give your program name and then press F5 or click on Create
  • 4. Created by Pavan Page 4 of 107 Mail: Praveen.srrec@gmail.com Fill all the attributes & then save it
  • 5. Created by Pavan Page 5 of 107 Mail: Praveen.srrec@gmail.com Here Goes your coding check for inconsistencies and then activate it
  • 6. Created by Pavan Page 6 of 107 Mail: Praveen.srrec@gmail.com *&---------------------------------------------------------------------* *& Report ZCLASSICAL * *& * *&---------------------------------------------------------------------* *& * *& * *&---------------------------------------------------------------------* REPORT ZCLASSICAL . TABLES: vbak,vbap. DATA: v_flag TYPE i. ******INTERNAL TABLE USED TO HOLD DATA TEMPORARILY DATA: BEGIN OF it_salesorder OCCURS 0, kunnr LIKE vbak-kunnr, " Sold To Party. vbeln LIKE vbak-vbeln, " Sales Document Number. posnr LIKE vbap-posnr, " Sales Document Item. matnr LIKE vbap-matnr, " Material Number. bstnk LIKE vbak-bstnk, " Customer purchase order number. bstdk LIKE vbak-bstdk, " Customer purchase order date. kwmeng LIKE vbap-kwmeng, " Cumulative order quantity. netpr LIKE vbap-netpr, " Net price. netwr LIKE vbap-netwr, " Net value of the order item. END OF it_salesorder. ***********INPUT THE DATA USING SELECT OPTIONS SELECT-OPTIONS: s_kunnr FOR vbak-kunnr, " Sold To Party. s_vbeln FOR vbak-vbeln. " Sales Document Number. **********INITIALIZATION INITIALIZATION. PERFORM initialization. *********FETCH THE DATA FROM TABLES AND PLACE THEM IN INTERNAL TABLE START-OF-SELECTION. PERFORM fetch_data. **********DISPLAYING THE DATA FROM INTERNAL TABLE END-OF-SELECTION. **********PAGE HEADINGS PERFORM Page_headings. PERFORM display_data. *&---------------------------------------------------------------------* *& Form initialization *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM initialization .
  • 7. Created by Pavan Page 7 of 107 Mail: Praveen.srrec@gmail.com s_kunnr-sign = 'I'. s_kunnr-option = 'BT'. s_kunnr-low = '1033'. s_kunnr-high = '1390'. APPEND s_kunnr. s_vbeln-sign = 'I'. s_vbeln-option = 'BT'. s_vbeln-low = '4969'. s_vbeln-high = '5000'. APPEND s_vbeln. ENDFORM. " initialization *&---------------------------------------------------------------------* *& Form fetch_data *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM fetch_data . REFRESH it_salesorder. CLEAR it_salesorder. SELECT kunnr vbak~vbeln posnr matnr bstnk bstdk kwmeng netpr vbap~netwr FROM vbak INNER JOIN vbap ON vbak~vbeln = vbap~vbeln INTO TABLE IT_SALESORDER WHERE kunnr IN s_kunnr AND vbak~vbeln IN s_vbeln. ENDFORM. " fetch_data *&---------------------------------------------------------------------* *& Form display_data *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM display_data . SORT it_salesorder BY kunnr vbeln. LOOP AT it_salesorder. AT NEW vbeln. format color 3 on. " COLOR START WRITE: / 'CUSTOMER:',it_salesorder-kunnr. format reset. "COLOR END ULINE. format color 4 on inverse on. "COLOR START
  • 8. Created by Pavan Page 8 of 107 Mail: Praveen.srrec@gmail.com WRITE:/ 'VBELN', "COLOR END 20 'POSNR', 35 'MATNR', 50 'BSTNK', 70 'BSTDK', 85 'KWMENG', 106 'NETPR', 121 'NETWR'. format reset. format color 4 on. WRITE: / it_salesorder-vbeln. format reset. ENDAT. format color 5 on inverse on. WRITE: /20 it_salesorder-posnr, 35 it_salesorder-matnr, 50 it_salesorder-bstnk, 70 it_salesorder-bstdk, 85 it_salesorder-kwmeng LEFT-JUSTIFIED, 101 it_salesorder-netpr, 109 it_salesorder-netwr. format reset. AT END OF vbeln. SKIP 2. ENDAT. ENDLOOP. ENDFORM. " display_data *&---------------------------------------------------------------------* *& Form page_headings *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM page_headings . format color 7 on inverse on. WRITE:/40 'SALES ORDER DOCUMENT FOR A GIVEN CUSTOMER'. SKIP. WRITE:/ 'DATE:',sy-datum, 100 'TIME:',sy-uzeit. format reset. SKIP 2. ENDFORM. " page_headings
  • 9. Created by Pavan Page 9 of 107 Mail: Praveen.srrec@gmail.com
  • 10. Created by Pavan Page 10 of 107 Mail: Praveen.srrec@gmail.com Interactive Reports: In simple Interactive reports are nothing but which were user interface the name itself signifies that it interacts with the users A classical non-interactive report consists of one program that creates a single list. Instead of one extensive and detailed list, with interactive reporting you create basic list from which the user can call detailed information by positioning the cursor and entering commands. Interactive reporting thus reduces information retrieval to the data actually required. Uses of interactive reporting: The user can actively control data retrieval and display during the session. Instead of an extensive and detailed list, you create a basic list with condensed information from which the user can switch to detailed displays by positioning the cursor and entering commands. The detailed information appears in secondary lists. Secondary list: It allows you to enhance the information presented in the basic list. The user can, for example, select a line of the basic list for which he wants to see more detailed information. You display these details on a secondary list. Secondary lists may either overlay the basic list completely or you can display them in an extra window on the screen. The secondary lists can themselves be interactive again. To prevent the user from selecting invalid lines, ABAP/4 offers several possibilities. At the end of the processing block END-OF-SELECTION, delete the contents of one or more fields you previously stored for valid lines using the HIDE statement. At the event AT LINE-SELECTION, check whether the work area is initial or whether the HIDE statement stored field contents there. After processing the secondary list, clear the work area again. This prevents the user from trying to create further secondary lists from the secondary list displayed.
  • 11. Created by Pavan Page 11 of 107 Mail: Praveen.srrec@gmail.com System fields for secondary lists: SY-LSIND Index of the list created during the current event (basic list = 0) SY-LISTI Index of the list level from which the event was triggered. SY-LILLI Absolute number of the line from which the event was triggered. SY-LISEL Contents of the line from which the event was triggered. SY-CUROW Position of the line in the window from which the event was triggered (counting starts with 1) SY-CUCOL Position of the column in the window from which the event was triggered (counting starts with 2). SY-CPAGE Page number of the first displayed page of the list from which the event was triggered. SY-STARO Number of the first line of the first page displayed of the list from which the event was triggered (counting starts with 1). Possibly, a page header occupies this line. SY-STACO Number of the first column displayed in the list from which the event was triggered (counting starts with 1). SY-UCOMM Function code that triggered the event. SY-PFKEY Status of the displayed list. Events for Interactive Reporting: AT LINE-SELECTION Moment at which the user selects a line by double clicking on it or by positioning the cursor on it and pressing F2. AT USER-COMMAND Moment at which the user presses a function key. TOP-OF-PAGE DURING Moment during list processing of a LINE-SELECTION secondary list at which a new page starts.
  • 12. Created by Pavan Page 12 of 107 Mail: Praveen.srrec@gmail.com AT PF-FUNCTION KEY function key from F5 to F12 to perform interactive action on the list.
  • 13. Created by Pavan Page 13 of 107 Mail: Praveen.srrec@gmail.com
  • 14. Created by Pavan Page 14 of 107 Mail: Praveen.srrec@gmail.com *&---------------------------------------------------------------------* *& Report ZSIMPLE_INTERACTIVE * *& * *&---------------------------------------------------------------------* *& * *& * *&---------------------------------------------------------------------* REPORT ZSIMPLE_INTERACTIVE . TABLES: MARA,MARC,MARD. SELECT-OPTIONS: SMATNR FOR MARA-MATNR. *********************************************************** * INITIALIZATION. *********************************************************** INITIALIZATION. SMATNR-LOW = '1300-1400'. SMATNR-HIGH = '1300-2000'. SMATNR-SIGN = 'I'. SMATNR-OPTION = 'BT'. APPEND SMATNR. *********************************************************** * START-OF-SELECTION. *********************************************************** START-OF-SELECTION. WRITE:/10 'MATERIAL NO',25 'PLANT LOCATION',45 'STORAGE LOCATION'. ULINE. SELECT * FROM MARA WHERE MATNR IN SMATNR. WRITE:/10 MARA-MATNR,30 MARA-MBRSH,50 MARA-MTART. HIDE MARA-MBRSH. ENDSELECT. *********************************************************** * AT LINE-SELECTION. *********************************************************** AT LINE-SELECTION. IF SY-LSIND EQ 1. SELECT * FROM MARC WHERE MATNR EQ MARA-MATNR. WRITE:/ MARC-MATNR,MARC-WERKS. HIDE MARC-MATNR. ENDSELECT. ENDIF.
  • 15. Created by Pavan Page 15 of 107 Mail: Praveen.srrec@gmail.com IF SY-LSIND EQ 2. SELECT * FROM MARD WHERE WERKS EQ MARC-WERKS. WRITE:/10 MARD-MATNR, 25 MARD-WERKS,45 MARD-LGORT. HIDE MARD-MATNR. ENDSELECT. ENDIF. *********************************************************** * TOP-OF-PAGE DURING LINE-SELECTION. *********************************************************** TOP-OF-PAGE DURING LINE-SELECTION. IF SY-LSIND EQ 1. WRITE:/1 'MATERIAL NO',15 'PLANT LOCATION'. ULINE. ENDIF. TOP-OF-PAGE DURING LINE-SELECTION. IF SY-LSIND EQ 2. WRITE:/10 'MATERIAL NO',25 'PLANT LOCATION',45 'STORAGE LOCATION'. ENDIF. ************************************************************************
  • 16. Created by Pavan Page 16 of 107 Mail: Praveen.srrec@gmail.com The AT LINE-SELECTION event is triggered by double-clicking on the output value to get the drilldown report. First create two tables for this report How to create Table?
  • 17. Created by Pavan Page 17 of 107 Mail: Praveen.srrec@gmail.com
  • 18.
  • 19.
  • 20. Created by Pavan Page 20 of 107 Mail: Praveen.srrec@gmail.com Create Data element
  • 21. Created by Pavan Page 21 of 107 Mail: Praveen.srrec@gmail.com
  • 22. Created by Pavan Page 22 of 107 Mail: Praveen.srrec@gmail.com Create Domain
  • 23. Created by Pavan Page 23 of 107 Mail: Praveen.srrec@gmail.com Fill all the Attributes and save it and activate it
  • 24.
  • 25.
  • 26. Created by Pavan Page 26 of 107 Mail: Praveen.srrec@gmail.com
  • 27. Created by Pavan Page 27 of 107 Mail: Praveen.srrec@gmail.com Message Class: This messages which we will set here will be displayed while executing a report. We can set up 4 kind of messages. 1. S- status Message. (Will appear green in status bar) 2. E-Error message. (Will appear red in status bar) 3. W-Warning message. (Will appear yellow in the status bar) 4. I-Information message (will appear as information box) Creating Message Class: After creating your report then it will directly shows your report name as REPORT ZSMALL_INTERACTIVE_REPORT. Now to create a message class you have first declare your message class at the start of the report as REPORT ZSMALL_INTERACTIVE_REPORT MESSAGE-ID ZPA1. Here ZPA1 is message class. Now double click on ZPA1
  • 28. Created by Pavan Page 28 of 107 Mail: Praveen.srrec@gmail.com
  • 29. Created by Pavan Page 29 of 107 Mail: Praveen.srrec@gmail.com
  • 30. Created by Pavan Page 30 of 107 Mail: Praveen.srrec@gmail.com
  • 31.
  • 32.
  • 33. Created by Pavan Page 33 of 107 Mail: Praveen.srrec@gmail.com
  • 34. Created by Pavan Page 34 of 107 Mail: Praveen.srrec@gmail.com In your report to call a table or to declare a table the syntax is Tables: zemp_details1. To declare an internal table this is the syntax Data: itab like zemp_details1 occurs 0 with header line. In internal table we declare in two types 1) Internal Table manipulations 2) with Header line & 3) without header line Syntax for Table Manipulations: 1. READ: READ TABLE <itab> WITH KEY < fieldname = ‘’>. 2. INSERT: INSERT <itab> index <sy-tabix>. 3. MODIFY: MODIFY <itab> index <sy-tabix> 4. DESCRIBE: DESCRIBE TABLE <itab> lines <var1> OCCURS <var2>. 5. APPEND: APPEND <itab>. 6. CLEAR CLEAR <itab>. 7. REFRESH REFRESH <itab>.
  • 35. Created by Pavan Page 35 of 107 Mail: Praveen.srrec@gmail.com Sample report for Internal Table with header manipulation: *&---------------------------------------------------------------------* *& Report ZITAB_WITH_HEADER_MANIPULATION * *& * *&---------------------------------------------------------------------* *& * *& * *&---------------------------------------------------------------------* REPORT ZITAB_WITH_HEADER_MANIPULATION . DATA: BEGIN OF ITAB OCCURS 0, BOOKNO(4) TYPE N, BOOKNAME(5) TYPE C, BOOKADD(10) TYPE C, END OF ITAB. ITAB-BOOKNO = '1234'. ITAB-BOOKNAME = 'SAP'. ITAB-BOOKADD = 'KOTI'. APPEND ITAB. CLEAR ITAB. ITAB-BOOKNO = '1235'. ITAB-BOOKNAME = 'ABAP'. ITAB-BOOKADD = 'PUNJAGUTTA'. APPEND ITAB. CLEAR ITAB. ITAB-BOOKNO = '1236'. ITAB-BOOKNAME = 'ERP'. ITAB-BOOKADD = 'BEGUMPET'. APPEND ITAB. CLEAR ITAB. LOOP AT ITAB. WRITE:/ ITAB-BOOKNO,ITAB-BOOKNAME,ITAB-BOOKADD. ENDLOOP. SKIP 2. READ TABLE ITAB WITH KEY BOOKNO = '1235'. WRITE:/ ITAB-BOOKNO,ITAB-BOOKNAME,ITAB-BOOKADD. SKIP 2. READ TABLE ITAB INDEX 3. WRITE:/ ITAB-BOOKNO,ITAB-BOOKNAME,ITAB-BOOKADD. SKIP 2. ITAB-BOOKNO = '9876'. ITAB-BOOKNAME = 'XI'. ITAB-BOOKADD = 'CHENNAI'. INSERT ITAB INDEX 2. LOOP AT ITAB. WRITE:/ ITAB-BOOKNO,ITAB-BOOKNAME,ITAB-BOOKADD. ENDLOOP. SKIP 2. ITAB-BOOKNO = '4567'. ITAB-BOOKNAME = 'BASIS'. ITAB-BOOKADD = 'SR NAGAR'. MODIFY ITAB INDEX 2. LOOP AT ITAB. WRITE:/ ITAB-BOOKNO,ITAB-BOOKNAME,ITAB-BOOKADD. ENDLOOP. SKIP 2.
  • 36. Created by Pavan Page 36 of 107 Mail: Praveen.srrec@gmail.com DELETE ITAB INDEX 2. LOOP AT ITAB. WRITE:/ ITAB-BOOKNO,ITAB-BOOKNAME,ITAB-BOOKADD. ENDLOOP. SKIP 2. CLEAR ITAB. WRITE:/ ITAB-BOOKNO,ITAB-BOOKNAME,ITAB-BOOKADD. SKIP 2. FREE ITAB. WRITE:/ ITAB-BOOKNO,ITAB-BOOKNAME,ITAB-BOOKADD. SKIP 2. REFRESH ITAB. LOOP AT ITAB. WRITE:/ ITAB-BOOKNO,ITAB-BOOKNAME,ITAB-BOOKADD. ENDLOOP.
  • 37. Created by Pavan Page 37 of 107 Mail: Praveen.srrec@gmail.com Sample report for Internal Table without header: *&---------------------------------------------------------------------* *& Report ZITAB_WITHOUT_HEADER * *& * *&---------------------------------------------------------------------* *& * *& * *&---------------------------------------------------------------------* REPORT ZITAB_WITHOUT_HEADER . DATA: BEGIN OF HEADER, BOOKNO(4) TYPE N, BOOKNAME(5) TYPE C, BOOKADD(10) TYPE C, END OF HEADER. DATA: BODY LIKE HEADER OCCURS 0. HEADER-BOOKNO = '1209'. HEADER-BOOKNAME = 'SAP'. HEADER-BOOKADD = 'HYD'. APPEND HEADER TO BODY. CLEAR HEADER. HEADER-BOOKNO = '1235'. HEADER-BOOKNAME = 'ABAP'. HEADER-BOOKADD = 'PUNJAGUTTA'. APPEND HEADER TO BODY. CLEAR HEADER. HEADER-BOOKNO = '1236'. HEADER-BOOKNAME = 'ERP'. HEADER-BOOKADD = 'KOTI'. APPEND HEADER TO BODY. CLEAR HEADER. LOOP AT BODY INTO HEADER. WRITE:/ HEADER-BOOKNO,HEADER-BOOKNAME,HEADER-BOOKADD. ENDLOOP.
  • 38. Created by Pavan Page 38 of 107 Mail: Praveen.srrec@gmail.com Sample report for Internal Table with header: *&---------------------------------------------------------------------* *& Report ZITAB_WITH_HEADER * *& * *&---------------------------------------------------------------------* *& * *& * *&---------------------------------------------------------------------* REPORT ZITAB_WITH_HEADER . DATA: BEGIN OF ITAB OCCURS 0, BOOKNO(4) TYPE N, BOOKNAME(10) TYPE C, BOOKADD(15) TYPE C, END OF ITAB. ITAB-BOOKNO = '1216'. ITAB-BOOKNAME = 'SAP'. ITAB-BOOKADD = 'GANDHINAGAR'. APPEND ITAB. CLEAR ITAB. ITAB-BOOKNO = '1209'. ITAB-BOOKNAME = 'PAVAN-ABAP'. ITAB-BOOKADD = 'GANDHINAGAR'. APPEND ITAB. CLEAR ITAB. ITAB-BOOKNO = '1236'. ITAB-BOOKNAME = 'ERP'. ITAB-BOOKADD = 'HYD'. APPEND ITAB. CLEAR ITAB. LOOP AT ITAB. WRITE:/ ITAB-BOOKNO,ITAB-BOOKNAME,ITAB-BOOKADD. ENDLOOP. SKIP 2. READ TABLE ITAB WITH KEY BOOKNO = '1235'. WRITE:/ ITAB-BOOKNO,ITAB-BOOKNAME,ITAB-BOOKADD. SKIP 2. READ TABLE ITAB INDEX 3. WRITE:/ ITAB-BOOKNO,ITAB-BOOKNAME,ITAB-BOOKADD. SKIP 2. ITAB-BOOKNO = '9876'. ITAB-BOOKNAME = 'HR'. ITAB-BOOKADD = 'PUNJAGUTTA'. INSERT ITAB INDEX 2. LOOP AT ITAB. WRITE:/ ITAB-BOOKNO,ITAB-BOOKNAME,ITAB-BOOKADD. ENDLOOP. SKIP 2. ITAB-BOOKNO = '4567'. ITAB-BOOKNAME = 'BASIS'. ITAB-BOOKADD = 'KOTI'. MODIFY ITAB INDEX 2. LOOP AT ITAB. WRITE:/ ITAB-BOOKNO,ITAB-BOOKNAME,ITAB-BOOKADD. ENDLOOP. SKIP 2. DELETE ITAB INDEX 2. LOOP AT ITAB. WRITE:/ ITAB-BOOKNO,ITAB-BOOKNAME,ITAB-BOOKADD.
  • 39. Created by Pavan Page 39 of 107 Mail: Praveen.srrec@gmail.com ENDLOOP. SKIP 2. CLEAR ITAB. WRITE:/ ITAB-BOOKNO,ITAB-BOOKNAME,ITAB-BOOKADD. SKIP 2. FREE ITAB. WRITE:/ ITAB-BOOKNO,ITAB-BOOKNAME,ITAB-BOOKADD. SKIP 2. REFRESH ITAB. LOOP AT ITAB. WRITE:/ ITAB-BOOKNO,ITAB-BOOKNAME,ITAB-BOOKADD. ENDLOOP. Initialization event is to set the initial values for the output that we get for the report. Low value – here refers to the low value for the primary key. High value – here refers to the highest value u need. Sign – can be either ‘Inclusive’ or ‘exclusive’. Option – can be ‘BT (between), GT(greater than), LT( lesser than). Now after declaring your internal table declare these values in your report SELECT-OPTIONS: EMP_NO FOR ZEMP_DETAILS1-EMPNO. INITIALIZATION. EMP_NO-LOW = '1000'. EMP_NO-HIGH = '4000'. EMP_NO-SIGN = 'I'. “ HERE ‘I’ REPRESENTS INTEGER EMP_NO-OPTION = 'BT'. APPEND EMP_NO. CLEAR EMP_NO. AT SELECTION-SCREEN is used to check the validity of the user input values by setting the messages in the Message Class. AT SELECTION-SCREEN. IF EMP_NO-LOW < '1000'. MESSAGE S000(ZPA1). ELSEIF EMP_NO-HIGH > '4000'. MESSAGE S001. ENDIF.
  • 40. Created by Pavan Page 40 of 107 Mail: Praveen.srrec@gmail.com START-OF SELECTION event where exactly we use the SQL statements to retrieve the output from the database table. START-OF-SELECTION. SELECT * FROM ZEMP_DETAILS1 INTO TABLE ITAB WHERE EMPNO IN EMP_NO. WRITE:/5 SY-ULINE(35). LOOP AT ITAB. WRITE:/5 SY-VLINE, 6 ITAB-EMPNO, 17 SY-VLINE,18 ITAB-EMPNAME,28 SY-VLINE , 39 SY-VLINE. ENDLOOP. To get the output in the table format we use 2 system variables such as SY- ULINE to draw the horizontal line and SY-VLINE to draw the vertical line. To get the header at the top of every page we use TOP-OF-PAGE event . TOP-OF-PAGE. WRITE:/5 SY-ULINE(35). WRITE:/5 SY-VLINE,6 'EMPNO',17 SY-VLINE,18 'EMPNAME',28 SY-VLINE, 39 SY-VLINE. WRITE:/5 SY-ULINE(35). In order to set the LINE-SIZE and the LINE-COUNT , REPORT ZSMALL_INTERACTIVE_REPORT MESSAGE-ID ZPA1 LINE-SIZE 255 we need to declare In the first line of the program and at the end of each and every page we can set the page no by using the END-OF PAGE event and at the end of selection we can set some message telling that the output is closed in the END- OF-SELECTION event. END-OF-PAGE. WRITE:/5 SY-ULINE(35). WRITE:/ 'THE PAGE NO IS',SY-PAGNO. END-OF-SELECTION. WRITE:/ 'THE RECORD IS CLOSED'. Up to here what we have performed is Classical report the events upto here same as interactive Some of the interactive events are: 1. At line Selection 2. At PFn.
  • 41. Created by Pavan Page 41 of 107 Mail: Praveen.srrec@gmail.com 3. At User-command. AT LINE-SELECTION event is triggered by double-clicking on the output value to get the drilldown report. AT LINE-SELECTION. IF SY-LSIND = 1. SELECT * FROM ZEMP_DETAILS1 INTO TABLE ITAB WHERE EMPNO = ITAB-EMPNO. LOOP AT ITAB. WRITE:/5 SY-VLINE,6 ITAB-EMPNO,17 SY-VLINE,18 ITAB-EMPNAME,28 SY-VLINE, 39 SY-VLINE. ENDLOOP. WRITE:/5 SY-ULINE(35). ELSEIF SY-LSIND = 2. SELECT * FROM ZCOMP_DETAILS INTO TABLE JTAB. LOOP AT JTAB. WRITE:/5 SY-VLINE,6 JTAB-COMP_NO,17 SY-VLINE,18 JTAB-COMP_NAME,28 SY-VLINE, 39 SY-VLINE. ENDLOOP. WRITE:/5 SY-ULINE(35). ENDIF. Complete Coding for Interactive report *&---------------------------------------------------------------------* *& Report ZSMALL_INTERACTIVE_REPORT * *& * *&---------------------------------------------------------------------* *& * *& * *&---------------------------------------------------------------------* REPORT ZSMALL_INTERACTIVE_REPORT MESSAGE-ID ZPA1 LINE-SIZE 255 LINE-COUNT 10(2). Tables: zemp_details1, zcomp_details. Data: itab like zemp_details1 occurs 0 with header line. Data: Jtab like zCOMP_details occurs 0 with header line. SELECT-OPTIONS: EMP_NO FOR ZEMP_DETAILS1-EMPNO. INITIALIZATION. EMP_NO-LOW = '1000'. EMP_NO-HIGH = '4000'. EMP_NO-SIGN = 'I'. EMP_NO-OPTION = 'BT'. APPEND EMP_NO. CLEAR EMP_NO. AT SELECTION-SCREEN. IF EMP_NO-LOW < '1000'. MESSAGE S000(ZPA1). ELSEIF EMP_NO-HIGH > '4000'. MESSAGE S001. ENDIF. START-OF-SELECTION.
  • 42. Created by Pavan Page 42 of 107 Mail: Praveen.srrec@gmail.com SELECT * FROM ZEMP_DETAILS1 INTO TABLE ITAB WHERE EMPNO IN EMP_NO. WRITE:/5 SY-ULINE(35). LOOP AT ITAB. WRITE:/5 SY-VLINE, 6 ITAB-EMPNO, 17 SY-VLINE,18 ITAB-EMPNAME,28 SY-VLINE , 39 SY-VLINE. ENDLOOP. TOP-OF-PAGE. WRITE:/5 SY-ULINE(35). WRITE:/5 SY-VLINE,6 'EMPNO',17 SY-VLINE,18 'EMPNAME',28 SY-VLINE, 39 SY-VLINE. WRITE:/5 SY-ULINE(35). END-OF-PAGE. WRITE:/5 SY-ULINE(35). WRITE:/ 'THE PAGE NO IS',SY-PAGNO. END-OF-SELECTION. WRITE:/ 'THE RECORD IS CLOSED'. AT LINE-SELECTION. IF SY-LSIND = 1. SELECT * FROM ZEMP_DETAILS1 INTO TABLE ITAB WHERE EMPNO = ITAB-EMPNO. LOOP AT ITAB. WRITE:/5 SY-VLINE,6 ITAB-EMPNO,17 SY-VLINE,18 ITAB-EMPNAME,28 SY-VLINE, 39 SY-VLINE. ENDLOOP. WRITE:/5 SY-ULINE(35). ELSEIF SY-LSIND = 2. SELECT * FROM ZCOMP_DETAILS INTO TABLE JTAB. LOOP AT JTAB. WRITE:/5 SY-VLINE,6 JTAB-COMP_NO,17 SY-VLINE,18 JTAB-COMP_NAME,28 SY-VLINE, 39 SY-VLINE. ENDLOOP. WRITE:/5 SY-ULINE(35). ENDIF. After executing this report if you click on the output any name or number then it will take you to the another line for which you have defined coding as above AT PF ’n’ event is triggered by clicking on the function key assigned at the n value wherein n can vary from 5 to 9. If we go to se41, we can get menus, items and different function keys, which we are using for secondary list in interactive report. AT PF7.
  • 43. Created by Pavan Page 43 of 107 Mail: Praveen.srrec@gmail.com Now to set an PF-STATUS we have to go to Menu Painter (Se41). This Pf status is for GUI. Goto se 41 and create a menu list or just follow this In your program write the following code SET PF-STATUS 'ZPA1_MENU'. And now double click on ZPA1_MENU
  • 44. Created by Pavan Page 44 of 107 Mail: Praveen.srrec@gmail.com Fill all the necessary fields and then press enter
  • 45. Created by Pavan Page 45 of 107 Mail: Praveen.srrec@gmail.com Click on this to expand the menu bar options
  • 46. Created by Pavan Page 46 of 107 Mail: Praveen.srrec@gmail.com Give any name to your object and double click on the same line
  • 47. Created by Pavan Page 47 of 107 Mail: Praveen.srrec@gmail.com In the application tool bar it provides option in output such as open, back, exit, folder etc, Fill your required option here so that it will be displayed in the output and then press enter
  • 48. Created by Pavan Page 48 of 107 Mail: Praveen.srrec@gmail.com Select Static or Dynamic text and then press enter
  • 49. Created by Pavan Page 49 of 107 Mail: Praveen.srrec@gmail.com Give your Function Text and in the icon name press F4 and select relevant icon to be displayed at output
  • 50. Created by Pavan Page 50 of 107 Mail: Praveen.srrec@gmail.com
  • 51. Created by Pavan Page 51 of 107 Mail: Praveen.srrec@gmail.com
  • 52. Created by Pavan Page 52 of 107 Mail: Praveen.srrec@gmail.com You have to assign any function keys to the object for which u have created and then press enter
  • 53. Created by Pavan Page 53 of 107 Mail: Praveen.srrec@gmail.com
  • 54. Created by Pavan Page 54 of 107 Mail: Praveen.srrec@gmail.com Here you can see your added function keys or else you can add from here also
  • 55. Created by Pavan Page 55 of 107 Mail: Praveen.srrec@gmail.com Complete code of present report *&---------------------------------------------------------------------* *& Report ZSMALL_INTERACTIVE_REPORT * *& * *&---------------------------------------------------------------------* *& * *& * *&---------------------------------------------------------------------* REPORT ZSMALL_INTERACTIVE_REPORT MESSAGE-ID ZPA1 LINE-SIZE 255 LINE-COUNT 10(2). Tables: zemp_details1, zcomp_details. Data: itab like zemp_details1 occurs 0 with header line. Data: Jtab like zCOMP_details occurs 0 with header line. SELECT-OPTIONS: EMP_NO FOR ZEMP_DETAILS1-EMPNO. SET PF-STATUS 'ZPA1_MENU'. INITIALIZATION. EMP_NO-LOW = '1000'. EMP_NO-HIGH = '4000'. EMP_NO-SIGN = 'I'. EMP_NO-OPTION = 'BT'. APPEND EMP_NO. CLEAR EMP_NO. AT SELECTION-SCREEN. IF EMP_NO-LOW < '1000'. MESSAGE S000(ZPA1). ELSEIF EMP_NO-HIGH > '4000'. MESSAGE S001. ENDIF. START-OF-SELECTION. SELECT * FROM ZEMP_DETAILS1 INTO TABLE ITAB WHERE EMPNO IN EMP_NO. LOOP AT ITAB. WRITE:/5 SY-VLINE,6 ITAB-EMPNO,17 SY-VLINE,18 ITAB-EMPNAME,28 SY-VLINE, 39 SY-VLINE. HIDE: ITAB-EMPNO. ENDLOOP. WRITE:/5 SY-ULINE(35). TOP-OF-PAGE. WRITE:/5 SY-ULINE(35). WRITE:/5 SY-VLINE,6 'EMPNO',17 SY-VLINE,18 'EMPNAME',28 SY-VLINE, 39 SY-VLINE. WRITE:/5 SY-ULINE(35). END-OF-PAGE. WRITE:/5 SY-ULINE(35).
  • 56. Created by Pavan Page 56 of 107 Mail: Praveen.srrec@gmail.com WRITE:/ 'THE PAGE NO IS',SY-PAGNO. END-OF-SELECTION. WRITE:/ 'THE RECORD IS CLOSED'. AT LINE-SELECTION. IF SY-LSIND = 1. SELECT * FROM ZEMP_DETAILS1 INTO TABLE ITAB WHERE EMPNO = ITAB-EMPNO. LOOP AT ITAB. WRITE:/5 SY-VLINE,6 ITAB-EMPNO,17 SY-VLINE,18 ITAB-EMPNAME,28 SY-VLINE, 39 SY-VLINE. ENDLOOP. WRITE:/5 SY-ULINE(35). ELSEIF SY-LSIND = 2. SELECT * FROM ZCOMP_DETAILS INTO TABLE JTAB. LOOP AT JTAB. WRITE:/5 SY-VLINE,6 JTAB-COMP_NO,17 SY-VLINE,18 JTAB-COMP_NAME,28 SY-VLINE, 39 SY-VLINE. ENDLOOP. WRITE:/5 SY-ULINE(35). ENDIF. AT PF7. IF SY-LSIND = 1. SELECT * FROM ZEMP_DETAILS1 INTO TABLE ITAB WHERE EMPNO = ITAB-EMPNO. LOOP AT ITAB. WRITE:/5 SY-VLINE,6 ITAB-EMPNO,17 SY-VLINE,18 ITAB-EMPNAME,28 SY-VLINE, 39 SY-VLINE. ENDLOOP. WRITE:/5 SY-ULINE(35). ELSEIF SY-LSIND = 2. SELECT * FROM ZCOMP_DETAILS INTO TABLE JTAB. LOOP AT JTAB. WRITE:/5 SY-VLINE,6 JTAB-COMP_NO,17 SY-VLINE,18 JTAB-COMP_NAME,28 SY-VLINE, 39 SY-VLINE. ENDLOOP. WRITE:/5 SY-ULINE(35). ENDIF. AT USER-COMMAND. IF SY-UCOMM = '0001'.
  • 57. Created by Pavan Page 57 of 107 Mail: Praveen.srrec@gmail.com IF SY-LSIND = 1. SELECT * FROM ZEMP_DETAILS1 INTO TABLE ITAB WHERE EMPNO = ITAB-EMPNO. LOOP AT ITAB. WRITE:/5 SY-VLINE,6 ITAB-EMPNO,17 SY-VLINE,18 ITAB-EMPNAME,28 SY-VLINE, 39 SY-VLINE. ENDLOOP. WRITE:/5 SY-ULINE(35). ELSEIF SY-LSIND = 2. SELECT * FROM ZCOMP_DETAILS INTO TABLE JTAB. LOOP AT JTAB. WRITE:/5 SY-VLINE,6 JTAB-COMP_NO,17 SY-VLINE,18 JTAB-COMP_NAME,28 SY-VLINE, 39 SY-VLINE. ENDLOOP. WRITE:/5 SY-ULINE(35). ENDIF. ENDIF.
  • 58. Created by Pavan Page 58 of 107 Mail: Praveen.srrec@gmail.com Logical Data Base Builder: A logical database is a special ABAP/4 program which combines the contents of certain database tables. You can link a logical database to an ABAP/4 report program as an attribute. The logical database then supplies the report program with a set of hierarchically structured table lines which can be taken from different database tables. If you need to find the logical database for a table name, you can used SE36 - Logical Database Builder. Steps:- Go to transaction SE36 Click Extras -> Table usage Supply the Table name and hit enter. A Display Logical Database will be shown on a pop-up window. More Information from help.sap.com Logical databases are special ABAP programs that retrieve data and make it available to application programs. The most common use of logical databases is still to read data from database tables and linking them to executable ABAP programs while setting the program contents. You edit logical databases using the Logical Database Builder in the ABAP Workbench. However, since Release 4.5A, it has also been possible to call logical databases independently of this tool using the function module LDB_PROCESS. This allows you to call several logical databases from any ABAP program, nested in any way. It is also possible to call a logical database more than once in a program, if it has been programmed to allow this. This is particularly useful for executable programs, allowing them to use more than one logical database and process a database more than once. Logical databases contain Open SQL statements that read data from the database. You do not therefore need to use SQL in your own programs. The logical database reads the program, stores them in the program if necessary, and then passes them
  • 59. Created by Pavan Page 59 of 107 Mail: Praveen.srrec@gmail.com line by line to the application program or the function module LDB_PROCESS using an interface work area. Views of Data in Logical Databases Logical databases provide a particular view of database tables. It is appropriate to use logical databases if the database tables you want to read correspond largely to the structure of the logical database and where the flow of the system program (select - read - process - display) meets the requirements of the application. The data structure in a logical database is hierarchical. Many tables in the R/3 System are linked to each other using foreign key relationships. Some of these dependencies form tree-like hierarchical structures. Logical databases read data from database tables that are part of these structures.
  • 60. Created by Pavan Page 60 of 107 Mail: Praveen.srrec@gmail.com A logical database can read the lines of these tables one after the other into an executable program in a sequence which is normally defined by the hierarchical structure. The term logical database is sometimes used to mean not only the program itself, but also the data that it can procure. Tasks of Logical Databases Logical databases serve mainly to reuse predefined functionality for reading data from database tables, but they can also be programmed for other tasks. To keep the application logic of application programs free from technical details, logical databases can perform the following tasks: · Reading the same data for several programs. The individual programs do not then need to know the exact structure of the relevant database tables (and especially not their foreign key relationships). Instead, they can rely on the logical database to read the database entries in the right order during the GET event. · Defining the same user interface for several programs. Logical databases have a built-in selection screen. Therefore, all of the programs that use the logical database have the same user interface. · Central authorization checks Authorization checks for central and sensitive data can be programmed centrally in the database to prevent them from being bypassed by simple application programs. · Improving Performance If you want to improve response times, logical databases permit you to take a number of measures to achieve this (for example, using joins instead of nested SELECT statements). These become immediately effective in all of the application programs concerned and save you from having to modify their source code.
  • 61. Created by Pavan Page 61 of 107 Mail: Praveen.srrec@gmail.com Goto Tcode SE36 to create logical Data base
  • 62. Created by Pavan Page 62 of 107 Mail: Praveen.srrec@gmail.com Give your short description and then press enter
  • 63. Created by Pavan Page 63 of 107 Mail: Praveen.srrec@gmail.com Give your table name here Give the text same as in declared in your table Again Declare your Table here
  • 64. Created by Pavan Page 64 of 107 Mail: Praveen.srrec@gmail.com Give the second node which should be hierarchically under the root node and enter the short description with the database table Name
  • 65. Created by Pavan Page 65 of 107 Mail: Praveen.srrec@gmail.com Give your second table name and the short text should be same as declared in your table for this particular table
  • 66. Created by Pavan Page 66 of 107 Mail: Praveen.srrec@gmail.com Select your table and then click on Selections Button
  • 67. Created by Pavan Page 67 of 107 Mail: Praveen.srrec@gmail.com
  • 68. Created by Pavan Page 68 of 107 Mail: Praveen.srrec@gmail.com
  • 69. Created by Pavan Page 69 of 107 Mail: Praveen.srrec@gmail.com
  • 70. Created by Pavan Page 70 of 107 Mail: Praveen.srrec@gmail.com Now uncomment your select-options and give any name for your select option
  • 71. Created by Pavan Page 71 of 107 Mail: Praveen.srrec@gmail.com This is our complete code after uncommenting few lines SELECT-OPTIONS : empno FOR ZEMP_DETAILS1-EMPNO. * Parameter for search pattern selection (Type SY-LDB_SP): * PARAMETERS p_sp AS SEARCH PATTERN FOR TABLE ZEMP_DETAILS1. SELECT-OPTIONS : compno FOR ZCOMP_DETAILS-COMP_NO. * Enable DYNAMIC SELECTIONS for selected nodes : SELECTION-SCREEN DYNAMIC SELECTIONS FOR TABLE ZEMP_DETAILS1. SELECTION-SCREEN DYNAMIC SELECTIONS FOR TABLE ZCOMP_DETAILS. * Enable FIELD SELECTION for selected nodes :
  • 72. Created by Pavan Page 72 of 107 Mail: Praveen.srrec@gmail.com Now go back to your initial screen and select your table and then Select Source code
  • 73. Created by Pavan Page 73 of 107 Mail: Praveen.srrec@gmail.com Now double click on TOP Include which is used for Header.
  • 74. Created by Pavan Page 74 of 107 Mail: Praveen.srrec@gmail.com Now check whether the tables you have defined are uncommented or not??
  • 75. Created by Pavan Page 75 of 107 Mail: Praveen.srrec@gmail.com Now go back to your Program screen and double click on Routines
  • 76. Created by Pavan Page 76 of 107 Mail: Praveen.srrec@gmail.com Now click on the include Double click on top include BASEN001 for emp details table here my table is ZEMP_DETAILS1
  • 77. Created by Pavan Page 77 of 107 Mail: Praveen.srrec@gmail.com Now uncomment the SQL statement and enter the field and the database table name according to the logical database builder.
  • 78. Created by Pavan Page 78 of 107 Mail: Praveen.srrec@gmail.com Now go back to includes screen and in the same way as done above for employee details now double click on Company details and uncomment the SQL statements then SAVE, CHECK and ACTIVATE the screen. Click BACK and SAVE, CHECK & ACTIVATE the screen until u reach the main screen and SAVE the logical database. Thus the logical database is constructed. In order to generate the query report, first construct the logical database and generation of query report is as follows. The transaction codes used in Query reports are: 1. SQ01 – For creating Query. 2. SQ02 – For creating Infoset. 3. SQ03 – For creating User. First u need to create the USER and generate the INFOSET, in turn can produce the Query report.
  • 79. Created by Pavan Page 79 of 107 Mail: Praveen.srrec@gmail.com Infoset: An SAP Infoset (formerly known as a Functional Area) is crucial for ABAP query usage (in SAP versions 4.6A - onward). The reason for Info Sets being important is because many R/3 clients find themselves faced with how to develop useful reports from an application using 20k+ tables. In addition, many clients desire to use third-party reporting tools; i.e., Crystal Reports. In this article, we will look at what an R/3 Infoset and how they relate to Crystal Reports. 1. Knowledge learned in this article can be put to use when: 2. Users require an understanding of how InfoSets are used within SAP R/3 3. Users require an understanding of the various methods of developing InfoSets 4. Users require an understanding of how InfoSets are used in concert with Crystal Reports. Report developers cannot be expected to cull through the thousands of tables and fields R/3 presents - even from a single logical database. Therefore, some form of technical shortcut is beneficial. InfoSets, when used with ABAP queries are an example of an available shortcut. At its simplest definition, an InfoSet determines which tables and/or fields within a table, queries may reference. To accomplish this, InfoSets are typically based upon table joins or logical databases (LDBs). Therefore, an Infoset is, for lack of a better term, a form of Ubber View (Super View).
  • 80. Created by Pavan Page 80 of 107 Mail: Praveen.srrec@gmail.com Go to Transaction Code SQ01. Now follow this path Environment Usergroups
  • 81. Created by Pavan Page 81 of 107 Mail: Praveen.srrec@gmail.com Give your Query name and Click on create button Click on Create Button
  • 82. Created by Pavan Page 82 of 107 Mail: Praveen.srrec@gmail.com Save or press Enter
  • 83. Created by Pavan Page 83 of 107 Mail: Praveen.srrec@gmail.com Go back to User Group initial screen and then click on Assign users and InfoSets Click on Assign users & InfoSets
  • 84. Created by Pavan Page 84 of 107 Mail: Praveen.srrec@gmail.com Assign any user existing in SAP and press enter
  • 85. Created by Pavan Page 85 of 107 Mail: Praveen.srrec@gmail.com Now go back to your user screen from there follow this menu path Environment InfoSets Or go to Tcode SQ02
  • 86. Created by Pavan Page 86 of 107 Mail: Praveen.srrec@gmail.com
  • 87. Created by Pavan Page 87 of 107 Mail: Praveen.srrec@gmail.com Give your InfoSet query name and press Create button
  • 88. Created by Pavan Page 88 of 107 Mail: Praveen.srrec@gmail.com Give your InfoSet name Select a logical data base by pressing F4
  • 89. Created by Pavan Page 89 of 107 Mail: Praveen.srrec@gmail.com This is the logical database which we had created in SE36
  • 90. Created by Pavan Page 90 of 107 Mail: Praveen.srrec@gmail.com
  • 91. Created by Pavan Page 91 of 107 Mail: Praveen.srrec@gmail.com You can drag & drop your fields on to the screen save it and come back to main screen
  • 92. Created by Pavan Page 92 of 107 Mail: Praveen.srrec@gmail.com Now in SQ03 assign your Infoset which u had created just above
  • 93. Created by Pavan Page 93 of 107 Mail: Praveen.srrec@gmail.com Now to create Query goto USER screen and click on the ENVIRONMENT QUERIES and the Query name and click on the CREATE button. It will ask for infoset. Choose the corresponding Infoset. Select your infoset query and then save it
  • 94. Created by Pavan Page 94 of 107 Mail: Praveen.srrec@gmail.com
  • 95. Created by Pavan Page 95 of 107 Mail: Praveen.srrec@gmail.com
  • 96. Created by Pavan Page 96 of 107 Mail: Praveen.srrec@gmail.com Select your infoset
  • 97. Created by Pavan Page 97 of 107 Mail: Praveen.srrec@gmail.com Now on the left hand side u can find the fields in the dictionary and on the right hand side the field required for the Query report. Drag and drop the field you want for the Query report and click on the GENERATE button.
  • 98. Created by Pavan Page 98 of 107 Mail: Praveen.srrec@gmail.com After selecting your fields click on generate
  • 99. Created by Pavan Page 99 of 107 Mail: Praveen.srrec@gmail.com In the Tcode SQ03 enter your title Select ABAP List
  • 100. Created by Pavan Page 100 of 107 Mail: Praveen.srrec@gmail.com Click on Next screen
  • 101. Created by Pavan Page 101 of 107 Mail: Praveen.srrec@gmail.com Check the Tables for which u want to make a query
  • 102. Created by Pavan Page 102 of 107 Mail: Praveen.srrec@gmail.com Click on Next screen
  • 103. Created by Pavan Page 103 of 107 Mail: Praveen.srrec@gmail.com ABAP/4 Query can generate the following 3 simple reports: Basic List: It is the simple reports. Statistics: Reports with statistical functions like Average, Percentages. Ranked Lists: For analytical reports. - For creating a ABAP/4 Query, programmer has to create user group and a functional group. Functional group can be created using with or without logical database table. Finally, assign user group to functional group. Finally, create a query on the functional group generated. Select the fields and click next screen
  • 104. Created by Pavan Page 104 of 107 Mail: Praveen.srrec@gmail.com Now select the data fields that you want to appear in the query report and click on the SAVE button. Then Click on the TEST button. Click on Basic List
  • 105. Created by Pavan Page 105 of 107 Mail: Praveen.srrec@gmail.com Select the fields which u want to display in the output The fields which u have selected will be displayed here
  • 106. Created by Pavan Page 106 of 107 Mail: Praveen.srrec@gmail.com In Logical data base(SE36) maintain all fields Such as Selection Texts, Documentation and then in query report SQ01 execute your report Execute the report
  • 107. Created by Pavan Page 107 of 107 Mail: Praveen.srrec@gmail.com