Register Login

Double click functionality in table control

Updated May 18, 2018

Hell all,

I have created a module pool with double click functionality. However I am getting an error stating that "Unable to interpret WA_0001-PERNR as a number".

I have pasted the code below as the .txt file was not getting attached (dont know why). Kindly help.

* 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.

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.
      IF LV_FIELD = 'WA_0001-PERNR'.
      CALL SCREEN 1002.
      ENDIF.
  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 LV_FIELD.

ENDMODULE.                 " GET_DATA_0006  OUTPUT
* Create transaction code and execute.

 


×