问题
I'm using SAP .NET Connector 3.0 to read data from SAP(R/3). I need to get some header texts from sales orders:
A lot of information I found regarding READ_TEXT function which can be used for this purpose. Here you can find some sample how to do it by using ERPConnect. I'm trying to do the same and I have following function which returns IRfcTable:
static IRfcTable ReadFunction(string destName, int rowCount)
{
// get the destination
RfcDestination dest = RfcDestinationManager.GetDestination(destName);
IRfcFunction func = dest.Repository.CreateFunction("RFC_READ_TEXT");
IRfcTable table = func.GetTable("TEXT_LINES");
table.Insert();
table.Insert();
table.Insert();
table.Insert();
table[0].SetValue("TDOBJECT", "VBBK");
table[1].SetValue("TDNAME", "3147856016");
table[2].SetValue("TDID", "Z019");
table[3].SetValue("TDSPRAS", "PL");
func.Invoke(dest);
return table;
}
VBBK
- means header objects, 3147856016
- sales order number, Z019
- ID for EDI Supplier text field, PL
- language.
As a result I'm retrieving some data, but field TDLINE is blank:
According to example this field should contain text.
Probably some parameters are incorrect. Here is a good post where I found how to obtain TDID parameter for each text field.
What I'm doing wrong?
UPDATE: According to vwegert
answer below, code has been changed like:
IRfcTable table = func.GetTable("TEXT_LINES");
table.Insert();
table[0].SetValue("TDOBJECT", "VBBK");
table[0].SetValue("TDNAME", "3147856016");
table[0].SetValue("TDID", "Z019");
table[0].SetValue("TDSPRAS", "PL");
func.Invoke(dest);
return table;
Now parameters are correct. But TDLINE
is still empty. Result:
回答1:
The function module needs the following parameters:
TDOBJECT TDNAME TDID TDSPRAS
----------- ------------ ---------- -------
1 VBRK 3147856016 Z019 PL
You are calling it with the following parameters:
TDOBJECT TDNAME TDID TDSPRAS
----------- ------------ ---------- -------
1 VBRK
2 3147856016
3 Z019
4 L
This won't work - the function module will take the line containing a TDNAME
, add TDBOJECT = 'DRAD'
, TDID = 'LTXT'
and TDSPRAS = SY-LANGU
and attempt to read that text. This will probably fail, resulting in the empty line you see. Also note that you need to supply the internal language designator, which is a single character.
Furthermore you are completely ignoring the MESSAGES
parameter that will probably contain some messages that would have told you a lot about what went wrong.
来源:https://stackoverflow.com/questions/20906107/retrieve-texts-from-a-sales-order-by-using-rfc-read-text