Tuesday, December 28, 2010

Creating a SalesOrder through .net applications or BC classes

Sometimes it would be necessary for us to create the SalesOrder through the .net application or some third party application at that time we need to make use of BC classes to create SalesOrder. Here is a small snipeet for creating the salesOrder through AXBC classes.

static void salesOrder(Args _args)
{   

       AxSalesTable axSalesTable;
       AxSalesLine axSalesLine;
       AxInventDim_SalesLine axInventDim;
       NumberSequenceReference numberSequenceReference;
       NumberSeq numSeq;
       SalesTable salesTable;
       SalesId salesId;
       ;
       ttsbegin;
       numberSequenceReference = SalesParameters::numRefSalesId();
       numSeq = new NumberSeq();
       numSeq = NumberSeq::newGetNum(numberSequenceReference,true);
       salesId = numSeq.num();
       axSalestable = AxSalesTable::construct();
       axSalesTable.parmCustAccount('100123');
       axSalesTable.salesTable().initFromCustTable();
       axSalesTable.salesTable().initValue();
       axSalesTable.salesTable().initFromContactInfo();
      axSalesTable.parmSalesId(salesId);
       if(!axSalesTable.salesTable().validateWrite())
       {
            numSeq.abort();
            break;
       }
       else
       {
           numSeq.used();
           axSalesTable.save();
        }
        SalesTable = SalesTable::find(salesId);
        axSalesLine = AxSalesLine::construct();
        axSalesLine.parmSalesId(salesId);
        axSalesLine.salesLine().initValue();
        axSalesLine.salesLine().initFromSalesTable(SalesTable);
        axSalesLine.parmItemId('1121');
        axSalesLine.salesLine().initfrominventTable();
        axInventDim = AxInventDim_SalesLine::newAxSalesLine(axSalesLine);
        axInventDim.parmInventSizeId('42');
        axInventDim.parmInventLocationId("21");
        axInventDim.parmConfigId("HD");
        axInventDim.parmInventColorId('01');
        axInventDim.parmInventSiteId('2');
        axInventDim.setInventDimId();
        axSalesLine.axInventDim(axInventDim);
        axSalesLine.save();
        ttscommit;
    
}

No comments:

Post a Comment