cancel
Showing results for 
Search instead for 
Did you mean: 

How to switch between different instances of component usage?

Former Member
0 Kudos

Hi All,

Need your help.

My application is about "Program Management", there is a table on the upper level which displays several program header data. in the lower level of the screen, I have a view container in which I embed another component to display program details.For instance,if you make a lead selection on one row of the table above, then the lower part will display the program detail.

Here is the problem: e.g. first, I make a selection on program '001', then I'll create a component usage of the program detail and I put it into a component uage group, second, I make a selection on program '002', then the same like above, I create another component usage and put it into a component usage group. Now I have two instances of program detail component usage, when I select program '001' again, how can I switch back to program '001' detail.

So, I'm trying to achieve multiple instances of program detail so that user don't need to wait for loading program details everytime.

Thanks in advance.

Regards,

Aaron

Edited by: Aaron Shen No.2 on Sep 22, 2009 3:44 AM

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Aaron,

As you are using two separate components, they would be having two separate views to display the required information.

In the onleadselect of your main view ( where you are using the individual views of the other components via the viewcontainerUI ), you have to embed the following code:

DATA lo_api_main TYPE REF TO if_wd_view_controller.

lo_api_main = wd_this->wd_get_api( ).

CALL METHOD LO_API_MAIN->FIRE_PLUG

EXPORTING

  • PARAMETERS =

PLUG_NAME = 'OP_TO_TWO'

.

Create two outbound plugs in your window, and link them to the inbound plugs of the individual views of used components.

I am embedding the code of my onleadselection:

method ONACTIONSELECTED .

DATA lo_nd_table_data TYPE REF TO if_wd_context_node.

DATA lo_el_table_data TYPE REF TO if_wd_context_element.

DATA ls_table_data TYPE wd_this->element_table_data.

DATA lt_table_data TYPE wd_this->elements_table_data.

data lv_selected_index type i.

  • navigate from <CONTEXT> to <TABLE_DATA> via lead selection

lo_nd_table_data = wd_context->get_child_node( name = wd_this->wdctx_table_data ).

  • get element via lead selection

lo_el_table_data = lo_nd_table_data->get_element( ).

CALL METHOD LO_EL_TABLE_DATA->GET_INDEX

RECEIVING

MY_INDEX = lv_selected_index

.

case lv_selected_index.

when 1.

data lo_cmp_usage type ref to if_wd_component_usage.

lo_cmp_usage = wd_this->wd_cpuse_comp_one( ).

if lo_cmp_usage->has_active_component( ) is initial.

lo_cmp_usage->create_component( ).

endif.

DATA lo_api_main TYPE REF TO if_wd_view_controller.

lo_api_main = wd_this->wd_get_api( ).

CALL METHOD LO_API_MAIN->FIRE_PLUG

EXPORTING

  • PARAMETERS =

PLUG_NAME = 'OP_TO_ONE'

.

clear lo_cmp_usage.

when 2.

  • DATA lo_api_main TYPE REF TO if_wd_view_controller.

lo_api_main = wd_this->wd_get_api( ).

CALL METHOD LO_API_MAIN->FIRE_PLUG

EXPORTING

  • PARAMETERS =

PLUG_NAME = 'OP_TO_TWO'

.

  • data lo_cmp_usage type ref to if_wd_component_usage.

lo_cmp_usage = wd_this->wd_cpuse_comp_two( ).

if lo_cmp_usage->has_active_component( ) is initial.

lo_cmp_usage->create_component( ).

endif.

endcase.

endmethod.

Regards,

Prosenjit.

Former Member
0 Kudos

Hi Prosenjit,

Thanks for your reply, but I don't think that's the case.

Cause in my case, the upper part is only a simple table display header data of each program. the lower part is an embeded interface view which belong to another component to display detail data of a program.

the number of programs is dynamic, maybe 2, maybe 200. According to what you've suggested, I need to create 200 component usage for that case? that's crazy, I don't think it's feasible.

Correct me if I take your solution in a wrong way.

Regards,

Aaron

Former Member
0 Kudos

Hi,

Do this select query -> pass component_name = <your_component_name>, and query the table WDY_COMPO_USAGE.

Store the results in an internal table.

From CALL METHOD LO_EL_TABLE_DATA->GET_INDEX

RECEIVING

MY_INDEX = lv_selected_index

.

you will get the index, using which read the above internal table.

Now use the followinf code:

*TRY.

CALL METHOD LO_CMP_USAGE->CREATE_COMPONENT

  • EXPORTING

  • COMPONENT_NAME = <component_name_read_from_internal_table>

  • CONFIGURATION_ID =

  • MODEL_USAGE =

  • ASSISTANCE_CLASS =

  • MODEL_USAGE_NAME =

.

  • CATCH CX_WD_RUNTIME_API .

*ENDTRY.

Try this.

Regards,

Prosenjit.

Former Member
0 Kudos

Hi prosenjit ,

In my case, I've already created 2 component usages( program '001' detail and program '002' detail ). and here is the case: I'm on program '002' detail. and I selece program '001' again, since I've already had program '001' component usage instance, so I just want to simply switch from program '002' detail to program '001' detail. My question is whether there is a way that I can make the staticly declared component usage( defined in the property tab, here is PROGRAM_DETAIL ) directly refer to another component usage instance without replug( I will load data in the handle inbound plug of program detail view, so I don't want to do that again, I've already done that when I create program '001' detail component usage instance ).

Answers (2)

Answers (2)

Former Member
0 Kudos
Former Member
0 Kudos

Hi,

Can you just paste your code on LeadSelection event...of ALV.

Regards,

Lekha.

Former Member
0 Kudos

 data lv_comp_usage_name type string.
  data lo_comp_usage      type REF TO IF_WD_COMPONENT_USAGE.
  data lo_comp_usage_static type REF TO if_wd_component_usage.

  lv_comp_usage_name = ls_prg-prg_id.
  lo_comp_usage_static = wd_this->wd_cpuse_prg_detail( ).
  lo_comp_usage = wd_comp_controller->GO_PRG_DETAIL_USAGE_GROUP->get_component_usage( name = lv_comp_usage_name ).

  IF lo_comp_usage is INITIAL.
    lo_comp_usage = wd_comp_controller->GO_PRG_DETAIL_USAGE_GROUP->ADD_COMPONENT_USAGE( NAME = lv_comp_usage_name ).
    lo_comp_usage->CREATE_COMPONENT( ).
    wd_this->fire_OP_TO_PRG_DETAIL_plg( EXPORTING prg_id = ls_prg-prg_id
                                                  prg_ctrl = wd_comp_controller->go_prg_ctrl ).

  ENDIF.
 lo_comp_usage_static->ENTER_REFERENCING_MODE( EXPORTING REFERENCED_COMPONENT_USAGE = lo_comp_usage ).