SAP / node-rfc

Asynchronous, non-blocking SAP NW RFC SDK bindings for Node.js
Apache License 2.0
252 stars 73 forks source link

Is there or could there be support for not specifying result tables? #34

Closed spacem closed 6 years ago

spacem commented 7 years ago

Hi, I am quite new to rfc and bapi but so far I have had good success with this library.

I am hitting one small hurdle - not sure if there is a workaround or maybe could be a fix? I am trying to get a detail of a tasklist using the BAPI using the function EAM_TASKLIST_GET_DETAIL

In the return structure there is an error message: "Task list A 00000008 is not hierarchical"

I read on the sap forum the way to get around this is not to specify ET_HDR_HIERARCHY or ET_OPR_HIERARCHY in the tables values but I think with node-rfc it automatically specifies all the tables or maybe this is a limitation in RFC?

You can see a forum post where someone else had this problem and the solution was not to pass these: https://archive.sap.com/discussions/thread/3484536

In case it is useful this is the full json that I get back from the call: { "IV_DATE": "00000000", "IV_EQUNR": "", "IV_LOCK": "", "IV_PLANT": "", "IV_PLNAL": "", "IV_PLNGR": "", "IV_PLNNR": "00000008", "IV_PLNTY": "A", "IV_REFRESH_BUFFER": "", "IV_STATUS": "", "IV_TPLNR": "", "IV_USAGE": "", "ET_COMPONENTS": [], "ET_HDR_HIERARCHY": [], "ET_HEADERS": [], "ET_MPACKAGES": [], "ET_OPERATIONS": [], "ET_OPR_HIERARCHY": [], "ET_PRTS": [], "ET_RELATIONS": [], "ET_RETURN": [ { "TYPE": "E", "ID": "DIWP1", "NUMBER": "212", "MESSAGE": "Task list A 00000008 is not hierarchical", "LOG_NO": "", "LOG_MSG_NO": "000000", "MESSAGE_V1": "A", "MESSAGE_V2": "00000008", "MESSAGE_V3": "", "MESSAGE_V4": "", "PARAMETER": "HIERARCHY", "ROW": 0, "FIELD": "", "SYSTEM": "ARTEST" } ], "ET_SPACK_CONTR_LIMITS": [], "ET_SPACK_LIMITS": [], "ET_SPACK_LINES": [], "ET_SPACK_OUTLINES": [], "ET_TEXT": [], "ET_TEXT_LINES": [] }

bsrdjan commented 6 years ago

@spacem, node-rfc issues here are related to nodejs/RFC connectivity. If node-rfc technically works, questions regarding particular function module usage or parameters' semantic can be posted and discussed on https://www.sap.com/community.html

spacem commented 6 years ago

@bsrdjan node-rfc technically does not work for calling this bapi

I believe node-rfc automatically passes all the tables right? Well that is great for most cases but for this bapi we need to NOT pass the hierarchy table.

bsrdjan commented 6 years ago

@spacem, can you test this BAPI using test transaction SE37, or small ABAP test report, and check if correct results returned there, without using node-rfc? You are right, all result tables are returned from node-rfc to nodejs client and not sending some of them could be considered as a new feature.That might however not help in this particular case.

Can you try to get correct results in ABAP report or SE37 and post correct input / output parameters' values? I will also check this BAPI in more detail.

spacem commented 6 years ago

Sorry for the long delay in replying. This has been a stopper for us so we started implementing by exposing bapi via soamanager (ie. soap requests). In an se37 test the bapi gives the same error and I cant see how to exclude the tables from there.. I can give you examples using soap XML though if that is useful.

Calling this gives the same error as with node-rfc:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:sap-com:document:sap:rfc:functions">
   <soapenv:Header/>
   <soapenv:Body>
      <urn:EAM_TASKLIST_GET_DETAIL>
         <ET_HDR_HIERARCHY>
         </ET_HDR_HIERARCHY>
         <ET_OPR_HIERARCHY>
         </ET_OPR_HIERARCHY>

         <ET_HEADERS>
         </ET_HEADERS>

         <ET_RETURN>
         </ET_RETURN>

          <IV_PLNTY>A</IV_PLNTY>
          <IV_PLNNR>00000008</IV_PLNNR>
          <IV_PLNAL>01</IV_PLNAL>
      </urn:EAM_TASKLIST_GET_DETAIL>
   </soapenv:Body>
</soapenv:Envelope>
<soap-env:Envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/">
   <soap-env:Header/>
   <soap-env:Body>
      <n0:EAM_TASKLIST_GET_DETAILResponse xmlns:n0="urn:sap-com:document:sap:rfc:functions">
         <ET_COMPONENTS/>
         <ET_HDR_HIERARCHY/>
         <ET_HEADERS/>
         <ET_MPACKAGES/>
         <ET_OPERATIONS/>
         <ET_OPR_HIERARCHY/>
         <ET_PRTS/>
         <ET_RELATIONS/>
         <ET_RETURN>
            <item>
               <TYPE>E</TYPE>
               <ID>DIWP1</ID>
               <NUMBER>212</NUMBER>
               <MESSAGE>Task list A 00000008  is not hierarchical</MESSAGE>
               <LOG_NO/>
               <LOG_MSG_NO>000000</LOG_MSG_NO>
               <MESSAGE_V1>A</MESSAGE_V1>
               <MESSAGE_V2>00000008</MESSAGE_V2>
               <MESSAGE_V3/>
               <MESSAGE_V4/>
               <PARAMETER>HIERARCHY</PARAMETER>
               <ROW>0</ROW>
               <FIELD/>
               <SYSTEM>ARTEST</SYSTEM>
            </item>
         </ET_RETURN>
         <ET_SPACK_CONTR_LIMITS/>
         <ET_SPACK_LIMITS/>
         <ET_SPACK_LINES/>
         <ET_SPACK_OUTLINES/>
         <ET_TEXT/>
         <ET_TEXT_LINES/>
      </n0:EAM_TASKLIST_GET_DETAILResponse>
   </soap-env:Body>
</soap-env:Envelope>

but when I pass only the tables I need (ie. the headers) it works fine:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:sap-com:document:sap:rfc:functions">
   <soapenv:Header/>
   <soapenv:Body>
      <urn:EAM_TASKLIST_GET_DETAIL>

         <ET_HEADERS>
         </ET_HEADERS>

         <ET_RETURN>
         </ET_RETURN>

          <IV_PLNTY>A</IV_PLNTY>
          <IV_PLNNR>00000008</IV_PLNNR>
          <IV_PLNAL>01</IV_PLNAL>
      </urn:EAM_TASKLIST_GET_DETAIL>
   </soapenv:Body>
</soapenv:Envelope>
<soap-env:Envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/">
   <soap-env:Header/>
   <soap-env:Body>
      <n0:EAM_TASKLIST_GET_DETAILResponse xmlns:n0="urn:sap-com:document:sap:rfc:functions">
         <ET_COMPONENTS/>
         <ET_HDR_HIERARCHY/>
         <ET_HEADERS>
            <item>
               <MANDT>000</MANDT>
               <PLNTY>A</PLNTY>
               <PLNNR>00000008</PLNNR>
               <PLNAL>01</PLNAL>
               <ZAEHL>00000001</ZAEHL>
               <DATUV>2017-09-12</DATUV>
               <TECHV/>
               <AENNR/>
               <LOEKZ/>
               <PARKZ/>
               <ANDAT>2017-09-12</ANDAT>
               <ANNAM>S0017500464</ANNAM>
               <AEDAT>2018-02-06</AEDAT>
               <AENAM>S0017500464</AENAM>
               <VERWE/>
               <WERKS>TEST</WERKS>
               <STATU>4</STATU>
               <PLNME/>
               <LOSVN>0.0</LOSVN>
               <LOSBS>99999999.0</LOSBS>
               <VAGRP/>
               <AESZN/>
               <KTEXT>test group counter</KTEXT>
               <TXTSP/>
               <ABDAT>0000-00-00</ABDAT>
               <ABANZ>0</ABANZ>
               <PROFIDNETZ/>
               <KOKRS/>
               <QVEWERKS/>
               <QVEMENGE/>
               <QVEVERSION/>
               <QVEDATUM>0000-00-00</QVEDATUM>
               <QVEGRUPPE/>
               <QVECODE/>
               <QDYNREGEL/>
               <QDYNHEAD/>
               <QPRZIEHVER/>
               <QVERSNPRZV/>
               <QKZRASTER/>
               <QDYNSTRING/>
               <STRAT>A</STRAT>
               <PPOOL/>
               <ISTRU>000000000000000001</ISTRU>
               <IWERK>TEST</IWERK>
               <ANLZU/>
               <ARBID>00000000</ARBID>
               <EXTNUM/>
               <DELKZ/>
               <ARBTY/>
               <STUPR/>
               <CLNDR/>
               <PRTYP>0</PRTYP>
               <REODAT>0000-00-00</REODAT>
               <NETID>00000000</NETID>
               <FLG_CHK>X</FLG_CHK>
               <PSPNR>00000000</PSPNR>
               <TTRAS>000000</TTRAS>
               <KZKFG/>
               <PLNNR_ALT/>
               <FLG_CAPO/>
               <STLTY/>
               <STLNR/>
               <STLAL/>
               <SLWBEZ/>
               <PPKZTLZU/>
               <CHRULE/>
               <CCOAA>000</CCOAA>
               <ST_ARBID>00000000</ST_ARBID>
               <MEINH/>
               <UMREZ>1</UMREZ>
               <UMREN>1</UMREN>
               <BMSCH>1.0</BMSCH>
               <ADPSP/>
               <MS_FLAG/>
               <TSTMP_BW>20180206052934</TSTMP_BW>
               <MES_ROUTINGID/>
               <XHIERTL/>
               <TL_EXTID/>
               <DATUB>9999-12-31</DATUB>
               <AENNR_AUS/>
               <KAP_ARBPL/>
               <ST_ARBPL/>
               <STAUFG/>
               <LINE/>
               <AEUZEIT>00:00:00</AEUZEIT>
               <QM_IP_TYPE_ALLOWED/>
               <ARBPL/>
               <NNAME/>
               <EQUNR/>
               <TPLNR/>
            </item>
         </ET_HEADERS>
         <ET_MPACKAGES/>
         <ET_OPERATIONS/>
         <ET_OPR_HIERARCHY/>
         <ET_PRTS/>
         <ET_RELATIONS/>
         <ET_RETURN/>
         <ET_SPACK_CONTR_LIMITS/>
         <ET_SPACK_LIMITS/>
         <ET_SPACK_LINES/>
         <ET_SPACK_OUTLINES/>
         <ET_TEXT/>
         <ET_TEXT_LINES/>
      </n0:EAM_TASKLIST_GET_DETAILResponse>
   </soap-env:Body>
</soap-env:Envelope>

While it is a nice feature of node-rfc not have to pass the correct structures you are limiting calls to this type of bapi. Maybe this is the only bapi function that gives different results based on the parameters but I feel also it is useful for many standard bapi to be able to load only the data you want instead of all the data available.

bsrdjan commented 6 years ago

@spacem it took a bit longer and new feature is now added to 0.1.15 release, together with few other improvements.

Please check the unit test for the semantic and let me know if works for you?