cancel
Showing results for 
Search instead for 
Did you mean: 

WDABAP: note of change of Lead Selection overall component

Former Member
0 Kudos

Hi,

I would like to build a similiar wd-application like wd-component 'wdt_master_detail'. There you will see a table with fly-data and below some details of the actual selected row of the table (by lead selection).

The difference is that I want to seperate the data retrieval in a model-component(z_model) and for the table / details two seperate wd-components(z_table / z_detail) which mapps the fly-data. The wd-application instantiate a wd-component (z_container) which includes in its view z_table and z_detail.

When the lead selection changes(by selecting a new row in the table of z_table) the details of z_detail should change to the details of the element with the lead selection. But this does not work! By node->get_lead_selection_index in z_detail I get only the inital lead-selection. node->get_lead_selection_index in z_table provides the right index.

I tried also following: z_table calls z_model->set_lead_selection and this method set the lead selection of the original node new. But this does not help.

Has someone an idee what I have to do that the component z_detail receive the information? Has the z_model to raise an event with the information of the new index? I hope not.

Thanks a lot!

Regards,

Marcel

added 1:

I have an assumption why it does not work:

Maybe z_table and z_detail instantiates two separate z_model.

So a solution would be that z_container instantiates z_model and provide this instance to z_table and z_detail but I have absolutly no idee whether and how this could be working... Please kindly help.

added 2:

I thinking further a little bit loud...

I have the idea that z_container mapps the context from z_model and set this these to input-node.

z_table and z_detail mapps from z_container. ok, if I would like to create many application then I have to create related components(z_comp_appl_xx) and these components includes z_container. This would be maybe the solution if there is a instance problem(see added1) but I have tested and the details screen gets NOT the lead selection

Message was edited by: Marcel Schreier

Accepted Solutions (1)

Accepted Solutions (1)

Ulli_Hoffmann
Contributor
0 Kudos

Hi Marcel,

to extend Thomas comments, here are some suggestions to turn it into code. Hope it helps.

option A)

assuming you name the usages in z_container "usage_z_model", "usage_Z_table", "usage_Z_detail":

in componentcontroller of z_container methode wddoinit() do the following:

DATA lr_model_usage TYPE REF TO if_wd_component_usage.

lr_model_usage = wd_this->wd_cpuse_usage_z_model( ).

IF lr_model_usage->has_active_component( ) IS INITIAL.

lr_model_usage->create_component( ).

ENDIF.

DATA lr_usage TYPE REF TO if_wd_component_usage.

lr_usage = wd_this->wd_cpuse_usage_z_table( ).

IF lr_usage->has_active_component( ) IS INITIAL.

lr_usage->create_component( model_usage = lr_model_usage ).

ENDIF.

lr_usage = wd_this->wd_cpuse_usage_z_detail( ).

IF lr_usage->has_active_component( ) IS INITIAL.

lr_usage->create_component( model_usage = lr_model_usage ).

ENDIF.

Following this way, it is required to name the usages of z_model in component z_table and z_detail "MODEL_USAGE".

*-----

option B)

in componentcontroller of z_table and z_detail create an interface-methode set_usage() with one parameter ir_usage type if_wd_component_usage

DATA lr_usage TYPE REF TO if_wd_component_usage.

lr_usage = wd_this->wd_cpuse_usage_z_model( ).

lr_usage->enter_referencing_mode( ir_usage ).

in component z_container method wddoinit() do the following:

DATA lr_usage TYPE REF TO if_wd_component_usage.

DATA lr_if_ctr_z_table TYPE REF TO iwci_z_table.

DATA lr_if_ctr_z_detail TYPE REF TO iwci_z_detail.

DATA lr_model_usage TYPE REF TO if_wd_component_usage.

*-- create instance of z_model

lr_model_usage = wd_this->wd_cpuse_usage_z_model( ).

IF lr_model_usage->has_active_component( ) IS INITIAL.

lr_model_usage->create_component( ).

ENDIF.

*-- create instance of z_table

lr_usage = wd_this->wd_cpuse_usage_z_table( ).

IF lr_usage->has_active_component( ) IS INITIAL.

lr_usage->create_component( ).

ENDIF.

*-- set usage

lr_if_ctr_z_table = wd_this->wd_cpifc_usgae_z_table( ).

lr_if_ctr_z_table->set_usage( model_usage = lr_usage).

*-- create instance of z_deatil

lr_usage = wd_this->wd_cpuse_usage_z_detail( ).

IF lr_usage->has_active_component( ) IS INITIAL.

lr_usage->create_component( model_usage = lr_model_usage ).

ENDIF.

*-- set usage

lr_if_ctr_z_detail = wd_this->wd_cpifc_usage_z_detail( ).

lr_if_ctr_z_detail->set_usage( model_usage = lr_usage).

regards, Ulli

Former Member
0 Kudos

Hi Ulli, Hi Thomas,

very thank you so far!

I tested both options - optionB is working but I like option A more because in option B you have to implement every time method set_usage() -

Option is actually not working but I don't understand why. I habe following coding in the wddoinit of z_container-componentcontroller:

-


CODING----

  • option A

  • Instantiates Model

lr_model_cmp_usage = wd_this->wd_cpuse_model( ).

IF lr_model_cmp_usage->has_active_component( ) IS INITIAL.

lr_model_cmp_usage->create_component( ).

ENDIF.

lv_has_active_component = lr_model_cmp_usage->has_active_component( ).

  • Instantiates Table

lr_table_cmp_usage = wd_this->wd_cpuse_table( ).

IF lr_table_cmp_usage->has_active_component( ) IS INITIAL.

>RUNTIME-ERROR> lr_table_cmp_usage->create_component( EXPORTING component_name = 'MODEL'

model_usage = lr_model_cmp_usage ).

ENDIF.

  • Instantiates Detail

...accordingly to Instantiating Table

-


END OF CODING----

Although at runtime lv_has_active_component is set to abap_true I get runtime error CX_WDR_RR_EXCEPTION because "Die Komponente ist nicht aktiv" .

In the runtime error long text I can see the exception is raised there:

raise exception type cx_wdr_rr_exception

exporting

textid = cx_wdr_rr_exception=>component_not_active

component = component_name.

with component_name = MODEL

I don't understand why model is not active because lv_has_active_component is abap_true. Do you see the error I made?

Thanks and Regards,

Marcel

Ulli_Hoffmann
Contributor
0 Kudos

Hi Marcel,

check whether the z_table component is activated.

Also check whether in z_table the usage of z_model is called 'MODEL_USAGE'.

regards, Ulli

Answers (1)

Answers (1)

thomas_szcs
Active Contributor
0 Kudos

Hi Marcel,

You are right. Each of those two components has its own copy of z_model. This can be overcome by creating the component instance of z_model in z_container and going into referencing mode for the component instances of z_model in z_table and z_detail.

Besides this, I think your design is quite challenging. How about using different views instead of different components as it seems that master and detail are closely related to each other? Another option would be use an assistance class with static methods a "business logic layer".

Best regards,

Thomas