cancel
Showing results for 
Search instead for 
Did you mean: 

How to trigger Variants in WDA FPM.

carlin_willams
Participant
0 Kudos

Hello All,

I have configured two different variants in FPM Say Variant_1 and Variant_1 both having different Steps.

Based on some processing logic I have to trigger Variant_1 and Variant_2.

Say

In the Button1 action need to trigger Variant_1

In the Button2 action need to trigger Variant_2

I am not sure where i have to write the below code.

What exactly Life Cycle of FPM in WDA?Can any one explain the developer guide bit hard to understand.

WDA FPM developers guide .In the Page : 52 given below code.

method OVERRIDE_EVENT_OIF of the IF_FPM_OIF_CONF_EXIT .

...

case io_oif->mo_event->MV_EVENT_ID.

when if_fpm_constants=>gc_event-leave_initial_screen.

io_oif->set_variant( ).

...

GAF Instance

method OVERRIDE_EVENT_GAF .

...

case io_gaf->mo_event->MV_EVENT_ID.

when if_fpm_constants=>gc_event-leave_initial_screen.

io_gaf->set_variant( ).

Thanks in Advance.

BR

-CW

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

The place where you can code this is OVERRIDE_EVENT_GAF method in component controller.

You get this method when you implement the if_fpm_gaf_conf_exit.

The runtime control comes to this method when you have the AppCC is configured. See the developer's manual page 52.

This all works based on FPM eventing and not wda event. So you have to check the event in the OVERRIDE_EVENT_GAF method and set the variant.

You refer button1 and button2 ? are they from fpm toolbar or WDA ?

If you refer wda then, you need to raise FPM event in the event handler in WDA, otherwise FPM would not know the wda event.

Edited by: Baskaran Senthivel on Jun 14, 2011 5:20 PM

carlin_willams
Participant
0 Kudos

Thanks Baskaran.

You mean i need to create two actions for two buttons in Webdynpro Views

*ACTBUTTON1.*_

data: lo_fpm type ref to if_fpm,

lr_event type ref to cl_fpm_event.

  • create event

lr_event = cl_fpm_event=>create_by_id(

cl_fpm_event=>gc_event_change_step ).

lo_fpm = cl_fpm_factory=>get_instance( ).

lr_event->mo_event_data->set_value(

iv_key = 'B1'

iv_value = 'BUTTON1').

*ACTBUTTON2.*_

data: lo_fpm type ref to if_fpm,

lr_event type ref to cl_fpm_event.

lr_event = cl_fpm_event=>create_by_id(

cl_fpm_event=>gc_event_change_step ).

lo_fpm = cl_fpm_factory=>get_instance( ).

lr_event->mo_event_data->set_value(

iv_key = 'B2'

iv_value = 'BUTTON2').

On click of above buttons need to go different variants. Say Button 1 should navigate to V1 and Button 2 should navigate to V2 .

How can get the evenst in the following OVERRIDE_EVENT_GAF.

Could you please suggest. If you have time pls give steps with some code.

Thanks & Regards

CW

Former Member
0 Kudos

Changing the variants usually happens at the initial screen, based on the choice you make in the initial screen you set the variants in the override method.

In your case

1. in the component configuration create a initial screen.

2. Embed a WDA interface view with actions(for example two buttons )

3. In the override method ,see the variant on leave_initial_screen event. (as shown the developers manual to set the variants ).

carlin_willams
Participant
0 Kudos

Hello Baskaran,

Really i confused what approach i have to follow Variants or initial screen or some else.

My Requirement is like this:

I have initial screen which is the first step for all below three different scenarios.

The initial screen contains two buttons, on corresponding actions should navigate to Scenario 2 and Scenario 3.

On Click of buttons i have navigate to Second Main steps of Scenario 2 and Scenario 3.

Scenario 1 Contains 5 Main Steps : M1 M2 M3 M4 M5

Scenario 2 Contains 5 Main Steps : M1 M3 M5

Scenario 3 Contains 5 Main Steps : M1 M4 M5

Could you please tell what is best approach have to follow for above requirement?

Best Regards

-CW

Former Member
0 Kudos

hi,

my approach would be initial screen instead of first step and then changing the variant.

Create 3 variants with combination of static steps and sub steps.

create a initial screen and use AppCC to decide which variant to choose.

carlin_willams
Participant
0 Kudos

Hello Baskaran,

1) In the FPM, i have maintained Intial screen , which contains two buttons from WD View.

2) i have created two Variants say V1 and V2.

3) I have made Start button Invisible in the intial screen.

4) On click of First Button need to navigate to V1 and On click of Second Button need to navigate to V2

5) I have created two events and raised in the button actions.

6) I have catched those events in OVERRIDE_EVENT_GAF based upon my Key i need to go to the different variants.

😎 I have written below code in the OVERRIDE_EVENT_GAF in dubugging mode button events triggering properly BUT I need able to navigate Variants.

How to navigate Variants on button clicks.

Code

data : lv_eveval type string,

ID_FIRST type fpm_event_id,

lv_fpm TYPE REF TO if_fpm,

lr_event TYPE REF TO cl_fpm_event.

lv_fpm = cl_fpm_factory=>get_instance( ).

  • create event

io_GAF->mo_event->MO_EVENT_DATA->get_value( exporting iv_key = 'F'

importing ev_value = lv_eveval ).

io_GAF->mo_event->MO_EVENT_DATA->get_value( exporting iv_key = 'S'

importing ev_value = lv_eveval ).

case lv_eveval.

when 'FIRST'.

TRY.

CALL METHOD IO_GAF->SET_VARIANT

EXPORTING

IV_VARIANT_ID = 'VARIANT_1'.

.

CATCH CX_FPM_FLOORPLAN .

ENDTRY.

when 'SECOND'.

TRY.

CALL METHOD IO_GAF->SET_VARIANT

EXPORTING

IV_VARIANT_ID = 'VARIANT_2'.

.

CATCH CX_FPM_FLOORPLAN .

ENDTRY.

ENDCASE.

Edited by: CarlinWilliams on Jun 21, 2011 2:20 PM

Former Member
0 Kudos

I would try the following.

1.Enable the Start button.

2.Have a context attribute binded to the action you wised to have (radio button/Checkbox ..etc) in the component controller.

3.capture the event in the override method and see the value in the context attribute (see step-2) and based on that set the variant.

IF ( IO_GAF->MO_EVENT->MV_EVENT_ID EQ CL_FPM_EVENT=>GC_EVENT_LEAVE_INITIAL_SCREEN ).

" get the value from the screen using the context.

      lv_variant_id = "fill the variant id".
   TRY.
    CALL METHOD io_gaf->set_variant
    EXPORTING
      iv_variant_id = lv_variant_id .
    .
    CATCH cx_fpm_floorplan .
   ENDTRY.

ENDIF.

carlin_willams
Participant
0 Kudos

Hello Baskaran

Thanks for your quick reply.

Below two points i am not clear.

2.Have a context attribute binded to the action you wised to have (radio button/Checkbox ..etc) in the component controller.

3.capture the event in the override method and see the value in the context attribute (see step-2) and based on that set the variant.

You mean :

1) I need to create context attribute in the component controller

2) On Button actions we need to set values like Button1 set 'V1' and for Button2 set 'V2'

3) We need to read (get) the context attribute value in the OVERRIDE_EVENT_GAF.

4) I have insert above code right?

Please explain more if my assumptions are wrong.

BR

CW

Former Member
0 Kudos

Your assumptions are right. Let me know if you get succeed.

carlin_willams
Participant
0 Kudos

Hello Baskaran

I am getting error : Access via 'NULL' object reference not possible. when i am doing test from FPM Application.

I have written below code in the method :OVERRIDE_EVENT_GAF.

On Button actions i had set the Variant_1 and Variant_1 in the context attribute.

data : lv_eveval type string,

ID_FIRST type fpm_event_id,

lv_fpm TYPE REF TO if_fpm,

lr_event TYPE REF TO cl_fpm_event.

  • get reference to FPM API

lv_fpm = cl_fpm_factory=>get_instance( ).

DATA lo_nd_sample TYPE REF TO if_wd_context_node.

DATA lo_el_sample TYPE REF TO if_wd_context_element.

DATA ls_sample TYPE wd_this->Element_sample.

DATA lv_first TYPE wd_this->Element_sample-first.

data lv_variant_id type string.

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

lo_nd_sample = wd_context->get_child_node( name = wd_this->wdctx_sample ).

  • get single attribute

lo_el_sample->get_attribute(

EXPORTING

name = `FIRST`

IMPORTING

value = lv_variant_id ).

IF lv_variant_id IS NOT INITIAL.

IF ( IO_GAF->MO_EVENT->MV_EVENT_ID EQ CL_FPM_EVENT=>GC_EVENT_LEAVE_INITIAL_SCREEN ).

TRY.

CALL METHOD io_gaf->set_variant

EXPORTING

iv_variant_id = lv_variant_id .

.

CATCH cx_fpm_floorplan .

ENDTRY.

ENDIF.

ENDIF.

Former Member
0 Kudos

i think, you need to change your code a little bit. Since Override method is called event before the initial screen you get this error.

You can change your code like this

data : lv_eveval type string,
ID_FIRST type fpm_event_id,
lv_fpm TYPE REF TO if_fpm,
lr_event TYPE REF TO cl_fpm_event.

* get reference to FPM API
lv_fpm = cl_fpm_factory=>get_instance( ).

DATA lo_nd_sample TYPE REF TO if_wd_context_node.

DATA lo_el_sample TYPE REF TO if_wd_context_element.
DATA ls_sample TYPE wd_this->Element_sample.
DATA lv_first TYPE wd_this->Element_sample-first.
data lv_variant_id type string.



IF ( IO_GAF->MO_EVENT->MV_EVENT_ID EQ CL_FPM_EVENT=>GC_EVENT_LEAVE_INITIAL_SCREEN ).
* navigate from <CONTEXT> to <SAMPLE> via lead selection
lo_nd_sample = wd_context->get_child_node( name = wd_this->wdctx_sample ).
* get single attribute
lo_el_sample->get_attribute(
EXPORTING
name = `FIRST`
IMPORTING
value = lv_variant_id ).

IF lv_variant_id IS NOT INITIAL.
TRY.
CALL METHOD io_gaf->set_variant
EXPORTING
iv_variant_id = lv_variant_id .
.
CATCH cx_fpm_floorplan .
ENDTRY.

ENDIF.
ENDIF.

carlin_willams
Participant
0 Kudos

Hello Baskaran,

I have changed the code accroding to u.Not getting any error in the intial screen while loading.

On click on First and Second Buttons nothing is happening. Means i kept debugging point it is not going inside of the both if conditions on action of buttons.

IF ( IO_GAF->MO_EVENT->MV_EVENT_ID EQ CL_FPM_EVENT=>GC_EVENT_LEAVE_INITIAL_SCREEN ).

IF lv_variant_id IS NOT INITIAL.

In above code.

Could you please give your any inputs why it is navagating to Variants.

BR

-CW

Former Member
0 Kudos

see my earlier post, you need to enable the start button. On pressing the start button you enter to the override method.

carlin_willams
Participant
0 Kudos

Hello Baskaran,

Thanks for your reply.

I have already enabled Start button.

BUT When i am clicking the START button it is going to the below inside IF method.

IF ( IO_GAF->MO_EVENT->MV_EVENT_ID EQ CL_FPM_EVENT=>GC_EVENT_LEAVE_INITIAL_SCREEN ).

It is giving NULL Pointer Exception since lv_variant_id null.

How i can navigate directly Variant1 and Variant2 on click of BUTTON1 and BUTTON2.I want avoid one click of START button (means i want to skip click of START Button)

Could you please guide me how to proceed.

BR

-CW

Former Member
0 Kudos

I would advice you to stick with Start button first and get things work and then later explore the possibility to avoid the start button.

Avoiding the start button means that you need to fire a event (leave_initial_screen ) from your button action.

I wonder why the lv_variant_id is empty ? When you are in initial screen , you have to make one variant as default variant and based on the button change the variant in your context. In this way the context has always value.

see for example FPM_TUT_VARAINT_INIT, FPM_TUT_VARAINT_VAR1 and FPM_TUT_VARAINT_VAR2 components.

carlin_willams
Participant
0 Kudos

Hello Baskaran

1) On action buttons i have raised one custom event with values like below for two buttons.

data : lv_fpm TYPE REF TO if_fpm,

lr_event type ref to cl_fpm_event,

ID_FIRST type fpm_event_id.

lv_fpm = cl_fpm_factory=>get_instance( ).

lr_event = cl_fpm_event=>create_by_id( ID_FIRST ).

lr_event->mo_event_data->set_value(

iv_key = 'F'

iv_value = 'FIRST' ).

lv_fpm->raise_event( lr_event ).

2) In the Override

data : lv_eveval type string,

io_GAF->mo_event->MO_EVENT_DATA->get_value( exporting iv_key = 'F'

importing ev_value = lv_eveval ).

io_GAF->mo_event->MO_EVENT_DATA->get_value( exporting iv_key = 'S'

importing ev_value = lv_eveval ).

case lv_eveval.

when 'FIRST'.

TRY.

CALL METHOD IO_GAF->SET_VARIANT

EXPORTING

IV_VARIANT_ID = 'VARIANT_1'.

.

CATCH CX_FPM_FLOORPLAN .

ENDTRY.

when 'SECOND'.

TRY.

CALL METHOD IO_GAF->SET_VARIANT

EXPORTING

IV_VARIANT_ID = 'VARIANT_2'.

.

CATCH CX_FPM_FLOORPLAN .

ENDTRY.

3) With above code and logic i am able goto the different variants BUT Problem is First i have to click the buttons next i have to click the START button then it is going corresponding VARIANT . I want to SKIP the START button click.

Could you please advise hwo to SKIP START for above steps.

Thanks in advance.

BR

-CW

Former Member
0 Kudos

CW,

To avoid the start button , you need to fire the fpm event leave_initial_screen

raise_event_by_id( if_fpm_constants=>gc_event-leave_initial_screen and add the parameters which you need to decide for Variants.

SO, in your case when the buttons are pressed, you fire a FPM event with Parameters (not the change_step event ).

You already have the code snippet for handling the Leave initial screen in override-method.

You only need to add piece of code to get the parameters from the event.

Just to make sure : on the button action handler fire the leave initial screen event with Parameters (if you need it ), i have done this using context mapping so no need of passing event parameters.