This sample shows how to create a Functional Location in SAP using the BAPI BAPI_FUNCLOC_CREATE.
About
The Functional Location (External Number) must match the structure defined in the exporting parameter STRIND of BAPI_FUNCLOC_CREATE. You can export the default value for the superior functional location under data_specific - SUPFLOC.
Tip
To change a Functional Location replace the function module "BAPI_FUNCLOC_CREATE" with the function module "BAPI_FUNCLOC_CHANGE".
Call BAPI_FUNCLOC_CREATE
The following sample code calls the BAPI BAPI_FUNCLOC_CREATE to create a Functional Location in SAP:
usingSystem;usingERPConnect;// Set your ERPConnect licenseLIC.SetLic("xxxx");usingvarconnection=newR3Connection(host:"server.acme.org",systemNumber:00,userName:"user",password:"passwd",language:"EN",client:"001"){Protocol=ClientProtocol.NWRFC,};connection.Open();RFCFunctionfunc=connection.CreateFunction("BAPI_FUNCLOC_CREATE");RFCStructuredata_specific=func.Exports["DATA_SPECIFIC"].ToStructure();data_specific["STRIND"]="A";//StrIndicatordata_specific["CATEGORY"]="M";//Categorydata_specific["SUPFLOC"]="";//Superior Function LocationRFCStructuredata_general=func.Exports["DATA_GENERAL"].ToStructure();data_general["DESCRIPT"]="My New Location2";//Descriptiondata_general["MAINTPLANT"]="1000";//Mainplant func.Exports["LABELING_SYSTEM"].ParamValue="A";//Labeling Systemfunc.Exports["EXTERNAL_NUMBER"].ParamValue="1111-111-AA-15";//Functional Locationfunc.Execute();RFCFunctionfuncCommit=connection.CreateFunction("BAPI_TRANSACTION_COMMIT");funcCommit.Exports["WAIT"].ParamValue="X";funcCommit.Execute();// ReturnMessage from BAPIRFCStructurefuncRet=func.Imports["RETURN"].ToStructure();//strmessage = funcRet["MESSAGE"].ToString();Console.WriteLine(funcRet["MESSAGE"].ToString());Console.WriteLine("Please press a Key to continue")Console.ReadLine();