Skip to Content

Access to an attribute of a value node of a component controller

Hello experts,

I'm new to the area of SAP CRM Web Client UI development. My problem is probably very simple and you will surely smile about it.

I have created my own component with the value node FILE (that consists of five atributes) in the component controller. Unfortunately I have not figured out yet how I can access the value of an attribute.

The first thing I do not know is where I can find the controller-ID.

In addition, I get an syntax error Field "TYPED_CONTEXT->FILE->COLLECTION_WRAPPER->GET_FIRST(" unknown in the line with "lo_entity = me->comp_controller->typed_context->file->collection_wrapper->get_first( ).".

Currently no functionality is included in my code, because firstly I want to understand the basics.

method OP_FILEUPLOAD.

  data lo_entity       type ref to if_bol_bo_property_access.
  data lv_file_name    type string.
  data lr_file_content type ref to data.
  field-symbols <lv_file_name> type string.

  IF ( comp_controller is INITIAL ).
    get_controller( 'xxxx' ).
  ENDIF.

  lo_entity = me->comp_controller->typed_context->file->collection_wrapper->get_first( ).

  while lo_entity is bound.
    lv_file_name = lo_entity->get_property_as_string( 'FILE_NAME' ).
    lr_file_content = lo_entity->get_property( 'FILE_CONTENT_STRING' ).

    assign lr_file_content->* to <lv_file_content>.

    lo_entity = me->typed_context->file->collection_wrapper->get_next( ).
  endwhile.

endmethod.

I hope that I will manage my "problem" with your help!

Sebastian

Edited by: Sebastian Lenz on Jun 27, 2011 2:35 PM

Add a comment
10|10000 characters needed characters exceeded

Related questions

3 Answers

  • Best Answer
    Posted on Jun 28, 2011 at 08:14 AM

    Hi Sebastian,

    The issue is in the following line of your code:

    lo_entity = me->comp_controller->typed_context->file->collection_wrapper->get_first( ).

    The 'typed_context' belongs to your own component controller class and not the standard framework superclass. So, you need to replace this single line of code with something as follows (assuming that your component controller class is ZCL_CUSTOM_BSPWDCOMPONENT_IMPL):

    DATA lr_coco TYPE REF TO ZCL_CUSTOM_BSPWDCOMPONENT_IMPL.
    
    lr_coco ?= me->comp_controller.
    lo_entity = lr_coco->typed_context->file->collection_wrapper->get_first( ).
    

    The me->comp_controller reference will refer to the standard framework superclass of all component controllers and this does not have any typed_context attribute with it. The real component controller that gets created when you create a BSP component will have this attribute. That is why you need to first cast it to your own reference type before trying to access its typed_context.

    And if your value node will have only single values, then you can as well do the following to access the attribute ATTRIB1 of context node node1:

    DATA lv_value TYPE string.
    lv_value = lr_coco->typed_context->node1->get_attrib1( attribute path = '' ).
    

    Basically all attributes can be accessed by above code by using the right getter method.

    Regards,

    Shiromani

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 27, 2011 at 03:58 PM

    Can you put down your requirement or a scenario, that would be helpful to understand things more.

    Thanks,

    Shobhit

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jun 27, 2011 at 04:22 PM

    Hello Shobhit,

    Please excuse my undetailed description.

    I would like to reuse the standard component GS_FILE_UPLOAD in my own component ZSL_FILE_UPLOAD, because I would like to upload data from an CSV-File to SAP CRM.

    I've already done that data is stored in the attribue FILE_CONTENT_STRING of the value node FILE in the component controller of my own component. My question is, how can I access the data in an value node of an component controller? Fore more information I uploaded an screenshot of my CMP_WB: http://img560.imageshack.us/img560/7767/screenshotgs.png

    I do hope this explanation helps you to help me 😉

    Kind regards,

    Sebastian

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.