Application Development and Automation 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: 
Read only

Diaglog Program - To write 'Find'

Former Member
0 Likes
870

Hello,

I am writing a dialog program, in PBO under 'Find' I entered '%SC'. Looks like I need to write the code for this 'Find'. Is there a way I can use SAP find code to utlize in my program.

Thanks,

PV

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
799

Here i am attaching code which i used in one of the programs to use FIND functionality. FIND is the user command assigned in the pf status and you need to alter this code and add to your User command module of PAI.

if sy-ucomm eq 'FIND'.

clear g_val2.

  • Popup for the user to enter value to search for

call function 'POPUP_TO_GET_VALUE'

exporting

fieldname = 'FINDSTR'

tabname = 'RSDXX'

titel = ''

valuein = l_val

importing

answer = l_ans

valueout = g_val2

exceptions

fieldname_not_found = 1

others = 2.

if sy-subrc <> 0.

endif.

endif.

move g_top_line to l_cnt.

loop at i_sl_tab from g_top_line.

if l_first eq 'X'.

clear l_first.

continue.

endif.

if i_sl_tab-err cs g_val2.

g_top_line = sy-tabix.

exit.

endif.

if i_sl_tab-res cs g_val2.

g_top_line = sy-tabix.

exit.

endif.

if i_sl_tab-num cs g_val2.

g_top_line = sy-tabix.

exit.

endif.

endloop.

  • If there are no more entries for the search, display message

if g_top_line eq l_cnt.

message s899 with 'String'(104) g_val2 'not found'(109).

endif.

Hopefully this will help you out.

5 REPLIES 5
Read only

Former Member
0 Likes
800

Here i am attaching code which i used in one of the programs to use FIND functionality. FIND is the user command assigned in the pf status and you need to alter this code and add to your User command module of PAI.

if sy-ucomm eq 'FIND'.

clear g_val2.

  • Popup for the user to enter value to search for

call function 'POPUP_TO_GET_VALUE'

exporting

fieldname = 'FINDSTR'

tabname = 'RSDXX'

titel = ''

valuein = l_val

importing

answer = l_ans

valueout = g_val2

exceptions

fieldname_not_found = 1

others = 2.

if sy-subrc <> 0.

endif.

endif.

move g_top_line to l_cnt.

loop at i_sl_tab from g_top_line.

if l_first eq 'X'.

clear l_first.

continue.

endif.

if i_sl_tab-err cs g_val2.

g_top_line = sy-tabix.

exit.

endif.

if i_sl_tab-res cs g_val2.

g_top_line = sy-tabix.

exit.

endif.

if i_sl_tab-num cs g_val2.

g_top_line = sy-tabix.

exit.

endif.

endloop.

  • If there are no more entries for the search, display message

if g_top_line eq l_cnt.

message s899 with 'String'(104) g_val2 'not found'(109).

endif.

Hopefully this will help you out.

Read only

Former Member
0 Likes
799

The "%SC" is for using the inbuilt "find" in lists (reports) and "%SC=" does "find again". To implement your own "find" in a module pool, you can set the button to whatever you need e.g. "ZSEEK", and then implement the logic that is appropriate to your business requirement withing the PAI... and you might find just having a "find value" / "position at" / "goto" field on the screen instead is easier for the users.

Jonathan

p.s. this thread might be better placed under UI Programming

Read only

0 Likes
799

Hi Jonathan,

How to use inbuilt "find"? When I used '%SC', 'Find' button doesn't do anything. Do you how to implement inbuilt find?

Thanks,

PV

Read only

0 Likes
799

As noted above, it depends on what you / your users want the "find" in your dialog program to do...

The "%SC" only works in a report ... for example, run transaction LIBS... then in the command box at the top of the SAPGui type in %SC - you will get the "Find" box and this will let you search the data that has been brought to the screen in the list.

So what is your dynpro doing?... For example "find" could mean "find an employee name" or "find the best price" or "find a file on the PC"... it very much depends on what your screens contain.

If you want to implement a "find" for a table control, for example, you would need to do something like the example the other person above wrote i.e. get a search value from the user, look through the internal table where you have the data values, match the search value to a row (or not!), and reposition the table control so that entry is at the top of the list... there's no magic solution, just traditional code logic.

Jonathan

Read only

Former Member
0 Likes
799

hi,

IS ur scenario like this?

U using one table control to display data and whn u press FIND button one screen opens in which u have to give find term?

If this is the case i can help u.

reward me back if this is so.