08-12-2005 5:03 AM
hii
i am using the RFC RFC_CALL_TRANSACTION in my visual basic programme, i have made Z txn which runs some bdc and download the data in txt format in my C drive, this transaction runs fine when run in SAP, but when i run this thru RFC_CALL_TRANSACTION in my visual basic programme it doesn't work, no error was given. can any one tell me wat can be the reason...
abhishek suppal
08-12-2005 5:06 AM
if possible can you post the code so that it will be very easy to find out the reason.
Regds
gv
01-20-2006 8:45 AM
Background job only downloads data to SAP application server but local PC.
You only download data to local PC by foreground
Message was edited by: David Huang
01-20-2006 3:52 PM
i think you can do it in a RFC function,
then call it in your visual basic program,
you can get the data by tables of the function ,then download to your c drive .
01-20-2006 5:27 PM
check this Vb code.
*/you can call a fuction from vb using this connection.
Option Explicit
Private Sesion As DESEJ04Lib.SessionComponent
Private CargarCombos As DESEJ04Lib.Helpvalues
Private CargarCliente As DESEJ04Lib.Customer
Private rsSelectionForHelpValues As ADODB.Recordset
Private rsHelpValues As ADODB.Recordset
Private rsValuesForField As ADODB.Recordset
Private rsDescriptionForHelpValues As ADODB.Recordset
Private aRegiones()
Private aPaises()
Private aMonedas()
Private aIdiomas()
Private Sub Form_Load()
On Error GoTo errSAP
Set Sesion = New DESEJ04Lib.SessionComponent
Sesion.Destination = "DES"
Sesion.UserID = "usuario"
Sesion.Password = "password"
Sesion.Client = "100"
Set CargarCombos = Sesion.CreateInstance("DES.HELPVALUES")
CargarCombos.DimAs "BapiGetList", _
"SELECTION4HELPVALUES", rsSelectionForHelpValues
CargarCombos.DimAs "BapiGetList", "HELPVALUES", rsHelpValues
CargarCombos.DimAs "BapiGetList", "VALUES4FIELD", rsValuesForField
CargarCombos.DimAs "BapiGetList", _
"DESCRIPTION4HV", rsDescriptionForHelpValues
' países
CargarCombo Combo(0), aPaises(), "KNA1", "Customer", _
"CreateFromData1", "PersonalData", "COUNTRY"
' moneda
CargarCombo Combo(2), aMonedas(), "KNA1", "Customer", _
"CreateFromData1", "PersonalData", "CURRENCY"
' idioma
CargarCombo Combo(3), aIdiomas(), "KNA1", "Customer", _
"CreateFromData1", "PersonalData", "LANGU_P"
Exit Sub
errSAP:
MsgBox Err.Number & " " & Err.Description
End Sub
Private Sub Generar()
Dim rsCliente As ADODB.Recordset
Dim rsReturn As ADODB.Recordset
Dim rsCopy As ADODB.Recordset
On Error GoTo errGraba
Set CargarCliente = Sesion.CreateInstance("DES.CUSTOMER")
CargarCliente.DimAs "BapiCreateFromData1", "PersonalData", rsCliente
CargarCliente.DimAs "BapiCreateFromData1", "CopyReference", rsCopy
CargarCliente.DimAs "BapiCreateFromData1", "Return", rsReturn
With rsCliente
.AddNew
.Fields("FIRSTNAME") = Text1(2).Text
.Fields("LASTNAME") = Text1(1).Text
.Fields("STREET") = Text1(3).Text
.Fields("CITY") = Text1(4).Text
.Fields("POSTL_COD1") = Text1(5).Text
.Fields("HOUSE_NO") = Text1(6).Text
.Fields("E_MAIL") = Text1(7).Text
.Fields("TEL1_NUMBR") = Text1(8).Text
.Fields("LANGU_P") = aIdiomas(Combo(3).ListIndex)
.Fields("CURRENCY") = aMonedas(Combo(2).ListIndex)
.Fields("REGION") = aRegiones(Combo(1).ListIndex)
.Fields("COUNTRY") = aPaises(Combo(0).ListIndex)
End With
With rsCopy
.AddNew
.Fields("SALESORG") = "3500"
.Fields("DISTR_CHAN") = "20"
.Fields("DIVISION") = "TA"
.Fields("REF_CUSTMR") = "0000012864"
End With
CargarCliente.BapiCreateFromData1 rsCliente, rsCopy, , rsReturn
With rsReturn
If Not .EOF Then
If .Fields(0).Value = "E" Then
MsgBox "Cáspita, se produjo un error al grabar"
End If
End If
End With
Set rsCliente = Nothing
Set rsReturn = Nothing
Set rsCopy = Nothing
Exit Sub
errGraba:
MsgBox Err.Number & " " & Err.Description
Set rsCliente = Nothing
Set rsReturn = Nothing
Set rsCopy = Nothing
End Sub
Private Sub CargarCombo(oCombo As ComboBox, aArray(), _
stObjType As String, stObjName As String, stMethod As String, _
stParameter As String, stField As String, _
Optional stMaxOfRows As Variant, Optional stDescriptionOnly As Variant, _
Optional stExplicitSHlp As Variant)
Dim bPaso As Boolean
Dim iCodigo As Integer
Dim iDescripcion As Integer
Dim iMedio As Integer
Dim lnRegistros As Long
Dim lnContador As Long
On Error GoTo errCarga
stMaxOfRows = IIf(IsMissing(stMaxOfRows), "0", stMaxOfRows)
stDescriptionOnly = IIf(IsMissing(stDescriptionOnly), "", stDescriptionOnly)
CargarCombos.BapiGetList stMethod, stParameter, stObjType, stObjName, stField, stMaxOfRows, , _
rsSelectionForHelpValues, rsHelpValues, _
rsValuesForField, rsDescriptionForHelpValues, stDescriptionOnly
With rsDescriptionForHelpValues
If Not .EOF Then
.MoveLast
.MoveFirst
lnRegistros = .RecordCount
Do While Not .EOF
lnContador = lnContador + 1
If lnContador = 1 Then
iCodigo = .Fields!Leng
ElseIf lnContador = lnRegistros Then
iDescripcion = .Fields!Leng
Else
iMedio = iMedio + .Fields!Leng + 1
End If
.MoveNext
Loop
End If
End With
oCombo.Clear
If rsHelpValues Is Nothing Then
Exit Sub
End If
With rsHelpValues
If Not .EOF Then
.MoveLast
.MoveFirst
lnRegistros = .RecordCount
ReDim aArray(0 To lnRegistros - 1)
Do While Not .EOF
oCombo.AddItem Mid$(.Fields(0).Value, iCodigo + iMedio + 1)
aArray(oCombo.NewIndex) = Left$(.Fields(0).Value, iCodigo)
.MoveNext
Loop
End If
End With
Exit Sub
errCarga:
MsgBox Err.Number, Err.Description
End Sub
Private Function Valida() As Boolean
Dim iBucle As Integer
For iBucle = Combo.LBound To Combo.UBound
If Combo(iBucle).ListIndex = -1 Then
MsgBox "Debe seleccionar un valor en todos los combos."
Exit Function
End If
Next iBucle
For iBucle = Text1.LBound + 1 To Text1.UBound
If Trim(Text1(iBucle).Text) = "" Then
MsgBox "Debe completar todos los textos."
Exit Function
End If
Next iBucle
Valida = True
End Function
Private Sub Combo_Click(Index As Integer)
If Index = 0 Then
CargarCombos.DimAs "BapiGetList", _
"SELECTION4HELPVALUES", rsSelectionForHelpValues
CargarCombos.DimAs "BapiGetList", "HELPVALUES", rsHelpValues
CargarCombos.DimAs "BapiGetList", "VALUES4FIELD", rsValuesForField
CargarCombos.DimAs "BapiGetList", _
"DESCRIPTION4HV", rsDescriptionForHelpValues
With rsSelectionForHelpValues
.AddNew
.Fields("SELECT_FLD") = "LAND1"
.Fields("SIGN") = "I"
.Fields("OPTION") = "EQ"
.Fields("LOW") = aPaises(Combo(0).ListIndex)
End With
' regiones
CargarCombo Combo(1), aRegiones(), "KNA1", "Customer", _
"CreateFromData1", "PersonalData", "REGION"
End If
End Sub
Private Sub Command1_Click(Index As Integer)
If Valida Then
Generar
End If
End Sub
01-22-2006 12:58 PM
With my experience, I would suggest call the transaction in a Z-function modle. Make the Z-function module RFC enabled and call it from VB .