on 02-19-2008 5:03 AM
pls help me
i wrote a RFC function module to create a BOM, it transfered a BAPI(BAPI_MATERIAL_BOM_GROUP_CREATE) to implement in my RFC FM.
while i running my RFC FM is normal at SAP environment, In VS2005, i using it made some mistakes after it be generated Web Service.
i found the data that transfer from VS2005 to SAP is correct, just as SAP environment i inputed data.
thanks in advance!
Andy Zhong
<h3>VS2005 code:</h3>
protected void Button2_Click(object sender, EventArgs e)
{
CreateBOM.ZWS_CREATE_BOMService proxy = new WebApplication4.CreateBOM.ZWS_CREATE_BOMService();
proxy.Credentials = new System.Net.NetworkCredential("XXXXXX", "XXXXXXX");
CreateBOM.ZSTRUCTURE_BOM_HEAD[] bomHeaders = new WebApplication4.CreateBOM.ZSTRUCTURE_BOM_HEAD[2];
CreateBOM.ZSTRUCTURE_BOM_ITEM[] bomItems = new WebApplication4.CreateBOM.ZSTRUCTURE_BOM_ITEM[2];
CreateBOM.BAPIRET2[] returnValue = new WebApplication4.CreateBOM.BAPIRET2[0];
CreateBOM.ZSTRUCTURE_BOM_HEAD header = new WebApplication4.CreateBOM.ZSTRUCTURE_BOM_HEAD();
string username = "zhongmingWStest";
header.MATNR = "XY-00071-0"; //material mast
header.WERKS = "CX21"; //工厂
header.STKTX = "可选的BOM文本1"; //可选的BOM文本
header.STLAL = "8"; //可选的BOM
header.STLAN = "1"; //BOM用途
header.ZTEXT = "test1.net,hao"; //BOM文本
header.BMENG = 2; //基本数量
bomHeaders.SetValue(header, 0);
CreateBOM.ZSTRUCTURE_BOM_ITEM item = new WebApplication4.CreateBOM.ZSTRUCTURE_BOM_ITEM();
item.POSNR = "0010"; //BOM项目号
item.IDNRK = "23XYT021100280R"; //BOM 组件
item.SANKA = "X"; //与成本相关
item.MENGE = 3; //组件数量
item.AUSCH = decimal.Parse("0.2"); //部件的损耗率%
item.ALPGR = "0"; //
item.ALPRF = "0"; //
item.ALPST = "0"; //
item.EWAHR = 0; //使用的可能性%
bomItems.SetValue(item,0);
CreateBOM.ZSTRUCTURE_BOM_ITEM item2 = new WebApplication4.CreateBOM.ZSTRUCTURE_BOM_ITEM();
item2.POSNR = "0020"; //BOM项目号
item2.IDNRK = "2570674907R"; //BOM 组件
item2.SANKA = "X"; //与成本相关
item2.MENGE = 3; //组件数量
item2.AUSCH = decimal.Parse("0.2"); //部件的损耗率%
item2.ALPGR = "0"; //
item2.ALPRF = "0"; //
item2.ALPST = "0"; //
item2.EWAHR = 0; //使用的可能性%
bomItems.SetValue(item2, 1);
try
{
proxy.ZFM_CREATE_BOMS_WITH_BAPI(ref bomHeaders, ref bomItems, ref returnValue, username);
GridView1.DataSource = returnValue;
GridView1.DataBind();
GridView2.DataSource = bomHeaders;
GridView2.DataBind();
GridView3.DataSource = bomItems;
GridView3.DataBind();
}
catch (Exception ex)
{
this.Label1.Text = ex.ToString();
}
}
<h3>SAP code:</h3>
FUNCTION zfm_create_boms_with_bapi.
*"----
""Local interface:
*" IMPORTING
*" VALUE(USERNAME) LIKE ZWS_HISTORY-CUSER OPTIONAL
*" TABLES
*" BOM_HEADER STRUCTURE ZSTRUCTURE_BOM_HEAD OPTIONAL
*" BOM_ITEMS STRUCTURE ZSTRUCTURE_BOM_ITEM OPTIONAL
*" RETURN STRUCTURE BAPIRET2 OPTIONAL
*"----
DATA:
it_bomgroup LIKE bapi1080_bgr_c OCCURS 0 WITH HEADER LINE,
it_variants LIKE bapi1080_bom_c OCCURS 0 WITH HEADER LINE,
it_items LIKE bapi1080_itm_c OCCURS 0 WITH HEADER LINE,
it_matrel LIKE bapi1080_mbm_c OCCURS 0 WITH HEADER LINE,
it_itemas LIKE bapi1080_rel_itm_bom_c OCCURS 0 WITH HEADER LINE.
DATA it_return LIKE bapiret2 OCCURS 0 WITH HEADER LINE.
DATA:
bom_group_identification LIKE bapi1080_bgr_c-bom_group_identification VALUE 'BAPI_SMP_COL1',
object_type_bgr LIKE bapi1080_bgr_c-object_type VALUE 'BGR',
object_type_bom LIKE bapi1080_bom_c-object_type VALUE 'BOM',
object_type_itm LIKE bapi1080_itm_c-object_type VALUE 'ITM',
object_id LIKE bapi1080_bgr_c-object_id VALUE 'SIMPLE1'.
DATA:
sbom_head LIKE zbom_pdm_upload,
sws_history LIKE zws_history,
wa_item like ztable_bom_item.
DATA:
succ(1),
id TYPE int4,
head_lines TYPE int4,
item_lines TYPE int4.
Fill the data
Material BoM Group Header Data
CLEAR it_bomgroup.
it_bomgroup-bom_group_identification = bom_group_identification.
it_bomgroup-object_type = object_type_bgr.
it_bomgroup-object_id = object_id.
it_bomgroup-bom_usage = bom_header-stlan. "BOM用途
it_bomgroup-created_in_plant = bom_header-werks. "生成 BOM 或可选/变式的工厂
it_bomgroup-ltxt_lang = sy-langu.
it_bomgroup-technical_type = ' '. "技术类型 M---多重
it_bomgroup-bom_text = bom_header-ztext. "BOM 文本
APPEND it_bomgroup.
Header Details of the different variants
CLEAR it_variants.
it_variants-bom_group_identification = bom_group_identification.
it_variants-object_type = object_type_bom.
it_variants-object_id = object_id.
it_variants-alternative_bom = bom_header-stlal. "可选的BOM
it_variants-bom_status = '01'. "BOM 状态
it_variants-base_qty = bom_header-bmeng. "基本数量
it_variants-valid_from_date = sy-datum.
it_variants-function = 'NEW'.
it_variants-alt_text = bom_header-stktx. "可选 BOM 文本
APPEND it_variants.
Details of the items of the variants
data time like sy-UZEIT.
time = sy-UZEIT.
LOOP AT bom_items.
IF bom_items-alpgr = '0'.
CLEAR bom_items-alpgr.
ENDIF.
IF bom_items-alpst = '0'.
CLEAR bom_items-alpst.
ENDIF.
IF bom_items-alprf = '0'.
CLEAR bom_items-alprf.
ENDIF.
CLEAR it_items.
it_items-bom_group_identification = bom_group_identification.
it_items-object_type = object_type_itm.
it_items-object_id = object_id.
it_items-item_no = bom_items-posnr. "BOM 项目号
it_items-item_cat = 'L'. "项目类别(物料单)
it_items-component = bom_items-idnrk. "BOM 组件
it_items-comp_qty = bom_items-menge. "组件数量
it_items-valid_from_date = sy-datum.
it_items-comp_scrap = bom_items-ausch. "部件废品百分数
it_items-cost_rel = bom_items-sanka. "成本核算相关项的标识符
it_items-alt_item_group = bom_items-alpgr. "替代项目:组
it_items-alt_item_prio = bom_items-alprf. "替代项目:评比定单
it_items-alt_item_strategy = bom_items-alpst. "替代项目:策略
it_items-usage_prob = bom_items-ewahr. "使用可能性按 % (可选项目)
APPEND it_items.
ENDLOOP.
Details of the materials of the different variants
CLEAR it_matrel.
it_matrel-bom_group_identification = bom_group_identification.
it_matrel-material = bom_header-matnr. "物料号
it_matrel-bom_usage = bom_header-stlan. "BOM用途
it_matrel-alternative_bom = bom_header-stlal. "可选的BOM
it_matrel-plant = bom_header-werks. "工厂
APPEND it_matrel.
Linking items to the corresponding variants
CLEAR it_itemas.
it_itemas-bom_group_identification = bom_group_identification.
it_itemas-sub_object_type = object_type_itm.
it_itemas-sub_object_id = object_id.
it_itemas-super_object_type = object_type_bom.
it_itemas-super_object_id = object_id.
it_itemas-valid_from_date = sy-datum.
it_itemas-function = 'NEW'.
APPEND it_itemas.
Create variants
CALL FUNCTION 'BAPI_MATERIAL_BOM_GROUP_CREATE'
EXPORTING
all_error = 'X'
TABLES
bomgroup = it_bomgroup
variants = it_variants
items = it_items
materialrelations = it_matrel
itemassignments = it_itemas
return = return.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
ENDFUNCTION.
<h3> Error of result </h3>
SYSTEM TYPE PARAMETER ID LOG_MSG_NO MESSAGE_V1 ROW MESSAGE NUMBER
ZSIM2 W BAPI1080 000000 ITM SIMPLE1 BAPI_SMP_COL1 0 检查组标识等于 ITM 的对象类型等于 SIMPLE1/标识等于 BAPI_SMP_COL1 时出错 029
ZSIM2 E ITM_CLASS_INTERFACE BOM 000000 1 物料清单无效 254
ZSIM2 E ITM_CLASS_INTERFACE BOM 000000 2 物料清单无效 254
ZSIM2 A BAPI 000000 BOMGroup 0 对象类型 BOMGroup 没有被创建的实例. 外部参考: 001
Hi,
i don't know if it is relevant for you, but you cab consume SAP eSOA Web Services using the "SAP Enterprise Services Explorer 1.0 for Microsoft .NET" addin to VS 2005.
link: https://www.sdn.sap.com/irj/sdn/dotnet
Best Regards,
Nadav
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
it's okey.
using 'header.STLAL = "08";' substitute for 'header.STLAL = "8";', because the STLAL element have 2 chars.
as below
header.WERKS = "CX21"; //工厂
header.STKTX = "可选的BOM文本1"; //可选的BOM文本
<h4>header.STLAL = "08";</h4> //可选的BOM
header.STLAN = "1"; //BOM用途
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
81 | |
25 | |
12 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.