Jan 4, 2012

Pass multiple table to SAP

use link
1 ) http://stackoverflow.com/questions/8157561/how-to-pass-multiple-tables-to-sap-using-irfc-funtions-from-net
or
2) http://stackoverflow.com/questions/8140087/how-to-add-multiple-rows-to-irfctable


============================================================================
1)

IRfcFunction orderDetails = _rfcDest.Repository.CreateFunction(strBapi);

        RfcStructureMetadata metaData = _rfcDest.Repository.GetStructureMetadata("ZBAPI_A_STRU_ORDER_CREATE_PART");

        IRfcStructure structPartners = metaData.CreateStructure();
        structPartners.SetValue("PARTN_ROLE", "SP");
        structPartners.SetValue("PARTN_NUMB", "110024");

        IRfcTable tblPartner = orderDetails.GetTable("PARTNERS");
        tblPartner.Append(structPartners);

        structPartners = metaData.CreateStructure();
        structPartners.SetValue("PARTN_ROLE", "SH");
        structPartners.SetValue("PARTN_NUMB", "110005");


        tblPartner.Append(structPartners);
        orderDetails.SetValue("PARTNERS", tblPartner);



        metaData = _rfcDest.Repository.GetStructureMetadata("ZBAPI_A_STRU_ORDER_CREATE_COND");
        IRfcStructure structConditions = metaData.CreateStructure();
        structConditions.SetValue("ITM_NUMBER", "10");
        structConditions.SetValue("COND_TYPE", "PR00");
        structConditions.SetValue("COND_VALUE", "30");
        structConditions.SetValue("CURRENCY", "USD");

        IRfcTable tblConditions = orderDetails.GetTable("CONDITIONS");
        tblConditions.Append(structConditions);
        orderDetails.SetValue("CONDITIONS", tblConditions);

        metaData = _rfcDest.Repository.GetStructureMetadata("ZBAPI_A_STRU_ORDER_CREATE_ITEM");
        IRfcStructure structItems = metaData.CreateStructure();
        structItems.SetValue("MATERIAL", "F500");
        structItems.SetValue("TARGET_QTY", "3");

        IRfcTable tblItems = orderDetails.GetTable("ITEMS");
        tblItems.Append(structItems);
        orderDetails.SetValue("ITEMS", tblItems);

        RfcSessionManager.BeginContext(_rfcDest);
        orderDetails.Invoke(_rfcDest);

        IRfcStructure bapiTable = orderDetails.GetStructure("RETURN");

        RfcSessionManager.EndContext(_rfcDest);


====================================================================================
2)

IRfcFunction bapiTEST = _rfcDest.Repository.CreateFunction(strBapi);
IRfcStructure structImport = _rfcDest.Repository.GetStructureMetadata("ZBAPI_A_STRU_ORDER_CLICK").CreateStructure();

structImport.SetValue("NUM1", "000001");
structImport.SetValue("NUM2", "000002");
structImport.SetValue("NUM3", "000003");
IRfcTable tblImport = bapiTEST.GetTable("IMPORT");
tblImport.Insert(structImport);

structImport.SetValue("NUM1", "000006");
structImport.SetValue("NUM2", "000007");
structImport.SetValue("NUM3", "000008");

tblImport.Insert(structImport);
bapiTEST.SetValue("IMPORT", tblImport);
RfcSessionManager.BeginContext(_rfcDest);
bapiTEST.Invoke(_rfcDest);
 
 
 
=============================================================================== 



2 comments:

  1. HI PLEASE HELP ME

    how-to-add-multiple-rows-to-irfctable
    DYNAMIC PASS VALUE FROM DATATABLE

    ReplyDelete
  2. Yes ... You can code like below...


    protected void Button1_Click(object sender, EventArgs e)
    {
    IRfcFunction FunSalesOrder = SapRfcRepository.CreateFunction("Sales_Order_RFC");
    FunSalesOrder.SetValue("ORDER_ITEMS_IN", GetItemData(FunSalesOrder));// add items
    FunSalesOrder.Invoke(SapRfcDestination);
    strSO = FunSalesOrder.GetValue("SalesDocument").ToString(); //return sucessfull message
    }

    private IRfcTable GetItemData(IRfcFunction FunSalesOrder)
    {
    DataTable dtItemDetails = GetItemDetails(); // fetch Your data in Datatable
    IRfcTable table = FunSalesOrder.GetTable("RfcTable"); // get Table object of Rfc

    for (int i = 0; i < dtItemDetails.Rows.Count; i++)
    {
    table.Append();
    table.SetValue("MATERIAL", dtItemDetails.Rows[i]["Catref"].ToString());
    table.SetValue("PLANT", dtMasterData.Rows[0]["vPlant"].ToString());
    }
    return table;

    }

    ReplyDelete

What is the use of n-tier architecture and 3-tier architecture?

how to implement 3-tier architecture in asp.net using c#. 3-Tier architecture is also called layered architecture. Some people called it ...