Skip to Content
author's profile photo Former Member
Former Member

The PAI Event Code to search for a record in Table Control

Logic

1. I have a position button and entry text field (search content) for a table control in my screen. Position button has the function code 'PBUT'.

2. Content of table control will be in an internal table. The entry text field is to be used for positioning.

3. I enter the search (key) field in text field & Click the position button.

4. The PAI event of button click (Module user_command) of that screen is as under.

Case sy_ucomm.

When 'PBUT'.

What will be the code to bring the row as selected in table control, that I have to write here, for this case-value.

Endcase.

Regards,

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

5 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Sep 02, 2006 at 09:56 AM

    hI,

    Alok, i`ve given u the reply to ur earlier thread.

    Check it out.

    Rgds

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 02, 2006 at 10:06 AM

    Hey,

    I`d sent you another reply after ur query about BD60. Look into that....i`ve sent some sample code alongwith the program.

    Reward points if helpful.

    Rgds

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 02, 2006 at 11:14 AM

    Hi Alok,

    I will show you a way to do this,

    in your table control, you will have first field, if that equals 'X', then that should be selected, rigth.

    so, in your PAI event, write the like

    case SY-UCOMM.

    when 'PBUT'.

    read that internal table with key field = search-field.

    if sy-subrc = 0.

    put the first value of that internal table = 'X', so

    that will be selected in the screen.

    else.

    give error message.

    endif.

    endcase.

    i hope you understand my point.

    Regards

    Sudheer

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 07, 2006 at 05:32 AM

    Hi Alok,

    Excuse me, couldn`t catch u yesterday. Ok i`ve the code which will set the cursor on the selected entry.

    Reward points if convinced.

    *&---------------------------------------------------------------------*
    *& Report  Y131_TC_TEST                                                *
    *&                                                                     *
    *&---------------------------------------------------------------------*
    *&                                                                     *
    *&                                                                     *
    *&---------------------------------------------------------------------*
    
    REPORT  y131_tc_test NO STANDARD PAGE HEADING.
    
    TABLES: vbak.
    
    DATA : BEGIN OF str_tc,
           vbeln LIKE vbak-vbeln,
           erdat LIKE vbak-erdat,
           END OF str_tc,
    
           it_tc LIKE TABLE OF str_tc WITH HEADER LINE,
           loopc LIKE sy-loopc,
           flag,
           lin TYPE i.
    
    CONTROLS : my_tc TYPE TABLEVIEW USING SCREEN 9000.
    
    CALL SCREEN 9000.
    *&---------------------------------------------------------------------*
    *&      Module  STATUS_9000  OUTPUT
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    MODULE status_9000 OUTPUT.
    *  SET PF-STATUS 'xxxxxxxx'.
    *  SET TITLEBAR 'xxx'.
    
      IF it_tc[] IS INITIAL.
    
        SELECT vbeln erdat INTO TABLE it_tc UP TO 10
        ROWS FROM vbak.
    
        DESCRIBE TABLE it_tc LINES lin.
        my_tc-top_line = loopc.
    
      ENDIF.
    
    ENDMODULE.                 " STATUS_9000  OUTPUT
    *&---------------------------------------------------------------------*
    *&      Module  USER_COMMAND_9000  INPUT
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    MODULE user_command_9000 INPUT.
    
      CASE sy-ucomm.
        WHEN 'EXIT'.
          LEAVE PROGRAM.
       <b> WHEN 'PBUT'.</b>
    **** Now this event is triggerred when the user uses the ****Position Push button to locate the field value.
          CALL SCREEN 9001 STARTING AT 10 15.
      ENDCASE.
    
    ENDMODULE.                 " USER_COMMAND_9000  INPUT
    *&---------------------------------------------------------------------*
    *&      Module  USER_COMMAND_9001  INPUT
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    MODULE user_command_9001 INPUT.
    
      CASE sy-ucomm.
    
        WHEN 'OKAY' OR ' ' or 'EXIT'.
    <b>**** When the user selects values from the search help on **** position button, the itab is read and index is *****assigned</b>
          READ TABLE it_tc WITH KEY vbeln = vbak-vbeln.
    
          IF sy-subrc = 0.
    
            loopc = sy-tabix.
            flag = 'X'.
    **** the cursor is set here
           <b> my_tc-top_line = loopc.</b>
             SET SCREEN 0.
          LEAVE SCREEN.
    
          ENDIF.
    
       
    
      ENDCASE.
    
    ENDMODULE.                 " USER_COMMAND_9001  INPUT
    *&---------------------------------------------------------------------*
    *&      Module  STATUS_9001  OUTPUT
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    MODULE status_9001 OUTPUT.
      SET PF-STATUS 'MODAL'.
    *  SET TITLEBAR 'xxx'.
    
    ENDMODULE.                 " STATUS_9001  OUTPUT

    Regards

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 07, 2006 at 06:19 AM

    Alok,

    To add a few points to my code.....

    In ur tablecontrol, either make it is input off or deactivate the search help on the field BOXNO in the table control.

    Attach a extra push button POSITION which`ll have the search help for BOXNO, now the user can only select values from this and not the table control.

    Whatever happening in ur case is very natural since only the BOXNO will get replaced.

    Rgds

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.