Frage

Is there an ABAP custom control with which I can realize syntax highlightning? I am using DynPro and not Web Dynpro.

I want to display a textarea which highlights XML code. It would also be great if I could move the cursor to a certain position inside the textarea and therefore inside the code.

Can I do this with cl_gui_textedit?

War es hilfreich?

Lösung

You can use the cl_gui_html_viewer class to display XML code in the SAP GUI. This control uses Internet Explorer by default to display HTML content, and is also capable of showing XML content. Here's some quick-and-dirty sample code to get you started. It's part of a program which has one screen 100, containing a custom control named XMLDEMO (height 27, width 120).

The report zxmldemo:

report zxmldemo.
include zxmldemo_status_0100o01.
start-of-selection.
  set screen '100'.

And the include zxmldemo_status_0100o01:

module status_0100 output.
  data xmlstringtable type standard table of char255.
  append '<?xml version="1.0" encoding="ISO-8859-1"?>' to xmlstringtable.
  append '<note><to>Tove</to><from>Jani</from>' to xmlstringtable.
  append '<heading>Reminder</heading>' to xmlstringtable.
  append '<body>Don''t forget me this weekend!</body></note>' to xmlstringtable.
  data container type ref to cl_gui_custom_container.
  create object container
    exporting
      container_name = 'XMLDEMO'.
  data htmlviewer type ref to cl_gui_html_viewer.
  create object htmlviewer
    exporting
      parent = container.
  data url(1024) type c value 'test.xml'.
  htmlviewer->load_data( exporting url = url type = 'text' subtype = 'xml'
                         changing data_table = xmlstringtable ).
  htmlviewer->show_url( url ).
endmodule.

I don't think it's possible to show and move the cursor.

Andere Tipps

You can use any ActiveX object or object that supports OLE automation on the client and run that inside a custom control in a SAP GUI screen. If you Google around, I think you may find something to suit your needs. Then, you can establish a custom control area on the screen and run the application inside there.

This requires of course that you know upfront that the application in question is installed on the client, and if you are not able to instantiate it from ABAP, you can give a an error to the user.

Improving on René`s answer: if you have an HTML control, you might as well load some HTML-based editor like EditArea into it instead of source document and show and/or edit XML in that editor.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top