Tuesday, December 28, 2010

Procedure: 

  1. PBO ->Set PF-STATUS for screen and set Function Code 'PICK' for F2 function key.
  2. Double click on each table control field ->Screen element properties popup->Click Display attributes tab->Check "Responds to Double-click" check box.
  3. PAI ->Read the line on which double click was happened. 

Sample program

  • Create one module program SAPMZTEST_DBL_CLICK at SE80.
  • Define two internal table IT_0001 and IT_0006 and two table control controller variable for two screens 1001 and 1002 in TOP include.
  • Define OK_CODE variable in TOP include.
  • Activate TOP include. 
  • Top include code
  • PROGRAM  SAPMZTEST_DBL_CLICK.
    TYPES:
         BEGIN OF TY_0001,
            PERNR TYPE PA0001-PERNR,
            ENAME TYPE PA0001-ENAME,
          END OF TY_0001,
          BEGIN OF TY_0006,
            PERNR TYPE PA0006-PERNR,
            ANSSA TYPE PA0006-ANSSA,
            NAME2 TYPE PA0006-NAME2,
            STRAS TYPE PA0006-STRAS,
            ORT01 TYPE PA0006-ORT01,
            ORT02 TYPE PA0006-ORT02,
            PSTLZ TYPE PA0006-PSTLZ,
            LAND1 TYPE PA0006-LAND1,
            TELNR TYPE PA0006-TELNR,
          END OF TY_0006.
    DATA:
          IT_0001 TYPE STANDARD TABLE OF TY_0001,
          IT_0006 TYPE STANDARD TABLE OF TY_0006.
    DATA:
          WA_0001 TYPE TY_0001,
          WA_0006 TYPE TY_0006.
    
    CONTROLS:
          TC_0001 TYPE TABLEVIEW USING SCREEN '1001',
          TC_0006 TYPE TABLEVIEW USING SCREEN '1002'.
    DATA: OK_CODE TYPE SY-UCOMM.
    
  • Create screen 1001 and table control(TC_0001) in it and place IT_0001 program table fields in the table control.
    • Click on each field of table control and check RESPOND TO DOUBLE-CLICK in the properties of screen field properties. 
    • PBO - Create SET PF-STAUS for screen 1001 and set "PICK" function code for F2 function key.
    • PAI - Read selected line of the table control( Statement GET CURSOR FIELD). 
    • Call Screen 1002.
    • Flow logic code.
    • PROCESS BEFORE OUTPUT.
      
        MODULE STATUS_1001.
        MODULE GET_DATA_0001.
        LOOP AT IT_0001 INTO WA_0001 WITH CONTROL TC_0001.
        ENDLOOP.
      
      PROCESS AFTER INPUT.
      
        LOOP AT IT_0001.
        ENDLOOP.
       MODULE USER_COMMAND_1001.
      

      *&------------------------------------------------------------*
      *&      Module  STATUS_1001  OUTPUT
      *&------------------------------------------------------------*
      *       text
      *-------------------------------------------------------------*
      MODULE STATUS_1001 OUTPUT.
        SET PF-STATUS 'ZTEST_DBL_CLICK'.
      ENDMODULE.                 " STATUS_1001  OUTPUT
      
    • Function code "PICK" should be set to F2 function key.

    • *&-----------------------------------------------------------*
      *&      Module  GET_DATA_0001  OUTPUT
      *&-----------------------------------------------------------*
      *       text
      *-----------------------------------------------------------*
      MODULE GET_DATA_0001 OUTPUT.
        IF IT_0001 IS INITIAL.
          SELECT *
            FROM PA0001
            INTO CORRESPONDING FIELDS OF TABLE IT_0001
            UP TO 50 ROWS.
          SORT IT_0001 BY PERNR.
          DELETE ADJACENT DUPLICATES FROM IT_0001.
        ENDIF.
      
      ENDMODULE.                 " GET_DATA_0001  OUTPUT
      

      *&------------------------------------------------------------*
      *&      Module  USER_COMMAND_1001  INPUT
      *&-----------------------------------------------------------*
      *       text
      *------------------------------------------------------------*
      MODULE USER_COMMAND_1001 INPUT.
        DATA: LV_FIELD(30),
              LV_LINE TYPE I.
        CASE OK_CODE  .
          WHEN 'PICK'.
            GET CURSOR FIELD LV_FIELD LINE LV_LINE.
            READ TABLE  IT_0001 INDEX LV_LINE INTO WA_0001.
            CALL SCREEN 1002.
        ENDCASE.
      ENDMODULE.                 " USER_COMMAND_1001  INPUT
      
  • Create screen 1002 and table control(TC_0006) in it and place IT_0006 program table fields in the table control. 
  • Flow logic code.
  • PROCESS BEFORE OUTPUT.
    
      MODULE GET_DATA_0006.
      LOOP AT IT_0006 INTO WA_0006 WITH CONTROL TC_0006.
      ENDLOOP.
    
    PROCESS AFTER INPUT.
      LOOP AT IT_0006.
      ENDLOOP.
    

    *&-------------------------------------------------------*
    *&      Module  GET_DATA_0006  OUTPUT
    *&------------------------------------------------------*
    *       text
    *-------------------------------------------------------*
    MODULE GET_DATA_0006 OUTPUT.
    
      SELECT *
        FROM PA0006
        INTO CORRESPONDING FIELDS OF TABLE IT_0006
       WHERE PERNR EQ WA_0001-PERNR.
    
    ENDMODULE.                 " GET_DATA_0006  OUTPUT
    
  • Create transaction code and execute. 


2 comments:

Your useful comments, suggestions are appreciated.Your comments are moderated.

Followers

Contact Form

Name

Email *

Message *

Web Dynpro ABAP Book

An SAP Consultant

Follow US


Want to Contribute ?

If you are interested in writing about the new stuff you learn everyday while working, please write to the.sap.consultants@gmail.com.

Click on Contribution for more details.