lab3_reportingalv (4)
TRANSCRIPT
-
7/25/2019 Lab3_ReportingALV (4)
1/13
ABAP ProgrammingLaboratory 3
Reporting
-
7/25/2019 Lab3_ReportingALV (4)
2/13
Reporting
Objectives:
1. Creating a program
2. Using a table
3. Using an interval parameter in SELECTION-OPTIONS
4. Using types and local variables
5. Using SELECT statement6. Creating routines and subroutines
7. Displaying using ALV
ABAP Programming Laboratory 3. Reporting2
-
7/25/2019 Lab3_ReportingALV (4)
3/13
Study case
3
1. Create a program named ZTEST_DT_008 without Top Include.
2. The table that will be used must be declared (ZTEST_FEAA_001).
3. In SELECT-OPTIONS an interval parameter p_uname of ztest_feaa_001-username type will be
declared.
4. In Start-of-selection a MAIN routine will be called. Two routines will be called in this procedure:
READand ALV_DISPLAY.
In READ subroutine the data from ZTEST_FEAA_001 will be read, the data beying filtered by
the interval value of p_uname;
In ALV_DISPLAY we will use REUSE_ALV_GRID_DISPLAY.
for creating the f ieldcatalog table we will use another routine ALV_FIELDCAT.
ABAP Programming Laboratory 3. Reporting
-
7/25/2019 Lab3_ReportingALV (4)
4/13
Creating a program
4
In SE80, right-click on Program, then choose Create.
Give it a name and unselect Top Include, then click on Continue.
ABAP Programming Laboratory 3. Reporting
-
7/25/2019 Lab3_ReportingALV (4)
5/13
Creating a program
5
Select as a type Executable program, as a Status Test program, then click Continue.
ABAP Programming Laboratory 3. Reporting
-
7/25/2019 Lab3_ReportingALV (4)
6/13
Writing the code
6
REPORT ZTEST_DT_008.
TABLES ztest_feaa_001.
TYPES gty_t_ztest_feaa_001 TYPE TABLE OF ztest_feaa_001.
SELECTION-SCREEN BEGIN OF BLOCK 1.
SELECT-OPTIONS: s_uname FOR ztest_feaa_001-username.SELECTION-SCREEN END OF BLOCK 1.
INITIALIZATION.
START-OF-SELECTION.PERFORM main.
END-OF-SELECTION.
ABAP Programming Laboratory 3. Reporting
-
7/25/2019 Lab3_ReportingALV (4)
7/13
Writing the code
7
FORM main.
DATA: lt_feaa_001 TYPE gty_t_ztest_feaa_001.
PERFORM readCHANGING lt_feaa_001.
PERFORM alv_displayUSING lt_feaa_001.
ENDFORM. " MAIN
FORM readCHANGING ch_t_feaa_001 TYPE gty_t_ztest_feaa_001.
SELECT * FROM ztest_feaa_001
INTO TABLE ch_t_feaa_001
WHERE username IN s_uname.
ENDFORM. " READ
ABAP Programming Laboratory 3. Reporting
-
7/25/2019 Lab3_ReportingALV (4)
8/13
Writing the code
8
FORM alv_displayUSING im_t_feaa_001 TYPE gty_t_ztest_feaa_001.
TYPE-POOLS: slis.DATA: lt_fieldcat TYPE slis_t_fieldcat_alv,
ls_fieldcat TYPE slis_fieldcat_alv,
ls_layout TYPE slis_layout_alv.
PERFORM alv_fieldcatCHANGING lt_fieldcat.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid
is_layout = ls_layout
it_fieldcat = lt_fieldcat
TABLES
t_outtab = im_t_feaa_001
EXCEPTIONS
program_error = 1
OTHERS = 2.IF sy-subrc 0.
MESSAGE e001(00) WITH 'Atentie, eroare ALV!'.
* &1&2&3&4&5&6&7&8
ENDIF.
ENDFORM. "alv_display
ABAP Programming Laboratory 3. Reporting
Select Pattern in order to call a function.
-
7/25/2019 Lab3_ReportingALV (4)
9/13
Writing the code
9
FORM alv_fieldcatCHANGING ch_t_fieldcat TYPE slis_t_fieldcat_alv.DATA: ls_fieldcat TYPE slis_fieldcat_alv.
ls_fieldcat-fieldname = 'MANDT'.
ls_fieldcat-key = 'X'.ls_fieldcat-reptext_ddic = text-001.
APPEND ls_fieldcat TO ch_t_fieldcat.
CLEAR: ls_fieldcat.
ls_fieldcat-fieldname = 'USERNAME'.
ls_fieldcat-reptext_ddic = text-002.
APPEND ls_fieldcat TO ch_t_fieldcat.
CLEAR: ls_fieldcat.
ls_fieldcat-fieldname = 'FIRSTNAME'.
ls_fieldcat-reptext_ddic = text-003.APPEND ls_fieldcat TO ch_t_fieldcat.
CLEAR: ls_fieldcat.
ABAP Programming Laboratory 3. Reporting
-
7/25/2019 Lab3_ReportingALV (4)
10/13
Writing the code
10
ls_fieldcat-fieldname = 'LASTNAME'.ls_fieldcat-reptext_ddic = text-004.
APPEND ls_fieldcat TO ch_t_fieldcat.
CLEAR: ls_fieldcat.
ls_fieldcat-fieldname = 'DATEOFBIRTH'.
ls_fieldcat-reptext_ddic = text-005.
APPEND ls_fieldcat TO ch_t_fieldcat.
CLEAR: ls_fieldcat.
ls_fieldcat-fieldname = 'ADDRESS'.
ls_fieldcat-reptext_ddic = text-006.
APPEND ls_fieldcat TO ch_t_fieldcat.
CLEAR: ls_fieldcat.
ENDFORM. " ALV_FIELDCAT
All the Text Symbols text-001 ... text-006 should be created by forward navigation, inserting the text we
want to be displayed, from MANDT to ADDRESS.
ABAP Programming Laboratory 3. Reporting
-
7/25/2019 Lab3_ReportingALV (4)
11/13
Running the program
11
Select two username values from the table.
Select Execute.
ABAP Programming Laboratory 3. Reporting
-
7/25/2019 Lab3_ReportingALV (4)
12/13
Running the program
12
Check the data from the table (SE16n). Type the name of the table, then select Execute.
ABAP Programming Laboratory 3. Reporting
-
7/25/2019 Lab3_ReportingALV (4)
13/13
Summary
13
In this laboratory work we created a program, we used a table and an interval parameter in aSELECTION-OPTIONS, we used types and local variables, SELECT statement, we createdroutines and subroutines and we displayed the filtered data using ALV.
ABAP Programming Laboratory 3. Reporting