on 03-13-2014 5:48 AM
Hi!!
I am using SAP .NET connector and creating a windows application.
Now I wanna read the column name when a table name is given....
Connection is done, but I don't know the code to read the column names alone...
Can anyone help me with the code??
HI Jeswin,
Assuming that destination is the RfcDestination that is used for your secnario, you can get the columns of a table NAME by looping over the line type metadata:
RfcStructureMetaData lineType=destination.Repository.GetTableMetaData("NAME").LineType.
String[] columns=new String[lineType.FieldCount];
for (int i; i<columns.Length; i++)
{
columns[i]=lineType[i].Name;
}
Best regards,
Markus
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I m using SAP.Middleware.Conncetor.. Current Code:
this displays only one column name.. It shows element count as 0... but it has 12 element in the table...
IRfcTable addressData = customerList.GetTable("AddressData");
for (int i = 0; i <= addressData.ElementCount; i++)
{
RfcElementMetadata metadata = addressData.GetElementMetadata(i);
listBox1.Items.Add(metadata.Name);
}
wow!! No error!!
But it's saying that no active tabs in the table....
SAP.Middleware.Connector.RfcInvalidStateException: metadata for TableOnly ADDRESSDATA not available: NOT_FOUND: No active nametab exists for ADDRESSDATA
at SAP.Middleware.Connector.RfcRepository.LookupRecordMetadataNew(String name, RecordType recordType)
at SAP.Middleware.Connector.RfcRepository.LookupRecordMetadata(String name, RecordType recordType)
at SAP.Middleware.Connector.RfcRepository.GetTableMetadata(String name)
at sapapplication.systems.GetCustomerDetails(RfcDestination destination) in d:\Client\sapapplication\sapapplication\systems.cs:line 502
at sapapplication.systems.btntest_Click(Object sender, EventArgs e) in d:\Client\sapapplication\sapapplication\systems.cs:line 395}
Wat does it mean ?
Yeah!! Now i got that point Thanks a lot Markus....
Another Doubt, I have called a function called:
IRfcFunction customerList = repo.CreateFunction("BAPI_CUSTOMER_GETLIST");
then I call table name AddressData:
IRfcTable addressData = customerList.GetTable("AddressData");
It works fine....
But when I use change the function as:
IRfcFunction customerList = repo.CreateFunction("RFC_READ_TABLE");
and I call the same table AddressData, it shows exception as
"Element AddressData of container metadata RFC_READ_TABLE unknown"..
I don't know SAP, my work is to extract data from SAP System using .NET(C#).
Can u plz explain clearly???
fine!!
So if i give the table name, which the RFC_READ_TABLE function module have, will it run properly? or i wanna change all the codes in order to support RFC_READ_TABLE function module?
Because from the beginning I was using BAPI_CUSTOMER_GETLIST function, but my client requirement is to use ERP function module RFC_READ_TABLE, he didn't give any table name also..
This is my code: What I have to change in this???
ECCDestinationConfig ECCDestination = new ECCDestinationConfig();
RfcDestinationManager.RegisterDestinationConfiguration(ECCDestination);
RfcDestination rfcDest = null;
rfcDest = RfcDestinationManager.GetDestination(a);
RfcRepository repo = rfcDest.Repository;
IRfcFunction customerList = repo.CreateFunction("BAPI_CUSTOMER_GETLIST");
IRfcTable addressData = customerList.GetTable("AddressTable"));
int j = addressData.Metadata.LineType.FieldCount;
for (int i = 0; i < j; i++)
{
RfcElementMetadata metadata = addressData.GetElementMetadata(i);
listallcolumn.Items.Add(metadata.Name);
}
Message was edited by: Jeswin Rebil
Hi Jeswin,
you should not use RFC_READ_TABLE in a productive scenario. From security point of view, this is really a bad approach: Thus, you bypass the authority checks in application code that protect the data in the respective table. Instead, you should implement an RFC function module that fits to your scenario in the ABAP system, if there isn't one that fits in the standard. There you can do authority checks. In principle you need to replace BAPI_CUSTOMER_GETLIST with the new function module and change also the name of the table parameters if there are some.
In principle it depends heavily on what you want to achieve.
Best regards,
Markus
Ok!! Thanks a lot Markus, I will look on that
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
83 | |
24 | |
12 | |
9 | |
7 | |
6 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.