c # call the input and output parameters of the case by RFC SAP interface program

The first step requires the introduction of appropriate dll, if the version is inconsistent, there will be references unsuccessful. I use net4.0

The second step using SAP.Middleware.Connector;

The third step: encoding the following

 #region            
        // ERP interaction design began Kele 

        IDestinationConfiguration ID = new new RfcConfig (); 
        RfcDestinationManager.RegisterDestinationConfiguration (ID);     // tell RFC destination registered manager configuration 
        RfcDestination prd = RfcDestinationManager.GetDestination ( " PRD_000 " ); // obtain the desired Object
         // RfcDestinationManager.UnregisterDestinationConfiguration (ID);         // logout RFC destination manager configured NET2.0 need to uncomment 
        RfcRepository repo = prd.Repository; 
        IRfcFunction companyBapi = repo.CreateFunction ( " ZMM_ABC_GET_ZTERM ");    // call the function name of 

        the try 
        { 
            companyBapi.SetValue ( " I_LIFNR " , "" + TextBox1.Text.Trim () + "" ); // SAP input parameters 
            companyBapi.Invoke (prd);    // execute the function 

            Label1. the Text = companyBapi.GetString ( " TEXT1 " ); // the SAP output parameter 
        } 
        the catch (RfcAbapException EX)   // this exception specifically configured to obtain a user-defined exception information! ! ! ! 
        { 
            JavaScript.Alert (companyBapi.Metadata.GetAbapException (ex.Key) .Documentation); 
        } 
        the catch(RfcAbapRuntimeException EX)    // This exception Exception dedicated to acquiring running process RFC execution! ! ! ! 
        { 
            JavaScript.Alert (companyBapi.Metadata.GetAbapException (ex.Key) .Documentation); 
        } 
        the catch (RfcBaseException EX)   // This is the total Exception Exception class, retrieves all exception if there is a plurality of the Catch, can not put The first one! ! ! ! 
        { 
            JavaScript.Alert ( " requisition number does not exist alone or SAP database connection error message as follows:! " + Ex.Message); 

        } 

        // the ERP ends interactive design 
        #endregion

 

Guess you like

Origin www.cnblogs.com/shuilong/p/11238951.html