cancel
Showing results for 
Search instead for 
Did you mean: 

where to code check authorization

Former Member
0 Kudos

Hi Experts,

I have a requirement where in the very first screen, which is a selection screen, has to behave differently based on authorization for the logging in user. i have to hide/show few fields based on authorization.

So i need to check authorization-check, where shoul id code this, is it in WD_DOINIT method of the selection screen view?

or shall i code it in wd_doinit method of component controller?

I am a beginner in WDA so request your advice. Many thanks,

Ajay

Edited by: ajay matam on Aug 27, 2009 11:31 AM

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

WDDOINIT will be called for the first time when the application is executed.

Again when you navigate in between the views WDDOMODIFYVIEW will be called,so check including in both the methods.

Former Member
0 Kudos

Hi Martina,

Thanks for the reply.

I need to find out who logged in based on authorization i.e contractor or internal user, it depends on the authorization.

So shall i do that in WD_DOINIT of the component controller or view?

Former Member
0 Kudos

Hi Ajay,

You can code in component controller's WDDOINIT method.

Steps:

1. Create attributes of type WDY_BOOLEAN in Comp's Context and bind them to View's UI elements, which needs to be hidden.

2. Now you can code in Comp's WDDOINIT, for auth check depending on User and set the visible attribute for respective UI element.

This way, you need not come for auth check in View.

Hope this helps!

Thanks,

Tejaswini

Former Member
0 Kudos

Hi Ajay,

You can code in component controller's WDDOINIT method.

Steps:

1. Create attributes of type WDY_BOOLEAN in Comp's Context and bind them to View's UI element's Visible property, which needs to be hidden.

2. Now you can code in Comp's WDDOINIT, for auth check depending on User and set the visible attribute for respective UI element.


  DATA lo_nd_cn_visible TYPE REF TO if_wd_context_node.
  DATA lo_el_cn_visible TYPE REF TO if_wd_context_element.
  DATA ls_cn_visible TYPE wd_this->element_cn_visible.
  DATA lv_ca_visible LIKE ls_cn_visible-ca_visible.
* navigate from <CONTEXT> to <CN_VISIBLE> via lead selection
  lo_nd_cn_visible = wd_context->get_child_node( name = wd_this->wdctx_cn_visible ).

* get element via lead selection
  lo_el_cn_visible = lo_nd_cn_visible->get_element(  ).

...
auth check for sy-uname
.......
if.....condition..
lv_ca_visible = abap_true.
else.
lv_ca_visible = abap_false.
endif.
* get single attribute
  lo_el_cn_visible->set_attribute(
    EXPORTING
      name =  `CA_VISIBLE`
      value = lv_ca_visible ).

This way, you need not come for auth check in View.

Hope this helps!

Thanks,

Tejaswini

Edited by: Tejaswini Chafekar on Aug 27, 2009 8:23 AM

Former Member
0 Kudos

Hi Tejaswini,

Thanks for your help. I will do as you said.

Regds,

Ajay

Answers (1)

Answers (1)

Former Member
0 Kudos

HI Ajay,

You can code in WDDOMODIFYVIEW of View, there you can access the view UI elements and based on the authorization code you can hide/display the fields.

authority-check .....

if sy-subrc eq 0.

view->get_element( EXPORTING id = 'TXV_AGE' RECEIVING element = lr_view_element ).

lr_text_view ?= lr_view_element.

lr_text_view->set_visible( EXPORTING value = cl_wd_text_view=>e_visible-visible ).

" cl_wd_text_view=>e_visible-none for Hide

endif.