2006 Aug 17 3:41 PM
Not sure where this question belongs, so I've posted it a couple of places.
I have an EXCEL spreadsheet which runs a VBA routine calling BAPI_GOODSMVT_CREATE.
With a very small set of data, 10 rows or so, everything works fine. The BAPI runs and I can commit the results.
With a larger set of data, about 400 rows, the BAPI call still works. However, immediately after the BAPI call, I call BAPI_TRANSACTION_COMMIT. At that point I get an error telling me that "NO SAP CONNECTION AVAILABLE".
Why am I losing my SAP connection? This process only runs approx 15 seconds?
Not sure where this question belongs, so I've posted it a couple of places.
I have an EXCEL spreadsheet which runs a VBA routine calling BAPI_GOODSMVT_CREATE.
With a very small set of data, 10 rows or so, everything works fine. The BAPI runs and I can commit the results.
With a larger set of data, about 400 rows, the BAPI call still works. However, immediately after the BAPI call, I call BAPI_TRANSACTION_COMMIT. At that point I get an error telling me that "NO SAP CONNECTION AVAILABLE".
Why am I losing my SAP connection? This process only runs approx 15 seconds?
2006 Aug 17 4:14 PM
I think in your VBA code the disconnection code is getting triggered. Can you run in debug mode .(F5).
Here while debugging you can able to know where exactly it is getting disconnected.
Regds
Manohar
2006 Aug 17 4:30 PM
Following is the code I am running. I run in debug and the connection drops where indicated below. But I don't know why.
Private Sub PROCESS_BTN_Click()
Dim return_tbl As Object
Dim sap_call As Object
Dim sap_prog As Object
Dim sap_commit As Object
Dim goods_mvt_tbl As Object
Dim goods_hdr As Object
Dim goods_code As Object
Dim testrun As Object
Dim errmsg As String
Dim r
Dim p
Dim po_hdr_arr(1, 15)
Set sap_call = CreateObject("SAP.Functions")
Set sap_prog = sap_call.Add("BAPI_GOODSMVT_CREATE")
Set sap_commit = sap_call.Add("BAPI_TRANSACTION_COMMIT")
Set good_mvt_tbl = sap_prog.tables("GOODSMVT_ITEM")
Set goods_hdr = sap_prog.exports("GOODSMVT_HEADER")
Set goods_code = sap_prog.exports("GOODSMVT_CODE")
Set testrun = sap_prog.exports("TESTRUN")
Set return_tbl = sap_prog.tables("RETURN")
p = 1
goods_hdr.Value(1) = "08/14/2006"
goods_hdr.Value(2) = "08/15/2006"
goods_code.Value(1) = "05"
If Range("H2").Value = "Y" Then
testrun = "X"
Else
testrun = ""
End If
Range("A2").Select
r = 0
Do While ActiveCell.Offset(r, 0).Value <> ""
p = r + 1
good_mvt_tbl.appendrow
good_mvt_tbl.Columns("MATERIAL").Value(p) = ActiveCell.Offset(r, 0)
good_mvt_tbl.Columns("PLANT").Value(p) = ActiveCell.Offset(r, 1)
good_mvt_tbl.Columns("STGE_LOC").Value(p) = ActiveCell.Offset(r, 2)
good_mvt_tbl.Columns("BATCH").Value(p) = ActiveCell.Offset(r, 3)
good_mvt_tbl.Columns("MOVE_TYPE").Value(p) = "561"
good_mvt_tbl.Columns("ENTRY_UOM").Value(p) = ActiveCell.Offset(r, 4)
good_mvt_tbl.Columns("ENTRY_QNT").Value(p) = ActiveCell.Offset(r, 5)
r = r + 1
Loop
sap_prog.call <== FIRST CALL IS HERE
If return_tbl.rowcount > 0 Then
For i = 1 To return_tbl.rowcount
r = return_tbl.Columns("ROW").Value(i)
errmsg = return_tbl.Columns("TYPE").Value(i) & "-" & return_tbl.Columns("MESSAGE").Value(i)
ActiveCell.Offset(r - 1, 6).Value = ActiveCell.Offset(r - 1, 6).Value & vbCrLf & errmsg
Next i
End If
If sap_commit.call = True Then <=== DISCONNECTED HERE
Range("I2").Value = "DONE"
End If
End Sub
2022 Nov 05 10:33 AM
Hi.
I've seen your post and I am having a problem with BAPI_GOODSMVT_GETDETAIL instead of yours.
This BAPI returns a table with items and I can show them with this code:
for n := 1 to it_items:RowCount
cText += it_items:Cell(n, 1) + ", " + it_items:Cell(n, 2) + ", " + it_items:Cell(n, 3) + ", " + it_items:Cell(n, 4) + ", " + it_items:Cell(n, 5)
next
The BAPI returns (EXPORTS)also the header of the document, but I can't use RowCount or Cell(n, n). If I use them, the program exits.
Do you know how to show the content of the structure GOODSMVT_HEADER of the BAPI? Is not a table.
Thanks.
Fernando Morales
Canary Islands