cancel
Showing results for 
Search instead for 
Did you mean: 

problem with BAPI_DOCUMENT_CHECKOUTVIEW2 and 4.7

Former Member
0 Kudos

We have a .NET based Web Service which has been successfully calling BAPI_DOCUMENT_CHECKOUTVIEW2 on a 4.6 system for quite some time now (after working through the various AllowRfcStart issues, etc.) to retreive documents from DMS. I am now trying to do the same thing on a 4.7 system and having no success. Here are some more details:

I am using the SAP .NET Connector (2.0) with v1.1 of the .NET Framework. The primary attempt to write the Web Service has been in C# although I have also tried VB.NET with the same results. When I have stepped through the code I find that an error is thrown when the following line is executed (which is part of the code generated by the .NET Connector):

results = this.SAPInvoke("Bapi_Document_Checkoutview2",new object[] { Docbomchangenumber,Docbomrevisionlevel,Docbomvalidfrom,Documentfile,Documentnumber,Documentpart,Documenttype,Documentversion,Getcomponents,Getheader,Getstructure,Hostname,Originalpath,Pf_Ftp_Dest,Pf_Http_Dest,Components,Documentfiles,Documentstructure });

The specific error message is "Object reference not set to an instance of an object."

We thought it might have something to do with needing an updated (Unicode) version SAPHTTP.exe or SAPFTP.exe but so far that has not seemed to make a difference. One of our SAP experts noticed that the SAPHTTP and SAPFTP desinations were missing on the 4.7 system but the behavior did not change after they followed the procedure in notea 337997 and 194829 to add them. One other clue: I am able to retrieve files successfully from the 4.7 system via SE37 and this BAPI.

Can anyone please offer some suggestions?

Also, a more general related question: this BAPI as well as some of the others that I use like GETLIST2 and GETDETAIL2 seem to have additional input parameters on the 4.7 system but the documentation I have been able to find on this is limited or non-existent; has anyone found a good source to explain all of the new parameters?

Thanks.

/jeff

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

It seems you CAN'T use this BAPI outside of SAPGUI but must instead use SCMS_DOC_READ!

METHOD load_doc_xstring.
**********************************************************************
  DATA: lt_files2          TYPE STANDARD TABLE OF bapi_doc_files2,
        ls_files2          TYPE bapi_doc_files2,
        ls_return          TYPE bapiret2,
        lt_bin             TYPE STANDARD TABLE OF sdokcntbin,
        lt_inf             TYPE STANDARD TABLE OF scms_acinf,
        ls_inf             TYPE scms_acinf.
**********************************************************************

  CALL FUNCTION 'BAPI_DOCUMENT_GETDETAIL2'
    EXPORTING
      documenttype    = documenttype
      documentnumber  = documentnumber
      documentpart    = documentpart
      documentversion = documentversion
      getdocfiles     = 'X'
    IMPORTING
      return          = ls_return
    TABLES
      documentfiles   = lt_files2.
  IF LINES( lt_files2 ) > 1.
    RAISE EXCEPTION TYPE zcx_root EXPORTING textid = 'MULTIPLE_FILES'.
  ENDIF.
  READ TABLE lt_files2 INTO ls_files2 INDEX 1.
  IF sy-subrc NE 0.
    RAISE EXCEPTION TYPE zcx_root EXPORTING textid = 'NO_FILES'.
  ENDIF.

  CALL FUNCTION 'SCMS_DOC_READ'
    EXPORTING
      stor_cat    = 'ZCR01'
      doc_id      = ls_files2-file_id
    TABLES
      access_info = lt_inf
      content_bin = lt_bin.
  READ TABLE lt_inf INTO ls_inf INDEX 1.
  IF sy-subrc NE 0.
    RAISE EXCEPTION TYPE zcx_root EXPORTING textid = 'NO_FILE_INFO'.
  ENDIF.

  " Convert XData to Xstring
  CALL FUNCTION 'SCMS_BINARY_TO_XSTRING'
    EXPORTING
      input_length = ls_inf-comp_size
    IMPORTING
      buffer       = contentx
    TABLES
      binary_tab   = lt_bin
    EXCEPTIONS
      failed       = 1
      OTHERS       = 2.
  IF sy-subrc NE 0.
    RAISE EXCEPTION TYPE zcx_root EXPORTING textid = 'BINARY_CONVERSION_ERROR'.
  ENDIF.

  filename = ls_inf-comp_id.

ENDMETHOD.

Former Member
0 Kudos

Can anyone provide an answer (or even a clue) on this?

Thanks.

/jeff

Former Member
0 Kudos

Hello Jeff,

did you get any clues meanwhile?

Sencerely,

F.Wöhrl

Former Member
0 Kudos

No, I have not been able to make any real progress toward solving this, so I am still looking for help.

Thanks.

/jeff

reiner_hille-doering
Active Contributor
0 Kudos

Where exactly does the exception happen (turn "Show Non-user code" on and look into the call stack)?

Former Member
0 Kudos

Thanks for the response. Unfortunately, in this case, I

am calling SAP via the SAP .NET Connector and the error

is displayed back to me as an exception when the "this.SAPinvoke" statement [in the code generated by the .NET Connector] is executed (full line is in the original note). I will attach the stack trace that I get back from .NET.

I am not familiar with the "Show Non-user code" option --

can you provide more detailed instructions?

Thanks.

/jeff

[NullReferenceException: Object reference not set to an instance of an object.]

SAP.Connector.Rfc.RfcApi.RfcCallReceive(Int32 handle, String function, RFC_PARAMETER[] exporting, RFC_PARAMETER[] importing, RFC_TABLE[] tables, String& exception) +0

SAP.Connector.Rfc.RfcClient.RfcInvoke(SAPClient proxy, String method, Object[] methodParamsIn) +369

SAP.Connector.SAPClient.SAPInvoke(String method, Object[] methodParamsIn) +70

DocViewDeliveryTEST.SAPProxy.BAPI_DOCUMENT_CHECKOUTVIEW2(String DOCBOMCHANGENUMBER, String DOCBOMREVISIONLEVEL, String DOCBOMVALIDFROM, BAPI_DOC_FILES2 DOCUMENTFILE, String DOCUMENTNUMBER, String DOCUMENTPART, String DOCUMENTTYPE, String DOCUMENTVERSION, String GETCOMPONENTS, String GETHEADER, String GETSTRUCTURE, String HOSTNAME, String ORIGINALPATH, String PF_FTP_DEST, String PF_HTTP_DEST, BAPIRET2& RETURNs, BAPI_DOC_COMPTable& COMPONENTS, BAPI_DOC_FILES2Table& DOCUMENTFILES, BAPI_DOC_STRUCTURETable& DOCUMENTSTRUCTURE) in C:\Inetpub\wwwroot\DocViewDeliveryTEST\SAPProxy.vb:148

DocViewDeliveryTEST.TestDocWS.btnDMXnew_Click(Object sender, EventArgs e) in C:\Inetpub\wwwroot\DocViewDeliveryTEST\TestDocWS.aspx.vb:97

System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108

System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +58

System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +18

System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33

System.Web.UI.Page.ProcessRequestMain() +1292

Former Member
0 Kudos

I am still running into dead-ends on this. Can ANYONE provide some assistance? Thanks.

/jeff

reiner_hille-doering
Active Contributor
0 Kudos

The exception seem to happen inside of unmanaged code (LIBRFC32), so it's likely related to the fact that BAPI_DOCUMENT_CHECKOUTVIEW2 is a very unusual function:

It's should execute some operations on an external document management system. In older versions of R/3 there has been no HTTP or FTP client built into R/3 kernel. Therefore this BAPI uses the following trick:

- It does a so called "CALL-BACK" to the calling RFC library.

- This is expected to be a full SAPGUI installation that contains SAPHTTP and SAPFTP which are command-line HTTP and FTP clients.

- The callback function would execute the necessary web request on the client.

- The data is tranfered back to the server.

- Then the data is backed into ABAP variables and trasfered back to the client.

Because this procedure is really complicated, it's difficult to configure correctly. If you still want to try, so the other (very long) thread.

A better approach (in my oppion) is to directly talk to the document management system from .NET and separate the SAP-related stuff. You could read the ABAP source code of BAPI_DOCUMENT_CHECKOUTVIEW2 to see what exactly happens.

Former Member
0 Kudos

Reiner -

Thanks for your response. In this case, however, I am using the same client (i.e.- my PC) that I have been using successfully with our 4.6 system; the new variable in the equation is the 4.7 SAP instance. Likewise, we have already been using the methodology of calling the CHECKOUTVIEW2 BAPI via the SAP .NET Connector for a long time (it is actually running in production now), so I am reluctant to follow a completely different path.

My conclusion is that there is something different in the configuration at the 4.7 end, but nobody has been able to determine what it is. Can you offer any suggestions of things we can check at that end? Also, what is the "other (very long) thread" that you refer to?

Thanks.

/jeff

reiner_hille-doering
Active Contributor
0 Kudos

I mean this thread:

As I said this is very hard to debug. The first thing that i would to is to turn RFC tracing on (on Server and Client) and check what goes over the wire before the exception happens.

Former Member
0 Kudos

Update - I have tried adding a try-catch in the system-generated proxy code in an attempt to get a more precise error message and now I am catching the following exception:

"Missing R3NAME=... or ASHOST=... in connect_param in RfcOpenEx".

Please let me know if this sheds any new light on the subject.

One other thing which has been suggested is to make sure that I have the most current version of librfc32.dll -- the one I have now has a timestamp of 9/25/2004 and a version of 6206.6.1658.4462. Is that the correct one?

Thanks.

/jeff

reiner_hille-doering
Active Contributor
0 Kudos

The question on the error message "Missing..." is where is comes from. Can you check if it really is related to the call-stack you posted earlier? If this happens on the (explicit or implicit) Open method of SAPConnection, it simply means that your connection string is wrong or empty.

Indeed your LIBRFC32 is fairly old. I recommend to update NCo to version 2.0.1 which comes with a newer LIBRFC32.

Former Member
0 Kudos

I think that the "Missing..." error message may have been a red herring... I was trying to do an explicit .Open to verify that the connection string was correct and it may have confused the rest of the code. I removed it and am now back to the "Object Reference not set..." message.

Regarding the LIBRFC32, I am having a lot of trouble locating the correct version... I looked around on the marketplace and ended with versions numbered 4620.5.312.2941 and 6100.5.364.3474, neither of which seemed to solve my problem. What is the version that I want? Do I need to find librfc32U.dll because the SAP system is Unicode?

I am hesitant to install v2.0.1 of the NCo because I had gotten the impression that this would produce proxies which were not compatible with ones created with v2.0 and so its implementation would have to be a step taken by my entire group. Can you please clarify?

Thanks.

/jeff

reiner_hille-doering
Active Contributor
0 Kudos

You should definitly have a LIBRFC32 version 6.40 meaning the version string would look like 6400.*. You don't need LIBRFC32U: this is only needed for C-Programs that want to have WideChar API-Version. Of cause also LIBRFC32 used by NCo supports Unicode.

NCo 2.0.1 is 100% compatible with 2.0.0 and just contains some bug fixes.

Former Member
0 Kudos

I have installed NCo 2.0.1, rebuilt my Web Services, verified that my librfc32.dll is 6.40, and rerun my testing. Unfortunately I am still getting exactly the same error:

Object reference not set to an instance of an object. at SAP.Connector.Rfc.RfcApi.RfcCallReceive(Int32 handle, String function, RFC_PARAMETER[] exporting, RFC_PARAMETER[] importing, RFC_TABLE[] tables, String& exception)

at SAP.Connector.Rfc.RfcClient.RfcInvoke(SAPClient proxy, String method, Object[] methodParamsIn)

at SAP.Connector.SAPClient.SAPInvoke(String method, Object[] methodParamsIn)

at DocViewDeliveryTEST.SAPProxy.BAPI_DOCUMENT_CHECKOUTVIEW2(String DOCBOMCHANGENUMBER, String DOCBOMREVISIONLEVEL, String DOCBOMVALIDFROM, BAPI_DOC_FILES2 DOCUMENTFILE, String DOCUMENTNUMBER, String DOCUMENTPART, String DOCUMENTTYPE, String DOCUMENTVERSION, String GETCOMPONENTS, String GETHEADER, String GETSTRUCTURE, String HOSTNAME, String ORIGINALPATH, String PF_FTP_DEST, String PF_HTTP_DEST, BAPIRET2& RETURNs, BAPI_DOC_COMPTable& COMPONENTS, BAPI_DOC_FILES2Table& DOCUMENTFILES, BAPI_DOC_STRUCTURETable& DOCUMENTSTRUCTURE) in C:\Inetpub\wwwroot\DocViewDeliveryTEST\SAPProxy.vb:line 170

What should I try next? Thanks.

/jeff

reiner_hille-doering
Active Contributor
0 Kudos

As I already wrote, you should turn on the Trace file both on client and server and analyze what goes over the wire before the exception happens.

Former Member
0 Kudos

[sorry for not responding sooner... for some reason I have not been able to connect to the SDN Forum for the last two days and, in fact, am now doing this from my home computer]

I was able to get some assistance regarding doing a trace on the SAP side of the equation and made some minor progress (although we did not really change anything!). I am now getting a message back from the BAPI which says something like "not able to create file". I have not been able to find documentation to explain how to turn on tracing on the client side for the .NET Connector, so any guidance you can offer would be greatly appreciated.

Also, I have found versions of SAPHTTP.EXE and SAPFTP.EXE that are 6.2 and they seem to work with my original code accessing 4.6 systems, but the 6.4 versions do not seem to work properly. My LIBRFC32.DLL is now 6.4. Another bit of information: I can use the GUI & SE37 to successfully retrieve the same file that is failing via the .NET Connector.

Please continue to provide suggestions. Thanks.

/jeff

Message was edited by: Jeff Haber

reiner_hille-doering
Active Contributor
0 Kudos

Turning on trace on client side is simple: just set the Trace property of your destination to true or set "TRACE=1" in you connection string. You will find the file in the working directory of your app.

Former Member
0 Kudos

Reiner -

I added the TRACE=1 to the connection string but there is no log to be found. Here is the connection string that I am using, not including the user and password:

"CLIENT=500 LANG=EN TRACE=1 SYSNR=0 R3NAME=DMX MSHOST=dmx-ms.cce.cpqcorp.net GROUP=Developer" -- do you see any problems with it?

I also tried using the following code, but I suspect that I am missing something there since it also had no effect.

Dim trcStg As SAP.Connector.Config.TraceSettings = New SAP.Connector.Config.TraceSettings

trcStg.Level = Diagnostics.TraceLevel.Verbose

trcStg.File = Server.MapPath("TRACE.TRC")

Am I supposed to add code related to .NCoTrace, too? Could you please provide an example?

Did you have any comments regarding the versions of SAPFTP.EXE and SAPHTTP.EXE as I mentioned in my previous note?

Thanks very much.

/jeff

reiner_hille-doering
Active Contributor
0 Kudos

The second thing (TraceSettings) doesn't have anything to do with RFC-Trace (it's NCo's internal Trace), so you can ignore it.

The RFC-Trace file is sometimes difficult to find, because it is created in the applications current working directory. Sometimes you don't know what it is.

Just search your hard disks for files with extension .trc and sort by date/time to find it.

About SAPFTP.EXE and SAPHTTP.EXE I can't tell you details. As I mentioned before the whole processing of this BAPI is really complicated and therefore kind of discouraged.

Former Member
0 Kudos

Reiner -

I have searched every folder of every disk on my PC and there are no .TRC files with today's timestamp. The only trace files I can find are related to a GUI session that I had late yesterday. Is there any setting on the SAP side that also needs to be changed in order to make the trace work? My current progress is such that the behavior implies that I am communicating my request to the BAPI successfully but that SAP is unable to write the file back to my PC. Again, just to make sure this is clear, this only happens when the SAP instance involved is our 4.7 Unicode system; this all seems to work just fine when using the 4.6 (non-Unicode) instances.

Thanks.

/jeff

Former Member
0 Kudos

I am still anxiously awaiting a response to my previous post.

Reiner: can you help?

Thanks.

/jeff

reiner_hille-doering
Active Contributor
0 Kudos

Can you please read OSS note 532918 to create and find a RFC trace file?

Former Member
0 Kudos

I read 532918 and was able to get a trace created on my client but did not have the privileges to run the suggested transactions on the SAP side. I shared the two trc files that were generated by my test with an ABAP developer here and he did not see anything which indicated any errors. One of the trc files is 330KB so I assume that is too big to post here. Please indicate how you would like me to share that information with you (email?).

One other new piece of data: while running my test request I noticed that first SAPHTTP.EXE entered a running state and then SAPFTP.EXE started running (as seen in Task Manager).

Further suggestions?

Thanks.

/jeff

reiner_hille-doering
Active Contributor
0 Kudos

You could attach the files to the OSS support ticket that your created. You created one, right? What's the number?

Former Member
0 Kudos

Update: I was able to work with a couple ABAP programmers and we believe that we isolated the problem. It seems to be happening in a routine called SYSTEM_START_REG_SERVER. The program seems to have a problem starting SAPHTTP (and SAPFTP) on the client machine although it was noted that programs did start running but then exited after about 1-2 seconds. There is some checking regarding the SAP GUI going on in this code but we weren't clear about whether that was checking that we had come in via the GUI or that the GUI was installed on the CLIENT machine -- can you please clarify?

Also, we were seeing an error message of "Only available with the RFC library from 4.0C onwards" logged on the SAP side but did not understand what this was trying to say because all of the files we have been looking at much higher revs. Again, can someone please explain?

It would be extremely helpful if somebody could spell out explicitly exactly what components should (and should not for that matter) be present on the client machine. In earlier messages we discussed things like librfg32.dll, saphttp.exe, and sapftp.exe (although the exact folder for the last two is still questionable since they appear in at least two locations [system32 and under the SAP GUI code] on the client machine). Therefore, it would be useful to have one statement that clarified the necessary versions, locations, etc., so we can determine whether the problem lies on the client, on the server, or in our code.

Thanks very much.

/jeff

Former Member
0 Kudos

In the previous message I typed "librfG32" instead of "librfc32".

reiner_hille-doering
Active Contributor
0 Kudos

Hi Jeff,

we need to follow this icident by an OSS ticket. Else I cannot forward to the responsible people. Can you please tell me the number?

Former Member
0 Kudos

Please use 0000387104. Thanks.

/jeff

Former Member
0 Kudos

Further update: we have discovered an OSS Note (756031) which seems to directly address our problem BUT

a) I have not been able to locate "libsap16.dll. as well as the Unicode versions for the ICU libraries." on the SAP downloads pages

b) I have questions concerning how the Unicode versions are supposed to be set up on the CLIENT machine in a way that they can co-exist with the non-Unicode ones. This is an absolute requirement since we must retrieve documents from both Unicode and non-Unicode systems.

Can you please offer some clarification regarding both of those areas? Thanks very much.

/jeff

reiner_hille-doering
Active Contributor
0 Kudos

Hi Jeff,

I spoke with a college from CMS that created the mentioned note. Here are the answers:

- The referenced paths in the note are invalid in the moment, but you should be able to get the files via you OSS ticket.

- There is not supported way for mixing Unicode and non-Unicode access, because SAPFTP and SAPHTTP are available in two different versions. You might find a trick to solve this (e.g. by renaming the files on demand.).

Sorry, but I can't help you more. I have added a comment to your OSS ticket. The colleges from CMS will hopefully help you soon.

Kind regards,

Reiner.

Former Member
0 Kudos

Reiner -

My colleagues checked the OSS note (I do not have direct access) and could not find your comment, so please post it here.

I am still quite unclear about exactly which versions of which files need to be present and where they should be located. CAN YOU (or someone from SAP) PLEASE PUBLISH A COMPLETE ANSWER? I know there are many, many SAP Notes which touch on this but I feel like I am going in circles and I can't find one cohesive answer.

Regarding the second point (mixing the versions), this will be a severe problem for us (once we get the initial problem solved). Is there any way that we can utilize the PF_HTTP_DEST and PF_FTP_DEST parameters or will this involve the DLLs, too?

Thanks.

/jeff

reiner_hille-doering
Active Contributor
0 Kudos

Hi Jeff,

sorry again, but I didn't implement these BAPIs nor SAPHTTP/SAPFTP, so I can not give you any advise or answers on your questions. The note that I added to your ticket is internal so you can't see it. I was just explaining your problem to the colleges. Your ticket is currently on the way to the correct department to help you. Please clearify all topic through the ticket.

You may raise the priority to Medium to speed up processing.

Former Member
0 Kudos

Update: By using the set of v6.40 UNICODE files that was made available to us via the OSS note I was able to successfully retrieve files from our 4.7 UNICODE system. HOWEVER, this setup does not seem to be backwards compatible because I can no longer access files from our 4.6 NON-UNICODE systems.

Ideas or comments? Thanks.

/jeff

Former Member
0 Kudos

Further update: by utilizing the destination parameters I have proven that I can control the versions of the SAPFTP.EXE and SAPHTTP.EXE programs that are called when the BAPI is called via the GUI. HOWEVER, when calling it via an RFC path these parameters seem to be ignored. Is it possible that the fix referenced in notes like 796709 was only made for the GUI path? If so, how can we get this changed so it works regardless of how the BAPI is invoked?

Thanks.

/jeff