Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Procedural-2-OOPS

Former Member
0 Kudos

Hello experts,

I want to rebuild a procedural report to object oriented, can some one tell me which steps i have to do , to redesign it ?

My Report Structure is :

*Structured Types*    


TYPES:BEGIN OF ty_projnum,
             prj_num    TYPE zprojectmst-prj_num,
             prj_name   TYPE zprojectmst-prj_name,
             cat_num    TYPE zprojectcard-cat_num,
       END OF ty_projnum.*
 

TYPES:BEGIN OF    ......
 



  END OF
 

DATA: ........
 


**---------------------------------------------------------------------**
**       Select Options                          **
**---------------------------------------------------------------------**

*..*

**----------------------------------------------------------------------**
 
**     AT SELECTION-SCREEN*
 
**----------------------------------------------------------------------**
 
*...*
 
**---------------------------------------------------------------------**
 
**             S T A R T   O F   S E L E C T I O N                     **
 
**---------------------------------------------------------------------**
 
*...*
 
*with reforms*
 
*..*

Edited by: Matt on Sep 7, 2009 9:50 AM - fixed formatting - why was it all BOLD?

1 ACCEPTED SOLUTION

dirk_wittenberg
Contributor
0 Kudos

Hi

a possible general structure for your program could be:

report ydemo.

data: g_model type ref to ycl_report_model,

         g_viewer type ref to ycl_report_viewer.

initialization.

  create object g_model.

at selection-screen.

  g_model->set_selections( ... ).

start-of-selection.

  g_model->make_data_selections( ).

end-of-selection.

  create object g_viewer.
  g_viewer->display( g_model ).

YCL_REPORT_MODEL and YCL_REPORT_VIEWER are global classes. The first to select the data, make calculations and so on, the second to display the results.

I hope this helps you,

regards

Dirk

7 REPLIES 7

Sandra_Rossi
Active Contributor
0 Kudos

we can't answer as OOPS means an in-depth knowledge of the job done by the program, what you want to reuse, what already exists "outside". You must do it by yourself. Or ask a more precise question.

0 Kudos

So I am new in ABAP Object World, what i knew from Java World have tried on this case but i dont know if it write .

I maked a Class diagram with some classe what i created for the report.

the qustion here is :

is there some thing calls Report Class ? or a class which can do the same work like a report ?

regards

0 Kudos

In term of OOP, this question makes no sense. Frankly, I recommend you to train on OOP without looking at this program, learn the major notions and make tests with little programs. At the end, you'll better understand if it's worth rewriting your program (there may be no advantage to rewrite it). Have a look at [SDN ABAP Objects section|/docs/DOC-8024#section2 [original link is broken]]

dirk_wittenberg
Contributor
0 Kudos

Hi

a possible general structure for your program could be:

report ydemo.

data: g_model type ref to ycl_report_model,

         g_viewer type ref to ycl_report_viewer.

initialization.

  create object g_model.

at selection-screen.

  g_model->set_selections( ... ).

start-of-selection.

  g_model->make_data_selections( ).

end-of-selection.

  create object g_viewer.
  g_viewer->display( g_model ).

YCL_REPORT_MODEL and YCL_REPORT_VIEWER are global classes. The first to select the data, make calculations and so on, the second to display the results.

I hope this helps you,

regards

Dirk

0 Kudos

The selection screen (SELECT-OPTIONS, PARAMETERS) however, have to be in a procedural report. So, build on Dirk's code.

report ydemo.
 
data: g_model type ref to ycl_report_model,
 
         g_viewer type ref to ycl_report_viewer.
 
PARAMETERS: p_param TYPE ...

SELECT-OPTIONS: o_sel FOR ...

initialization.
 
  create object g_model.
 
at selection-screen.
 
  g_model->set_selections( i_param = p_param ir_sel = o_sel[] ).
 
start-of-selection.
 
  g_model->make_data_selections( ).
 
end-of-selection.
 
  create object g_viewer.
  g_viewer->display( g_model ).

Within set_selections, I define ir_sel as a STANDARD TABLE. I then use:

FIELD-SYMBOLS: <lr_sel> TYPE STANDARD TABLE.
CREATE DATA me->rr_sel LIKE ir_sel. " rr_sel is an instance attribute of type REF TO DATA
ASSIGN me->rr_sel->* TO <lr_sel>.
<lr_sel> = ir_sel.

In make_data_selections, I do this

FIELD-SYMBOLS: <lr_sel> TYPE STANDARD TABLE.
ASSIGN me->rr_sel->* TO <lr_sel>.

SELECT * FROM table WHERE sel IN <lr_sel>.

matt

nomssi
Active Contributor
0 Kudos

Advice from Martin Fowler's Refactoring book:

http://sourcemaking.com/refactoring/convert-procedural-design-to-objects

hope this helps,

Jacques Nomssi Nzali

matt
Active Contributor
0 Kudos

Normally, I'm against single links - but this is a good one. Very relevant.