Skip to Content
1
Feb 18, 2021 at 12:17 PM

RFC Error: The XML document that was read had an invalid format.

614 Views Last edit Jun 25, 2021 at 12:42 PM 2 rev

Dear SAP Community,

I'm creating a expanded entityset which contains a header and 2 item tables. and i am getting this error when executing it:

URL: /sap/opu/odata/AAG362/SD_ZMIRO_SRV/miroHeaderSet?$filter-docNum eq '5105600377' and year eq '2021'&$expand=nheaderToPODetails,nheaderToGLDetails

please find below structures and associations of the same:

miroHeader (header structure)

PODetails

GLDetails

/IWBEP/IF_MGW_APPL_SRV_RUNTIME~GET_EXPANDED_ENTITYSET

  METHOD /iwbep/if_mgw_appl_srv_runtime~get_expanded_entityset.
    DATA: BEGIN OF ts_deep_structure.
        INCLUDE TYPE /aag362/cl_sd_zmiro_mpc=>ts_miroheader.
    DATA: nheadertopodetails TYPE /aag362/cl_sd_zmiro_mpc=>tt_podetail,
          nheadertogldetails TYPE /aag362/cl_sd_zmiro_mpc=>tt_gldetail,
          END OF ts_deep_structure.


    DATA: ls_deep_structure LIKE ts_deep_structure,
          ls_header_mpc     TYPE /aag362/cl_sd_zmiro_mpc=>ts_miroheader,
          ls_podetails_mpc  TYPE /aag362/cl_sd_zmiro_mpc=>ts_podetail,
          ls_gldetails_mpc  TYPE /aag362/cl_sd_zmiro_mpc=>ts_gldetail.


    DATA: lv_belnr     TYPE rbkp-belnr,
          lv_gjahr     TYPE rbkp-gjahr,
          lv_lifnr     TYPE rbkp-lifnr,
          lv_name1     TYPE name1,
          ls_header    TYPE /aag362/cl_sd_zmiro=>ts_header,
          lt_header    TYPE TABLE OF /aag362/cl_sd_zmiro=>ts_header,
          ls_vendor    TYPE /aag362/cl_sd_zmiro=>ts_vendor,
          lt_vendor    TYPE TABLE OF /aag362/cl_sd_zmiro=>ts_vendor,
          ls_podetails TYPE /aag362/cl_sd_zmiro=>ts_podetails,
          lt_podetails TYPE TABLE OF /aag362/cl_sd_zmiro=>ts_podetails,
          ls_gldetails TYPE /aag362/cl_sd_zmiro=>ts_gldetails,
          lt_gldetails TYPE TABLE OF /aag362/cl_sd_zmiro=>ts_gldetails,
          ls_return    TYPE bapiret2,
          lt_return    TYPE STANDARD TABLE OF bapiret2.


    DATA: ls_filter_select_options LIKE LINE OF it_filter_select_options,
          lv_expand_tech_clause    TYPE string VALUE ''.


    DATA: cl_obj TYPE REF TO /aag362/cl_sd_zmiro.
    CREATE OBJECT cl_obj.


    "get key values and read MIRO details
    READ TABLE it_filter_select_options WITH KEY property = 'docNum' INTO ls_filter_select_options.
    IF sy-subrc = 0.
      READ TABLE ls_filter_select_options-select_options ASSIGNING FIELD-SYMBOL(<lfs_filter1>) INDEX 1.
      IF sy-subcs = 0.
        lv_belnr = <lfs_filter1>-low.            "Document number
      ENDIF.
    ENDIF.
    READ TABLE it_filter_select_options WITH KEY property = 'year' INTO ls_filter_select_options.
    IF sy-subrc = 0.
      READ TABLE ls_filter_select_options-select_options ASSIGNING FIELD-SYMBOL(<lfs_filter2>) INDEX 1.
      IF sy-subcs = 0.
        lv_gjahr = <lfs_filter2>-low.           "Fiscal Year
      ENDIF.
    ENDIF.
    READ TABLE it_filter_select_options WITH KEY property = 'vendor' INTO ls_filter_select_options.
    IF sy-subrc = 0.
      READ TABLE ls_filter_select_options-select_options ASSIGNING FIELD-SYMBOL(<lfs_filter3>) INDEX 1.
      IF sy-subcs = 0.
        lv_lifnr = <lfs_filter3>-low.            "Vendor
      ENDIF.
    ENDIF.
    READ TABLE it_filter_select_options WITH KEY property = 'name' INTO ls_filter_select_options.
    IF sy-subrc = 0.
      READ TABLE ls_filter_select_options-select_options ASSIGNING FIELD-SYMBOL(<lfs_filter4>) INDEX 1.
      IF sy-subcs = 0.
        lv_name1 = <lfs_filter4>-low.           "Name
      ENDIF.
    ENDIF.


    "Insert Navigation property into ET_EXPANDED_TECH_CLAUSES
    lv_expand_tech_clause = 'nheadertovendor'.
    INSERT lv_expand_tech_clause INTO TABLE et_expanded_tech_clauses.
    CLEAR lv_expand_tech_clause.


    lv_expand_tech_clause = 'nheadertopodetails'.
    INSERT lv_expand_tech_clause INTO TABLE et_expanded_tech_clauses.
    CLEAR lv_expand_tech_clause.


    lv_expand_tech_clause = 'nheadertogldetails'.
    INSERT lv_expand_tech_clause INTO TABLE et_expanded_tech_clauses.
    CLEAR lv_expand_tech_clause.


    CALL METHOD cl_obj->get_mirodetails
      EXPORTING
        im_miro        = lv_belnr
        im_gjahr       = lv_gjahr
        im_lifnr       = lv_lifnr
        im_name1       = lv_name1
      IMPORTING
        ex_s_header    = ls_header
        ex_s_vendor    = ls_vendor
        ex_t_podetails = lt_podetails
        ex_t_gldetails = lt_gldetails
        ex_t_return    = lt_return.


    IF lt_return IS INITIAL.
      ls_deep_structure-docnum   = ls_header-zinv_doc_no.
      ls_deep_structure-year     = lv_gjahr.
      ls_deep_structure-ponum    = ls_header-zpo_number.
      ls_deep_structure-refdoc   = ls_header-zref_doc_no.
      ls_deep_structure-gramt    = ls_header-zgross_amnt.
      ls_deep_structure-currency = ls_header-zcurrency.
      IF ls_header-zpstng_date IS NOT INITIAL.
        ls_deep_structure-pstdate  = ls_header-zpstng_date.
      ELSE.
        ls_deep_structure-pstdate = sy-datum.
      ENDIF.
      ls_deep_structure-vendor   = ls_header-zlifnr.
      ls_deep_structure-name     = ls_header-zname.
      ls_deep_structure-taxamt   = ls_header-ztax_amount.
      IF ls_vendor-zdoc_date IS NOT INITIAL.
        ls_deep_structure-docdate = ls_vendor-zdoc_date.
      ELSE.
        ls_deep_structure-docdate = sy-datum.
      ENDIF.
      ls_deep_structure-businessplace = ls_vendor-zplc_sup.
      ls_deep_structure-whtaxtype = ls_vendor-zwi_tax_type.
      ls_deep_structure-whtaxcode = ls_vendor-zwi_tax_code.
      ls_deep_structure-whtaxbase = ls_vendor-zwi_tax_base.
      IF ls_vendor-zbline_date IS NOT INITIAL.
        ls_deep_structure-baselinedate = ls_vendor-zbline_date.
      ELSE.
        ls_deep_structure-baselinedate = sy-datum.
      ENDIF.
      ls_deep_structure-paymentterms = ls_vendor-zpmnttrms.
      ls_deep_structure-potext = ls_vendor-zvtext.
      ls_deep_structure-doctype = ls_vendor-zdoc_type.
      ls_deep_structure-exchrate = ls_vendor-zexch_rate.


      LOOP AT lt_podetails INTO ls_podetails.
        ls_podetails_mpc-docnum = lv_belnr.
        ls_podetails_mpc-docitem = ls_podetails-zinvoice_doc_item.
        ls_podetails_mpc-material = ls_podetails-zmaterial.
        ls_podetails_mpc-description = ls_podetails-zmaktx.
        ls_podetails_mpc-quantity = ls_podetails-zquantity.
        ls_podetails_mpc-pounit = ls_podetails-zpo_unit.
        ls_podetails_mpc-price = ls_podetails-zitem_amount.
        ls_podetails_mpc-currency = ls_podetails-zcurrency.
        ls_podetails_mpc-poitem = ls_podetails-zitem_amount1.
        ls_podetails_mpc-poamt = ls_podetails-zpo_item.
        ls_podetails_mpc-plant = ls_podetails-zwerks.
        ls_podetails_mpc-costcenter = ls_podetails-zcostcenter.
        ls_podetails_mpc-ccdescription = ls_podetails-zktext.
        ls_podetails_mpc-potext = ls_podetails-zpo_text.
        ls_podetails_mpc-hsc_sac = ls_podetails-zhsn_sac.
        ls_podetails_mpc-taxcode = ls_podetails-ztax_code.
        ls_podetails_mpc-grqty = ls_podetails-zerfmg.
        ls_podetails_mpc-irqty = ls_podetails-zrbmng.
        ls_podetails_mpc-orderqty = ls_podetails-zpo_pr_qnt.
        APPEND ls_podetails_mpc TO ls_deep_structure-nheadertopodetails.
      ENDLOOP.


      LOOP AT lt_gldetails INTO ls_gldetails.
        ls_gldetails_mpc-docnum = lv_belnr.
        ls_gldetails_mpc-glaccount = ls_gldetails-zgl_account.
        ls_gldetails_mpc-gldescription = ls_gldetails-ztxt20.
        ls_gldetails_mpc-orderid = ls_gldetails-zorderid.
        APPEND ls_gldetails_mpc TO ls_deep_structure-nheadertogldetails.
      ENDLOOP.
    ENDIF.

    "Fill ER_ENTITY
    copy_data_to_ref(
      EXPORTING
           is_data = ls_deep_structure
      CHANGING
           cr_data = er_entityset ).

  ENDMETHOD.
<br>

regards

Attachments

miroheader.png (85.9 kB)
axrcs.png (43.9 kB)
naysn.png (37.6 kB)
qk3q8.png (96.8 kB)
pgprn.png (33.9 kB)