Skip to Content
author's profile photo Former Member
Former Member

parser error in ABAP mapping

Hi ,

i am using the following ABAP mapping program

method if_mapping~execute .

data: t_edidc type table of edi_dc40,

ls_edidc type edi_dc40,

ls_edidc_h type edi_dc40,

t_edidd type table of edi_dd40,

ls_edidd_h type edi_dd40,

ls_idx_xmb type idx_xmb,

t_result type string,

t_resultc type string,

t_resultd type string.

data: ls_idx1 type idxporsm59.

data: t_segtyp type table of edilsegtyp,

el_segtyp type edilsegtyp,

el_released type segdefrel,

el_error_text type string.

  • =======================

  • 0. parse input document

  • =======================

  • initialize iXML

type-pools: ixml.

break-point.

class cl_ixml definition load.

  • create main factory

data: ixmlfactory type ref to if_ixml.

break-point.

ixmlfactory = cl_ixml=>create( ).

  • create stream factory

data: streamfactory type ref to if_ixml_stream_factory.

streamfactory = ixmlfactory->create_stream_factory( ).

  • create input stream

data: istream type ref to if_ixml_istream.

istream = streamfactory->create_istream_xstring( source ).

  • initialize input document

data: idocument type ref to if_ixml_document.

idocument = ixmlfactory->create_document( ).

  • parse input document

data: iparser type ref to if_ixml_parser.

iparser = ixmlfactory->create_parser( stream_factory = streamfactory

istream = istream

document = idocument ).

iparser->parse( ).

  • =================================================

  • 1. get IDoc header data and connection parameters

  • =================================================

data: el_message_id type sxmsguid.

el_message_id = param->get( if_mapping_param=>message_id ).

data: el_element type ref to if_ixml_element.

el_element = idocument->find_from_name( 'TABNAM' ).

ls_edidc-tabnam = el_element->get_value( ).

el_element = idocument->find_from_name( 'MANDT' ).

ls_edidc-mandt = el_element->get_value( ).

el_element = idocument->find_from_name( 'DOCNUM' ).

ls_edidc-docnum = el_element->get_value( ).

el_element = idocument->find_from_name( 'STATUS' ).

ls_edidc-status = el_element->get_value( ).

el_element = idocument->find_from_name( 'OUTMOD' ).

ls_edidc-outmod = el_element->get_value( ).

el_element = idocument->find_from_name( 'TEST' ).

if not el_element is initial.

ls_edidc-test = el_element->get_value( ).

endif.

el_element = idocument->find_from_name( 'IDOCTYP' ).

ls_edidc-idoctyp = el_element->get_value( ).

el_element = idocument->find_from_name( 'CIMTYP' ).

if not el_element is initial.

ls_edidc-cimtyp = el_element->get_value( ).

endif.

el_element = idocument->find_from_name( 'MESTYP' ).

ls_edidc-mestyp = el_element->get_value( ).

el_element = idocument->find_from_name( 'STDVRS' ).

if not el_element is initial.

ls_edidc-stdvrs = el_element->get_value( ).

endif.

el_element = idocument->find_from_name( 'STD' ).

if not el_element is initial.

ls_edidc-std = el_element->get_value( ).

endif.

el_element = idocument->find_from_name( 'STDMES' ).

ls_edidc-stdmes = el_element->get_value( ).

el_element = idocument->find_from_name( 'SNDPOR' ).

ls_edidc-sndpor = el_element->get_value( ).

el_element = idocument->find_from_name( 'SNDPRT' ).

ls_edidc-sndprt = el_element->get_value( ).

el_element = idocument->find_from_name( 'SNDPRN' ).

ls_edidc-sndprn = el_element->get_value( ).

el_element = idocument->find_from_name( 'RCVPOR' ).

ls_edidc-rcvpor = el_element->get_value( ).

el_element = idocument->find_from_name( 'RCVPRT' ).

ls_edidc-rcvprt = el_element->get_value( ).

el_element = idocument->find_from_name( 'RCVPRN' ).

ls_edidc-rcvprn = el_element->get_value( ).

el_element = idocument->find_from_name( 'CREDAT' ).

ls_edidc-credat = el_element->get_value( ).

el_element = idocument->find_from_name( 'CRETIM' ).

ls_edidc-cretim = el_element->get_value( ).

el_element = idocument->find_from_name( 'SERIAL' ).

ls_edidc-serial = el_element->get_value( ).

ls_edidc-direct = '2'.

move-corresponding ls_edidc to ls_idx_xmb.

  • Connection data to application system to get IDoc metadata

select single * from idxporsm59 into ls_idx1

where port = ls_edidc-sndpor

and client = ls_edidc-mandt.

ls_idx_xmb-port = ls_edidc-sndpor.

ls_idx_xmb-rfcdest = 'NONE'. "not necessary

  • Get DOCREL and SAPREL

el_element = idocument->find_from_name( 'DOCREL' ).

if not el_element is initial.

ls_edidc-docrel = el_element->get_value( ).

else.

select segtyp into table t_segtyp from idxidocsyn

where port = ls_edidc-sndpor

and idoctyp = ls_edidc-idoctyp

and cimtyp = ls_edidc-cimtyp.

loop at t_segtyp into el_segtyp.

select released into el_released from idxedisdef

where port = ls_edidc-sndpor

and segtyp = el_segtyp

and actrelease = 'X'.

endselect.

if el_released gt ls_edidc-docrel.

ls_edidc-docrel = el_released.

endif.

endloop.

endif.

  • ======================================

  • 2. convert XML to IDoc table structure

  • ======================================

break-point.

call function 'IDX_XML_TO_IDOC'

exporting

xml_data = source

guid = el_message_id

edidc40 = ls_edidc

idx_xmb = ls_idx_xmb

typ_def = 'X'

tables

idoc_control_40 = t_edidc

idoc_data_40 = t_edidd

exceptions

unknown_xml = 1

customizing_error = 2

no_data_found = 3

syntax_error = 4

others = 5.

if sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

endif.

  • To keep the original DOCNUM uncomment the following 8 lines of coding

  • Otherwise a new DOCNUM will be created

  • LOOP AT t_edidc into ls_edidc_h.

  • ls_edidc_h-DOCNUM = ls_edidc-DOCNUM.

  • modify t_edidc from ls_edidc_h.

  • ENDLOOP.

  • *

    • LOOP AT t_edidd into ls_edidd_h.

    • ls_edidd_h-DOCNUM = ls_edidc-DOCNUM.

    • modify t_edidd from ls_edidd_h.

    • ENDLOOP.

    • =========================================

    • 3. convert IDoc table structure to string

    • =========================================

    call function 'ZSOTR_SERV_TABLE_TO_STRING'

    • EXPORTING

    • FLAG_NO_LINE_BREAKS = ' '

    • LINE_LENGTH = 0

    • LANGU = SY-LANGU

    importing

    text = t_resultc

    tables

    text_tab = t_edidc.

    • convert IDoc table structure to string

    call function 'ZSOTR_SERV_TABLE_TO_STRING'

    • EXPORTING

    • FLAG_NO_LINE_BREAKS = ' '

    • LINE_LENGTH = 0

    • LANGU = SY-LANGU

    importing

    text = t_resultd

    tables

    text_tab = t_edidd.

    concatenate t_resultc t_resultd into t_result.

    • convert string to xstring

    call function 'SCMS_STRING_TO_XSTRING'

    exporting

    text = t_result

    • MIMETYPE = ' '

    • ENCODING =

    importing

    buffer = result.

    • EXCEPTIONS

    • FAILED = 1

    • OTHERS = 2

    .

    if sy-subrc <> 0.

    • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

    • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

    endif.

    endmethod.

    <b> i am getting the following parse error in FM IDX_XML_TO_IDOC :

    " unexpected symbol; expected '<', '</', entity reference, character data, CDATA section, processing instruction or comment "

    can anybody help

    points will be given

    Regards</b>

    Add a comment
    10|10000 characters needed characters exceeded

    Assigned Tags

    Related questions

    1 Answer

    • author's profile photo Former Member
      Former Member
      Posted on Jul 11, 2007 at 10:59 AM

      HI,

      is it possible that you have to use "-" instead of "=" in this [ixmlfactory = cl_ixml=>create( ).] line ?

      regards,

      gordon

      Add a comment
      10|10000 characters needed characters exceeded

    Before answering

    You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
    You must be Logged in to submit an answer.

    Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.