Documente Academic
Documente Profesional
Documente Cultură
REPORTs are generally formatted output from the manipulated data. With the report, we can
come to the idea about further decision.
In abap, reports are like the output processed from a large amount of data obtained.
These data are selected from the tables of the ABAP dictionary and after that the selected data are
processed using ABAP statement and given in the form of reports.
To generate a report in the abap, first the user request is obtained in the form of the values
obtained from the user. Depending upon the values, the report is generated.
In ABAP, these reports are classified as:
classical report
interactive report
ALV
(ABAP LIST VIEWER) report
interactive ALV report.
Classical reports:
these are reports developed for the first time. Now several reports outcomes this report. But
still because of its nature, it was still in the use.
Classical reports are simplied form of report allows the user to view the report generated
without the options severed by other kind of reports.
these classical reports are created with the use of write statement in the ABAP program.
Let's consider an example using the table SPFLI.
SPFLI this is a demo table containing the details of FLIGHT SCHEDULE.
Eg:
let's find the list of files scheduled, to find it we need the input like whether to take all the
records of flight schduled or only for selected no of flights is required.
to know this the values is obtained from the user in the form of values, in abap we obtain
using the parameter value in case of single value or using select-options in case of range of values.
Here i am using the select-options for getting the input and using these values, will fetch
the data from the SPFLI table.
Coding for the classical report for generating report on the flight schedule using the input as
the airlines:
*&---------------------------------------------------------------------*
*& Report ZSIM_REPORT1
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT zsim_report1 NO STANDARD PAGE HEADING .
TABLES spfli.
SELECT-OPTIONS: sele FOR spfli-carrid NO-EXTENSION.
DATA: BEGIN OF it OCCURS 0,
carrid TYPE spfli-carrid,
connid TYPE spfli-connid,
countryfr TYPE spfli-countryfr,
cityfrom TYPE spfli-cityfrom,
countryto TYPE spfli-countryto,
cityto TYPE spfli-cityto,
fltime TYPE spfli-fltime,
deptime TYPE spfli-deptime,
arrtime TYPE spfli-arrtime,
distance TYPE spfli-distance,
fltype TYPE spfli-fltype,
END OF it.
DATA: wa_it LIKE LINE OF it.
DATA: BEGIN OF down OCCURS 0,
strn TYPE string,
END OF down.
*LOOP AT down.
* WRITE:/ down-strn.
*ENDLOOP.
*
*LOOP AT it INTO wa_it.
* WRITE: / wa_it-carrid , wa_it-connid , wa_it-countryfr , wa_it-cityfrom ,
*
wa_it-countryto , wa_it-cityto , wa_it-fltime , wa_it-deptime , wa_it-arrtime ,
*
wa_it-distance, wa_it-fltype .
* ENDLOOP.
TOP-OF-PAGE.
WRITE: / 'SIMPLE CLASSICAL REPORT OF AIRLINES'.
SKIP 2.
SET PF-STATUS 'MENU'.
AT USER-COMMAND.
CASE sy-ucomm.
WHEN 'EXIT'.
LEAVE PROGRAM.
WHEN 'SAVE'.
CALL FUNCTION '/SAPDMC/LSM_F4_FRONTEND_FILE'
EXPORTING
PATHNAME
= 'C:\'
CHANGING
pathfile
= FILEPATH
*
EXCEPTIONS
*
CANCELED_BY_USER
=1
*
SYSTEM_ERROR
=2
*
OTHERS
=3
.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
* BIN_FILESIZE
=
filename
= FILEPATH
FILETYPE
= 'ASC'
* APPEND
=''
* WRITE_FIELD_SEPARATOR
=''
* HEADER
= '00'
* TRUNC_TRAILING_BLANKS
=''
* WRITE_LF
= 'X'
* COL_SELECT
=''
* COL_SELECT_MASK
=''
* DAT_MODE
=''
* CONFIRM_OVERWRITE
=''
* NO_AUTH_CHECK
=''
* CODEPAGE
=''
* IGNORE_CERR
= ABAP_TRUE
* REPLACEMENT
= '#'
* WRITE_BOM
=''
* TRUNC_TRAILING_BLANKS_EOL
= 'X'
* WK1_N_FORMAT
=''
* WK1_N_SIZE
=''
* WK1_T_FORMAT
=''
* WK1_T_SIZE
=''
* WRITE_LF_AFTER_LAST_LINE
= ABAP_TRUE
* SHOW_TRANSFER_STATUS
= ABAP_TRUE
* VIRUS_SCAN_PROFILE
= '/SCET/GUI_DOWNLOAD'
* IMPORTING
* FILELENGTH
=
tables
data_tab
= it
* FIELDNAMES
=
* EXCEPTIONS
* FILE_WRITE_ERROR
=1
* NO_BATCH
=2
* GUI_REFUSE_FILETRANSFER
=3
* INVALID_TYPE
=4
* NO_AUTHORITY
=5
* UNKNOWN_ERROR
=6
* HEADER_NOT_ALLOWED
=7
* SEPARATOR_NOT_ALLOWED
=8
* FILESIZE_NOT_ALLOWED
=9
* HEADER_TOO_LONG
= 10
* DP_ERROR_CREATE
= 11
* DP_ERROR_SEND
= 12
* DP_ERROR_WRITE
= 13
* UNKNOWN_DP_ERROR
= 14
* ACCESS_DENIED
= 15
* DP_OUT_OF_MEMORY
= 16
* DISK_FULL
= 17
* DP_TIMEOUT
= 18
* FILE_NOT_FOUND
= 19
* DATAPROVIDER_EXCEPTION
= 20
* CONTROL_FLUSH_ERROR
= 21
* OTHERS
= 22
.
IF sy-subrc <> 0.
MESSAGE: 'SUCCESSFULLY SAVED IN filepath ' TYPE 'S'.
ENDIF.
.
* WHEN .
* WHEN OTHERS.
ENDCASE.
Output:
giving the input from AA to UA in the select option screen. The extension is made not to
display.
The output was shown as below with the total entries of 26.
and these output can be viewed for a time, to share it and to save it the same function module
is used and with the use of that the result can be saved in desired format as
in the above snapshot it is shown that the output is saved in the desired path and the values
are present in the file opened.
INTERACTIVE REPORT:
Interactive reports are similar to the classical report differing only in terms of responding the
user. In the interactive report, as the name implies, it is interactive. Like when we got the view of
the classical report and if we want the detail about the specified record, then we have to click on
that record to display the details of the concern record.
Eg:
let's consider the similar example what we tired with the classical report only with the
difference that is now going to be a interactive one.
Things used other than in classical report:
keyword : hide
at line-selection.
System fields like: sy-lsind, sy-pagno.
Coding for the interactive program:
*&---------------------------------------------------------------------*
*& Report ZSIM_REPORT2
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT zsim_report2 NO STANDARD PAGE HEADING.
TABLES spfli.
TABLES sbook.
SELECT-OPTIONS: sele FOR spfli-carrid NO-EXTENSION.
DATA: BEGIN OF it OCCURS 0,
carrid TYPE spfli-carrid,
connid TYPE spfli-connid,
countryfr TYPE spfli-countryfr,
cityfrom TYPE spfli-cityfrom,
countryto TYPE spfli-countryto,
cityto TYPE spfli-cityto,
fltime TYPE spfli-fltime,
deptime TYPE spfli-deptime,
arrtime TYPE spfli-arrtime,
distance TYPE spfli-distance,
fltype TYPE spfli-fltype,
END OF it.
DATA: wa_it LIKE LINE OF it.
DATA: BEGIN OF it2 OCCURS 0,
carrid TYPE sbook-carrid,
connid TYPE sbook-connid,
fldate TYPE sbook-fldate,
bookid TYPE sbook-bookid,
customid TYPE sbook-customid,
custtype TYPE sbook-custtype,
smoker TYPE sbook-smoker,
luggweight TYPE sbook-luggweight,
wunit TYPE sbook-wunit,
invoice TYPE sbook-invoice,
class TYPE sbook-class,
forcuram TYPE sbook-forcuram,
forcurkey TYPE sbook-forcurkey,
loccuram TYPE sbook-loccuram,
loccurkey TYPE sbook-loccurkey,
order_date TYPE sbook-order_date,
SELECT * FROM spfli INTO CORRESPONDING FIELDS OF TABLE it WHERE carrid IN sele ORDER BY carrid
ASCENDING cityfrom ASCENDING.
LOOP AT it INTO wa_it.
AT FIRST.
WRITE:/8 'AIRLINE |' , 18 'FLIGHT NUMBER |', 34 'COUNTRY |' , 43 'DEPARTURE CITY |' ,
59 'ARRIVAL COUNTRY |' , 77 'ARRIVAL CITY |' , 92 'FLIGHT TIME |' , 106 'DEPARTURE |' , 117 ' ARRIV
AL |',
128 'DISTANCE |' , 139 'CHARTER |'.
ENDAT.
WRITE: /8 wa_it-carrid ,18 wa_it-connid , 34 wa_it-countryfr ,43 wa_it-cityfrom ,
59 wa_it-countryto , 77 wa_it-cityto , 92 wa_it-fltime ,106 wa_it-deptime ,117 wa_it-arrtime ,
127 wa_it-distance, 139 wa_it-fltype .
HIDE wa_it-carrid.
AT LAST.
SKIP 2.
ULINE.
SKIP 2.
WRITE:/ 'NO OF AIRLINES FOUND:', sy-dbcnt.
ENDAT.
ENDLOOP.
AT LINE-SELECTION.
CASE sy-lsind.
WHEN 1.
SELECT carrid fldate bookid customid FROM sbook INTO CORRESPONDING FIELDS OF TABLE it2 WHERE
carrid = wa_it-carrid ORDER BY bookid ASCENDING customid ASCENDING.
LOOP AT it2 INTO wa_it2.
AT FIRST.
WRITE:/8 'AIRLINE |', 18 'FLIGHT DATE |', 32 'BOOKING ID |', 45 'CUSTOMER ID'.
ENDAT.
WRITE:/8 wa_it2-carrid, 19 wa_it2-fldate, 32 wa_it2-bookid,45 wa_it2-customid.
HIDE: wa_it2-bookid, wa_it2-carrid.
ENDLOOP.
WHEN 2.
REFRESH it2.
SELECT * FROM sbook INTO CORRESPONDING FIELDS OF TABLE it2 WHERE bookid = wa_it2-bookid
AND carrid = wa_it2-carrid.
*
*
*
*
*
*
*
*
screen 2:
screen 3:
in the interactive report as you can find above, that the user can interact with the report and
to the record that he wants and it depends on how the code was made.
wa_field-col_pos = 5.
wa_field-fieldname = 'DEPTIME'.
wa_field-tabname = 'IT1'.
wa_field-seltext_l = 'DEPARTURE TIME'.
APPEND wa_field TO fieldcat.
wa_field-col_pos = 6.
wa_field-fieldname = 'DISTANCE'.
wa_field-tabname = 'IT1'.
wa_field-seltext_l = 'DISTANCE'.
APPEND wa_field TO fieldcat.
ENDFORM.
FORM display.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program
= sy-cprog
i_callback_pf_status_set = 'MENU'
i_callback_user_command = 'UCOMM'
TABLES
t_outtab
= it1
.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
ENDFORM.
the above is the report generated using the ALV. This is the simple example of
alv generated by getting the input using select options. This is again the flight
schedule details.
INTERACTIVE ALV REPORT:
INTERACTIVE ALV report are advanced version of the ALV report. Here like the
interactive report the ALV can interact, using which we can fetch the required data.
Interactive alv report respond in the similar way like the interactive report with the difference that
these will be in the ALV format.
wa_fieldcat-col_pos = 1.
wa_fieldcat-fieldname = 'CARRID'.
wa_fieldcat-seltext_l = 'AIRLINE'.
APPEND wa_fieldcat TO fieldcat.
wa_fieldcat-col_pos = 2.
wa_fieldcat-fieldname = 'CONNID'.
wa_fieldcat-seltext_l = 'FLIGHT CODE'.
APPEND wa_fieldcat TO fieldcat.
wa_fieldcat-col_pos = 3.
wa_fieldcat-fieldname = 'FLDATE'.
wa_fieldcat-seltext_l = 'FLIGHT DATE'.
APPEND wa_fieldcat TO fieldcat.
wa_fieldcat-col_pos = 4.
wa_fieldcat-fieldname = 'BOOKID'.
wa_fieldcat-seltext_l = 'BOOKING ID'.
APPEND wa_fieldcat TO fieldcat.
wa_fieldcat-col_pos = 5.
wa_fieldcat-fieldname = 'CUSTOMID'.
wa_fieldcat-seltext_l = 'CUSTOMER ID'.
APPEND wa_fieldcat TO fieldcat.
wa_fieldcat-col_pos = 6.
wa_fieldcat-fieldname = 'CUSTTYPE'.
wa_fieldcat-seltext_l = 'CUSTOMER TYPE'.
APPEND wa_fieldcat TO fieldcat.
***************************************
wa_fieldcat1-col_pos = 1.
wa_fieldcat1-fieldname = 'CARRID'.
wa_fieldcat1-seltext_l = 'AIRLINE'.
APPEND wa_fieldcat1 TO fieldcat1.
wa_fieldcat1-col_pos = 2.
wa_fieldcat1-fieldname = 'CONNID'.
wa_fieldcat1-seltext_l = 'FLIGHT CODE'.
APPEND wa_fieldcat1 TO fieldcat1.
wa_fieldcat1-col_pos = 3.
wa_fieldcat1-fieldname = 'CITYFROM'.
wa_fieldcat1-seltext_l = 'CITY FROM'.
APPEND wa_fieldcat1 TO fieldcat1.
wa_fieldcat1-col_pos = 4.
wa_fieldcat1-fieldname = 'CITYTO'.
wa_fieldcat1-seltext_l = 'CITY TO'.
APPEND wa_fieldcat1 TO fieldcat1.
wa_fieldcat1-col_pos = 5.
wa_fieldcat1-fieldname = 'FLTIME'.
wa_fieldcat1-seltext_l = 'FLIGHT TIME'.
APPEND wa_fieldcat1 TO fieldcat1.
wa_fieldcat1-col_pos = 6.
wa_fieldcat1-fieldname = 'DISTANCE'.
wa_fieldcat1-seltext_l = 'DISTANCE'.
APPEND wa_fieldcat1 TO fieldcat1.
wa_fieldcat1-col_pos = 7.
wa_fieldcat1-fieldname = 'DISTID'.
wa_fieldcat1-seltext_l = 'DISTANCE IN'.
APPEND wa_fieldcat1 TO fieldcat1.
********
w_header-typ = 'H'.
w_header-info = 'BOOKING DETAILS OF FLIGHTS'.
APPEND w_header TO t_header.
CLEAR w_header.
**********
w_event-name = 'TOP_OF_PAGE'.
w_event-form = 'TOPPAGE'.
APPEND w_event TO t_event.
CLEAR w_event.
w_event-name = 'USER_COMMAND'.
w_event-form = 'SUB2'.
APPEND w_event TO t_event.
CLEAR w_event.
w_event1-name = 'TOP_OF_PAGE'.
w_event1-form = 'TOPPAGE1'.
APPEND w_event1 TO t_event1.
CLEAR w_event1.
w_event1-name = 'USER_COMMAND'.
w_event1-form = 'SUB3'.
APPEND w_event1 TO t_event1.
CLEAR w_event1.
*****************
SELECT-OPTIONS: s_carrid FOR struct1-carrid.
START-OF-SELECTION.
SELECT * FROM sbook INTO CORRESPONDING FIELDS OF TABLE it1 WHERE carrid IN s_carrid.
DELETE it1 FROM 100.
***********
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program
= sy-cprog
i_grid_title
= 'BOOKED FLIGHTS'
it_fieldcat
= fieldcat
it_events
= t_event
is_layout
= layout
TABLES
t_outtab
= it1.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
FORM toppage.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = t_header
i_logo
= 'LOGO_ALV'.
ENDFORM.
FORM sub2 USING ucomm LIKE sy-ucomm fields1 TYPE slis_selfield.
READ TABLE it1 INTO struct1 INDEX fields1-tabindex.
SELECT * FROM spfli INTO CORRESPONDING FIELDS OF TABLE it2 WHERE carrid = struct1-carrid.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-cprog
i_background_id = 'TEST'
i_grid_title
= 'LIST OF FLIGHTS BOOKED IN ID'
it_fieldcat
= fieldcat1
it_events
= t_event1
is_layout
= layout
TABLES
t_outtab
= it2.
ENDFORM.
FORM toppage1.
*&------------APPEND COMMENTRYOF SECONDRY SCREEN--------------------w_header1-typ = 'H'.
w_header1-info = 'LIST OF FLIGHTS'.
APPEND w_header1 TO t_header1.
w_header1-typ = 'S'.
w_header1-key = 'CUSTOMER'.
w_header1-info = struct1-carrid.
APPEND w_header1 TO t_header1.
CLEAR w_header1.
w_header1-typ = 'A'.
w_header1-info = struct1-customid.
APPEND w_header1 TO t_header1.
CLEAR w_header1.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = t_header1
i_logo
= 'LOGO_ALV'.
REFRESH t_header1.
ENDFORM.
FORM sub3 USING ucomm LIKE sy-ucomm fields1 TYPE slis_selfield.
READ TABLE it2 INTO struct2 INDEX fields1-tabindex.
SET PARAMETER ID 'AUN' FIELD struct2-carrid.
ENDFORM.
Screen 2:
in the screen 2, for the corresponding customer id and airline, how many flight booking are
there can be viewed.
End of report.