cancel
Showing results for 
Search instead for 
Did you mean: 

Conversion of an Adobe XSTRING to XML

0 Kudos

Hi All,

I m working on an Interactive Adobe form and I have bound the pdf_source of the Interactive Form to an attribute which is of type XSTRING. Is there a function module through which I can convert this binary form of data to an XML.

I am currently displaying the value of this attribute in a text edit control and it appears to be in hex format.

Any hints will be greatly appreciated

Best regards,

Sudhi

Accepted Solutions (1)

Accepted Solutions (1)

raja_thangamani
Active Contributor
0 Kudos

check this thread..

try to use 'CEP_XSTRING_PARSE_XML_CLASS'

Raja T

0 Kudos

This function module is to conver an XML message to the characteristic values in the SAP system. What I need is to convert an XSTRING which is in Base64 to an XML file.

raja_thangamani
Active Contributor
0 Kudos

Look at the below thread it might help you..

Raja T

0 Kudos

Hi,

I have a button which just converts this BinaryHex value. In the action I am writing the following code:

METHOD ONACTIONCONVERT .

DATA:

ELEM_CONTEXT TYPE REF TO IF_WD_CONTEXT_ELEMENT,

STRU_CONTEXT TYPE IF_ADOBEVIEW=>ELEMENT_CONTEXT ,

ITEM_PDF_SOURCE LIKE STRU_CONTEXT-PDF_SOURCE,

XML_TAB TYPE TABLE OF SMUM_XMLTB.

  • get element via lead selection

ELEM_CONTEXT = WD_CONTEXT->GET_ELEMENT( ).

  • get single attribute

ELEM_CONTEXT->GET_ATTRIBUTE(

EXPORTING

NAME = `PDF_SOURCE`

IMPORTING

VALUE = ITEM_PDF_SOURCE ).

DATA:

ITEM_STRING LIKE STRU_CONTEXT-STRING,

DOC TYPE REF TO IF_IXML_DOCUMENT.

  • get element via lead selection

ELEM_CONTEXT = WD_CONTEXT->GET_ELEMENT( ).

CALL TRANSFORMATION ('ID')

SOURCE XML ITEM_PDF_SOURCE

RESULT XML ITEM_STRING.

  • get single attribute

ELEM_CONTEXT->SET_ATTRIBUTE(

EXPORTING

NAME = `STRING`

VALUE = ITEM_STRING ).

ENDMETHOD.

I just get the pdfSource in the attribute ITEM_PDF_SOURCE which is of type XSTRING and use the call transformation to the ITEM_STRING which is of type STRING. It results in a short dump and says that the format is incorrect.

Any hints?

Best regards,

Sudhi

0 Kudos

Ok now I managed to get somewhere I used the following code:

METHOD ONACTIONCONVERT .

DATA:

ELEM_CONTEXT TYPE REF TO IF_WD_CONTEXT_ELEMENT,

STRU_CONTEXT TYPE IF_ADOBEVIEW=>ELEMENT_CONTEXT ,

ITEM_PDF_SOURCE LIKE STRU_CONTEXT-PDF_SOURCE,

XML_TAB TYPE TABLE OF SMUM_XMLTB.

  • get element via lead selection

ELEM_CONTEXT = WD_CONTEXT->GET_ELEMENT( ).

  • get single attribute

ELEM_CONTEXT->GET_ATTRIBUTE(

EXPORTING

NAME = `PDF_SOURCE`

IMPORTING

VALUE = ITEM_PDF_SOURCE ).

DATA:

ITEM_STRING LIKE STRU_CONTEXT-STRING,

IXML TYPE REF TO IF_IXML,

DOCUMENT TYPE REF TO IF_IXML_DOCUMENT,

STREAMFACTORY TYPE REF TO IF_IXML_STREAM_FACTORY,

ISTREAM TYPE REF TO IF_IXML_ISTREAM,

PARSER TYPE REF TO IF_IXML_PARSER,

I_ELEMENT TYPE REF TO IF_IXML_ELEMENT,

INT TYPE I,

COUNT TYPE I,

P_ERR TYPE REF TO IF_IXML_PARSE_ERROR,

S_ERR TYPE STRING.

  • get element via lead selection

ELEM_CONTEXT = WD_CONTEXT->GET_ELEMENT( ).

*-- create the main factory

IXML = CL_IXML=>CREATE( ).

*-- create the initial document

DOCUMENT = IXML->CREATE_DOCUMENT( ).

STREAMFACTORY = IXML->CREATE_STREAM_FACTORY( ).

ISTREAM =

STREAMFACTORY->CREATE_ISTREAM_XSTRING( ITEM_PDF_SOURCE ).

PARSER = IXML->CREATE_PARSER(

STREAM_FACTORY = STREAMFACTORY

ISTREAM = ISTREAM

DOCUMENT = DOCUMENT ).

CALL METHOD PARSER->PARSE

RECEIVING

RVAL = INT.

CALL METHOD PARSER->NUM_ERRORS

  • EXPORTING

  • MIN_SEVERITY = 3

RECEIVING

RVAL = INT.

COUNT = 0.

DO INT TIMES.

CALL METHOD PARSER->GET_ERROR

EXPORTING

INDEX = COUNT

  • MIN_SEVERITY = 3

RECEIVING

RVAL = P_ERR

.

COUNT = COUNT + 1.

CALL METHOD P_ERR->GET_REASON

RECEIVING

RVAL = S_ERR.

CONCATENATE ITEM_STRING S_ERR INTO ITEM_STRING SEPARATED BY SPACE.

ENDDO.

  • get single attribute

ELEM_CONTEXT->SET_ATTRIBUTE(

EXPORTING

NAME = `STRING`

VALUE = ITEM_STRING ).

ENDMETHOD.

But this returns me an error saying that "unexpected symbol: '<' "

I am not sure where to correct this...

Best regards,

Sudhi

Answers (0)