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

MAKE AN ENTRY IN ALL REQUIRED FIELDS

Former Member
0 Likes
1,270

HI,

I AM USING THE FOLLOWING EXCEL VBA CODE TO TRY AND CALL A TRANSACTION LX02 DIRECT INTO EXCEL.

Public Sub add_bdcdata(BdcTable As Object, program As String, dynpro As String, dynbegin As String, fnam As String, fval As String)

Dim vField As Variant

j = j + 1

BdcTable.Rows.Add

BdcTable.Value(BdcTable.Rows.Count, "PROGRAM") = "RLS10020"
BdcTable.Value(BdcTable.Rows.Count, "DYNPRO") = "1000"
BdcTable.Value(BdcTable.Rows.Count, "DYNBEGIN") = "X"
BdcTable.Value(BdcTable.Rows.Count, "FNAM") = "BDC_OKCODE"
BdcTable.Value(BdcTable.Rows.Count, "FVAL") = "NEXT"

Debug.Print BdcTable.Value(j, "FVAL")
End Sub

Public Sub rfc_call_transaction()
Dim Functions As Object
Dim RfcCallTransaction As Object
Dim Messages As Object
Dim BdcTable As Object

'***************************************************************************
' Create the Function control (that is, the high-level Functions collection):
'***************************************************************************
Set Functions = CreateObject("SAP.Functions")

'***************************************************************************
' Set the rest of Connection object values:
'***************************************************************************
Functions.Connection.System = "QA2"
Functions.Connection.client = "900"
Functions.Connection.user = "mbrough"
Functions.Connection.Password = "st34lhv3"
Functions.Connection.Language = "EN"

If Functions.Connection.Logon(0, False) <> True Then
Exit Sub
End If

Dim iBOB As Integer
iBOB = Range("A1")
Do

'*****************************************************************************
' 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") = "LX02"
RfcCallTransaction.exports("UPDMODE") = "S"
Set BdcTable = RfcCallTransaction.Tables("BDCTABLE")

'*****************************************************************************
' Set the tables parameter and add the data for the call transaction
'*****************************************************************************
add_bdcdata BdcTable, "RLS10020", "1000", "X", "", ""
add_bdcdata BdcTable, "", "", "", "BDC_CURSOR", "S1_LGNUM"
add_bdcdata BdcTable, "", "", "", "BDC_OKCODE", "=ONLI"
add_bdcdata BdcTable, "", "", "", "S1_LGNUM", "900"
add_bdcdata BdcTable, "", "", "", "S1_LGNUM", "ActiveCell"
add_bdcdata BdcTable, "", "", "", "S1_LGTYP-LOW", "K01"
add_bdcdata BdcTable, "", "", "", "BDC_SUBSCR", "SAPLSSEL"
add_bdcdata BdcTable, "", "", "", "BDC_SUBSCR", "SAPLSSEL"
add_bdcdata BdcTable, "SAPMSSYO", "0120", "X", "", ""
add_bdcdata BdcTable, "", "0", "", "BDC_OKCODE", "=BACK"
add_bdcdata BdcTable, "RLS10020", "1000", "X", "", ""
add_bdcdata BdcTable, "", "", "", "BDC_OKCODE", "/EE"
add_bdcdata BdcTable, "", "", "", "BDC_CURSOR", "S1_LGNUM"
add_bdcdata BdcTable, "", "", "", "S1_LGNUM", ActiveCell.Value

'******************************************************************************
'End SubCall the function (if the result is false, then display a message):
'******************************************************************************
If RfcCallTransaction.Call = True Then
Set Messages = RfcCallTransaction.imports("MESSG")
MsgBox Messages.Value("MSGTX")
Else
MsgBox " Call Failed! error: " + GetCustomers.Exception
End If
iBOB = iBOB + 1
Loop Until IsEmpty(ActiveCell.Offset(iBOB, 0))

Functions.Connection.Logoff
End Sub

I KEEP GETTING AN ERROR MESSAGE SAYING 'MAKE AN ENTRY IN ALL REQUIRED FIELDS' AND THEN NOTHING DOWNLOADS INTO EXCEL.

CAN ANYONE HELP PLEASE?

THANKS

3 REPLIES 3
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
971

Yes, run the transaction SAPgui, and make sure that you are filling all fields that are required while running in SAPgui.

Regards,

Rich Heilman

Read only

0 Likes
971

When I run this transaction through SAPgui I only have to fill out the field S1_LGNUM, and I have specified this in my code.

Is my code below correct?

Public Sub add_bdcdata(BdcTable As Object, program As String, dynpro As String, dynbegin As String, fnam As String, fval As String)

    Dim vField As Variant
    Static j As Integer
    
    j = j + 1
    BdcTable.Rows.Add
    
    BdcTable.Value(j, "PROGRAM") = "RLS10020"     ' Program Name
    BdcTable.Value(j, "DYNPRO") = "1000"        ' Dynpro Number
    BdcTable.Value(j, "DYNBEGIN") = "X"    ' X if a screen
    BdcTable.Value(j, "FNAM") = "BDC_OKCODE"            ' Field Name
    BdcTable.Value(j, "FVAL") = "NEXT"            ' Field Value
End Sub

As i have seen this in examples where it looks like below.

Public Sub add_bdcdata(BdcTable As Object, program As String, dynpro As String, dynbegin As String, fnam As String, fval As String)

    Dim vField As Variant
    Static j As Integer
    
    j = j + 1
    BdcTable.Rows.Add
    
    BdcTable.Value(j, "PROGRAM") = program    ' Program Name
    BdcTable.Value(j, "DYNPRO") = dynpro        ' Dynpro Number
    BdcTable.Value(j, "DYNBEGIN") = dynbegin    ' X if a screen
    BdcTable.Value(j, "FNAM") = fnam            ' Field Name
    BdcTable.Value(j, "FVAL") = fval            ' Field Value
End Sub

Thanks

Read only

Former Member
0 Likes
971

.