‎2008 Jun 18 10:37 AM
Hi ,
How to provide 'FIND' button functinality for table control.
thanks .
‎2008 Jun 18 10:39 AM
hi,
when user press find button , one screen get call and i enter search term in that and then it finds the row with same string...
if u want so then do like this
MODULE user_command_1000 INPUT.
CASE sy-ucomm.
WHEN 'BACK' OR 'UP' OR 'CANC'.
LEAVE PROGRAM.
WHEN 'FND'.
CALL SCREEN 1001 STARTING AT 37 5 ENDING AT 87 22.
ENDCASE.
ENDMODULE. " user_command_1000 INPUT
when user enters search term u need to call ur main screen
MODULE user_command_1001 INPUT.
CASE sy-ucomm.
WHEN 'OK'.
CALL SCREEN 1000.
ENDCASE.
ENDMODULE. " USER_COMMAND_1001 INPUT
now u will have on module in PBO in which u fetching data...
write this in that module..
MODULE fetch_data OUTPUT.
SELECT matnr matkl INTO CORRESPONDING FIELDS OF TABLE itab
FROM mara
WHERE matnr BETWEEN '000000000000000101' AND '000000000000000115'.
IF strin IS NOT INITIAL.
wa_itab-mark = 'X'.
LOOP AT itab.
IF itab-matnr = strin.
line1 = sy-tabix.
EXIT.
ENDIF.
ENDLOOP.
IF line1 0.
MODIFY itab INDEX line1 FROM wa_itab TRANSPORTING mark.
SET CURSOR LINE line1.
tab1-top_line = line1.
ENDIF.
ENDIF.
ENDMODULE. " fetch_data OUTPUT
strin is variable of screen 1001 in which i give search term..
reward if usefull.
‎2008 Jun 18 10:39 AM
‎2008 Jun 18 10:39 AM
hi,
when user press find button , one screen get call and i enter search term in that and then it finds the row with same string...
if u want so then do like this
MODULE user_command_1000 INPUT.
CASE sy-ucomm.
WHEN 'BACK' OR 'UP' OR 'CANC'.
LEAVE PROGRAM.
WHEN 'FND'.
CALL SCREEN 1001 STARTING AT 37 5 ENDING AT 87 22.
ENDCASE.
ENDMODULE. " user_command_1000 INPUT
when user enters search term u need to call ur main screen
MODULE user_command_1001 INPUT.
CASE sy-ucomm.
WHEN 'OK'.
CALL SCREEN 1000.
ENDCASE.
ENDMODULE. " USER_COMMAND_1001 INPUT
now u will have on module in PBO in which u fetching data...
write this in that module..
MODULE fetch_data OUTPUT.
SELECT matnr matkl INTO CORRESPONDING FIELDS OF TABLE itab
FROM mara
WHERE matnr BETWEEN '000000000000000101' AND '000000000000000115'.
IF strin IS NOT INITIAL.
wa_itab-mark = 'X'.
LOOP AT itab.
IF itab-matnr = strin.
line1 = sy-tabix.
EXIT.
ENDIF.
ENDLOOP.
IF line1 0.
MODIFY itab INDEX line1 FROM wa_itab TRANSPORTING mark.
SET CURSOR LINE line1.
tab1-top_line = line1.
ENDIF.
ENDIF.
ENDMODULE. " fetch_data OUTPUT
strin is variable of screen 1001 in which i give search term..
reward if usefull.
‎2008 Jun 18 10:42 AM
Hi,
The fun module TABLE_GET_KEY_TO_SET_CUR_ROW is called for the Function position to find the correct Row .
Means suppose in you table control you have lot of records .To find particular and select that this Fm is useful..
EX:
1) add a button say search box .
2) when user clicks on this button show
dialog box with enter key field No:
3) when user enter box no search table control
intternal table and if found
set tc1-current_line = sy-tabix of record found.
DATA : ata: h_table_key(20) type c.
'V_TQ85 is internal table.
call function 'TABLE_GET_KEY_TO_SET_CUR_ROW'
EXPORTING
table = 'V_TQ85'
IMPORTING
table_key = h_table_key
EXCEPTIONS
cancelled_by_user = 1
table_not_found = 2
others = 3.
Help children of U.N World Food Program by rewarding them and encourage others to answer your queries
‎2008 Jun 18 10:43 AM
‎2008 Jun 18 10:54 AM
‎2008 Jun 18 11:11 AM
hi shah ,
The set cursor is not wroking , the value is geting displayed based on the top line index .
Eg . if have ten lines in table control that are displayed i.e sy-loopc .
if iam searching for say '9' , which is present in the 9th line . then i can see 9 at the top line and again 9 after 8 lines .
‎2008 Jun 19 9:18 AM