Показать сообщение отдельно
Старый 16.04.2018, 15:49   #3  
Stitch_MS is offline
Stitch_MS
Участник
Аватар для Stitch_MS
Соотечественники
 
268 / 259 (9) ++++++
Регистрация: 27.02.2006
Адрес: Дания
Еще для вдохновения:

1. Packing slip
X++:
    SalesFormLetter     salesFormLetter;
    SalesParmUpdate     salesParmUpdate;
    SetEnumerator       set;
    CustPackingSlipJour     custPackingSlipJour;
    SysQueryRun         chooseLines;

    salesFormLetter = SalesFormLetter::construct(DocumentStatus::PackingSlip);

    salesFormLetter.getLast();
    salesFormLetter.resetParmListCommonCS();
    salesFormLetter.proforma(false);

    salesFormLetter.createParmUpdateFromParmUpdateRecord(
	SalesFormletterParmData::initSalesParmUpdateFormletter(
	DocumentStatus::PackingSlip, 
	salesFormLetter.pack()));

    salesParmUpdate = salesFormLetter.salesParmUpdate();
    salesParmUpdate.SpecQty     = SalesUpdate::DeliverNow;
    salesParmUpdate.Proforma    = NoYes::No;

    if(salesParmUpdate.SumBy == AccountOrder::Order)
    {
        salesParmUpdate.SumSalesId      = _sumSalesId;
    }

    salesParmUpdate.update();
    salesFormLetter.salesParmUpdate(salesParmUpdate);

    chooseLines  = this.calcQuery();  // Custom Query

    salesFormLetter.chooseLinesQuery(chooseLines);
    salesFormLetter.reArrangeNow(true);
    salesFormLetter.validateAll(false);
    salesFormLetter.chooseLines();
    salesFormLetter.run();

    set = Set::create(SysOperationHelper::base64Decode(salesFormLetter.getOutputContract().parmAllJournals())).getEnumerator();

    while (set.moveNext())
    {
        custPackingSlipJour = set.current();
        break;
    }

    return custPackingSlipJour.PackingSlipId;
Фильтр по строкам заказа:
X++:
public SysQueryRun calcQuery()
{
        Query                           q = new Query(queryStr(SalesUpdate));
        QueryBuildDataSource            qbds;

	qbds = q.dataSourceTable(tableNum(SalesLine));
        
	... join your table ...

        return new SysQueryRun(q);
}
2. Invoice
X++:
    SalesFormLetter         salesFormLetter;
    SalesParmUpdate         salesParmUpdate;
    CustPackingSlipJour     custPackingSlipJour;
    TmpFrmVirtual           tmpFrmVirtual;
    List            selectedList = new List(Types::Record);
    SalesParmTable          salesParmTable;

    select firstonly RecId, TableId from custPackingSlipJour
        where custPackingSlipJour.PackingSlipId == _consolidatedPackingSlipId;

    tmpFrmVirtual.clear();
    tmpFrmVirtual.TableNum      = custPackingSlipJour.TableId;
    tmpFrmVirtual.RecordNo      = custPackingSlipJour.RecId;
    tmpFrmVirtual.NoYes     = NoYes::Yes;
    tmpFrmVirtual.Id        = _sumSalesId;
    tmpFrmVirtual.insert();

    selectedList.addEnd(tmpFrmVirtual);

    salesFormLetter = SalesFormLetter::construct(DocumentStatus::Invoice);

    salesFormLetter.selectFromJournal(selectedList.pack());

    salesFormLetter.specQty(SalesUpdate::PackingSlip);

    salesFormLetter.run();
За это сообщение автора поблагодарили: trud (5).