Copyright 2024 - BV TallVision IT

When the user double clicks on a vendor number, the display vendor transaction is called presenting the vendor to your end user. How should a double click be caught ? A simple report example.

When a report is displayed, the next step to make the report interactive is most likely double clicks. Your end user double clicks on a line, and your program continues the processing of this line. Here's a short example of a report that allows double clicks:

REPORT ZDOUBLE_CLICK.

  WRITE: / 'Please', / 'double', 
         / 'click', / 'here'.

AT LINE-SELECTION.
  WRITE: / 'You double clicked !'.

You may well notice: if you press the Back button, you "drop back" into the first report. This means by doing the double click, you actually activated a second level report (check out SY-LSIND).

When a menu (status) is used (other than the SAP standard menu), it has to be indicated in this menu that double clicking has to be processed. This can be done as follows: enter a function code for function key PF2 in the menu painter. Choose for example "PICK" as function code. The idea is that double clicks are caught by the user menu (status). If the function key reserved for this is not maintained in the status, the double clicks will be ignored. Whenever SAP's standard status is used, double clicks will be accepted.

Also: Make sure you use both system variables SY-CUCOL and SY-STACO if you want to calculate the position that was double clicked on. If only SY-CUCOL is used, your program won't take scrolling of windows into account. This is the formulae to calculating the report position:

CLICKED_POSITION = SY-CUCOL + SY-STACO - 1.

Determine the context

However nice it is that a report can respond to a double click, it's of paramount importance to find out what was double clicked on. Here's a few pointers to get you started:

  • Hide information with your report lines, you can store information with the line you are reporting, without outputting this info using the HIDE statement.
    DATA: LINETYPE. "Identifies the type of line 2b written
    
    LINETYPE = 'H'. "Type: header data
    WRITE: / 'Ordernumber: ', AUFK-AUFNR.
    HIDE LINETYPE.
    ULINE.
    LINETYPE = 'P'. "Type: position data
    WRITE: / 'Orderposition:', AFPO-POSNR.
    HIDE LINETYPE.
    SKIP 2.
    WRITE: / 'Amount', POSITION_AMOUNT. 
    
    With the above preparation the end user can, by double clicking, easily track which processing the ABAP has to chose for the selected line.
    AT LINE-SELECTION.
    
    READ CURRENT LINE.
    CASE LINETYPE. 
      WHEN ' '.      "Empty: no position or header selected  
       MESSAGE I019. 
      WHEN 'H'.      "Header data selected  
        PERFORM DISPLAY_ORDER.  
      WHEN 'P'.      "Position data selected  
        PERFORM DISPLAY_ORDERPOSITIE.  
    ENDCASE. 
    
  • Pick up the name of the field that was clicked on with:
    GET CURSOR FIELD <my_fieldname>.
  • Pick up the value of the field that was clicked on with:
    GET CURSOR FIELD <my_fieldname> VALUE <my_fieldvalue>.