Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

flat file in http folder

Former Member
0 Likes
762

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.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
713

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

6 REPLIES 6
Read only

Former Member
0 Likes
713

Hi

Have you tried by FTP?

Max

Read only

Former Member
0 Likes
714

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

Read only

0 Likes
713

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

Read only

0 Likes
713

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

Read only

0 Likes
713

Thank you very much.

Read only

0 Likes
713

Glad to be of help and thanks for awarding the points.