朋友们。我目前正在使用 SAP 默认 BAPI。我使用过任何由 abappers 或我创建的 Z*。
我用 C# vb 编写代码。2010. mi 关于那个 bapi 的问题是我目前看到 2 个表,一个带有参数,另一个带有结果。
到目前为止,我已经设法用参数填充了一个,但我不知道如何检索结果表的信息。
我已经通过互联网搜索了没有答案。我不知道我这样做是对还是错。:P
我发布我的代码,以便任何人都可以帮助我。
谢谢。
String include = "I", rango = "EQ";// EQ - BT -- Equal o Between
DataTable dt = new DataTable("ws_clientes_contactos");
dt.Columns.Add("PARTNEREMPLOYEEID", typeof(String));
dt.Columns.Add("CUSTOMER", typeof(String));
dt.Columns.Add("LASTNAME", typeof(String));
dt.Columns.Add("FIRSTNAME", typeof(String));
dt.Columns.Add("SEX", typeof(String));
dt.Columns.Add("TITLE_P", typeof(String));
dt.Columns.Add("LANGU_P", typeof(String));
dt.Columns.Add("LANGUP_ISO", typeof(String));
dt.Columns.Add("COUNTRY", typeof(String));
dt.Columns.Add("COUNTRYISO", typeof(String));
dt.Columns.Add("CITY", typeof(String));
dt.Columns.Add("POSTL_COD1", typeof(String));
dt.Columns.Add("REGION", typeof(String));
dt.Columns.Add("STREET", typeof(String));
dt.Columns.Add("TEL1_NUMBR", typeof(String));
dt.Columns.Add("FAX_NUMBER", typeof(String));
dt.Columns.Add("FUNCTION", typeof(String));
dt.Columns.Add("SORT1_P", typeof(String));
dt.Columns.Add("ADDRESS", typeof(String));
dt.Columns.Add("PERS_NO", typeof(String));
dt.Columns.Add("E_MAIL", typeof(String));
try
{
RfcDestination SapRfcDestination = RfcDestinationManager.GetDestination("DEV");
RfcRepository SapRfcRepository = SapRfcDestination.Repository;
IRfcFunction bapigetcontactlist = SapRfcRepository.CreateFunction("BAPI_CUSTOMER_GETCONTACTLIST");
IRfcTable CUSTOMERRANGE, CONTACTADDRESSDATA;
CUSTOMERRANGE = bapigetcontactlist.GetTable("CUSTOMERRANGE");
//LLENA TABLA FILTROS DE LA BAPI
if (Opc == "B")
{
rango = "BT";
}
CUSTOMERRANGE.Append();
CUSTOMERRANGE.SetValue("SIGN", include);
CUSTOMERRANGE.SetValue("OPTION", rango);
CUSTOMERRANGE.SetValue("LOW", ClienteMin);
if (Opc == "B") // BETWEEEN
{
CUSTOMERRANGE.SetValue("HIGH", ClienteMax);
}
else // EQUAL = LWO
{
CUSTOMERRANGE.SetValue("HIGH", " ");
}
bapigetcontactlist.SetValue("MAXROWS", 1000);
//DataTable dtt = CreateDataTable(CUSTOMERRANGE);
bapigetcontactlist.SetValue("CUSTOMERRANGE", CUSTOMERRANGE);
CONTACTADDRESSDATA = bapigetcontactlist.GetTable("CONTACTADDRESSDATA");
bapigetcontactlist.Invoke(SapRfcDestination);
IRfcTable Result = bapigetcontactlist["CONTACTADDRESSDATA"].GetTable();
for (Int16 i = 0; i < (Result.RowCount); i++)
{
DataRow dr = dt.NewRow();
dr["PARTNEREMPLOYEEID"] = CONTACTADDRESSDATA[i].GetString(0);
dr["CUSTOMER"] = CONTACTADDRESSDATA[i].GetString(1);
dr["LASTNAME"] = CONTACTADDRESSDATA[i].GetString(2);
dr["FIRSTNAME"] = CONTACTADDRESSDATA[i].GetString(3);
dr["SEX"] = CONTACTADDRESSDATA[i].GetString(4);
dr["TITLE_P"] = CONTACTADDRESSDATA[i].GetString(5);
dr["LANGU_P"] = CONTACTADDRESSDATA[i].GetString(6);
dr["LANGUP_ISO"] = CONTACTADDRESSDATA[i].GetString(7);
dr["COUNTRY"] = CONTACTADDRESSDATA[i].GetString(08);
dr["COUNTRYISO"] = CONTACTADDRESSDATA[i].GetString(9);
dr["CITY"] = CONTACTADDRESSDATA[i].GetString(10);
dr["POSTL_COD1"] = CONTACTADDRESSDATA[i].GetString(11);
dr["REGION"] = CONTACTADDRESSDATA[i].GetString(12);
dr["STREET"] = CONTACTADDRESSDATA[i].GetString(13);
dr["TEL1_NUMBR"] = CONTACTADDRESSDATA[i].GetString(14);
dr["FAX_NUMBER"] = CONTACTADDRESSDATA[i].GetString(15);
dr["FUNCTION"] = CONTACTADDRESSDATA[i].GetString(16);
dr["SORT1_P"] = CONTACTADDRESSDATA[i].GetString(17);
dr["ADDRESS"] = CONTACTADDRESSDATA[i].GetString(18);
dr["PERS_NO"] = CONTACTADDRESSDATA[i].GetString(19);
dr["E_MAIL"] = CONTACTADDRESSDATA[i].GetString(20);
dt.Rows.Add(dr);
}