Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Error in the code

former_member194669
Active Contributor
0 Likes
611

Hi,

Can anybody please explain what will be mistake i am doing in this code.

report z012798_34.

data : itab type table of t134,

l_xml type ref to cl_xml_document.

select * from t134 into table itab.

data : lv_size type sytabix.

data : lv_ret_code type sysubrc.

data : lv_string type string.

data : lv_rcode type sysubrc.

create object l_xml.

call method l_xml->create_with_table

exporting

table = itab[]

receiving

retcode = lv_rcode.

<b>Here i am always getting return code as 1 or 99</b>

call method l_xml->render_2_string

EXPORTING

PRETTY_PRINT = 'X'

IMPORTING

RETCODE = lv_ret_code

STREAM = lv_string

SIZE = lv_size.

1 ACCEPTED SOLUTION
Read only

uwe_schieferstein
Active Contributor
0 Likes
535

Hello

The following coding works:

*&---------------------------------------------------------------------*
*& Report  ZUS_SDN_ABAP_TO_XML
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT  zus_sdn_abap_to_xml.


DATA :
  itab TYPE STANDARD TABLE OF t134,
  l_xml TYPE REF TO cl_xml_document.


DATA : lv_size TYPE sytabix.
DATA : lv_ret_code TYPE sysubrc.
DATA : lv_string TYPE string.

DATA : lv_rcode TYPE sysubrc.


START-OF-SELECTION.


  SELECT * FROM t134 INTO TABLE itab.



  CREATE OBJECT l_xml.



*  CALL METHOD l_xml->create_with_table
*    EXPORTING
*      table   = itab
*    RECEIVING
*      retcode = lv_rcode.
**  here i am always getting return code as 1 or 99

  CALL METHOD l_xml->create_with_data
    EXPORTING
*      NAME       = 'DATA'
      dataobject = itab
    receiving
      retcode    = lv_rcode.



  CALL METHOD l_xml->render_2_string
    EXPORTING
      pretty_print = 'X'
    IMPORTING
      retcode      = lv_ret_code
      stream       = lv_string
      size         = lv_size.

  CALL METHOD l_xml->display
*    EXPORTING
*      WITH_BDN = SPACE
      .

END-OF-SELECTION.

I do not know the reason for the error, but on a unicode system the old coding would result in a short dump.

Regards

Uwe

3 REPLIES 3
Read only

Former Member
0 Likes
535

is your itab getting filled.. Have you checked that?

Read only

Former Member
0 Likes
535

Hi,

I don't think you are using the create_with_table for it's intended purpose. This method does not convert a ITAB to an XML representation (this is what it seems your code is meant to do) it imports actual XML from an internal table. You should check out the SET_DATA method of CL_XML_DOCUMENT instead.

De Wildt

Read only

uwe_schieferstein
Active Contributor
0 Likes
536

Hello

The following coding works:

*&---------------------------------------------------------------------*
*& Report  ZUS_SDN_ABAP_TO_XML
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT  zus_sdn_abap_to_xml.


DATA :
  itab TYPE STANDARD TABLE OF t134,
  l_xml TYPE REF TO cl_xml_document.


DATA : lv_size TYPE sytabix.
DATA : lv_ret_code TYPE sysubrc.
DATA : lv_string TYPE string.

DATA : lv_rcode TYPE sysubrc.


START-OF-SELECTION.


  SELECT * FROM t134 INTO TABLE itab.



  CREATE OBJECT l_xml.



*  CALL METHOD l_xml->create_with_table
*    EXPORTING
*      table   = itab
*    RECEIVING
*      retcode = lv_rcode.
**  here i am always getting return code as 1 or 99

  CALL METHOD l_xml->create_with_data
    EXPORTING
*      NAME       = 'DATA'
      dataobject = itab
    receiving
      retcode    = lv_rcode.



  CALL METHOD l_xml->render_2_string
    EXPORTING
      pretty_print = 'X'
    IMPORTING
      retcode      = lv_ret_code
      stream       = lv_string
      size         = lv_size.

  CALL METHOD l_xml->display
*    EXPORTING
*      WITH_BDN = SPACE
      .

END-OF-SELECTION.

I do not know the reason for the error, but on a unicode system the old coding would result in a short dump.

Regards

Uwe