cancel
Showing results for 
Search instead for 
Did you mean: 

how to read the field values of a table using SAP.NET Connector?

Former Member
0 Kudos

Again I displayed a wrong details in my output screen.... I want the column names to be displayed in listbox but what the code below dows is, it prints the defaullt fields like [FIELD NAME,OFFSET,LENGTH,TYPE,FIELD TEXT]  from the RFC_READ_TABLE function module... I want the column names like BNAME,CITY...etc!! Table name is USR02

                RfcRepository repo = rfcDest.Repository;

                IRfcFunction customerList = repo.CreateFunction("RFC_READ_TABLE");

                customerList.SetValue("QUERY_TABLE", "USR02");

                customerList.SetValue("DELIMITER", ";");

               

                IRfcTable addressData = customerList.GetTable("FIELDS");

                int j = addressData.Metadata.LineType.FieldCount;

                for (int i = 0; i < j; i++)

                {

                    RfcElementMetadata metadata = addressData.GetElementMetadata(i);

                   listallcolumn.Items.Add(metadata.Name);

                }

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

I found out

This is the code:

int j = addressData.RowCount;

                for (int i = 0; i < j; i++)

                {

                    listallcolumn.Items.Add(addressData[i].GetString("FIELDNAME"));

                }

This added the column names...

Thanks a lot Case Ahr

Answers (1)

Answers (1)

Former Member
0 Kudos

Some one help me with this plz

former_member197445
Contributor
0 Kudos

Your sample code is what you would use to get the field names of the return table "FIELDS."  In this particular instance, the field names of the table are actual values in the table.  So you would do this to get the list.


            IRfcTable addressData = customerList.GetTable("FIELDS");

            int j = addressData.RowCount;

            for (int i = 0; i < j; i++)

            {

                IRfcStructure row = addressData.GetStructure(i);

                listallcolumn.Items.Add(row.GetString("FIELDNAME"));

            }

MarkusTolksdorf
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Jeswin,

I can only tell again: Don't use RFC_READ_TABLE.

Best regeards,

Markus

Former Member
0 Kudos

My boss ordered to use this, If I say to him about this he will say "do as I say"

Former Member
0 Kudos

Great Now it counts the column as 43, its correct

but I get this error while coming to this line

int j = addressData.RowCount;

                for (int i = 0; i < j; i++)

                {

                    IRfcStructure row = addressData.GetStructure(i);---> Error at this line

ERROR msg:     FIELD FIELDNAME of TABLE [STRUCTURE RFC_DB_FLD] (GETTER): cannot convert CHAR30 into IRfcStructure

so I changed the code to

IRfcStructure row = addressData.GetStructure(i.ToString());

It shows error as: Element 0 of container metadata  unknown [RfcInvalidParameter Exception]

Former Member
0 Kudos

I have planned to use this function for extraction..


SWNC_GET_AGGREGATES_FRAME


Now can u say how to extract the table values [means value inside the column name] using this function?