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

values from structured objects

Former Member
0 Likes
603

Hi,

I'm not a developer and I have no intention to understand ABAP objects. I can only write a procedural things using modules and such.

But I need to write a code to get some values from a higly structured object. Here is my problem in detail.

I have a FM called ISM_ECP_KPI_GET_COST_ESTIMATE which returns the parametr EX_CE of type "class" CL_COST_ESTIMATE. This class has an atribute NUMBER_SERVICE which is type "class interface" CL_COST_COMPONENT_NO_SERVICE. This class interface has an atribute T_COMPONENTS which is of table type CKF_NS_COMPONENT_TABLE. This has a line type (structure) CL_COSTING_COMPONENT which again leads to another class interface;(

And finaly here, this class interface has an atribute PRICES where are my values. There are usually more lines in the atribute T_COMPONENTS and I need to access one by one to get the price from it.

Can anybody please help me out here and advice some ABAP coding how to access the data?

Thanks to anybody contributing.

pk

3 REPLIES 3
Read only

naimesh_patel
Active Contributor
0 Likes
535

Attribute T_COMPONENTS in class CL_COST_COMPONENT_NO_SERVICE is private. So, you can't access it outside the class. There is a method GET_COMPONENT in the same class to get the component. Similarly, you can't access the PRICES outside the class as it is protected attribute. However, you can use the method GET_PRICE to get the price line.


DATA: o_cost_est TYPE REF TO cl_cost_estimate,
      o_services TYPE REF TO cl_cost_component_no_service,
      o_comp     TYPE REF TO cl_costing_component.

CALL FUNCTION 'ISM_ECP_KPI_GET_COST_ESTIMATE'
  IMPORTING
    ex_ce = o_cost_est.

o_services = o_cost_est->number_service.

* you need to know the ID
DATA: lv_id TYPE ck_component_id.  "<<
o_services->get_component( EXPORTING im_id = lv_id
                           IMPORTING ex_component = o_comp ).

* to get prices, need to call method GET_PRICE
DATA: lv_curtp TYPE ckf_price_line-curtp,  " <<
      lv_currency TYPE ckf_price_line-currency,  "<<
      lv_price TYPE ckf_price_line,
      lv_return TYPE i.
o_comp->get_price(
  EXPORTING
    im_curtp       = lv_curtp
    im_currency    = lv_currency
  IMPORTING
    ex_price       = lv_price
    ex_return      = lv_return
  EXCEPTIONS
    not_found      = 1
    internal_error = 2
    OTHERS         = 3
       ).
IF sy-subrc <> 0.
  MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
             WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.

Regards,

Naimesh Patel

Read only

0 Likes
535

Hi,

Thanks for the wonderful script. There is a small problem within the method GET_COMPONENT. It says, that the CONDITION_NOT_FOUND. sy-subrc is eq 4.

METHOD get_component.

  • ...

DATA:

l_component_line TYPE ckf_ns_component_table_line.

READ TABLE t_components INTO l_component_line

WITH TABLE KEY id = im_id.

IF sy-subrc <> 0.

>>>>>> RAISE component_not_found.

ENDIF.

ex_component = l_component_line-component.

ENDMETHOD.

Read only

Ramneek
Product and Topic Expert
Product and Topic Expert
0 Likes
535

Hello Peter,

I think the problem is that you do not know the Item Number (value to be sent in the parameter IM_ID). What is the value that you pass to this parameter?

I am not sure how you would identify the Component ID, perhaps the method GET_ID of the class CL_COST_COMPONENT_NO_SERVICE could be used in your case.

Hope it helps.

Thank you,

Ramneek