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

NO BATCH INPUT DATA FOR SCREEN!!

Former Member
0 Likes
2,231

Hi,

I am trying to call a transaction from SAP by using VBA in excel.

Please see the code I am using below.


Dim j As Integer

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(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

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 = "st34lhv2"
Functions.Connection.Language = "EN"

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

Dim iBOB As Integer

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

' Set the tables parameter and add the data for the call transaction
add_bdcdata BdcTable, "RSSYSTDB", "1000", "X", "", ""
add_bdcdata BdcTable, "", "", "", "BDC_CURSOR", "SP$00001-LOW"
add_bdcdata BdcTable, "", "", "", "BDC_OKCODE", "/00"
add_bdcdata BdcTable, "", "", "", "SP$00001-LOW", ActiveCell.Offset(iBOB, 1).Value
add_bdcdata BdcTable, "", "", "", "SP$00002-LOW", ActiveCell.Offset(iBOB, 2).Value
add_bdcdata BdcTable, "", "", "", "SP$00003-LOW", "30000966"
add_bdcdata BdcTable, "", "", "", "SP$00003-LOW", ActiveCell.Offset(iBOB, 3).Value
add_bdcdata BdcTable, "", "", "", "SP$00004-LOW", ActiveCell.Offset(iBOB, 4).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

Can anyone tell me where I am going wrong or if there is a better way of calling a transaction through VBA?

Thanks,

Mike

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,236

Are you sure RSSYSTDB is the program you are trying to get?

I'm looking at my system and here is a form-pool, no selection screen.

If you want to execute a report is better to have a submit in your RFC rather than a call transaction

5 REPLIES 5
Read only

Former Member
0 Likes
1,237

Are you sure RSSYSTDB is the program you are trying to get?

I'm looking at my system and here is a form-pool, no selection screen.

If you want to execute a report is better to have a submit in your RFC rather than a call transaction

Read only

0 Likes
1,236

Hi,

Yes this is a report. It is a query report which our SAP analyst has developed for me.

Which is the best way to call this report into excel using VBA? I have managed to use VBA code to call tables using RFC_READ_TABLE but I couldn't find a way of joining two tables together extracting them into VBA, so we developed a query report and this is why I am trying to call this report.

I got RSSYSTDB from the program name after pressing F1 in the report screen and going to technical information.

Can you help further?

Thanks,

Mike

Read only

0 Likes
1,236

Ok, you are doing things wrong.

To know which fields you need to fill you use SHDB first to get an idea.

The program name you are using is the wrong one.

But again, that is with a call transaction.

If you are using a report I think is way better to have a submit rather than a call transaction.

Read only

0 Likes
1,236

If I wanted to run the whole transaction, would I still need to specify fields?

I am trying to run a transaction now instead of a report, so I can still use RFC_CALL.

I am now trying to run transaction LX02 and I think the program name is RLS10020.

When specifying fields, do I need to specify the field name or Screen field?

I am waiting on IT to give me access to SHDB.

Thanks,

Mike

Read only

0 Likes
1,236

Hi,

I have accessed SHDB for my custom report and I have entered the information provided into my code as you can see below.

' Set the tables parameter and add the data for the call transaction
add_bdcdata BdcTable, "AQW8Z_MERCH=====ZARTICLECREATE", "1000", "X", "", ""
add_bdcdata BdcTable, "", "", "", "BDC_CURSOR", "SP$00001-LOW"
add_bdcdata BdcTable, "", "", "", "BDC_OKCODE", "=ONLI"
add_bdcdata BdcTable, "", "", "", "SP$00001-LOW", "900"
add_bdcdata BdcTable, "", "", "", "SP$00003-LOW", "30000966"
'add_bdcdata BdcTable, "", "", "", "BDC_OKCODE", "/EE"
add_bdcdata BdcTable, "", "", "", "BDC_CURSOR", "SP$00001-LOW"

I am still getting a NO BATCH INPUT DATA FOR SCREEN error message but this time it is saying NO BATCH INPUT DATA FOR SCREEN SAPMSSYO 0120.

Does anyone know what this error means and where I could be going wrong?

Thanks,

Mike