Professional Documents
Culture Documents
ABAP Object Oriented Approach For Reports - Initial Design
ABAP Object Oriented Approach For Reports - Initial Design
I would start this post with few bad examples. After them, I would take you back to
procedural program very simple program using subroutines. After that, I would show you
the way I generally write Report programs using OO.
The core logic of the report is hidden beneath the local classes in the program. As I
have noted in when to use local class, this limits the reuse of the core logic
Static methods along with other issues, lacks the basic advantage of method
redefinition as we recently discussed in ABAP Static vs Instance method Which to
use when?
By simply looking at the design you would think what would be the benefit of using the
methods as wrapper to the subroutines. This design has more issues than the previous one
as this creates lot more confusion on which method calls which.
ENDIF.
ENDIF.
ENDMETHOD.
"VALIDATE_PLANT
Procedural Report
Lets take a step back and think how this design can be improved. So, Start with this basic
program. Program has few subroutines to validate the input, get the data and generate the
output.
*&---------------------------------------------------------------------*
*& Purpose - Simple procedrual report
*& Author - Naimesh Patel
*& URL
- http://zevolving.com/?p=2037
*&---------------------------------------------------------------------*
REPORT ztest_np_t100_report.
*
DATA: v_msgnr TYPE t100-msgnr.
DATA: v_arbgb LIKE t100-arbgb.
*
DATA: t_t100 TYPE STANDARD TABLE OF t100.
DATA: o_salv TYPE REF TO cl_salv_table.
*
SELECTION-SCREEN: BEGIN OF BLOCK blk1 WITH FRAME TITLE text-t01.
PARAMETERS:
p_arbgb TYPE t100-arbgb OBLIGATORY.
SELECT-OPTIONS: s_msgno FOR v_msgnr.
SELECTION-SCREEN: END OF BLOCK blk1.
*
AT SELECTION-SCREEN ON p_arbgb.
PERFORM f_validate_message_class.
*
START-OF-SELECTION.
PERFORM f_get_data.
*
END-OF-SELECTION.
PERFORM f_show_data.
*
FORM f_validate_message_class.
SELECT SINGLE arbgb
INTO v_arbgb
FROM t100
WHERE arbgb = p_arbgb.
IF sy-subrc NE 0.
MESSAGE 'Message Class not found' TYPE 'E'.
ENDIF.
ENDFORM.
"f_validate_message_Class
*
*
FORM f_get_data.
SELECT * FROM t100
INTO TABLE t_t100
WHERE arbgb = p_arbgb
AND
msgnr IN s_msgno.
ENDFORM.
"f_get_Data
*
*
FORM f_show_data.
TRY.
CATCH cx_salv_msg .
ENDTRY.
ENDFORM.
"f_show_Data
Next Post
In the next post, I would cover, how you can achieve much more flexible and reusable
design. The second part is now available at ABAP Object Oriented Approach for Reports
Redesign (or file)