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: 

Search and move in a control table

Former Member
0 Kudos

Hi guys,

I create a control table that reads a lot of data, so i need to implement a search function.

the easy part is that i can search it in the internal table, my problem is that i need to move the cursor to that position. who do i scroll it?

its dynpro.

any ideas?

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Javier; after i check the code i can give a solution

1. After you know the line in your IT you need to put your the TOP_LINE in the structure of the TC; all this must to be in PAI.


*&SPWIZARD: set the new top line                                       *
   TC-TOP_LINE = Line_to_Move_after_search.

The code that gave you Seshu only move the cursor inside of your TC.

Regards

David N

3 REPLIES 3

Former Member
0 Kudos

Hi Javier, Please check this function "SCROLLING_IN_TABLE" and the next code that is generated by wizard

*&---------------------------------------------------------------------*
*&      Form  COMPUTE_SCROLLING_IN_TC
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_TC_NAME  name of tablecontrol
*      -->P_OK       ok code
*----------------------------------------------------------------------*
 FORM COMPUTE_SCROLLING_IN_TC USING    P_TC_NAME
                                       P_OK.
*&SPWIZARD: BEGIN OF LOCAL DATA----------------------------------------*
   DATA L_TC_NEW_TOP_LINE     TYPE I.
   DATA L_TC_NAME             LIKE FELD-NAME.
   DATA L_TC_LINES_NAME       LIKE FELD-NAME.
   DATA L_TC_FIELD_NAME       LIKE FELD-NAME.

   FIELD-SYMBOLS <TC>         TYPE cxtab_control.
   FIELD-SYMBOLS <LINES>      TYPE I.
*&SPWIZARD: END OF LOCAL DATA------------------------------------------*

   ASSIGN (P_TC_NAME) TO <TC>.
*&SPWIZARD: get looplines of TableControl                              *
   CONCATENATE 'G_' P_TC_NAME '_LINES' INTO L_TC_LINES_NAME.
   ASSIGN (L_TC_LINES_NAME) TO <LINES>.


*&SPWIZARD: is no line filled?                                         *
   IF <TC>-LINES = 0.
*&SPWIZARD: yes, ...                                                   *
     L_TC_NEW_TOP_LINE = 1.
   ELSE.
*&SPWIZARD: no, ...                                                    *
     CALL FUNCTION 'SCROLLING_IN_TABLE'
          EXPORTING
               ENTRY_ACT             = <TC>-TOP_LINE
               ENTRY_FROM            = 1
               ENTRY_TO              = <TC>-LINES
               LAST_PAGE_FULL        = 'X'
               LOOPS                 = <LINES>
               OK_CODE               = P_OK
               OVERLAPPING           = 'X'
          IMPORTING
               ENTRY_NEW             = L_TC_NEW_TOP_LINE
          EXCEPTIONS
*              NO_ENTRY_OR_PAGE_ACT  = 01
*              NO_ENTRY_TO           = 02
*              NO_OK_CODE_OR_PAGE_GO = 03
               OTHERS                = 0.
   ENDIF.

*&SPWIZARD: get actual tc and column                                   *
   GET CURSOR FIELD L_TC_FIELD_NAME
              AREA  L_TC_NAME.

   IF SYST-SUBRC = 0.
     IF L_TC_NAME = P_TC_NAME.
*&SPWIZARD: et actual column                                           *
       SET CURSOR FIELD L_TC_FIELD_NAME LINE 1.
     ENDIF.
   ENDIF.

*&SPWIZARD: set the new top line                                       *
   <TC>-TOP_LINE = L_TC_NEW_TOP_LINE.


 ENDFORM.                              " COMPUTE_SCROLLING_IN_TC

Regards

David N

Former Member
0 Kudos

You can use below code :

set cursor field 'name of the field' line table_control_name-current_line.

Thanks

Seshu

Former Member
0 Kudos

Hi Javier; after i check the code i can give a solution

1. After you know the line in your IT you need to put your the TOP_LINE in the structure of the TC; all this must to be in PAI.


*&SPWIZARD: set the new top line                                       *
   TC-TOP_LINE = Line_to_Move_after_search.

The code that gave you Seshu only move the cursor inside of your TC.

Regards

David N