2012 Jul 17 9:13 AM
Hello Experts,
I have a requirement to display and edit an XML document in ABAP and then some processing of changed XML.
After searching on many threads in SCN i found that i can use the Class cl_gui_xml_editor for this .
Now I am able to see the XML in the left hand tree of my screen but If i Click on the Node of tree, data is not populated on the right
hand side Table control.
Do I need to Handle the click event of the tree node with my custom class. If yes then what attribute should be set and how to
show the data on the right hand table ?
here is the code which i have implemented in my subroutine :
* Create docking container
CREATE OBJECT go_docking
EXPORTING
parent = cl_gui_container=>screen0
ratio = 90
EXCEPTIONS
OTHERS = 6.
CALL METHOD cl_gui_xml_editor=>create
EXPORTING
im_container = go_docking
im_xml = gd_xml " this contains the XML
IMPORTING
ex_editor = go_xml_editor.
go_xml_editor->get_editor( ).
* Link the docking container to the target dynpro
CALL METHOD go_docking->link
EXPORTING
repid = syst-repid
dynnr = '0100'
* CONTAINER =
EXCEPTIONS
OTHERS = 4.
gx_xml_editor_prop = go_xml_editor->get_properties( ).
CALL METHOD gx_xml_editor_prop->set_attributes
EXPORTING
im_readonly = 0
im_view = 'X'
im_view_mode = 'X'.
* ok-code field = GD_OKCODE, no elements on screen
CALL SCREEN '0100'.
2012 Jul 17 9:30 AM
I checked it and when we click on the folder it displays the values. In your case try clicking on "Engineers","task","assignment". If it does not work please update here, I will try to provide a sample.
Kesav
Hello Experts,
I have a requirement to display and edit an XML document in ABAP and then some processing of changed XML.
After searching on many threads in SCN i found that i can use the Class cl_gui_xml_editor for this .
Now I am able to see the XML in the left hand tree of my screen but If i Click on the Node of tree, data is not populated on the right
hand side Table control.
Do I need to Handle the click event of the tree node with my custom class. If yes then what attribute should be set and how to
show the data on the right hand table ?
here is the code which i have implemented in my subroutine :
* Create docking container
CREATE OBJECT go_docking
EXPORTING
parent = cl_gui_container=>screen0
ratio = 90
EXCEPTIONS
OTHERS = 6.
CALL METHOD cl_gui_xml_editor=>create
EXPORTING
im_container = go_docking
im_xml = gd_xml " this contains the XML
IMPORTING
ex_editor = go_xml_editor.
go_xml_editor->get_editor( ).
* Link the docking container to the target dynpro
CALL METHOD go_docking->link
EXPORTING
repid = syst-repid
dynnr = '0100'
* CONTAINER =
EXCEPTIONS
OTHERS = 4.
gx_xml_editor_prop = go_xml_editor->get_properties( ).
CALL METHOD gx_xml_editor_prop->set_attributes
EXPORTING
im_readonly = 0
im_view = 'X'
im_view_mode = 'X'.
* ok-code field = GD_OKCODE, no elements on screen
CALL SCREEN '0100'.
2012 Jul 17 9:30 AM
I checked it and when we click on the folder it displays the values. In your case try clicking on "Engineers","task","assignment". If it does not work please update here, I will try to provide a sample.
Kesav
2012 Jul 17 9:39 AM
Check this code, click on the folders MARC. You have missed im_behavior
REPORT yyy_xmleditor.
DATA:
go_docking TYPE REF TO cl_gui_docking_container,
go_xml_editor TYPE REF TO cl_gui_xml_editor,
go_editor_props TYPE REF TO cl_gui_xml_properties,
go_params TYPE REF TO cl_apl_ecatt_params,
go_ecatt TYPE REF TO cl_apl_ecatt_object,
gs_behavior TYPE etxmlbehvr.
DATA:
gd_xml TYPE xstring,
gt_marc TYPE STANDARD TABLE OF marc.
gs_behavior-no_params_ref = 'X'.
*END-OF-SELECTION.
SELECT * FROM marc INTO TABLE gt_marc UP TO 3 ROWS WHERE werks = '1000'.
CALL TRANSFORMATION id SOURCE itab = gt_marc RESULT XML gd_xml.
CREATE OBJECT go_docking
EXPORTING
parent = cl_gui_container=>screen0
ratio = 90
EXCEPTIONS
OTHERS = 6.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
CALL METHOD cl_gui_xml_editor=>create
EXPORTING
im_container = go_docking
im_xml = gd_xml
IMPORTING
ex_editor = go_xml_editor.
CREATE OBJECT go_editor_props.
CALL METHOD go_editor_props->set_attributes
EXPORTING
im_behavior = gs_behavior.
CALL METHOD go_xml_editor->set_properties
EXPORTING
im_properties = go_editor_props.
CALL METHOD go_docking->link
EXPORTING
repid = sy-repid
dynnr = '0100'
EXCEPTIONS
OTHERS = 4.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
CALL SCREEN '0100'.
END-OF-SELECTION.
MODULE status_0100 OUTPUT.
SET PF-STATUS 'STATUS_0100'.
ENDMODULE. " STATUS_0100 OUTPUT
MODULE user_command_0100 INPUT.
CASE sy-ucomm.
WHEN 'BACK' OR
'END' OR
'CANC'.
SET SCREEN 0. LEAVE SCREEN.
WHEN OTHERS.
ENDCASE.
ENDMODULE.
2012 Jul 17 10:45 AM
Hi Kesav,
I tried with the sample which you have provided but it does not work. One more point
If i dont set im_view_mode = 'X' then on clicking in the tree node gives Null object ref exception.
Do i need to handle click event or something like that ?
Regards
Vivek
2012 Jul 17 10:53 AM
Hi Vivek,
The code which I provided works for me correctly( I hope you double clicked on the folder MARC( correct ) and not on the "arrow button" for drop down( in correct ) ).. Could you please provide your compiled code for me to check it. I will try uploading a sample xml file and check it. There is no need of any click event to display the values on the right hand side.
Kesav
2012 Jul 17 11:04 AM
2012 Jul 17 11:20 AM
Hi Kesav,
here is the code which i am using .
REPORT
ZTEST_XML_EDITOR.
DATA:
go_docking TYPE REF TO cl_gui_docking_container,
go_xml_editor TYPE REF TO cl_gui_xml_editor,
go_editor_props TYPE REF TO cl_gui_xml_properties,
go_params TYPE REF TO cl_apl_ecatt_params,
go_ecatt TYPE REF TO cl_apl_ecatt_object,
gs_behavior TYPE etxmlbehvr.
DATA:
gd_xml TYPE xstring,
gt_marc TYPE STANDARD TABLE OF marc.
gs_behavior-no_params_ref = 'X'.
SELECT * FROM marc INTO TABLE gt_marc UP TO 3 ROWS WHERE werks = '8500'.
CALL TRANSFORMATION id SOURCE itab = gt_marc RESULT XML gd_xml.
CREATE OBJECT go_docking
EXPORTING
parent = cl_gui_container=>screen0
ratio = 90
EXCEPTIONS
OTHERS = 6.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
CALL METHOD cl_gui_xml_editor=>create
EXPORTING
im_container = go_docking
im_xml = gd_xml
IMPORTING
ex_editor = go_xml_editor.
CREATE OBJECT go_editor_props.
CALL METHOD go_editor_props->set_attributes
EXPORTING
im_behavior = gs_behavior
im_view_mode = 'X'..
CALL METHOD go_xml_editor->set_properties
EXPORTING
im_properties = go_editor_props.
CALL METHOD go_docking->link
EXPORTING
repid = sy-repid
dynnr = '0100'
EXCEPTIONS
OTHERS = 4.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
CALL SCREEN '0100'.
END-OF-SELECTION.
MODULE status_0100 OUTPUT.
* SET PF-STATUS 'STATUS_0100'.
ENDMODULE. " STATUS_0100 OUTPUT
MODULE user_command_0100 INPUT.
CASE sy-ucomm.
WHEN 'BACK' OR
'END' OR
'CANC'.
SET SCREEN 0. LEAVE SCREEN.
WHEN OTHERS.
ENDCASE.
ENDMODULE.
and here is the screen shot of output ...
As i said before
If i dont set im_view_mode = 'X' then on clicking in the tree node gives Null object ref exception.
now double clicking on the node does not display anything .
Thanks for the help
Regards
Vivek
2012 Jul 17 11:45 AM
2012 Jul 17 12:30 PM
Hi Vivek,
For read only mode I coded as, it worked fine.
CREATE OBJECT go_editor_props.
CALL METHOD go_editor_props->set_attributes
EXPORTING
im_behavior = gs_behavior
im_readonly = 1.
for editing mode I code as below, I do not get any error as you said in this case.
CREATE OBJECT go_editor_props.
CALL METHOD go_editor_props->set_attributes
EXPORTING
im_behavior = gs_behavior.
Not sure why it happens the other way for you.
Kesav
2012 Jul 17 12:41 PM
Hi Kesav ,
Can you please let me know your WebAS details . I tried the same code on another system which is WebAS 7.0 and there also i got the same error .
Regards
Vivek
2012 Jul 17 1:22 PM
2012 Jul 18 10:36 AM
Hi Kesav ,
Is there any other framework exists in ABAP to edit an XML ??
Regards
Vivek
2012 Jul 18 12:56 PM
Hi Vivek,
The below code will display xml but not as a tree. .
CALL TRANSFORMATION id SOURCE itab = gt_marc RESULT XML gd_xml.
CALL FUNCTION 'SCOL_TRACE_SHOW_XML'
EXPORTING
xdoc = gd_xml.
2012 Jul 18 2:01 PM
Issue resolved ... Found bug in coding of cl_gui_xml_editor class method
2012 Jul 19 5:26 AM
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |