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: 

Position pushbutton (SEARCH ) functionality with a table control

Former Member
0 Kudos

Hi All,

I need a Position pushbutton functionality with a table control ....

If i click on that button ,it should pop-up another small screen with a two input field (primary keys ) based on which it should be able to locate (placing the cursor ) on that matching entry in the table control ....

Eg. similar table control applications can be found in SPRO ....to locate the serached entry in the table control ......

// in other words .....................

I have displayed records from DB table to a table control.There are more than 100 records.Now i want to keep a search button in which we want to give the key value and it want to take to tht particular line(either it is 99th line or 12th line)

Note : In the screen we can only view 10 records at a time.

can any tell how to get this

Any help will be appreciated ...

Regards

Jaman

Edited by: ABAP Techie on Jan 28, 2008 1:03 PM

Edited by: ABAP Techie on Jan 28, 2008 1:12 PM

Edited by: ABAP Techie on Jan 29, 2008 10:54 AM

Edited by: ABAP Techie on Jan 29, 2008 11:07 AM

1 ACCEPTED SOLUTION

Former Member
0 Kudos

use this

It has worksed for me.

It will work sure shot

DATA IT_FIELDS TYPE STANDARD TABLE OF SVAL WITH HEADER LINE.

  • under user-command

POPUP_TITLE = 'Choose Purchase Order Number'.

CLEAR IT_FIELDS.

IT_FIELDS-TABNAME = 'Z11KUSH_EKPO_NEW'.

  • IT_FIELDS-FIELDNAME = 'EBELN'.

IT_FIELDS-FIELDNAME = 'EBELP'.

IT_FIELDS-FIELD_ATTR = ' '.

IT_FIELDS-FIELD_OBL = 'X'.

APPEND IT_FIELDS.

CALL FUNCTION 'POPUP_GET_VALUES'

EXPORTING

NO_VALUE_CHECK = 'X'

POPUP_TITLE = POPUP_TITLE

START_COLUMN = '5'

START_ROW = '5'

IMPORTING

RETURNCODE = RETURNCODE

TABLES

FIELDS = IT_FIELDS

EXCEPTIONS

ERROR_IN_FIELDS = 1

OTHERS = 2.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

IF RETURNCODE = ' '.

SORT I_EKPO BY EBELP.

READ TABLE I_EKPO WITH KEY EBELP = IT_FIELDS-VALUE.

IF SY-SUBRC = 0.

TABLECONTROL-TOP_LINE = SY-TABIX.

V_CURR_LINE = sy-tabix.

V_TOT_LINE = tablecontrol-lines.

REFRESH IT_FIELDS.

CLEAR RETURNCODE.

ENDIF.

ENDIF.

Dont forget to reward points,

kush

5 REPLIES 5

Former Member
0 Kudos

rohan,

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.

Don't forget to reward if useful...

0 Kudos

Hi Mahesh,

Would you plz elaborate your explanation ......I have accomplished unto the below but throws an error

1) Placed a pushbutton with FCODE "SRCH"

2) Created a Module USER_COMMAND_0200 INPUT in PAI

DATA : key(20),

position TYPE i VALUE 0,

SELLIST TYPE standard table of VIMSELLIST,

EXCLUDE_FIELDS TYPE standard table of VIMEXCLFLD.

FIELD-SYMBOLS: <F1>.

&----


*& Module USER_COMMAND_0200 INPUT

&----


MODULE USER_COMMAND_0200 INPUT.

CASE SY-UCOMM.

WHEN 'SRCH'.

CALL FUNCTION 'TABLE_GET_KEY_TO_SET_CUR_ROW'

EXPORTING

TABLE = 'INT1'

F4_FORMNAME = 'TSFP_F4'

F4_PROGRAMNAME = 'SAPLSVIX'

  • F1_FORMNAME = ' '

  • F1_PROGRAMNAME = ' '

IMPORTING

TABLE_KEY = key

  • TABLES

  • SELLIST = SELLIST

  • EXCLUDE_FIELDS = EXCLUDE_FIELDS

EXCEPTIONS

CANCELLED_BY_USER = 1

TABLE_NOT_FOUND = 2

OTHERS = 3.

CASE SY-SUBRC.

WHEN 1. RAISE CANCELLED_BY_USER.

WHEN 2. RAISE TABLE_NOT_FOUND.==========>getting this error

WHEN 3. RAISE OTHERS.

ENDCASE.

POSITION = 1.

SY-FDPOS = STRLEN( key ).

IF SY-FDPOS = 0.

SY-FDPOS = 1.

ENDIF.

ASSIGN key(SY-FDPOS) TO <F1>.

READ TABLE INT1 WITH KEY <F1> BINARY SEARCH.

IF sy-subrc EQ 0.

position = SY-TABIX.

tab200-top_line = position.

ENDIF.

Where am i going wrong ?????? Plz help ...

Regards

Jaman

Edited by: ABAP Techie on Jan 29, 2008 11:30 AM

Former Member
0 Kudos

You have to place a push button in Table Control.and write the following code in PAI for the corresponding function-code

'GET CURSOR FIELD <field> LINE <line >'

Where field is the field name and you can get the line number in <line>.

Then you can read the corresponding ITAB based on this line number.

Former Member
0 Kudos

hi,

write down this on user_command module of PAI of first screen

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

and on other screen's user_command module

MODULE user_command_1001 INPUT.

CASE sy-ucomm.

WHEN 'OK'.

CALL SCREEN 1000. " call first screen again

ENDCASE.

ENDMODULE. " USER_COMMAND_1001 INPUT

here is my module of PBO in which i am fetching value for table control

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

here on screen 1001( second screen to enter search term) i have taken one i/o field named strin

reward me back if u not get....

Former Member
0 Kudos

use this

It has worksed for me.

It will work sure shot

DATA IT_FIELDS TYPE STANDARD TABLE OF SVAL WITH HEADER LINE.

  • under user-command

POPUP_TITLE = 'Choose Purchase Order Number'.

CLEAR IT_FIELDS.

IT_FIELDS-TABNAME = 'Z11KUSH_EKPO_NEW'.

  • IT_FIELDS-FIELDNAME = 'EBELN'.

IT_FIELDS-FIELDNAME = 'EBELP'.

IT_FIELDS-FIELD_ATTR = ' '.

IT_FIELDS-FIELD_OBL = 'X'.

APPEND IT_FIELDS.

CALL FUNCTION 'POPUP_GET_VALUES'

EXPORTING

NO_VALUE_CHECK = 'X'

POPUP_TITLE = POPUP_TITLE

START_COLUMN = '5'

START_ROW = '5'

IMPORTING

RETURNCODE = RETURNCODE

TABLES

FIELDS = IT_FIELDS

EXCEPTIONS

ERROR_IN_FIELDS = 1

OTHERS = 2.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

IF RETURNCODE = ' '.

SORT I_EKPO BY EBELP.

READ TABLE I_EKPO WITH KEY EBELP = IT_FIELDS-VALUE.

IF SY-SUBRC = 0.

TABLECONTROL-TOP_LINE = SY-TABIX.

V_CURR_LINE = sy-tabix.

V_TOT_LINE = tablecontrol-lines.

REFRESH IT_FIELDS.

CLEAR RETURNCODE.

ENDIF.

ENDIF.

Dont forget to reward points,

kush