How can I assign an operation of my choice to a doubleclick on a given field?

SAP GUI transforms the doubleclick into "F2". With

On "/2"  process="return.txt"

where the script "return.txt" consists of  a "return" command only, all doubleclicks are ignored.
In order to assign a special action, you can query the name of the field which has been doubleclicked:

if V[_cursorfieldname=xxx]

  // operation of your choice

endif

where xxx is the field label.

Alternatively you may use the technical field name

V[_cursorfieldtechname]

For table cells you may use

V[_cursortabname]

V[_cursortabtechname]

V[_cursorcol]

V[_cursorcolname]

V[_cusrorcoltechname]

V[_tabrow]

V[_tabcol]