<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>Question Re: Function /DocumentIsValid not found in the metadata ! in Technology Q&amp;A</title>
    <link>https://community.sap.com/t5/technology-q-a/function-documentisvalid-not-found-in-the-metadata/qaa-p/12411429#M4645929</link>
    <description>&lt;P&gt;Hey Cengiz, &lt;/P&gt;&lt;P&gt;Please, show US what is behind this.oAppModel.&lt;/P&gt;&lt;P&gt;Best, &lt;/P&gt;&lt;P&gt;Michal&lt;/P&gt;</description>
    <pubDate>Fri, 17 Sep 2021 14:48:06 GMT</pubDate>
    <dc:creator>michal_majer</dc:creator>
    <dc:date>2021-09-17T14:48:06Z</dc:date>
    <item>
      <title>Function /DocumentIsValid not found in the metadata !</title>
      <link>https://community.sap.com/t5/technology-q-a/function-documentisvalid-not-found-in-the-metadata/qaq-p/12411428</link>
      <description>&lt;P&gt;Dear Experts&lt;/P&gt;
  &lt;P&gt;When I call my function import in my SAPUI5 code, I receive the error message above (in subject). Please take the details from the descriptions below.&lt;/P&gt;
  &lt;P&gt;&lt;STRONG&gt;01. Implementing Function Import (SEGW)&lt;/STRONG&gt;&lt;/P&gt;
  &lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/1975694-implementing-function-import.png" /&gt;&lt;/P&gt;
  &lt;P&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;
  &lt;P&gt;&lt;STRONG&gt;02. The redefined method EXECUTE_ACTION&lt;/STRONG&gt;&lt;/P&gt; 
  &lt;PRE&gt;&lt;CODE&gt;  METHOD /iwbep/if_mgw_appl_srv_runtime~execute_action.
*************************************************************************
* Funktionsimporte ausführen
*
* Parameter
* ----------------------------------------------------------------------
* @param  IO_TECH_REQUEST_CONTEXT       Request Data
* @param  ER_DATA                       Rückgabewerte
* @param  /IWBEP/CX_MGW_BUSI_EXCEPTION  Ausnahme in der Businesslogik
* @param  /IWBEP/CX_MGW_TECH_EXCEPTION  Technische Ausnahme
*************************************************************************
    TYPES: BEGIN OF documentisvalid,
             docstat TYPE string,
             docart  TYPE string,
           END OF documentisvalid.

    DATA: ls_dokar         TYPE zcl_pm_bp_infotool_mpc=&amp;gt;ts_dokar,
          ls_import_docart TYPE documentisvalid,
          ls_doc_type      TYPE zca_dokart_pop.

    CASE iv_action_name.
      WHEN 'DocumentIsValid'.
        io_tech_request_context-&amp;gt;get_converted_parameters( IMPORTING es_parameter_values = ls_import_docart ).

        SELECT SINGLE dokar FROM zca_dokart_pop INTO ls_doc_type WHERE dokar = ls_import_docart-docart.

        CLEAR ls_dokar.
        IF ( sy-subrc EQ 0 ).
          IF ls_import_docart-docart EQ ''.
            ls_dokar-dokar = ''.
          ELSE.
            ls_dokar-dokar = ls_import_docart-docart.
          ENDIF.
        ENDIF.

        copy_data_to_ref(
        EXPORTING
          is_data = ls_dokar
          CHANGING
            cr_data = er_data ).

      WHEN OTHERS.
        CALL METHOD super-&amp;gt;/iwbep/if_mgw_appl_srv_runtime~execute_action
          EXPORTING
            iv_action_name          = iv_action_name
            it_parameter            = it_parameter
            io_tech_request_context = io_tech_request_context
          IMPORTING
            er_data                 = er_data.
    ENDCASE.
  ENDMETHOD.&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;
  &lt;P&gt;&lt;STRONG&gt;03. Checking the metadata of OData Service&lt;/STRONG&gt;&lt;/P&gt;
  &lt;P&gt;Code section with "function import":&lt;/P&gt;
  &lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/1975695-odata-metadata.png" /&gt;&lt;/P&gt;
  &lt;P&gt;&lt;IMG alt="" /&gt;&lt;/P&gt;
  &lt;P&gt;&lt;STRONG&gt;04. Test call of function import in /IWFND/GW_CLIENT&lt;/STRONG&gt;&lt;/P&gt;
  &lt;P&gt;Request URL:&lt;/P&gt; 
  &lt;PRE&gt;&lt;CODE&gt;/sap/opu/odata/sap/{SERVICE_NAME}/DocumentIsValid?DocArt='ZAA'&amp;amp;DocStat='SP'&amp;amp;$fo
rmat=json&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/1975696-gw-client.png" /&gt;&lt;/P&gt;
  &lt;P&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;
  &lt;P&gt;&lt;STRONG&gt;05. Calling the function import in SAPUI5&lt;/STRONG&gt;&lt;/P&gt; 
  &lt;PRE&gt;&lt;CODE&gt;…
this.oAppModel.callFunction("/DocumentIsValid", {
  method: "GET",
  success: fnSuccess,
  error: fnError,
      urlParameters: {
      "DocArt": sDokar,
      "DocStat": sDokst
  }
});
…&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;The full error message is:&lt;/P&gt;
  &lt;P&gt;&lt;EM&gt;Assertion failed: EventProvider sap.ui.model.odata.v2.ODataModel: Function /DocumentIsValid not found in the metadata !&lt;/EM&gt;&lt;/P&gt;
  &lt;P&gt;&lt;EM&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;/P&gt;
  &lt;P&gt;&lt;STRONG&gt;06. Troubleshooting&lt;/STRONG&gt;&lt;/P&gt;
  &lt;OL&gt; 
   &lt;LI&gt;The HTTP method GET, POST etc. are supported by the OData Model v2&lt;/LI&gt; 
   &lt;LI&gt;Modification on the function import (SEGW) didn't bring the solution&lt;/LI&gt; 
  &lt;/OL&gt;
  &lt;P&gt;Many thanks und best regards&lt;/P&gt;
  &lt;P&gt;Cengiz&lt;/P&gt;</description>
      <pubDate>Fri, 17 Sep 2021 13:54:45 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/function-documentisvalid-not-found-in-the-metadata/qaq-p/12411428</guid>
      <dc:creator>ct-ch</dc:creator>
      <dc:date>2021-09-17T13:54:45Z</dc:date>
    </item>
    <item>
      <title>Re: Function /DocumentIsValid not found in the metadata !</title>
      <link>https://community.sap.com/t5/technology-q-a/function-documentisvalid-not-found-in-the-metadata/qaa-p/12411429#M4645929</link>
      <description>&lt;P&gt;Hey Cengiz, &lt;/P&gt;&lt;P&gt;Please, show US what is behind this.oAppModel.&lt;/P&gt;&lt;P&gt;Best, &lt;/P&gt;&lt;P&gt;Michal&lt;/P&gt;</description>
      <pubDate>Fri, 17 Sep 2021 14:48:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/function-documentisvalid-not-found-in-the-metadata/qaa-p/12411429#M4645929</guid>
      <dc:creator>michal_majer</dc:creator>
      <dc:date>2021-09-17T14:48:06Z</dc:date>
    </item>
    <item>
      <title>Re: Function /DocumentIsValid not found in the metadata !</title>
      <link>https://community.sap.com/t5/technology-q-a/function-documentisvalid-not-found-in-the-metadata/qaa-p/12411430#M4645930</link>
      <description>&lt;P&gt;check the metadata in your browser, did you see the function there?&lt;/P&gt;</description>
      <pubDate>Fri, 17 Sep 2021 15:41:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/function-documentisvalid-not-found-in-the-metadata/qaa-p/12411430#M4645930</guid>
      <dc:creator>junwu</dc:creator>
      <dc:date>2021-09-17T15:41:15Z</dc:date>
    </item>
    <item>
      <title>Re: Function /DocumentIsValid not found in the metadata !</title>
      <link>https://community.sap.com/t5/technology-q-a/function-documentisvalid-not-found-in-the-metadata/qaa-p/12411431#M4645931</link>
      <description>&lt;P&gt; &lt;SPAN class="mention-scrubbed"&gt;michal.majer&lt;/SPAN&gt; : Hi Michal. Thank you for your response. The code behind the "this.oAppModel" you can find under the subtitle "&lt;STRONG&gt;05. Calling the function import in SAPUI5".&lt;/STRONG&gt; Is that what you mean?&lt;/P&gt;&lt;P&gt;&lt;SPAN class="mention-scrubbed"&gt;a20200220&lt;/SPAN&gt; : Hi Jun. Thank you for your response. The XML code section "&lt;STRONG&gt;03. Checking the metadata of OData Service"&lt;/STRONG&gt; is from the browser's metadata.&lt;/P&gt;</description>
      <pubDate>Mon, 20 Sep 2021 04:34:40 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/function-documentisvalid-not-found-in-the-metadata/qaa-p/12411431#M4645931</guid>
      <dc:creator>ct-ch</dc:creator>
      <dc:date>2021-09-20T04:34:40Z</dc:date>
    </item>
    <item>
      <title>Re: Function /DocumentIsValid not found in the metadata !</title>
      <link>https://community.sap.com/t5/technology-q-a/function-documentisvalid-not-found-in-the-metadata/qaa-p/12411432#M4645932</link>
      <description>&lt;P&gt;Maybe this is also an interesting code section behind the "this.oAppModel":&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;this.oOwnerComp = this.getOwnerComponent();&lt;BR /&gt;this.oAppModel = this.oOwnerComp.oAppModel;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 20 Sep 2021 08:23:45 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/function-documentisvalid-not-found-in-the-metadata/qaa-p/12411432#M4645932</guid>
      <dc:creator>ct-ch</dc:creator>
      <dc:date>2021-09-20T08:23:45Z</dc:date>
    </item>
    <item>
      <title>Re: Function /DocumentIsValid not found in the metadata !</title>
      <link>https://community.sap.com/t5/technology-q-a/function-documentisvalid-not-found-in-the-metadata/qaa-p/12411433#M4645933</link>
      <description>&lt;P&gt;Could You share also Component.js? It seems there could be problem with oAppModel.&lt;BR /&gt;Check if it's correct. Is it not undefined during function call?&lt;/P&gt;&lt;P&gt;Maybe You could try:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt; this.oAppModel = this.oOwnerComponent.getModel()&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 20 Sep 2021 08:49:00 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/function-documentisvalid-not-found-in-the-metadata/qaa-p/12411433#M4645933</guid>
      <dc:creator>michal_majer</dc:creator>
      <dc:date>2021-09-20T08:49:00Z</dc:date>
    </item>
    <item>
      <title>Re: Function /DocumentIsValid not found in the metadata !</title>
      <link>https://community.sap.com/t5/technology-q-a/function-documentisvalid-not-found-in-the-metadata/qaa-p/12411434#M4645934</link>
      <description>&lt;P&gt;Hi together&lt;/P&gt;&lt;P&gt;The issue is fixed. The problem was using the wrong "this" initiation.&lt;/P&gt;&lt;P&gt;WRONG:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;var that = this;&lt;BR /&gt;....&lt;BR /&gt;this.oAppModel.callFunction("/DocumentIsValid", {&lt;BR /&gt;   ...&lt;BR /&gt;}&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;RIGHT:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;var that = this;&lt;BR /&gt;....&lt;BR /&gt;that.oAppModel.callFunction("/DocumentIsValid", {&lt;BR /&gt;   ...&lt;BR /&gt;}&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 20 Sep 2021 09:43:23 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/function-documentisvalid-not-found-in-the-metadata/qaa-p/12411434#M4645934</guid>
      <dc:creator>ct-ch</dc:creator>
      <dc:date>2021-09-20T09:43:23Z</dc:date>
    </item>
  </channel>
</rss>

