‎2006 Oct 26 6:11 PM
Hi,
Is there anyway of downloading a flat file into a folder in some http address rather than the application server or local directory.
Regards,
Sukumar.
‎2006 Oct 26 6:44 PM
Hi,
Instead of saving the flatfile from sap on a http address or fileserver you could use a scripting language for example vbscript to extract the data from SAP and store it as a flatfile from your webserver or any other computer with the gateway installed on it.
If you want I can give you an example of a vb script.
Regards,
Dennis
‎2006 Oct 26 6:32 PM
‎2006 Oct 26 6:44 PM
Hi,
Instead of saving the flatfile from sap on a http address or fileserver you could use a scripting language for example vbscript to extract the data from SAP and store it as a flatfile from your webserver or any other computer with the gateway installed on it.
If you want I can give you an example of a vb script.
Regards,
Dennis
‎2006 Oct 26 7:07 PM
If it is a vb script where do we have to execute it. And please do send me a sample code too.
Regards,
Sukumar.
Message was edited by: sukumar kumar
‎2006 Oct 31 1:31 PM
You can run the VB script on any PC where the SAP Gateway and SDK have been installed.
I am working on a project where we use vbscript and ASP to extract data from SAP and use it on the intranet.
You can use the VB-Script in an excel or word document and also on a webpage. The example below I have used in a excel spreadsheet (use a macro to call the subroutine).
I hope this helps you.
Example below retrieves a list of vendors.
VBScript to list vendors from SAP table LFA1
Sub GetTable()
'Logon
Dim sapConn As Object 'Declare variant
Set sapConn = CreateObject("SAP.Functions") 'Create ActiveX object
If sapConn.Connection.Logon(0, False) <> True Then 'Try Logon
MsgBox "Cannot Log on to SAP"
End If
'Define function
Dim objRfcFunc As Object
Set objRfcFunc = sapConn.Add("RFC_READ_TABLE")
'Set import parameters
Dim objQueryTab, objRowCount As Object
'Table name
Set objQueryTab = objRfcFunc.Exports("QUERY_TABLE")
objQueryTab.Value = "LFA1"
'Set max nr of rows
Set objRowCount = objRfcFunc.Exports("ROWCOUNT")
objRowCount.Value = "10"
'Set table parameters
Dim objOptTab, objFldTab, objDatTab As Object
Set objOptTab = objRfcFunc.Tables("OPTIONS")
Set objFldTab = objRfcFunc.Tables("FIELDS")
Set objDatTab = objRfcFunc.Tables("DATA")
'First we set the condition
objOptTab.FreeTable 'Refresh table
'Then set values where statement (TEXT field in table parameter OPTIONS)
objOptTab.Rows.Add
objOptTab(objOptTab.RowCount, "TEXT") = "KTOKK = 'HSUB' and "
objOptTab.Rows.Add
objOptTab(objOptTab.RowCount, "TEXT") = "ORT01 = 'London'"
'Next we set fields to obtain (fields we want to retrieve from the table)
objFldTab.FreeTable 'Refresh table
'Then set values (FIELDNAME field in table parameter FIELDS)
objFldTab.Rows.Add
objFldTab(objFldTab.RowCount, "FIELDNAME") = "LIFNR" 'vendor nr
objFldTab.Rows.Add
objFldTab(objFldTab.RowCount, "FIELDNAME") = "NAME1" 'vendor name
objFldTab.Rows.Add
objFldTab(objFldTab.RowCount, "FIELDNAME") = "ORT01" 'city
objFldTab.Rows.Add
objFldTab(objFldTab.RowCount, "FIELDNAME") = "ADRNR" 'address nr
objFldTab.Rows.Add
objFldTab(objFldTab.RowCount, "FIELDNAME") = "ERNAM" 'user who created the vendor
If objRfcFunc.Call = False Then
MsgBox objRfcFunc.Exception
End If
Dim objDatRec As Object
Dim objFldRec As Object
For Each objDatRec In objDatTab.Rows
For Each objFldRec In objFldTab.Rows
Cells(objDatRec.Index, objFldRec.Index) = Mid(objDatRec("WA"), objFldRec("OFFSET") + 1, objFldRec("LENGTH"))
Next
Next
End Sub
‎2006 Oct 31 6:12 PM
‎2006 Nov 01 2:12 PM