cancel
Showing results for 
Search instead for 
Did you mean: 

Entity initial for the new bol component created

Former Member
0 Kudos

I created a new component using component workbench. Created a model node of bol entity BuilAddress and added 3 fields to the view through configuration. Added a button using the html page. In the event handler of the button Iam trying to access the value entered in those fields using the code.

  lr_entity ?= me->typed_context->mapaddress->collection_wrapper->get_current( ).

but lr_entity is always initial. I also checked the collection wrapper,it's also initial. Please let me know if Iam missing any step.

Thanks in advance.

Accepted Solutions (0)

Answers (6)

Answers (6)

Former Member
0 Kudos

Hi All,

I just wanted the fields for Address like Street,city,state...So I created a new value node and the existing code itself worked. But Can anyone please tell me why it did not work for a model node.

Thanks,

Arvind Raj.

kumar5
Active Contributor
0 Kudos

Hi,

The Model Node uses the BOL to get the data. So for this you first need to load the BOL and only then you can get the entities .

In the Web UI when we login the BOL gets loaded and we will get the data through BOL.

On the other side in case of Value Node we get the data from database tables directly.

Thanks

Kumar

Former Member
0 Kudos

Thanks Kumar, Can u please let me know how to load the Bol for BuilAddress.

Former Member
0 Kudos

Hi Arvind

If you are in custom component

Use model as ONEORDER

---> use the Dynamic Query Object BuilHeaderAdvancedSearch


from this you will get the ressut object as Root Object BuilHeader ( collection of entities ie., result )

in the DO_INIT_CONTEXT of the view impl class you can write the code to get the data ( ie., get the query instance and pass the query parameters then search for result . From result we can get child entities and add the required one to our node in the component )

--->From the builheader entity you get the Dependent Object BuilAddress entity

( builaddress is the child entity of builheader )

Regards

Dinesh Gurram

kumar5
Active Contributor
0 Kudos

You can use below code :

data: lr_core type ref to cl_crm_bol_core,

      lr_query type ref to CL_CRM_BOL_QUERY_SERVICE,

      LR_RESULT TYPE REF TO IF_BOL_ENTITY_COL,

      LR_ENTITY TYPE REF TO cl_crm_bol_entity,

************************************************

      lr_children type ref to IF_BOL_ENTITY_COL,

      lr_child type ref to cl_crm_bol_entity,

      lr_parent type ref to cl_crm_bol_entity,

lr_core = cl_Crm_bol_core=>get_instance( ).

*Load the component set

LR_CORE->LOAD_COMPONENT_SET( 'BP_APPL'  ).

*----------------------------------------------------------------

*Create the query instance by passing the search object name

lr_query = CL_CRM_BOL_QUERY_SERVICE=>get_instance(

                  iv_query_name = 'BuilHeaderSearch' ).

From this you can get related entities i.e. BuilAddress and find the relevant data from them.

Thanks

Kumar Gaurav.

kumar5
Active Contributor
0 Kudos

From the above code you will get the query in lr_query.

Use below code to set search  parameters and find the result and then from result getting the entities and then find relation 'BuilAddress'.

WA_PARMS-NAME = 'BP_NUMBER'.

WA_PARMS-VALUE = '81'.

Append WA_PARMS to IT_PARMS.

*Add the selection parameters

CALL METHOD LR_QUERY->SET_QUERY_PARAMETERS

   EXPORTING

     IT_PARAMETERS = IT_PARMS.

*Get the result list

LR_RESULT = LR_QUERY->GET_QUERY_RESULT( ).

*----------------------------------------------------------------

*Get the first object(entity) in the result list

LR_ENTITY = LR_RESULT->GET_FIRST( ).

*If the entity is bound

WHILE LR_ENTITY IS BOUND.

*Get the related entities by mentioning the relation ship name

lr_children = lr_entity->get_related_entity(

           iv_relation_name = 'BuilAddress' ).

Now from lr_children you can get the address fields for the particular Partner.

i_tab-STRING2 = LR_children->GET_PROPERTY_AS_STRING( 'STREET' ).

Hope it helps

Thanks

Kumar

former_member188098
Active Contributor
0 Kudos

Hi,

If you are Testing your custom component independently with bsp_wd_cmpwb,As i think you will not able to get data with

lr_entity ?= me->typed_context->mapaddress->collection_wrapper->get_current( ).

Try to put your custom component in standard component like BP_Head and then try with login in CRM_UI.

Regards,



jotsaroop_singh
Active Participant
0 Kudos

Hi Arvind,

Concept:

Actually BuilAddress is a dependent object on BuilHeader. you can not have a direct entity created for BuilAddress. you must have a BuilHeader and then use create related entity for BuilAddress.

Solution to your problem

  1. Add one more context node to your view, BuilHeader.
  2. At do_it_context method of view implementation class, create the entity for BuilHeader from factory methods.
  3. Then create the related entity for BuilAddress.

Don't hesitate to ask further question if needed.

Regards,

JotSaroop Singh

Former Member
0 Kudos

I had created another component with a model node of type BuilHeader and there too Iam facing the same problem. Iam not able to get the values entered on the screen. The entity is always initial.

Thanks

Arvind Raj.

kumar5
Active Contributor
0 Kudos

Hi Arvind,

You have written the correct code. Its how you can get the current entity.

But its not possible to get the Data from the fields as you are trying to achieve.

Thanks

Kumar

jotsaroop_singh
Active Participant
0 Kudos

Do you get "not bound" text written in the fields ?

Former Member
0 Kudos

Yes,I got "not bound" text in the fields.But I changed the method get_x of the attribute and removed that text. Similarly the field was not enabled so I commented the code in get_I_X and passed the value

rv_disabled = 'FALSE'.

Former Member
0 Kudos

Hi Arvind. .

Builaddress is a model node

You cannot make the attributes of that node enabled by using GET_I method. . .it is possible for value node. . .

You can enable the model node ( builaddress ) by using the method Set_view__group_context method

Regards

Dinesh Gurram

jotsaroop_singh
Active Participant
0 Kudos

Hi Arvind,

NOTE: do the below activities for the view in which you have builheader only.

Delete all that stuff what you did to remove "not bound message".  Write the following piece of code in your "do_init_context" method of view implementation.

DATA: lr_builheader_factory TYPE REF TO cl_crm_bol_entity_factory,

   lv_bol_core TYPE REF TO cl_crm_bol_core,

   lt_params TYPE crmt_name_value_pair_tab,

   ls_params TYPE crmt_name_value_pair,

   lr_ent TYPE REF TO cl_crm_bol_entity,

   lr_col_wrap TYPE REF TO cl_bsp_wd_collection_wrapper.

   ls_params-name = 'BP_CATEGORY'.

   ls_params-value = '1'.

   APPEND ls_params TO lt_params.

   ls_params-name = 'BP_GROUP'.

   ls_params-value = '0001'.

   APPEND ls_params TO lt_params.

   lv_bol_core = cl_crm_bol_core=>get_instance( ).

   lr_builheader_factory = lv_bol_core->get_entity_factory( iv_entity_name = 'BuilHeader' ).

   lr_ent ?= lr_builheader_factory->create( iv_params = lt_params ).

   lr_col_wrap ?= me->typed_context->contextnodename->get_collection_wrapper( ).

   lr_col_wrap->add(

     EXPORTING

       iv_entity    =  lr_ent ).

Former Member
0 Kudos

I don't have a node of type BuilHeader but just BuilAddress.

kavindra_joshi
Active Contributor
0 Kudos

Instead of

  lr_entity ?= me->typed_context->mapaddress->collection_wrapper->get_current( ).

do try this

  lr_entity ?= me->ztyped_context->mapaddress->collection_wrapper->get_current( ).

~Kavindra


Former Member
0 Kudos

Hi Kavindra,

I tried this but it's throwing an error.

-Arvind Raj.

Former Member
0 Kudos

Hi,

I think there is no data present.Bind the context nodes using component controller or custom controller.add your custom component to another standard component and redefine the method WD_USAGE_INITIALIZE in the component controller of standard component and bind the context nodes of custom component and standard component.

Regards.

V CH Bharadwaj

kumar5
Active Contributor
0 Kudos

Hi Arvind,

First check you set method of the fields . I think your entity is initial there as well.

Put a breakpoint in set method of the fields and then try to debug.

If the entity is initial in set method as well then you can not get the entity with value in the event.

Hope it helps

Thanks

Kumar Gaurav.

kumar5
Active Contributor
0 Kudos

Also check DO_INIT_CONTEXT method of the view .

Thanks

Kumar Gaurav

Former Member
0 Kudos

I checked in the set method of the field and as you mentioned the current entity is also initial. So what should be done to get the entered values in this case.

Thanks

Arvind Raj.