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

Replacement for obselete function module- TABLE_COMPRESS

Former Member
0 Likes
1,950

Hi,

I have a requirement to replace the obselete function module - TABLE_COMPRESS .

As per the thread given below http://wiki.sdn.sap.com/wiki/display/Snippets/ABAP+Program+for+Compressing+and+De-Compressing+a+tabl...

I have used the method    CALL METHOD cl_abap_gzip=>compress_text and    CALL METHOD cl_abap_gzip=>decompress_text.

But i got the following runtime error.

The read XML document had an invalid format

The XML document did not have the specified format. Therefore, it could

not be interpreted correctly.

An exception occurred that is explained in detail below.

The exception, which is assigned to class 'CX_XSLT_FORMAT_ERROR', was not

caught and

therefore caused a runtime error.

The reason for the exception is:

The XML format was recognized as invalid for one of the following

reasons:

1. The basic structure of the document was incorrect - for example, the
root tag <abap> must be in the XML namespace "http://www.sap.com/abapxml".

2. Start tags appear where no more are expected - for example, when an integer value is to be read.

3. You have to specify the correct version number to read certain data types.

4. Too few or too many properties exist

Can any one help me .

1 ACCEPTED SOLUTION
Read only

arindam_m
Active Contributor
0 Likes
1,607

Hi,

Yesterday there was no system access available for me, today debugged and the reason is the following. The below statement the parameter t_out is structure to which you are trying to do a table data capture.

CALL TRANSFORMATION id      "Dump is coming here
                SOURCE XML lw_xml_in
                 RESULT output = t_out.

Change the statement:


t_out like table of t_spfli,

to

t_out type table of spfli,

It will work and not give a Dump.

Cheers,

Arindam

11 REPLIES 11
Read only

arindam_m
Active Contributor
0 Likes
1,607

Hi,

Looks like your input XML is erroneous. Check the the transactions SSTDEMO2 or SXSLTDEMO1. Should help you understand the CALL TRANSFORMATION.

I think something has gone wrong there. Can you post your code or sections of it and the exact location where the dump happens.

Cheers,

Arindam

Read only

Former Member
0 Likes
1,607

Hi Arindam,

Please find the code below.

   DATA: t_spfli TYPE TABLE OF spfli,
      t_out like table of t_spfli,
  lw_xml_in   TYPE string,
  lw_xml_out  TYPE xstring.

SELECT carrid
       connid
  UP TO 2 ROWS
FROM spfli INTO TABLE t_spfli.

  CALL TRANSFORMATION id
       SOURCE output = t_spfli
       RESULT XML lw_xml_in.  " XML Format
  IF sy-subrc NE 0.
    RAISE compress_error.
  ENDIF.                               " IF SY-SUBRC NE 0

  CALL METHOD cl_abap_gzip=>compress_text
    EXPORTING
      text_in        = lw_xml_in
*    text_in_len    = -1
*    compress_level = 6
*    conversion     = 'DEFAULT'
  IMPORTING
    gzip_out       = lw_xml_out  " Compressed Output
*    gzip_out_len   =
.
      .
  IF sy-subrc NE 0.
    RAISE compress_error.
  ENDIF.                               " IF SY-SUBRC NE 0

*** Decompressing***

      CALL METHOD cl_abap_gzip=>decompress_text
        EXPORTING
          gzip_in      = lw_xml_out
*    gzip_in_len  = -1
*    conversion   = 'DEFAULT'
        IMPORTING
          text_out     = lw_xml_in
*    text_out_len =
.
>>>>>>>>  CALL TRANSFORMATION id      "Dump is coming here
                SOURCE XML lw_xml_in
                 RESULT output = t_out.

  IF sy-subrc NE 0.
    RAISE compress_error.
  ENDIF.

Read only

arindam_m
Active Contributor
0 Likes
1,607

Hi,

It looks like the same code as given in the wiki. Have you checked your transformations in the repository. The error is that the document is not in XML format. Check if your transformation by name ID exists in transformation repository and if it does XML-> ABAP conversion.

Check the links below for a better understanding of the CALL TRANSFORMATION syntax and also how to call or create transformations.

http://help.sap.com/erp2005_ehp_03/helpdata/En/fd/9d734b389211d596a200a0c94260a5/content.htm

http://help.sap.com/abapdocu_70/en/ABAPCALL_TRANSFORMATION.htm

Cheers,

Arindam

Read only

Former Member
0 Likes
1,607

Hi Arindam,

ABAP TO XML conversion is happening, as i could see the XML doc .

<?xml version="1.0" encoding="utf-8" ?> 

- <asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">

- <asx:values>

- <OUTPUT>

- <SPFLI>

<MANDT>AA</MANDT>

<CARRID>001</CARRID>

<CONNID>0000</CONNID>

<COUNTRYFR />

<CITYFROM />

<AIRPFROM />

<COUNTRYTO />

<CITYTO />

<AIRPTO />

<FLTIME>0</FLTIME>

<DEPTIME>00:00:00</DEPTIME>

<ARRTIME>00:00:00</ARRTIME>

<DISTANCE>0.0</DISTANCE>

<DISTID />

<FLTYPE />

<PERIOD>0</PERIOD>

</SPFLI>

- <SPFLI>

<MANDT>AA</MANDT>

<CARRID>006</CARRID>

<CONNID>0000</CONNID>

<COUNTRYFR />

<CITYFROM />

<AIRPFROM />

<COUNTRYTO />

<CITYTO />

<AIRPTO />

<FLTIME>0</FLTIME>

<DEPTIME>00:00:00</DEPTIME>

<ARRTIME>00:00:00</ARRTIME>

<DISTANCE>0.0</DISTANCE>

<DISTID />

<FLTYPE />

<PERIOD>0</PERIOD>

</SPFLI>

</OUTPUT>

</asx:values>

</asx:abap>

But the reverse is not happening.

Read only

arindam_m
Active Contributor
0 Likes
1,607

Hi,

That's what I am saying the transformation for changing from XML->ABAP is not present in the transformation by name 'ID'. Check the transformation 'ID'.

See the first link. The Transformation routine must have logic to change from XML->ABAP in transformation by name 'ID' . Else you will have to find a different Transformation routine

Check the thread below. Should help you to create a TRANSFORMATION to help you change from XML-> ABAP

http://scn.sap.com/thread/1289115

Cheers,

Arindam

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
1,607

Arindam Mondal wrote:

That's what I am saying the transformation for changing from XML->ABAP is not present in the transformation by name 'ID'. Check the transformation 'ID'.

ID is an XSLT transformation & not a Simple transformation. So ABAP2XML & XML2ABAP are implicit.

- Suhas

Read only

arindam_m
Active Contributor
0 Likes
1,607

Hi,

You can try just TRANSFORMATION instead of TRANSFORMATION ID. They do the changing differently. Check the link

http://help.sap.com/abapdocu_731/en/abenasxml_id_vs_st_abexa.htm

Also check the transformation ID in transaction STRANS or via SE80 test the transformation ID. See the link below, it also says how you can debug the same. Test if the TRANSFORMATION 'ID' works

http://help.sap.com/saphelp_nw73/helpdata/en/78/84353c9a70a57be10000000a11402f/content.htm?frameset=...

http://help.sap.com/saphelp_nw73/helpdata/en/fd/9d734e389211d596a200a0c94260a5/content.htm?frameset=...

Cheers,

Arindam

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
1,607

Hello,

Did you check the "Comments" section of the WiKi. The person who has commented faced the same runtime error as yours, so there is definitely something wrong with the code.

Edited by: Suhas Saha

My mistake I just copy pasted the code in my system & it runs fine!

BR,

Suhas

Read only

arindam_m
Active Contributor
0 Likes
1,608

Hi,

Yesterday there was no system access available for me, today debugged and the reason is the following. The below statement the parameter t_out is structure to which you are trying to do a table data capture.

CALL TRANSFORMATION id      "Dump is coming here
                SOURCE XML lw_xml_in
                 RESULT output = t_out.

Change the statement:


t_out like table of t_spfli,

to

t_out type table of spfli,

It will work and not give a Dump.

Cheers,

Arindam

Read only

Former Member
0 Likes
1,607

Thanks Arindam.

It si fine now.

Read only

arindam_m
Active Contributor
0 Likes
1,607

Hope its solved. Check the link below you will get additional idea of how to create your own transformations.

http://scn.sap.com/docs/DOC-41774

Cheers,

Arindam