cancel
Showing results for 
Search instead for 
Did you mean: 

code for execute button on selection screen to get result

Former Member
0 Kudos

hi experts,

I need a help for writing a code for execution button on selection screen.Like in normal report on abap editor

we insert selection criteria like number and we get the result according that particular number on next screen.

same thing i am trying here also. So i am writing a code on button that when i press the button it will go to the next

screen according to the selection criteria.

Plz help me helpful answers are appriatiated !!!

Thanks & regards

Vipul Gupta

Accepted Solutions (0)

Answers (6)

Answers (6)

Former Member
0 Kudos

thanks for your helpful suggestions.

Former Member
0 Kudos

Thankyou for reply but still my query is there.As we have to write select statement also to retrive the value

whatever we have enter in the selection screen value for that how we have write the code on button.

Former Member
0 Kudos

hi,

In the OnAction write :

1. get the values entered in selection criteria using :

DATA lo_nd_cn_check TYPE REF TO if_wd_context_node.

DATA lo_el_cn_check TYPE REF TO if_wd_context_element.

DATA ls_cn_check TYPE wd_this->element_cn_check.

DATA lv_ca_check LIKE ls_cn_check-ca_check.

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

lo_nd_cn_check = wd_context->get_child_node( name = wd_this->wdctx_cn_check ).

  • get element via lead selection

lo_el_cn_check = lo_nd_cn_check->get_element( ).

  • get single attribute

lo_el_cn_check->get_attribute(

EXPORTING

name = `CA_CHECK`

IMPORTING

value = lv_ca_check ).

Now lv_ca_check has your value entered in Selection criteria.

2. write the select query to fetch data according to selection criteria.

select * from <table> into correponding field of table <internl table>

where Field = lv_ca_check.

3. Now in the internal table <internl table> you have values according to search criteria.

4. Bind the internal table with node which is binded to table to show data.

lo_nd->bind_table( internaltable ).

I hope it is clear .

Former Member
0 Kudos

As we have to write select statement also to retrive the value

whatever we have enter in the selection screen value for that how we have write the code on button.

whatever value the user enters , we get it thru get_attribute method

we bind our UI to context attributes and read the same using code wizard

try to use minimal business logic in methods of ur view

Former Member
0 Kudos

Thankyou for reply but my question is not for navigation but my question is how to write the code on execution button

like we have to write select statement on button (Method tab) so that whatever we give the selection criteria it will give the result according to that.

Thanks

Vipul

Former Member
0 Kudos

hi,

When you navigate to next view then you can write code there also in the Handler of inbound plug in View2.

or

In case you want to write the code in Button, write the select query - Fetch the data into an internal table - bind this internal table with node used in view2.

Map your View2 node with Component controller and similarly have same node in View1 and do maping with comp controller.

This way , you will be able to set the data in Table of View2 in the oncation of button only.

Former Member
0 Kudos

hi Vipul ,

suppose ur selection criteria is that certain field needs to be filled in INput field UI , thn only u navigate to ur second view

thn u need to proceed as follow :

1 read the attribute which is binded to ur Input field

by pressing CNTRL + F7 and selecting read context node/attribute



DATA lo_nd_cn_check TYPE REF TO if_wd_context_node.
    DATA lo_el_cn_check TYPE REF TO if_wd_context_element.
    DATA ls_cn_check TYPE wd_this->element_cn_check.
    DATA lv_ca_check LIKE ls_cn_check-ca_check.
*   navigate from <CONTEXT> to <CN_CHECK> via lead selection
    lo_nd_cn_check = wd_context->get_child_node( name = wd_this->wdctx_cn_check ).

*   get element via lead selection
    lo_el_cn_check = lo_nd_cn_check->get_element(  ).

*   get single attribute
    lo_el_cn_check->get_attribute(
      EXPORTING
        name =  `CA_CHECK`
      IMPORTING
        value = lv_ca_check ).

I read ca_check under cn_check

2 thn according to ur criteria , u put a IF condition



IF lv_ca_check NE ' ' .
// donot fire to second view
ELSE.
// fire to second view

u need all this logic in ur onAction method

regards,

amit

Former Member
0 Kudos

Hi ,

Refer the SAP Online Help on View Navigation with Examples:

http://help.sap.com/saphelp_nw04s/helpdata/en/1f/464941db42f423e10000000a155106/frameset.htm

I hope it will help you.

Former Member
0 Kudos

hi,

1. Create two views V1 , V2.

2. In the first view V1 , have the input fields with labels for selection criteria.

3. Also insert a button B1 in view V1.

4. Now create outbound plug in View V1.

5. Create inbound plug in View V2.

6. Now on the Action of button, fire the oubound plug of View 1. You can use Code Wizard (control + F7) to fire .

Refer this thread:

Former Member
0 Kudos

make a action for ur button and write the code in the on Action method

Former Member
0 Kudos

Thankyou for reply but what is the code for action method.

Former Member
0 Kudos

in that method , go to ur 2nd view

make a outbound plug for ur 2nd view and fire to tht


wd_this->fire_out_edit_plg(
  ).

1 here in the 1st screen ( say view1) tab -> OUTBOUND PLUG , I have made a outbound plug OUT_EDIT

2 similarly make a inbound plug to the view , where u want to fire say view2

3 now go to the windows , drill down to the outbound plug of ur current view view1 , right click on outbound plug,

create navigation plug and select the inbound plug of ur view2

regards,

amit

Former Member