cancel
Showing results for 
Search instead for 
Did you mean: 

BOL~GenIL filling node with an specific entity

former_member206638
Participant
0 Kudos

Hi gurus.

I'm working with my own BOL and GenIL models and objects, and due to the business requirement I came across a weird situation that I haven't been able to solve yet.

I have a BOL object which, respect to its "parent" object, has a 1...n cardinality, like a Business Partner (1)-> Business Address (0...n).

My problem is: how do I show an specific entity from that collection on screen?

I've added a Model Node in my component, corresponding to this object, but (of course) it's automatically filled by the BOL buffer with the first entity of the collection. How can I manipulate that?

How can I choose, in runtime, which entity to show, if I want to show specifically one?

Thanks a lot.

FSA

Accepted Solutions (1)

Accepted Solutions (1)

former_member206638
Participant
0 Kudos

Thanks man.

I thought about doing this. Could you please provide a code template to see how to manipulate the collection, or give me some clues on how do I access my collection in runtime?

And where should I code this, the do_init_context of my value node? On every single get_xxx method of the node attibute?

FSA

Former Member
0 Kudos

First I would try having two BOL based context nodes - one for the collection of 'addresses' and one for the individual address.

From what I got so far, you have the collection. Based on your criteria you can find the right BOL entity (1 address). Then you can set it into the context node that represents one address. The only different from the previously proposed solution is that you do not create a value node, but a model node - saves some time

You could perform the above in the init_context but keep in mind that it is executed only 1. So if you want to change this upon refresh (rountrip) you will still have to do something in the do_prepare_output (especially if you get some error in the do_init_context). My suggestion is to stick to the do_prepare_output. There you can 'poll' the collection and retrieve the key of the address that has to be 'displayed'. You can cache that key in the view controller and when a different key is requested simply replace the content in the 1 address context node with the relevant entity/value node. The polling should be a cheep operation. The do_prepare_output has an input parameter indicating if it is being executed for the first time. So if you use that parameter you can "simulate" the do_init_context. The benefit is that if at some point you want to do some sort of a refresh on the address, your logic is already in the context node.

Here are some hints regarding your other questions.

1) You get a collection of entities via something similar to the following:

lr_collection = lr_entity->get_related_entities(

iv_relation_name = 'all_addresses'

iv_mode = iv_mode ).

2) lr_collection is of type IF_BOL_BO_COL. Take a look at it. You can use GET_FIRST, GET_NEXT (GET_ITERATOR is an option ) .. You should be able to figure it out From here you can get your BOL obejct... actually you will get IF_BOL_BO_PROPERTY_ACCESS. You can cast it to cl_crm_bol_entity if you must.The point is that you have the required address (in a variable of type BO_PROPERTY_ACCESS)

3) Create a new collection and add your object there:

CREATE OBJECT lr_collection

TYPE

cl_crm_bol_bo_col.

lr_collection->add( iv_entity = lr_object ).

5) Put the new collection in the context node that represents a single address.

single_address_context_node->collection_wrapper->set_collection( lr_collection ).

Cheers,

Tzanko

Answers (2)

Answers (2)

former_member206638
Participant
0 Kudos

Thank you very much for your time, and for so detailed explanation, Tzanko.

I'm getting the entities collection from my typed_context->addresses->get_collection_wrapper, and then everything just flows.

Very appreciated!!

FSA.

Former Member
0 Kudos

Hi FSA

Please follow the below approach, create a value node with required fields , use the value node fields to create view configuration . now loop through the entity collection and move the reqired values and set these values to value node this will diaplay the required data on screen.

Thanks & Regards

Raj