cancel
Showing results for 
Search instead for 
Did you mean: 

How to show view based on condition

praveenkumar_kadi
Active Contributor
0 Kudos

Hi,

I have a scenario with login screen with a submit button and two views(success and error).

Now I want to show

a)a successful view if user enters a correct login name and password(which will be validated with static values in action method of submit button)

b)a Error view if user enters wrong username and password.

I am struck at action code to write a condition to show respective views.

Some thing like (In Java)

If (login.id=='abc' && login.password='xyz')

show.view1

else

show.view2

I am not familar to ABAP coding as I just started to know.

If anyone know action code, Please help on this.

Thanks in advance

Praveen

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Create Outbound plugs to the view1 and view2 from Main view(where submit button is placed) and also create inbound plug in view1( from main) and view2(from main).

If (login.id=='abc' && login.password='xyz')

fire_view1_plug

else

fire_view2-plug.

check this Blog how to navigate to the other view.

https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/cfb80249-0801-0010-3eaa-829afeac...

https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/b52e13c3-0901-0010-8fa6-d11a5182...

Thanks

Suman

praveenkumar_kadi
Active Contributor
0 Kudos

Hi,

Thanks for the docs.As I said I'm struck at ABAP action code for the submit button, I would appreciate if I get ABAP code that processes login and password with static values and shows appropriate view(success or failure).

OR any application example that demonstrates view navigation based on user input values.

Points will not be a constraint for the expected action code.

Thanks

Praveen

Former Member
0 Kudos

Hi Praveen,

Check this code.

First you have to create Plugs for view1 and view2 from Main view as show in the blogs.

Method onsubmit.
data:
    node_input_data  type ref to if_wd_context_node,
    elem_input_data  type ref to if_wd_context_element,
    stru_input_data  type if_first=>element_input_data.
    
*  navigate from <CONTEXT> to <INPUT_DATA> via lead selection
  node_input_data = wd_context->get_child_node( name = 'INPUT_DATA' ).

*  get element via lead selection
  elem_input_data = node_input_data->get_element(  ).

*  get all declared attributes
  elem_input_data->get_static_attributes(
    importing
      static_attributes = stru_input_data ).

if stru_input_data-user_name = 'XXXX ' and 
  stru_input_data-password = 'YYYY'.
* Navigate to view1
  wd_this->fire_<plugname>_plg(
  ).
else.
* Navigate to View2
  wd_this->fire_<plugname>_plg(
  ).
endif.
endmethod.

Thanks

Suman

praveenkumar_kadi
Active Contributor
0 Kudos

Hi Suman,

Thanks for the code. my issue is still not solved

I have to change the code with respect to context node info.

My context looks like

Root

->Person

-->Name

-->Address (which is designted as password)

Now how to do modify your code with respect to the context. I'm sorry I m new to ABAP coding.I tried with below changed code.it gave me an error as shown in below.(type if_first=>element_name is unknown)

method ONACTIONACTION_GO .

data:

node_input_data type ref to if_wd_context_node,

elem_input_data type ref to if_wd_context_element,

stru_input_data type iffirst=>element_name._

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

node_input_data = wd_context->get_child_node( name = 'PERSON' ).

  • get element via lead selection

elem_input_data = node_input_data->get_element( ).

  • get all declared attributes

elem_input_data->get_static_attributes(

importing

static_attributes = stru_input_data ).

if stru_input_data-name = 'praveen ' and

stru_input_data-address = 'ilkal'.

  • Navigate to view1

wd_This->Fire_Outtov2_Plg(

).

else.

  • Navigate to View2

  • wd_this->fire_<plugname>_plg(

  • ).

wd_This->Fire_Outtov2_Plg(

).

endif.

endmethod.

Error:

type if_first=>element_name is unknown (why this error..?)

Thanks

Praveen

Edited by: Praveen kumar Kadi on Sep 12, 2008 9:38 AM

Former Member
0 Kudos

Hi Praveen,

You have declared correct context node and attributes.

In the previous answer i pasted my code.you have to make some little changes..

You no need to write the code by yourself.you have a code wizard button in the application tool bar,click on that and then select Read from context.Select your context node from value help.thats all it will give you ready made code.

then implement your logic.

Thanks

Suman

praveenkumar_kadi
Active Contributor
0 Kudos

Thanks..It learnt a lot.

It's working now.

Praveen

Answers (0)