cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with IF Condition?

Former Member
0 Kudos

Hi all,

I have scenario lik the following..

I have one input field and search button. if i enter one value in input field, it shuld fetch the data as per my input. This is working fine. But,

if i not enter any input, it should fetch all the records. but no records are fetched. Wat is error here?

node_input->get_attribute( EXPORTING name = 'KUNNR'

IMPORTING value = it_kunnr ).

data:

node_size TYPE int1.

node_size = node_input->get_element_count( ).

if ( node_size eq '1' ).

SELECT * FROM KNA1 into table itab where Kunnr = it_kunnr.

ELSEIF ( node_size ne '1' ).

SELECT * FROM KNA1 into table itab.

endif.

Thanks and Regards,

Gopi.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Try this way :

if it_kunnr is not initial.
SELECT * FROM KNA1 into table itab where Kunnr = it_kunnr.
ELSE.
SELECT * FROM KNA1 into table itab.
endif.

Answers (4)

Answers (4)

Chaitanya_Priya
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi,

DATA lo_nd_node_inputTYPE REF TO if_wd_context_node.

DATA lo_el_node_inputTYPE REF TO if_wd_context_element.

DATA ls_node_inputTYPE wd_this->element_node_input.

lo_nd_node_input= wd_context->get_child_node( name = wd_this->wdctx_resume_info ).

lo_el_node_input= lo_nd_node_input->get_element( ).

lo_el_node_input->get_attribute(

EXPORTING

name = 'KUNNR'

IMPORTING

value = it_kunnr ).

if it_kunnr is not initial.

SELECT * FROM KNA1 into table itab where Kunnr = it_kunnr.

ELSE

SELECT * FROM KNA1 into table itab." this statement should fetch all the records of the table

endif.

Priya.

Former Member
0 Kudos

Thank you for your valuable replies..

my problem gets solved..

now my doubt is how can i get node size ? ( how to use that)

Thanks and Regards,

Gopi.

Former Member
0 Kudos

Hi,

for getting all the values

use

GET_STATIC_ATTRIBUTE_TABLE

refer this thread

Former Member
0 Kudos

node_input->get_attribute( EXPORTING name = 'KUNNR'

IMPORTING value = it_kunnr ).

read the attribute which is binded to the input field and use get_static_attributes_table

for getting the conteents of ur internal table instead of get_attribute


DATA: lv_node TYPE REF TO if_wd_context_node,
        lt_kunnr TYPE if_main=>elements_kunnr,
        wa_kunnr TYPE if_main=>element_kunnr.
        
 
  lv_node = wd_context->get_child_node( name = 'KUNNR' ).
  CALL METHOD lv_node->get_static_attributes_table
    IMPORTING
      table = lt_kunnr.