Hi developers,
I want to share with you a new way of doing reports. This tool allows you to create reports in 2 minutes. ZQ2R creates quickly reports from a query. The selection screen, selection texts and code are automatically generated.
The ZQ2R code is attached to this post.
An example is shown below.
The Query (SQVI)
After running ZQ2R, press the QuickViewer button
Here we will create a query to see the flights from New York City.
After you input the query’s name (FlightsFrom_NY) press the button Create.
In this example we will use the data source “Table join”.
Press the insert table button to add the following tables: SPFLI (Flight schedule), SFLIGHT (Flight) and SCARR (Airline).
Once selected the three tables, press the back button (F3).
Set the displayed fields and selection fields.
After selecting the report fields, you can set the sort sequence.
Finally save the query and get the report name.
ZQ2R
Copy and paste the assigned report (AQ01SYSTQV000001FLIGHTSFROM_NY)
After running ZQ2R, set the selection fields behavior.
You can also define default values by clicking the corresponding check box.
By clicking the “Sel. Text” column you can edit the selection texts.
Finally press the back button and the zq2r_flightsfrom_ny report will be created!
Now, you can run the newly created report from SE38 transaction
The automatically generated code (zq2r_flightsfrom_ny):
*&-----------------------------------------------------------------*
*& Report ZQ2R_FLIGHTSFROM_NY
*&-----------------------------------------------------------------*
REPORT zq2r_flightsfrom_ny.
*&-----------------------------------------------------------------*
*& Include ZQ2R_FLIGHTSFROM_NY_TOP
*&-----------------------------------------------------------------*
CONSTANTS:
c_cityfr TYPE spfli-cityfrom VALUE 'NEW YORK'.
TABLES:
spfli,
sflight.
TYPES:
tyr_carrid TYPE RANGE OF spfli-carrid,
tyr_fldate TYPE RANGE OF sflight-fldate,
BEGIN OF ty_data,
cityfrom TYPE spfli-cityfrom,
cityto TYPE spfli-cityto,
carrname TYPE scarr-carrname,
fldate TYPE sflight-fldate,
END OF ty_data,
tyt_data TYPE STANDARD TABLE OF ty_data.
DATA t_data TYPE STANDARD TABLE OF ty_data.
*&-----------------------------------------------------------------*
*& Include ZQ2R_FLIGHTSFROM_NY_SEL
*&-----------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK a WITH FRAME.
PARAMETER p_cityfr TYPE spfli-cityfrom DEFAULT c_cityfr.
SELECT-OPTIONS s_carrid FOR spfli-carrid MEMORY ID car.
SELECT-OPTIONS s_fldate FOR sflight-fldate MEMORY ID day OBLIGATORY.
SELECTION-SCREEN END OF BLOCK a.
*&-----------------------------------------------------------------*
*& Include ZQ2R_FLIGHTSFROM_NY_F01
*&-----------------------------------------------------------------*
*&-----------------------------------------------------------------*
*& Form SET_SELECTION_FIELD_DISABLED
*&-----------------------------------------------------------------*
FORM set_selection_field_disabled USING p_spname TYPE aqs_spname.
DATA lv_spname_length TYPE i.
lv_spname_length = strlen( p_spname ).
LOOP AT SCREEN.
IF screen-name(lv_spname_length) = p_spname.
screen-input = 0.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
ENDFORM. " SET_SELECTION_FIELD_DISABLED
*&-----------------------------------------------------------------*
*& Form GET_DATA
*&-----------------------------------------------------------------*
FORM get_data USING p_cityfr TYPE spfli-cityfrom
s_carrid TYPE tyr_carrid
s_fldate TYPE tyr_fldate
CHANGING t_data TYPE tyt_data.
SELECT spfli~cityfrom
spfli~cityto
scarr~carrname
sflight~fldate
FROM ( spfli
INNER JOIN sflight
ON sflight~carrid = spfli~carrid
AND sflight~connid = spfli~connid
INNER JOIN scarr
ON scarr~carrid = sflight~carrid )
INTO TABLE t_data
WHERE spfli~cityfrom = p_cityfr
AND spfli~carrid IN s_carrid
AND sflight~fldate IN s_fldate .
ENDFORM. " GET_DATA
*&-----------------------------------------------------------------*
*& Form ALV
*&-----------------------------------------------------------------*
FORM alv USING t_data TYPE tyt_data.
DATA:
o_sorts TYPE REF TO cl_salv_sorts,
o_columns TYPE REF TO cl_salv_columns,
o_display TYPE REF TO cl_salv_display_settings,
o_functions TYPE REF TO cl_salv_functions_list,
o_layout TYPE REF TO cl_salv_layout,
ls_key TYPE salv_s_layout_key,
o_alv TYPE REF TO cl_salv_table.
* Gel ALV object
TRY.
cl_salv_table=>factory(
IMPORTING
r_salv_table = o_alv
CHANGING
t_table = t_data ).
CATCH cx_salv_msg.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDTRY.
* ALV Sort
o_sorts = o_alv->get_sorts( ).
TRY.
o_sorts->add_sort( 'CITYFROM' ).
o_sorts->add_sort( 'CITYTO' ).
o_sorts->add_sort( 'CARRNAME' ).
CALL METHOD o_sorts->add_sort
EXPORTING
columnname = 'FLDATE'
sequence = if_salv_c_sort=>sort_down.
CATCH cx_salv_not_found
cx_salv_existing
cx_salv_data_error.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDTRY.
* Get columns
o_columns = o_alv->get_columns( ).
* Set the column optimization
o_columns->set_optimize( ).
o_display = o_alv->get_display_settings( ).
o_display->set_striped_pattern( abap_true ).
* Generic ALV functions
o_functions = o_alv->get_functions( ).
o_functions->set_all( ).
* Layout
o_layout = o_alv->get_layout( ).
ls_key-report = sy-repid.
o_layout->set_key( ls_key ).
o_layout->set_save_restriction( if_salv_c_layout=>restrict_none ).
o_alv->display( ).
ENDFORM. " ALV
AT SELECTION-SCREEN OUTPUT.
PERFORM set_selection_field_disabled: USING 'P_CITYFR'.
START-OF-SELECTION.
PERFORM get_data USING p_cityfr
s_carrid[]
s_fldate[]
CHANGING t_data.
END-OF-SELECTION.
PERFORM alv USING t_data.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
3 | |
3 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |