cancel
Showing results for 
Search instead for 
Did you mean: 

How to populate internal table( varaible of ABAP table type) in Excel VBA?

Former Member
0 Kudos

Hi,

I am trying to update a database table from excel using a VBA Macro.

I am able to connect to SAP and able to read data from SAP using a RFC. Similarly after updating certain values, i want to update a table in SAP.

Below are the steps I am doing  apart from basic settings.

  1. Getting the reference of the SAP TABLE type from RFC fucntion module

' Call RFC

Set MyFunc = R3.Add("UPDATE_TVARVC_VIA_RFC")

' Get reference and Values TVARVC

Set oParam4 = MyFunc.Tables("TVARVC")   

   2. Loop over the active cells and populate oParam4

          " add values as below

    oParam4.Rows.Add

    oParam4.Value(1, "NAME") = ..................

    oParam4.Value(1, "TYPE") = ..................

    oParam4.Value(1, "NUMB") = ..................

  Do it for all columns in the table line.

My query is how to identify active cells and make the above code dynamic in step 2.

Thanks in Advance,

Best,

Aneel

Accepted Solutions (1)

Accepted Solutions (1)

script_man
Active Contributor
0 Kudos

Hi Aneel,

You can try the following:

e.g.

. . .

for j = 1 to ActiveCell.SpecialCells(11).Column

  oParam4.Rows.Add

  if j=1 then oParam4.Value(j, "NAME") = ActiveSheet.Cells(1,j).Value

  if j=2 then oParam4.Value(j, "TYPE")  = ActiveSheet.Cells(1,j).Value

  if j=3 then oParam4.Value(j, "NUMB") = ActiveSheet.Cells(1,j).Value

  . . .

next j

  . . .

Regards,

ScriptMan

Answers (1)

Answers (1)

holger_khn
Contributor
0 Kudos

Hello.

You have an customized functionmodule UPDATE_TVARVC_VIA_RFC created in your System?

Former Member
0 Kudos

Hi Holger,

Its a 'Z' function module... sorry typo error.

Best,

Aneel