Application Development and Automation 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: 
Read only

ABAP Objects and table processing (with logical databases)

Former Member
0 Likes
696

I have a report that is written right now using procedural abap and a logical database. The report is structured follows (high level):


start-of-selection.

get pernr.

  perform get_it0001 using wtab.
  perform get_it0002 using wtab.
  perform get_it0003 using wtab.

  append wtab to itab.

end-of-selection.

  call function 'reuse_alv_grid_display'
    exporting
      i_structure_name       = 'itabstructure'
    tables
      t_outtab               = itab.

So basically I'm going through a bunch of personnel numbers, getting a few infotypes and outputting to ALV. I don't see where ABAP Objects is going to help me for this particular program.

Can somebody show me where OO ABAP would make this easier? Does it even make sense to use OO when you're processing with a logical database? (Not just PNP, but any logical database in general).

Thanks in advance.

1 ACCEPTED SOLUTION
Read only

uwe_schieferstein
Active Contributor
0 Likes
599

Hello Lee

I assume that the routines GET_ITnnnn are written by yourself. For reading infotypes ABAP Objects provides us with same very helpful classes as shown below:

* define data
  DATA:
    gif_employee      type ref to if_pt_employee,
    go_employee       type ref to cl_pt_employee,
    gt_infotypes      TYPE tim_tmw_itlist_tab,
    go_control        TYPE REF TO if_pt_td_control,
    go_data           TYPE REF TO if_pt_td_base,
    go_pnnnn          TYPE REF TO if_pt_td_itnnnn,
    gt_p0001          TYPE TIM_P0001_TAB,
    gt_p0002          TYPE TIM_P0002_TAB,
    gt_p0003          TYPE TIM_P0003_TAB.


start-of-selection.

GET pernr.

<b>* Create employee instance</b>
  gif_employee = cl_pt_employee=>get_employee( pernr ).
  go_employee ?= gif_employee.

<b>* Get master infotypes (0001, 0002)</b>
  CALL METHOD go_employee->get_master_data
    EXPORTING
      im_begda = id_fromdate
      im_endda = id_todate
    IMPORTING
*      EX_I0000 =
      EX_I0001 = gt_p0001
      EX_I0002 = gt_p0002
*      EX_I0007 =
*      EX_I0008 =
      .

<b>* Append all other required infotypes to itab</b>
  APPEND '0003' TO gt_infotypes.

  CALL METHOD go_employee->get_infotypes
    EXPORTING
      i_itlist      = gt_infotypes
      i_fromdate    = id_fromdate  " start date
      i_todate      = id_todate    " end date
*      I_FILTER      =
      i_noauthcheck = 'X'
    IMPORTING
      e_result      = gt_infty_request
      e_retcd       = gd_retcd.
* Please see documentation of parameter e_retcd...

  
  LOOP AT gt_infty_request INTO go_control.
    go_data = go_control->data.  <b>" get data object</b>
 
*   Casting
    TRY.
        go_pnnnn ?= go_data.
 
      CATCH cx_sy_move_cast_error.
        CONTINUE.
    ENDTRY.
 
<b>*   Convert infotype (semi-transparent -> transparent)</b>
    CALL METHOD cl_hr_pnnnn_type_cast=>prelp_to_pnnnn
      EXPORTING
        prelp = lo_pnnnn->prelp
      IMPORTING
        pnnnn = gs_p0003.
 
    APPEND gs_p0027 TO gt_p0003.
  ENDLOOP.

The class CL_PT_EMPLOYEE provides us already with very easy access to so-called master infotypes (000, 0001, 0002, 0007 and 0008). All other infotypes can be read using method GET_INFOTYPES.

Using these classes we have a very convenient and standardized way of accessing all kinds of infotypes.

Regards

Uwe

3 REPLIES 3
Read only

uwe_schieferstein
Active Contributor
0 Likes
600

Hello Lee

I assume that the routines GET_ITnnnn are written by yourself. For reading infotypes ABAP Objects provides us with same very helpful classes as shown below:

* define data
  DATA:
    gif_employee      type ref to if_pt_employee,
    go_employee       type ref to cl_pt_employee,
    gt_infotypes      TYPE tim_tmw_itlist_tab,
    go_control        TYPE REF TO if_pt_td_control,
    go_data           TYPE REF TO if_pt_td_base,
    go_pnnnn          TYPE REF TO if_pt_td_itnnnn,
    gt_p0001          TYPE TIM_P0001_TAB,
    gt_p0002          TYPE TIM_P0002_TAB,
    gt_p0003          TYPE TIM_P0003_TAB.


start-of-selection.

GET pernr.

<b>* Create employee instance</b>
  gif_employee = cl_pt_employee=>get_employee( pernr ).
  go_employee ?= gif_employee.

<b>* Get master infotypes (0001, 0002)</b>
  CALL METHOD go_employee->get_master_data
    EXPORTING
      im_begda = id_fromdate
      im_endda = id_todate
    IMPORTING
*      EX_I0000 =
      EX_I0001 = gt_p0001
      EX_I0002 = gt_p0002
*      EX_I0007 =
*      EX_I0008 =
      .

<b>* Append all other required infotypes to itab</b>
  APPEND '0003' TO gt_infotypes.

  CALL METHOD go_employee->get_infotypes
    EXPORTING
      i_itlist      = gt_infotypes
      i_fromdate    = id_fromdate  " start date
      i_todate      = id_todate    " end date
*      I_FILTER      =
      i_noauthcheck = 'X'
    IMPORTING
      e_result      = gt_infty_request
      e_retcd       = gd_retcd.
* Please see documentation of parameter e_retcd...

  
  LOOP AT gt_infty_request INTO go_control.
    go_data = go_control->data.  <b>" get data object</b>
 
*   Casting
    TRY.
        go_pnnnn ?= go_data.
 
      CATCH cx_sy_move_cast_error.
        CONTINUE.
    ENDTRY.
 
<b>*   Convert infotype (semi-transparent -> transparent)</b>
    CALL METHOD cl_hr_pnnnn_type_cast=>prelp_to_pnnnn
      EXPORTING
        prelp = lo_pnnnn->prelp
      IMPORTING
        pnnnn = gs_p0003.
 
    APPEND gs_p0027 TO gt_p0003.
  ENDLOOP.

The class CL_PT_EMPLOYEE provides us already with very easy access to so-called master infotypes (000, 0001, 0002, 0007 and 0008). All other infotypes can be read using method GET_INFOTYPES.

Using these classes we have a very convenient and standardized way of accessing all kinds of infotypes.

Regards

Uwe

Read only

Former Member
0 Likes
599

Thank you very much Uwe, that was an excellent reply! I'm going to try using some of those on my next development task.

Is it true that SAP is in the process of 'objectifying' the collection of logical databases so it leverages ABAP Objects more and more? Perhaps this is the beginning such a conversion?

Thanks again, help much appreciated!

Lee

Read only

0 Likes
599

Hello Lee

The SAP_BASIS part of SAP is becoming more and more object-oriented. Module that have been developed completely using ABAP-OO are SRM and RE-FX.

The "classical" modules like FI, CO, MM and SD still contain plenty of procedural coding. However, it is really important to start now with ABAP-OO. If you require a certain function do not only check the function library (SE37) but also the class builder (SE24).

For example, if I need to deal with controlling area I will use the methods of class CL_REEXC_CONTROLLING_AREA, message handling is done using CL_RECA_MESSAGE_LIST. Other useful classes are:

- company code => CL_REEXC_COMPANY_CODE

- texts of objects => CL_REEX_SERVICES_FICO

Regards

Uwe