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

Changing OO Reference variable

Former Member
0 Likes
837

Good Day Ladies and Gentle,men,

I am endeavouring to make a change to a BADI method attached to HR transaction PTMW. I need to modify a value in a field in structure p2002. Because the p2002 data is only accessible via the interface attached to, in this case, the object I_RECORD, I can only read it by dereferencing (is that the right term?) the object a couple of times.

Once I've done this I can read the p2002 structure data into my work area ls_p2002, and modify the data I need to. My question is, how do I write this information back to either a) the i_record object or b) to a new object copying the i_record data but with my new p2002 data for passing out via the e_time_data structure.

   
method process_it2002.
**************************************************************** 
*  Import I_RECORD    TYPE REF TO  IF_PT_TD_CONTROL
*         I_TIME_DATA TYPE         TIM_BLP_REQUEST_TAB
*  Export E_MESSAGES  TYPE         BAPIRET2_T
*         E_TIME_DATA TYPE         TIM_BLP_REQUEST_TAB
**************************************************************** 
 
  data:
        ls_it2002 type p2002,
        ls_data   type ref to cl_pt_td_it2002,
        ls_time   type ref to CL_PT_TD_CONTROL,
        ls_p2002  type p2002.

  field-symbols: <fs1> type any.

  ls_time ?= i_record.
  ls_data ?= i_record->data.
  ls_p2002 = ls_data->if_pt_td_it2002~p2002.

  if ls_p2002-subty = 'TRNG'.
    ls_p2002-stdaz = ( ls_p2002-enduz - ls_p2002-beguz ) / 3600.           "My Code Change
   
* need to get ls_p2002 back into i_record or a copy of this object so I can
* update e_time_data.   
  endif.

*  append i_time_data to e_time_data.

endmethod. 

Any help would be greatly appreciated.

Thanks, Stephen

1 ACCEPTED SOLUTION
Read only

MarcinPciak
Active Contributor
0 Likes
758

I think the method IF_PT_TD_IT2002~SET_DATA serves this purpose. So the solution would be directly changing I_RECORD with


....
ls_data->IF_PT_TD_IT2002~SET_DATA( ls_p2002 ).

Regards

Marcin

2 REPLIES 2
Read only

MarcinPciak
Active Contributor
0 Likes
759

I think the method IF_PT_TD_IT2002~SET_DATA serves this purpose. So the solution would be directly changing I_RECORD with


....
ls_data->IF_PT_TD_IT2002~SET_DATA( ls_p2002 ).

Regards

Marcin

Read only

Former Member
0 Likes
758

Thanks for your help, Marcin. That was the answer.