VBA with SAPbobsCOM.Recordset
Hi all,
I'm trying to do a report using VBA microsoft word.
I manage to connect to the database using the DI API.
But when i tried to do the
SAPbobsCOM.Recordset, i got error.
Need advice.
Regards,
Bruce.
The code I have contains plenty of other stuff, I try to give you some pseudocode for a dll - OK I know this is a very bad pseudocode, it is just to give you an idea ...;-). You should then use this dll from your VBA module: this is what we did and it worked well.
SAPbobsCOM.Company company = new Company();
int Initialize()
/// connect the company
int Finalize()
/// disconnect the company
/// this method read data from the DB with a Recordset
/// and returns them into an array of strings
string[] loadData()
/// your returned data
string[] ret = new string[];
/// your SQL query
string query;
/// the recordset
SAPbobsCOM.Recordset rset;
rset = company.GetBusinessObject(SAPbobsCOM.BoRecordset);
rset.DoQuery(query);
/// loop to fill into the string array
/// move the position in the recordset with rset.MoveNext
/// until you reach rset.EoF and copy the data in ret
return ret;
Similar Messages
-
Set crystal report .rtp file with SAPbobsCOM.Recordset type object
Hi Experts,
I need to pass the resultset of my SAPbobsCOM.Recordset type query to the rpt file. what report object should i use. at the moment i am using reportdocument but at the point of calling .SetDataSource(rs) it says the datasource is not valid.
Please help.
Is there any addon sample regarding setting the recordsouce of a report by setting it with SAPbobsCOM.Recordset type object is availabel.
Regards.Hi Maryam,
In my sample I'm getting the values from a DataTable. But the procedure is the same for a RecordSet.
Private Sub PrintDM(ByRef oCompany As SAPbobsCOM.Company, ByRef oApplication As SAPbouiCOM.Application, ByRef oForm As SAPbouiCOM.Form)
Dim dt_h As Data.DataTable = Nothing
Dim drh As Data.DataRow = Nothing
Dim dt_r As Data.DataTable = Nothing
Dim drr As Data.DataRow = Nothing
Dim ds As Data.DataSet = Nothing
Dim rsNotaRecepcao As SAPbobsCOM.Recordset = Nothing
Dim rsMorada As SAPbobsCOM.Recordset = Nothing
Dim rptConnectionInfo As ConnectionInfo = Nothing
Dim rptPath As String = Nothing
Dim myTables As Tables = Nothing
Dim myTableLogonInfo As TableLogOnInfo = Nothing
Dim rptDocument As ReportDocument = Nothing
Dim FileName As String = "DiarioDeMovimentos"
Try
dt_h = New Data.DataTable("HEADER")
dt_h.Columns.Add("Key")
dt_h.Columns.Add("Empresa")
dt_h.Columns.Add("DiaryCod")
dt_h.Columns.Add("DiaryNam")
dt_h.Columns.Add("FromNum")
dt_h.Columns.Add("ToNum")
dt_h.Columns.Add("FromDate")
dt_h.Columns.Add("ToDate")
dt_h.Columns.Add("G")
dt_h.Columns.Add("A")
dt_h.Columns.Add("F")
dt_r = New Data.DataTable("ROWS")
dt_r.Columns.Add("Key")
dt_r.Columns.Add("Arquivo")
dt_r.Columns.Add("DataLancamento")
dt_r.Columns.Add("TipoDocumento")
dt_r.Columns.Add("Conta")
dt_r.Columns.Add("Debito")
dt_r.Columns.Add("Credito")
dt_r.Columns.Add("NumExterno")
dt_r.Columns.Add("DataDocumento")
dt_r.Columns.Add("DataVencimento")
dt_r.Columns.Add("Detalhes")
'#### Fill HEADER fields
With oForm.DataSources.UserDataSources
drh = dt_h.NewRow()
drh("Key") = "1"
drh("Empresa") = oCompany.CompanyName
drh("DiaryCod") = .Item("DSDiaryCod").ValueEx
drh("DiaryNam") = .Item("DSDiaryNam").ValueEx
If .Item("DSFromNum").ValueEx = "" Then
drh("FromNum") = "0"
Else
drh("FromNum") = DateFromDS(oApplication, .Item("DSFromNum").ValueEx)
End If
If .Item("DSToNum").ValueEx = "" Then
drh("ToNum") = "0"
Else
drh("ToNum") = DateFromDS(oApplication, .Item("DSToNum").ValueEx)
End If
If .Item("DSFromDate").ValueEx = "" Then
drh("FromDate") = "0"
Else
drh("FromDate") = DateFromDS(oApplication, .Item("DSFromDate").ValueEx)
End If
If .Item("DSToDate").ValueEx = "" Then
drh("ToDate") = "0"
Else
drh("ToDate") = DateFromDS(oApplication, .Item("DSToDate").ValueEx)
End If
drh("G") = .Item("DSGeneral").ValueEx
drh("A") = .Item("DSAnalitic").ValueEx
drh("F") = .Item("DSCashFlow").ValueEx
End With
dt_h.Rows.Add(drh)
Dim creditString As String = ""
Dim oBP As SAPbobsCOM.BusinessPartners
oBP.CreditLimit = IIf(creditString = "", 0.0, Convert.ToDouble(creditString))
(continues)
Hope it helps,
Regards,
Vítor Vieira -
Bug in SAPbobsCOM.Recordset.GetAsXML()?
I am using the following code:
string query =
"SELECT BoxCode as stBoxcode, (CASE WHEN TaxCode = 'B' THEN BaseAmount ELSE Debit + Credit END) AS Amountx " +
"FROM (SELECT VatTaxBox.BoxCode, VatTaxBox.TaxCode, SUM(dbo.JDT1.Basesum * VatTaxBox.FSign) as BaseAmount, SUM(dbo.JDT1.Debit * VatTaxBox.FSign) AS Debit, SUM(dbo.JDT1.Credit * VatTaxBox.FSign) AS Credit " +
"FROM dbo.JDT1 INNER JOIN dbo.OJDT ON dbo.JDT1.TransId = dbo.OJDT.TransId " +
"INNER JOIN dbo.OVTG ON dbo.JDT1.VatGroup = dbo.OVTG.Code " +
"inner join (SELECT (CASE WHEN BOXx IS NULL THEN VatBoxes.Boxcode ELSE BOXx END) AS BoxCode, VATMember, FormulSignx * FormulSign as FSign, OBOX.summayfld AS TaxCode " +
"FROM (SELECT TOP 100 PERCENT B11.BoxCode AS BOXx, B0.boxcode, B0.BoxMember, B0.VATMember, isnull((select (case when formulSign='M' then -1 else +1 END) as FSignX from box1 b1 " +
"where b1.boxcode=B0.boxcode and b1.SeqNum = B0.Seqnum-1), +1) AS FormulSignx, isnull((select (case when formulSign='M' then -1 else +1 END) as FSignX from box1 b1 " +
"where b1.boxcode=B11.boxcode and b1.SeqNum = B11.Seqnum-1), +1) AS FormulSign " +
"FROM BOX1 B0 LEFT OUTER JOIN BOX1 B11 ON B0.BoxCode = B11.BoxMember " +
"WHERE (NOT (B0.VATMember IS NULL)) ORDER BY B11.BoxCode, B0.BoxCode, B0.SeqNum) AS VatBoxes " +
"INNER JOIN OBOX ON VatBoxes.boxcode = obox.boxcode) as VatTaxBox ON JDT1.VatGroup = VatTaxBox.VATMember " +
"WHERE (dbo.OJDT.RefDate >= '2005/01/01') AND (dbo.OJDT.RefDate <= '2005/07/01') AND OJDT.Series = 4 GROUP BY VatTaxBox.BoxCode, VatTaxBox.TaxCode ) as ResultSet ";
SAPbobsCOM.Recordset rs = (SAPbobsCOM.Recordset)_sapCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);
try
rs.DoQuery(query);
int i = rs.RecordCount;
int j = i++;
string s = rs.GetAsXML(); //-> throws an error: "External component has thrown an exception."
catch (Exception ex)
System.Windows.Forms.MessageBox.Show(ex.ToString());
The statement rs.GetAsXML() throws an exception. However when I use a simpler query everything works fine.
What am I doing wrong?
JurgenI don't specifically, but one trick I've learned of is to "hide" complex SQL queries in functions or stored procedures. SBO sometimes has problems with complex SQL queries. They're aware of this, but until it's fixed, try putting that "monster" in a function or a view.
Hope that helps. -
SAPBobsCOM Recordset cannot execute Stored Procedure
I have a query stored in a SQL 2005 Stored Procedure, and when want to retrieve my procedure with the Recordset.doQuery() command, this error message appears :
System.Runtime.InteropServices.COMException (0xFFFFF930) at SAPbobsCOM.IRecordset.DoQuery(String QueryStr) at [ blah2..... (it refers to my code line) ]
My code is :
Dim oRec As SAPbobsCOM.Recordset
oRec = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)
Try
oRec.DoQuery("EXEC PO_LIst2")
Catch ex As Exception
MsgBox(ex.GetBaseException.ToString)
End Try
And when I change my code to be like this :
Dim oRec As SAPbobsCOM.Recordset
oRec = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)
Try
oRec.DoQuery("Select * From OPOR")
Catch ex As Exception
MsgBox(ex.GetBaseException.ToString)
End Try
I don't get any error....
For all of the code I use SQL Server 2005, Visual Studio 2008, and SAPBobsCOM version 8.8.
Have anyone experience this?? Why the recordset can't execute my stored procedure??
Edited by: Rinaldi Sugiono on Jun 18, 2010 1:44 PMI would search the forums for SAPBobsCOM to find a more appropriate forum, since the BusinessOne components are outside of scope for this forum.
Sincerely,
Ted Ueda -
I need some help with a recordset that selects a series of
vehicle makes that then show models when a make is selected. The
problem is when I select the make it shows a list of models like it
should, some of the make lists have five models and some have ten
or more. What I need help with is how to limit the list to just the
models and not include the "null" values. This makes my drop down
list have large empty spaces at the end of the options listed. The
query is as follows:
SELECT *
FROM saa.vehicle_make
WHERE make = '#FORM.select_make#'
Question # 2:
What can I add to this recordset so that I can search on just
the make alone without the model included. The submit includes both
of the make and model lists so that makes it tough to break up.
Here is the recordset:
SELECT make
FROM saa.vehicle_make
ORDER BY make ASC
Thanks
ShaneSorry I guess I wasn't being clear. The lists work fine with
the present recordsets but I was trying to clean them up just a
little. I am using a table in mysql instead of an array for ease of
maintenance due to the high number of makes and models I am working
with.
For question number one I was looking for sql that allows me
to only show the models in the table for each make no matter how
many are in the row. Currently when I use the existing recordset I
get a long list of blank spaces as it is returning the "null"
fields also. I would like it to just show the models and stop at
the first null field.
For the second question I wanted to be able to submit the
form with just the make listed if someone wanted to see all Hondas
lets say. Not I have to select the make also so it limits the
return.
Thanks for all of the input
Shane
Here is the code I am using for the two dependent select
boxes:
<p align="center">Vehicle Search by
Make/Model</p>
<!--- store the selected make variable after the first
select boxes submits itself --->
<cfif isDefined('form.select_make')>
<cfset page.select_make = form.select_make>
</cfif>
<cfoutput>
<form name="DropDown" method="post">
<!--- query DB for the first drop down list --->
<cfquery name="get_make" datasource="saa">
SELECT make FROM saa.vehicle_make ORDER BY make ASC
</cfquery>
<!--- first drop down list --->
<!--- NOTICE the onChange javascript event in the select
tag, this is what submits the form after the first selection
--->
<p align="center">Model:<select name="select_make"
required="yes" onchange="this.form.submit()">
<option>Select Make</option>
<!--- dynamically populate the first drop down list based
on the get_make query --->
<cfloop query="get_make">
<option value="#make#" <cfif
isDefined('form.select_make')><cfif form.select_make eq
"#make#">selected</cfif></cfif>>#make#</option>
</cfloop>
</select></p>
<!--- if the first selection has been made, display the
second drop down list with the appropriate results --->
<cfif isDefined('form.select_make')>
<!--- query DB for second drop down list, based on the
selected item from the first list --->
<cfquery name="get_model" datasource="saa">
SELECT * FROM saa.vehicle_make WHERE make =
'#FORM.select_make#'
</cfquery>
<!--- second drop down list --->
</cfif>
</form>
</cfoutput>
<cfoutput>
<form action="buyerModelSearchresults.cfm"
method="POST">
<p align="center">Model: <select name="model"
required="yes">
<option>Select Model</option>
<!--- dynamically populate the second drop down list
based on the get_make query --->
<cfloop query="get_model">
<option value="#model1#">#model1#</option>
<option value="#model2#">#model2#</option>
<option value="#model3#">#model3#</option>
<option value="#model4#">#model4#</option>
<option value="#model5#">#model5#</option>
<option value="#model6#">#model6#</option>
<option value="#model7#">#model7#</option>
<option value="#model8#">#model8#</option>
<option value="#model9#">#model9#</option>
<option value="#model10#">#model10#</option>
<option value="#model11#">#model11#</option>
<option value="#model12#">#model12#</option>
<option value="#model13#">#model13#</option>
<option value="#model14#">#model14#</option>
<option value="#model15#">#model15#</option>
<option value="#model16#">#model16#</option>
<option value="#model17#">#model17#</option>
<option value="#model18#">#model18#</option>
<option value="#model19#">#model19#</option>
<option value="#model20#">#model20#</option>
<option value="#model21#">#model21#</option>
<option value="#model22#">#model22#</option>
<option value="#model23#">#model23#</option>
<option value="#model24#">#model24#</option>
<option value="#model25#">#model25#</option>
</cfloop>
</select>
</p>
<p align="center">Search by Make/Model:</p>
<p align="center"><input type="submit" name="Submit"
value="Submit"></p>
</form>
</cfoutput> -
Using the SAPbobsCOM.Recordset & DataTables
I'm trying to find the best way to tie the SAPbobsCOM.Recordset object (based, for example, on a query to return all Employees) to a more .NET compatible data object such as a datatable or dataset.
In other words, for things such as combo boxes, datagrids etc in .NET how are you guys usually binding data from SBO?
I can just write a call directly to the DB, but wanted to go through the SDK if possible.
Thanks!I actually ended up putting this into a utility .dll, but here's the function...
Public Function ConvertRecordset(ByVal SAPRecordset As SAPbobsCOM.Recordset) As DataTable
'\ This function will take an SAP recordset from the SAPbobsCOM library and convert it to a more
'\ easily used ADO.NET datatable which can be used for data binding much easier.
Dim dtTable As New DataTable
Dim NewCol As DataColumn
Dim NewRow As DataRow
Dim ColCount As Integer
Try
For ColCount = 0 To SAPRecordset.Fields.Count - 1
NewCol = New DataColumn(SAPRecordset.Fields.Item(ColCount).Name)
dtTable.Columns.Add(NewCol)
Next
Do Until SAPRecordset.EoF
NewRow = dtTable.NewRow
'populate each column in the row we're creating
For ColCount = 0 To SAPRecordset.Fields.Count - 1
NewRow.Item(SAPRecordset.Fields.Item(ColCount).Name) = SAPRecordset.Fields.Item(ColCount).Value
Next
'Add the row to the datatable
dtTable.Rows.Add(NewRow)
SAPRecordset.MoveNext()
Loop
Return dtTable
Catch ex As Exception
MsgBox(ex.ToString & Chr(10) & "Error converting SAP Recordset to DataTable", MsgBoxStyle.Exclamation)
Exit Function
End Try
End Function -
Is it possible to work with two recordsets in one method?
If so, I havnt been able to figure out how.
Any Suggestions?
StefSure. Why not? But your problem has nothing to with them being "in the same method". It's more likely to do with this quote from the API documentation for java.sql.Statement:
"Only one ResultSet object per Statement object can be open at any point in time. Therefore, if the reading of one ResultSet object is interleaved with the reading of another, each must have been generated by different Statement objects. All statement execute methods implicitly close a statment's current ResultSet object if an open one exists." -
Trouble with SAPBobsCOM.Documents
Hello everyone. I am having strange trouble with SAPBobsCOM.Documents that I cannot seem to resolve. I have used this code before and now it is not working and I don't know why. When I instantiate an object as follows:
Dim oAPCredit As SAPbobsCOM.Documents
Set oAPCredit = vCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oPurchaseCreditNotes)
If I look at the oAPCredit object, every row says: Application-defined or Object-defined error
Then when I try to set the values, the add on completely bombs out. What is even more strange is that it only fails on me for PurchaseCreditNotes in this company but if I point to another company on another server, it won't work for oDeliveryNotes or oInvoices either, but those do work in my current environment. Has anyone ever seen anything like this? I am working in 2005A PL 16 and the DI API is 6.80.318.0. Any help would be greatly appreciated.
Thanks so much in advance! Have a great day!One time I had a problem like this, and I saw that the user of B1 that I was using it didn't have enough permissions into SAP B1, so you check the permissions of your user.
-
Recordset - updating 2 tables with 1 recordset using application object update record
I have a recordset that uses a field from 2 different tables
with a select statement where clause that joins a userid. I can
display the field’s data just fine. Now I want to use the
Application object “update record” so I can modify
either of the fields. The problem is the Application object
“update record” only allows you to update one table.
How does Dreamweaver mx 2004 allow me to update 2 tables with one
recordset and 1 submit button? Currently using php.
Example of where:
Where member.userid = member_detail.userid
I tried creating the one form with the field from the first
table and that works just fine. I added the other field from the
other table into the form but ofcourse there isn’t any code
that will update the second table so it won’t work.
My application requires me to update alot of fields between 2
tables at the same time.
Does anyone know a way using Dreamweaver mx 2004 to do this?
I don’t have much php experience.jon-rookie wrote:
> DreamerJim,
>
> I am sorry but I don't think you are correct. I just
can't believe that with
> all the powers to be at Macromedia and now Adobe can't
figure out how to update
> two tables at once. There are millions of db's out there
that require this. I
> spent several hours today perusing lots of posts on the
internet. It seems I
> am not the only one out there that has asked this
question. Unfortunately
> there are no good answers yet to my surprise.
>
> I did find a Dreamweaver extension that does exactly
what I myself and many
> others want. The problem is it is no longer available
unless you purchase a
> bundle of software from Adobe.
>
> I have not looked into it in detail so I am not 100%
sure that is accurate!
>
> Still, alot of php programmers do this all the time
without much trouble. I
> just want to know if Dreamweaver mx 2004 has the
capability if a person knows
> the right steps.
>
> Hopefully a Dreamweaver expert will post something to
let us know for sure.
> Until then I am stuck.
>
Not even CS3 has this built in, you will either have to code
it yourself
or buy the extension you have found. Dreamweaver gives you
basic
features to help you develop applications, but if you want to
do
anything really clever you have to do it yourself.
One thing to consider is maybe creating an SQL view that is
can be
updated. I am pretty sure it exists, then you use the view
instead of
the table in the update behaviour. I have never done it
myself, but I am
sure it can be done.
Steve -
Call BEX-Query from VBA with BEX-automatic login?
Hi,
I'm trying to call a query from VBA. I have two problems/questions:
1. Automatic login?
I want to do an automatic login. I found this peace of code here, but I get an error:
Public Function LogonToYourBW()
' create Logon & RFC-Handle
logonToBW = False clear connect Flag the flag can be used to find out if connected or not
'load SAP functionality by opening BEX file ( use your installation path)
Workbooks.Open (c:\sappc\bw\sapbex.xla)
With Run("sapbex.xla!sapbexGetConnection") call the connection
' Set the params for Auto logon
.client = YOUR CLIENT NO
.user = YOUR BW USER
.Password = YOUR BW PWD I recommend to create a dummy reporting user for this task
.Language = YOUR LANGUAGE YOU LIKE TO USE FOR QUERY DISPLAY ( i.E. EN)
.SystemNumber = YOUR SYSTEM NO
.ApplicationServer = YOUR SERVER Name OR IP-ADDRESS
.UseSAPLOgonIni = FALSE 'important for automatic connection
.logon 0, True This will provide a dialog to appear
If .IsConnected <> 1 Then
.logon 0, False
If .IsConnected <> 1 Then Exit Function
Else
Set g_oFunction = CreateObject("SAP.Functions")
Set g_oFunction.Connection = g_oConnection
End If
End With
Run "sapbex.xla!sapbexinitConnection" this will enable the connection you just created
logonToBW = True
End Function
The error is by this row:
Set g_oFunction.Connection = g_oConnection
Object is needed! How is the g_oConnection-object defined?
2. How can I pass values for the parameters from VBA?
If I open the query usually from SAP-BEX-Toolbar, after selecting the query, I get a parameter mask, where I must put in a value. How can I this automatize from VBA? Has anybody a short samplecode for that?
Thank you for your help
Stefan
[email protected]Peter and others:
What I really want to do is write a stand-alone application that I can run from windows scheduler that queries our BW for sales data for certain items (in a tabular form) and pulls that data into a VB recordset, or a .NET dataset so that I can insert the rows into another database (SQL Server, or Access) I already know how to do all the data movement to/from datasets and databases I just cannot figure out how to programmatically grab this sales data from BW our company has workbooks already set up that aggregate WW sales information by region (IE, there is a separate workbook for each region of the world) I can manually go into the Excel interface, tell it which items to pull the sales info for, and it dumps the data into the worksheet (organized by customer, and then by cat #)
So, what Id like to do is write an app that will pull data every week or so from the BW (from each regions sales invoice detail workbook), and insert it into another database that we use for reporting other, non-sales, data.
Thoughts on this ? Is there another, non-BEx method that is better ?
thanks !! -
Hi,
I am trying to add a BOM using the code below but none gets added. Err ends up as -5002, ErrCode as -1107, and ErrMsg as "The object's key is not set". NBS_BOMType() is a function to convert the input to a tree type and "rs" is a recordset containing the data used for the new BOM. What am I missing?
Thanks,
Mike
'Add BOM.
Dim BOMToAdd As SAPbobsCOM.ProductTrees
BOMToAdd = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oProductTrees)
Dim Err as Long
With BOMToAdd
.TreeCode = rs.Fields.Item("BOMItemID").Value
.TreeType = NBS_BOMType(rs.Fields.Item("TreeType").Value)
.Quantity = rs.Fields.Item("Qty").Value
.UserFields.Fields.Item("U_NBS_DwgFile").Value = rs.Fields.Item("DwgFile").Value
.UserFields.Fields.Item("U_NBS_ECNRev").Value = rs.Fields.Item("NewRev").Value
Err = .Add
If Err <> 0 Then
oCompany.GetLastError(ErrCode, ErrMsg)
SBO_Application.MessageBox(ErrMsg)
End If
End WithJohn,
Thanks for your help. Your advice tells me that I have to know one of the BOMs line items in order to create it. This is problematic for me because it makes the query needed very tricky. Having to know any of the details of an object in order to create it appears to me to be counter to good object oriented design. It seems more logical to me to create the object (any object) and then specify its collections - an object must exist (be instantiated) in order to have a collection. Maybe I don't really understand OOD. Does anyone?
My intended approach was to add a BOM object and then specify its line items until all BOMs have been created. But it looks like that wont work unless I can specify the entire BOM before adding it. Is this possible?
Thanks, -
RFC & Excel VBA with ECC 6.0
I use a routine like this to post movements in R/3 (This is an example for MB1A Transaction) based on information posted on a excel spreadsheet + VBA and seudo-code created with SM35 transaction
Public Sub updateRFC_BDC()
'Set sheet specific variables / constants
j = 0
startRow = 3
colStatus = 1
colMsg = 1
' Cell information on the excel spreadsheet
colMKPF_BLDAT = 2
colMKPF_BUDAT = 3
colMKPF_OIB_BLTIME = 4
colRM07M_BWARTWA = 5
colRM07M_WERKS = 6
colRM07M_LGORT = 7
colXFULL = 8
colRM07M_WVERS3 = 9
colMSEG_MATNR = 10
colMSEG_ERFMG = 11
colMSEG_ERFME = 12
colMSEG_WERKS = 13
colMSEG_LGORT = 14
colMSEG_CHARG = 15
colMSEG_OIHANTYP = 16
colOIB_A08_TDICH = 17
colOIB_A08_TDICHEH = 18
colOIB_A08_MTTMP = 19
colOIB_A08_MTTEH = 20
colOIB_A08_TSTMP = 21
colOIB_A08_TSTEH = 22
colOIB_A08_MCF = 23
colDKACB_FMORE = 24
colCOBL_PRCTR = 25
i = 0
'Set debug mode
If CheckBox1.Value = True Then
DEBUG_MODE = True
Else
DEBUG_MODE = False
End If
'Reset status column
Range(Cells(startRow, colMsg), Cells(60000, colMsg)).Value = ""
'Login to SAP, if it fails, notify user and exit sub
updateStatus "Logging into SAP...", colStatus, 1
If Not login2SAP Then
MsgBox "Login to SAP failed. Remote Function Call NOT performed.", vbInformation, "Login Failed"
updateStatus "", colStatus, 1
Exit Sub
End If
'While the next row is not empty loop through BDC
While Trim(Cells(startRow + i, 2).Value) <> ""
firstTime = True
updateStatus "Processing Row " & (startRow + i), colStatus, 1
' Retrieve the Function object (the Connection object must be set up before Function objects can be created):
Set RfcCallTransaction = Functions.Add("RFC_CALL_TRANSACTION")
'Set the export parameters
RfcCallTransaction.exports("TRANCODE") = "MB1A "
RfcCallTransaction.exports("UPDMODE") = "S"
Set BdcTable = RfcCallTransaction.Tables("BDCTABLE")
'Highlight current row so user knows what is happening
Cells(startRow + i, 2).Select
'Screen SAPMM07M BDC code
add_BDCData BdcTable, "SAPMM07M", "0400", "X", "", ""
add_BDCData BdcTable, "", "", "", "BDC_CURSOR", "RM07M-LGORT"
testForBlank_AddToBDC "MKPF-BLDAT", Cells(startRow + i, colMKPF_BLDAT).Value
testForBlank_AddToBDC "MKPF-BUDAT", Cells(startRow + i, colMKPF_BUDAT).Value
testForBlank_AddToBDC "MKPF-OIB_BLTIME", Cells(startRow + i, colMKPF_OIB_BLTIME).Value
testForBlank_AddToBDC "RM07M-BWARTWA", Cells(startRow + i, colRM07M_BWARTWA).Value
testForBlank_AddToBDC "RM07M-WERKS", Cells(startRow + i, colRM07M_WERKS).Value
testForBlank_AddToBDC "RM07M-LGORT", Cells(startRow + i, colRM07M_LGORT).Value
testForBlank_AddToBDC "XFULL", Cells(startRow + i, colXFULL).Value
testForBlank_AddToBDC "RM07M-WVERS3", Cells(startRow + i, colRM07M_WVERS3).Value
add_BDCData BdcTable, "", "", "", "BDC_OKCODE", "=NPE"
'Screen SAPMM07M BDC code
add_BDCData BdcTable, "SAPMM07M", "0410", "X", "", ""
add_BDCData BdcTable, "", "", "", "BDC_CURSOR", "MSEG-OIHANTYP"
testForBlank_AddToBDC "MSEG-MATNR", Cells(startRow + i, colMSEG_MATNR).Value
testForBlank_AddToBDC "MSEG-ERFMG", Cells(startRow + i, colMSEG_ERFMG).Value
testForBlank_AddToBDC "MSEG-ERFME", Cells(startRow + i, colMSEG_ERFME).Value
testForBlank_AddToBDC "MSEG-WERKS", Cells(startRow + i, colMSEG_WERKS).Value
testForBlank_AddToBDC "MSEG-LGORT", Cells(startRow + i, colMSEG_LGORT).Value
testForBlank_AddToBDC "MSEG-CHARG", Cells(startRow + i, colMSEG_CHARG).Value
testForBlank_AddToBDC "MSEG-OIHANTYP", Cells(startRow + i, colMSEG_OIHANTYP).Value
add_BDCData BdcTable, "", "", "", "BDC_SUBSCR", "SAPMM07M 2400BLOCK1"
add_BDCData BdcTable, "", "", "", "BDC_SUBSCR", "SAPMM07M 2400BLOCK2"
add_BDCData BdcTable, "", "", "", "BDC_OKCODE", "/00"
'Screen SAPLOIB_QCI BDC code
add_BDCData BdcTable, "SAPLOIB_QCI", "0500", "X", "", ""
add_BDCData BdcTable, "", "", "", "BDC_CURSOR", "OIB_A08-TDICH"
testForBlank_AddToBDC "OIB_A08-TDICH", Cells(startRow + i, colOIB_A08_TDICH).Value
testForBlank_AddToBDC "OIB_A08-TDICHEH", Cells(startRow + i, colOIB_A08_TDICHEH).Value
testForBlank_AddToBDC "OIB_A08-MTTMP", Cells(startRow + i, colOIB_A08_MTTMP).Value
testForBlank_AddToBDC "OIB_A08-MTTEH", Cells(startRow + i, colOIB_A08_MTTEH).Value
testForBlank_AddToBDC "OIB_A08-TSTMP", Cells(startRow + i, colOIB_A08_TSTMP).Value
testForBlank_AddToBDC "OIB_A08-TSTEH", Cells(startRow + i, colOIB_A08_TSTEH).Value
testForBlank_AddToBDC "OIB_A08-MCF", Cells(startRow + i, colOIB_A08_MCF).Value
add_BDCData BdcTable, "", "", "", "BDC_OKCODE", "=CONT"
'Screen SAPMM07M BDC code
add_BDCData BdcTable, "SAPMM07M", "0410", "X", "", ""
add_BDCData BdcTable, "", "", "", "BDC_SUBSCR", "SAPLKACB 0001BLOCK"
testForBlank_AddToBDC "DKACB-FMORE", Cells(startRow + i, colDKACB_FMORE).Value
'Screen SAPLKACB BDC code
add_BDCData BdcTable, "SAPLKACB", "0002", "X", "", ""
add_BDCData BdcTable, "", "", "", "BDC_CURSOR", "COBL-AUFNR"
testForBlank_AddToBDC "COBL-PRCTR", Cells(startRow + i, colCOBL_PRCTR).Value
add_BDCData BdcTable, "", "", "", "BDC_SUBSCR", "SAPLKACB 9999BLOCK1"
add_BDCData BdcTable, "", "", "", "BDC_OKCODE", "=ENTE"
'Screen SAPMM07M BDC code
add_BDCData BdcTable, "SAPMM07M", "0410", "X", "", ""
add_BDCData BdcTable, "", "", "", "BDC_CURSOR", "MSEG-ERFMG"
testForBlank_AddToBDC "MSEG-ERFMG", Cells(startRow + i, colMSEG_ERFMG).Value
add_BDCData BdcTable, "", "", "", "BDC_SUBSCR", "SAPMM07M 2400BLOCK1"
add_BDCData BdcTable, "", "", "", "BDC_SUBSCR", "SAPMM07M 2400BLOCK2"
add_BDCData BdcTable, "", "", "", "BDC_SUBSCR", "SAPLKACB 0001BLOCK"
testForBlank_AddToBDC "DKACB-FMORE", Cells(startRow + i, colDKACB_FMORE).Value
add_BDCData BdcTable, "", "", "", "BDC_OKCODE", "=BU"
'Screen SAPLKACB BDC code
add_BDCData BdcTable, "SAPLKACB", "0002", "X", "", ""
add_BDCData BdcTable, "", "", "", "BDC_CURSOR", "COBL-AUFNR"
testForBlank_AddToBDC "COBL-PRCTR", Cells(startRow + i, colCOBL_PRCTR).Value
add_BDCData BdcTable, "", "", "", "BDC_SUBSCR", "SAPLKACB 9999BLOCK1"
add_BDCData BdcTable, "", "", "", "BDC_OKCODE", "=ENTE"
add_BDCData BdcTable, "TCDEMB1A ", "", "", "", ""
firstTime = False
' Call the function (if the result is false, then display a message):
If RfcCallTransaction.CALL = True Then
Set Messages = RfcCallTransaction.imports("MESSG")
If DEBUG_MODE Then
printBDCTable (startRow + i)
End If
Cells(startRow + i, colMsg).Value = Messages.Value("MSGTX")
Else
MsgBox " Call Failed! error: " + RfcCallTransaction.Exception
updateStatus "Error!", colStatus, 1
End If
i = i + 1
j = 0
Messages.Value("MSGTX") = ""
Wend
logOffSAP
If DEBUG_MODE Then
MsgBox "BDC file written to : " & DEBUG_FILE
End If
updateStatus "Processing Done. Logged off of SAP", colStatus, 1
End Sub
Now I'm trying to use this routine for ECC 6.0, but it looks like the export parameter changed and it is not working.
Could you please help me to debug this routine to make it work with ECC 6.0
ThanksDear Javier Cantini,
Welcome to SCN.
Post your queries in relevant forum. Your query is technical in nature and should be posted in ABAP forums. Moving your thread to ABAP, General forum.
Regards,
Naveen -
Sender FCC with unbounded RecordSet Structure produces Empty File
Hi Experts,
My scenario is File (FTP) to IDoc, using FCC on the sender.
The source file is a flat file representation of the IDoc e.g. with the segment names preceeding each record row.
FCC parameters are as follows:
RecordSet Name: Z1RECORDSETNAME
RecordSet Structure: EDI_DC,1,E1TPDLH,1,Z1TPI2H,1,E1TPACC,E1TPTRM,,E1EDT13,,E1TPDIH,1,Z1TPI2HD,1,E1TPNOT,*
RecordSet Sequence: Variable OR Ascending
.fieldFixedLengths
.fieldNames
.keyFieldValue
.endSeparator
.keyFieldInStructure
above parameters are used in all segments, except in E1TPNOT where ignoreRecordsetName is added
My issue is when the test file contains more than 1 value for the unbounded segments E1TPTRM, E1EDT13 (e.g. 3 row values for E1TPTRM and 2 row values for E1EDT13) the Content Conversion succesfully finishes but produces an Empty File (size = 0)
Does anyone know how to fix this issue? Am i missing something in the parameters to be able to support the current file structure?
Kindly share your ideas/solution
I've tried to edit the test file to have only 1 record value for the unbounded segments and it is succesfull and does not produce an empty file.Try giving
EDI_DC,1,E1TPDLH,1,Z1TPI2H,1,E1TPACC,E1TPTRM, * ,E1EDT13, * ,E1TPDIH,1,Z1TPI2HD,1,E1TPNOT,*
I got it, i guess even you have given the astrix after E1TPTRM and E1EDT13 and it changed to bold.
Ok ignore my answer. -
Problem with SAP log-in using VBA with Excel Bexanalyzer add-in
I am trying to login in to SAP using VBA code but the code fails as indicated below .
In Function GetBEx(Optional iWb As Workbook) As Object
GetBEx = pAddin.ExcelInterface.WorkbookBExExcelApplication(lName)
Works properly – I get an object
However, in the sapBEXgetConnection function it seems that the lBex.ComConnection fails. The p_connectionObj doesn’t get assigned (p_connectionObj is Nothing)
Function sapBEXgetConnection(Optional IWhat As Integer) As Variant
If IWhat = 0 Then
' try to get BexApi Connection
Dim lBEx As Object
Set lBEx = GetBEx
On Error Resume Next
Set p_connectionObj = lBEx.ComConnection 'fails here
If Err.Number <> 0 Then Set p_connectionObj = Nothing
On Error GoTo 0
If p_connectionObj Is Nothing Then If Not prepareConnection Then Exit Function
Set sapBEXgetConnection = p_connectionObj
End If
End Function
All of this code is part of the Bexanalyzer Excel Add-In
I’m assuming that I’m missing a patch or some configuration is incorrect but, since I’m not very familiar with SAP I don’t know. Any help would be greatly appreciated. Thank you.Hello Sebastien,
Since I don't know what an SSO automatic connection is I can't give you an answer. Can you explain it?
Here's what I'm trying to achieve: on demand I'd like to execute VBA code that will use Bexanalyzer.xla functions to log in and then refresh a query that exists in the Excel workbook. Ultimately I'll want to apply parameters / variables to the query when it is refreshed. I may then automatically execute VBA code to manipulate the resulting data in the workbook. Basically I want to be able to do all of this without any user input.
Paul -
The question about RAW datatype in VBA with OO4O
Hi all.
I have developed a sort of VBA program with oo4o.
When I issued "select rawtohex(saddr),saddr from v$session where rownum < 2" and I displayed the result on excel spread sheet.
The result was below.
RAWTOHEX(SADDR) SADDR
C0000000E14ADDF0 �
I found I couldn't display a raw datatype result without using RAWTOHEX function.
But, I query the table using "*",such as " select * from v$session" sometime. So I have to display the raw datatype result without using oracle function.
I heard that the "RAW" datatype is a array of byte, so I used byte array.
The following is my first idea and the result is wrong.
The result is 'FF000000......', not 'C000000....'
Is there any good idea?
Dim oSession As Object
Dim oDatabase As Object
Dim oRs As Object
Dim cntCol, cntRow As Long
Dim rowNum, colNum As Long
Dim sraw() As Byte
Dim k As Integer
Dim hexaString As String
Set oSession = CreateObject("OracleInProcServer.XOraSession")
Set oDatabase = oSession.DbOpenDatabase(gTargetServer, gUserID & "/" & gPasswd, 0&)
Set oRs = oDatabase.DbCreateDynaset(gSqlString, 0&)
cntCol = oRs.Fields.Count
cntRow = oRs.RecordCount
ReDim resData(cntRow, cntCol) ' the variant type array to store result
'To store column title.
For colNum = 0 To cntCol - 1
resData(0, colNum) = oRs.Fields(colNum).Name
Next colNum
'To store data.
For rowNum = 1 To cntRow
For colNum = 0 To cntCol - 1
Select Case oRs.Fields(colNum).Type
Case 11
sraw = oRs.Fields(colNum).Value
For k = 0 To UBound(sraw)
hexaString = hexaString & Hex(sraw(k)) '<= here.***********
Next k
resData(rowNum, colNum) = hexaString
Case Else
resData(rowNum, colNum) = oRs.Fields(colNum).Value
End Select
Next colNum
oRs.MoveNext
Next rowNum
I hope I get helps.
Bill.But, I query the table using "*",such as " select * from v$session" sometimeCan't you use
select rawtohex(saddr) hexaddr, t.* from v$session t
(if you really need '*' ) ?
Rgds.
Maybe you are looking for
-
WLC 5508 with LAP-1142n - Several Errors
Hello all, I had installed a WLC 5508 with 7 LAP 1142n and 2 converted AP 1131abg. I am seeing some errors relating 2 issues. 1st- One particular AP 1142 is disassociating and reseting the radios. /* Style Definitions */ table.MsoNormalTable {mso-sty
-
When I was doing my regular backup for my iphone 5 on my laptop, I accidentally set it up as a new iphone. How can I set it back to my old one so I can get all my pictures an everything back??
-
Maximum LVA amt exceeded in the case of at least 1 asset - Msg no MEPO053
Hi All, I am hitting an error when i am trying to post a Purchase Order (ME21N) for my asset. The asset that i am trying to post is created from non LVA asset class I have done the configuration at OAY2 to LVA 0 No maximum amount check. The err
-
My office is using a shared printer, a Toshiba e-Studio2540C PCL6 V4. For months the printer will work fine for all of us until it suddenly decides to go offline. Every solution I see for this involves right clicking on the printer from the control p
-
Grave sound problem, don't know where the problem lies.
When I first play with my guitar into Logic, it is delayish, then comes an awful noise for about 20 seconds. When that noise stops, everything is "nearly" ok, though the sound quality is quite crappy. If I'm silent for some time, I'll have to wait ag