Skip to Content
avatar image
Former Member

CopyTo CopyFrom functionality in SAPB1 ( c# )

I'm new in SAP B1. i have to understand how CopyTO and CopyFrom works in the form...... As a sample project i was trying to CopyTo from a button click in an addon form to salesorder. Any one please help with this in c# codes.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    Nov 15, 2017 at 01:04 PM

    Hi Dibin,

    It can be done something as below:

    SAPbouiCOM.EditText oEditCode = (SAPbouiCOM.EditText)m_SBO_Form.Items.Item(enControlName.Code).Specific;
    SAPbouiCOM.EditText oEditCustomerCode = (SAPbouiCOM.EditText)m_SBO_Form.Items.Item(enControlName.CustomerCode).Specific;
    
    
    if (oEditCustomerCode.Value.Trim() != "")
    {
        SBO_Application.ActivateMenuItem("2050"); // This is the Menu ID for Sales Order.
        SAPbouiCOM.Form oFormSalesOrder = (SAPbouiCOM.Form)SBO_Application.Forms.GetForm("139", 1); // 139 is the Sales Order's Form Type.
        SAPbouiCOM.Matrix oMatrix = (SAPbouiCOM.Matrix)m_SBO_Form.Items.Item(enControlName.Matrix).Specific;
        SAPbouiCOM.ComboBox oComboDocType = (SAPbouiCOM.ComboBox)oFormSalesOrder.Items.Item("3").Specific;
        SAPbouiCOM.EditText oEditCardCode = (SAPbouiCOM.EditText)oFormSalesOrder.Items.Item("4").Specific;
        SAPbouiCOM.ComboBox oComboCurrency = (SAPbouiCOM.ComboBox)oFormSalesOrder.Items.Item("63").Specific;
        SAPbouiCOM.Matrix oMatrixSalesOrder = (SAPbouiCOM.Matrix)oFormSalesOrder.Items.Item("38").Specific;
        oComboDocType.Select("I", BoSearchKey.psk_ByValue);
        oEditCardCode.Value = oEditCustomerCode.Value.Trim();
        oComboCurrency.Select("USD", BoSearchKey.psk_ByValue);
    
        try
        {
            if (oMatrix.VisualRowCount > 0)
            {
                int count = _dBDataSourceChild.Size;
    
    
                for (int i = 0; i <= count - 1; i++)
                {
                    double NQty = Convert.ToDouble(_dBDataSourceChild.GetValue("U_NQty", i));
                    double AddedQty = Convert.ToDouble(_dBDataSourceChild.GetValue("U_AQty", i));
                    double Rate = Convert.ToDouble(_dBDataSourceChild.GetValue("U_Rate", i));
                    string ProjectDetails = Convert.ToString(_dBDataSourceChild.GetValue("U_PrjDet", i)).Trim();
                    string LineID = Convert.ToString(_dBDataSourceChild.GetValue("U_LineID", i)).Trim();
                    string DocRef = Convert.ToString(_dBDataSourceChild.GetValue("U_DocRef", i)).Trim();
                    double AmountAccordingWorkDone = Convert.ToDouble(_dBDataSourceChild.GetValue("U_AAWD", i));
                    double RateToUpdate = AmountAccordingWorkDone / (NQty + AddedQty);
    
    
                    int K = oMatrixSalesOrder.RowCount;
    
    
                    SAPbouiCOM.EditText oEditItemCode = (SAPbouiCOM.EditText)oMatrixSalesOrder.Columns.Item("1").Cells.Item(K).Specific;
                    SAPbouiCOM.EditText oEditQty = (SAPbouiCOM.EditText)oMatrixSalesOrder.Columns.Item("11").Cells.Item(K).Specific;
                    SAPbouiCOM.EditText oEditPrice = (SAPbouiCOM.EditText)oMatrixSalesOrder.Columns.Item("14").Cells.Item(K).Specific;
                    SAPbouiCOM.EditText oEditProjectDetails = (SAPbouiCOM.EditText)oMatrixSalesOrder.Columns.Item("U_PRJDETAILS").Cells.Item(K).Specific;
                    SAPbouiCOM.EditText oEditBOQReference = (SAPbouiCOM.EditText)oMatrixSalesOrder.Columns.Item("U_BOQREF").Cells.Item(K).Specific;
                    SAPbouiCOM.EditText oEditBOQLineID = (SAPbouiCOM.EditText)oMatrixSalesOrder.Columns.Item("U_BASELINE").Cells.Item(K).Specific;
                    SAPbouiCOM.EditText oEditMakeInvoiceRef = (SAPbouiCOM.EditText)oMatrixSalesOrder.Columns.Item("U_MAKINVREF").Cells.Item(K).Specific;
    
    
                    oEditItemCode.Value = "SALESITEM";
                    oEditQty.Value = (NQty + AddedQty).ToString();
                    oEditPrice.Value = RateToUpdate.ToString();
                    oEditProjectDetails.Value = ProjectDetails;
                    oEditBOQReference.Value = DocRef;
                    oEditBOQLineID.Value = LineID;
                    oEditMakeInvoiceRef.Value = oEditCode.Value.Trim();
                }
                oMatrixSalesOrder.Columns.Item("1").Cells.Item(1).Click(BoCellClickType.ct_Double, 0);
            }
        }
        catch
        {
            throw;
        }
    
    
        finally
        {
            m_SBO_Form.Close();
        }
    }
    

    Hope it helps!
    All the best to you!

    Kind regards,

    ANKIT CHAUHAN

    SAP SME Support

    Add comment
    10|10000 characters needed characters exceeded