cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

DMS - BAPI - BAPI_DOCUMENT_CHECKIN2 - No upload to server

Former Member
0 Likes
4,010

Hi,

I am having a problem with BAPI_DOCUMENT_CHECKIN2. I use it to checkin a document into an existing Document info record.

Example of how I am using the BAPI:

REPORT ztestdms .

DATA: it_files  LIKE TABLE OF bapi_doc_files2 WITH HEADER LINE.
DATA: ln_return LIKE bapiret2.

it_files-docfile       = 'C:tempDMS_Test.txt'.
it_files-wsapplication = 'TXT'.
APPEND it_files.

CALL FUNCTION 'BAPI_DOCUMENT_SETCOMMITMODE'
     EXPORTING
          auto_commit = 'X'.

CALL FUNCTION 'BAPI_DOCUMENT_CHECKIN2'
  EXPORTING
    documenttype            = 'TEK'
    documentnumber          = '0000000000000010000000046'
    documentpart            = '000'
    documentversion         = '00'
*   HOSTNAME                = ' '
*   STATUSINTERN            = ' '
*   STATUSEXTERN            = ' '
    statuslog               = 'test mb'
*   REVLEVEL                = ' '
*   AENNR                   = ' '
*   PF_FTP_DEST             = ' '
*   PF_HTTP_DEST            = ' '
  IMPORTING
    return                  = ln_return
  TABLES
    documentfiles           = it_files
*   COMPONENTS              =
*   DOCUMENTSTRUCTURE       =
          .

WRITE ln_return.

The BAPI links the file to the DIR but does not upload it, the lock symbol in transaction CV02N is still open and the file is still available at the client. A manual checkin completes the process but this is not wanted.

What I would like to happen is the file to be uploaded (actually checked in) and removed from the client.

Any help is welcome and thanks in advance.

View Entire Topic
Former Member
0 Likes

Hi,

I have developed a BAPI which uses BAPI_DOCUMENT_CREATE2 to create a BAPI and BAPI_DOCUMENT_CHECKIN2 to check in the same document.

These 2 BAPIS works fine and they do Checkin the concerned document when called from SE37. But When I call these BAPIs from a VB Program, it does not checks in the document. Kindly suggest what could be the issue.

Former Member
0 Likes

Sunil,

I am having the same problem and have already created an OSS note for SAP in which they reply:

<i>However, as you use Visual Basic, your query represents

a consulting issue rather than a problem based on a

software error in R/3 (as you said, the BAPI works in TA

se37). Therefore, I would ask you to contact our Remote

Consulting and to open a new call under component XX-RC.

Our consultants will assist you.

Nevertheless, you could also try to use CVAPI_DOC_CHECKIN

instead of BAPI_DOCUMENT_CHECKIN2, API-s are much more

flexible than BAPI-s.

Thank you for your understanding.!

</i>

I have just finished testing this other function but it has the same result. Below you will find an example program with this other function.


Function SAPCheckinExample()

Dim R3 As Object
Dim conn As Connection
Dim rfcFunc As SAPFunctionsOCX.Function

Dim PF_DOKAR As Object, PF_DOKNR As Object, PF_DOKTL As Object
Dim PF_DOKVR As Object, PSX_MESSAGE As Object, PT_FILES_X As Object
Dim PS_DOC_STATUS As Object

Dim blnResult As Boolean
Dim strMsg As String, strTtl As String, intStl As Integer, strTyp As String

'**** Change these constants as desired *************************************
Const strApplicationServer = "ur_server"
Const strSystemNumber = "XX"
Const strClient = "XXX"
Const strLanguage = "EN"
Const strDocTyp As String = "TEK"
Const strDocNum As String = "0000000000000010000000045"
Const strDocPrt As String = "000"
Const strDocVer As String = "06"
Const strFile As String = "C:CADDEV_RFC.TXT"
Const strApplication As String = "TXT"
Const strStorage As String = "DMS_C1_ST"
'****************************************************************************

'**** Program extract *******************************************************
' Create a new connection object
Set R3 = CreateObject("SAP.Functions")
Set conn = R3.Connection

' Set the logon parameters
'R3.LogFileName = "C:WINDOWSDESKTOPSAPLOG.TXT"
  conn.ApplicationServer = strApplicationServer
  conn.SystemNumber = strSystemNumber
  conn.Client = strClient
  conn.Language = strLanguage
  conn.AutoLogon = True
  
  ' Logon
  If conn.Logon(0, False) <> True Then
      strMsg = "Logon failure!"
      strTtl = "Logon"
      intStl = vbOKOnly & vbExclamation
      MsgBox strMsg, intStl, strTtl
      Exit Function
  End If
  
  ' Create the checkin rfc in the connection object
  Set rfcFunc = R3.Add("CVAPI_DOC_CHECKIN")
  
  ' Link the parameters from the rfc to the objects called in this function
  With rfcFunc
      Set PF_DOKAR = .Exports("PF_DOKAR")
      Set PF_DOKNR = .Exports("PF_DOKNR")
      Set PF_DOKTL = .Exports("PF_DOKTL")
      Set PF_DOKVR = .Exports("PF_DOKVR")
      Set PS_DOC_STATUS = .Exports("PS_DOC_STATUS")
      Set PSX_MESSAGE = .Imports("PSX_MESSAGE")
      Set PT_FILES_X = .Tables("PT_FILES_X")
  End With
  
  ' Set the parameters for the rfc
  PF_DOKAR.Value = strDocTyp     ' Document Type
  PF_DOKNR.Value = strDocNum     ' Document number
  PF_DOKTL.Value = strDocPrt     ' Document Part
  PF_DOKVR.Value = strDocVer     ' Document Version
  
  With PT_FILES_X
    .Rows.Add
    .Value(1, "PATHNAME") = strFile
    .Value(1, "DAPPL") = strApplication
    .Value(1, "STORAGE_CAT") = strStorage
  End With
  
  ' Call the rfc
  blnResult = rfcFunc.Call
  Debug.Print blnResult ' True if the function is called succesfully

  'Check if the rfc is executed correctly
  Set PSX_MESSAGE = rfcFunc.Imports("PSX_MESSAGE")
  Debug.Print PSX_MESSAGE("MSG_TYPE"); PSX_MESSAGE("MSG_ID"); PSX_MESSAGE("MSG_NO"); PSX_MESSAGE("MSG_TXT")
  strTyp = PSX_MESSAGE("MSG_TYPE")
  strMsg = PSX_MESSAGE("MSG_TXT")
  Select Case strTyp
    Case "S"
      intStl = vbOKOnly + vbInformation
      strTtl = "Info"
    Case "I"
      intStl = vbOKOnly + vbInformation
      strTtl = "Info"
    Case "E"
      intStl = vbOKOnly + vbExclamation
      strTtl = "Error!"
    Case "W"
      intStl = vbOKOnly + vbExclamation
      strTtl = "Error!"
    Case "A"
      intStl = vbOKOnly + vbCritical
      strTtl = "Critical error!"
  End Select

  conn.Logoff

  If strMsg = "" Then
    strMsg = "File checked in!"
    strTtl = "Info"
    intStl = vbOKOnly + vbInformation
    MsgBox strMsg, intStl, strTtl
  Else
    MsgBox strMsg, intStl, strTtl
  End If
  
End Function

Message was edited by: Maurice Brouwers