Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

problem in IF and ENDIF.

Former Member
0 Kudos

Hi Experts,

I have a problem in the IF AND IF loops, since my program I find a string based on the grid, what's happening is in the pop up if i type the string which is in the first grid, at the first click of find itself it finds the string.

But if i type the string which is in the second grid, I have press the continue button in the pop up twice and then only it finds it.

Samething vice-versa for other grids, 3 times for 3rd grid 4 times for 4th grid.

Here is my code.

FORM search.

DATA: search TYPE sy-subrc.

PERFORM find USING grid1

itab1

CHANGING search.

IF search NE 0.

PERFORM find USING grid2

itab2

CHANGING search.

IF search NE 0.

PERFORM find USING grid3

itab3

CHANGING search.

IF search NE 0.

PERFORM find USING grid4

itab4

CHANGING search.

ENDIF.

ENDIF.

ENDIF.

ENDFORM.

Can anyone please tell me what could be the problem?

Thanks in advance.

Prabs.

8 REPLIES 8

Former Member
0 Kudos

Well, it looks as if you're calling the popup in form 'find' rather than before the first call to it.

Rob

Former Member
0 Kudos

Hi

Where are you calling your popup? In FORM FIND?

Max

0 Kudos

Hi,

Yes I am calling the pop up in form find.

thanks.

0 Kudos

Call it once before you search the grids.

Rob

0 Kudos

Hi Rob,

I tried calling it once but it doesn't work, Here is the code of form find.

FORM find USING grid_name TYPE REF TO cl_gui_alv_grid

itab TYPE table

CHANGING search.

*

DATA: record TYPE sy-tabix,

sel_row type lvc_t_row,

sel_row_table type lvc_s_row,

column TYPE alv_s_fcat-fieldname.

DATA: curr_field_catalog TYPE LVC_T_FCAT.

*

call method grid_name->refresh_table_display.

CALL FUNCTION 'ALV_POPUP_TO_SEARCH2'

  • EXPORTING

  • I_DISABLE_SEARCH_SEQUENCE = ' '

  • I_INFORM = ' '

  • IMPORTING

  • E_CANCELLED =

CHANGING

C_STRING = str.

  • C_SEARCH_ORDER = ' '

  • C_SINH = ' '

  • C_GZAHL = ' '

CALL METHOD grid_name->get_frontend_fieldcatalog

IMPORTING

et_fieldcatalog = curr_field_catalog.

PERFORM search_in_scr USING itab

curr_field_catalog

CHANGING search

record

column.

sel_row_table-index = record.

CLEAR sel_row.

APPEND sel_row_table TO sel_row.

IF search = 0.

CALL METHOD grid_name->set_selected_rows

EXPORTING

it_index_rows = sel_row.

ELSE.

ENDIF.

ENDFORM. "l_okcode_find

I called the pop up before calling this once, but it did not find the string. What could be done.

Thanks,

Prabs.

0 Kudos

Call the popup only if STR is initial (I'm assuming it's global).

Rob

0 Kudos

Hi,

I tried this

Call the popup only if STR is initial ( str is global)

But still it finds the string only after 2 clicks in 2nd grid.

What to do ?

Thanks,

Prabs.

0 Kudos

Have you put a break-point in the form yet? You have the code there and can see better what's going on.

Are you clearing out STR in search_in_scr or anywhere else??

Rob

Message was edited by: Rob Burbank