Pages

Banner 468 x 60px

 

Monday, March 27, 2017

Container x++

0 comments
public container getVoucherInfo(Voucher     _VoucherId)
{
    CustTrans           _CustTrans;
    LedgerJournalTrans  _LedgerJournalTrans, _LedgerJournalTrans2;
    TaxTrans            _taxtrans;
    TaxTable            _taxtable;
    TaxData             _TaxData;
    ProjInvoiceJour     _ProjInvoiceJour;
    CustTable           _CustTable;

    CustAccount         _CustAccount;
    CustInvoiceJour     _CustInvoiceJour;
    TransDate           _VoucherDate;
    CurrencyCode        _CurrencyCode;
    JournalId           _JournalNum;
    Amount              _VoucherTotalAmt;
    Amount              _TempAmt;
    ExchRate            _PPNExchRate, _PPhExchRate;
    GG_FPJVoucherType   _FPJVoucherType;
    SalesId             _SalesId;
    TaxCode             taxppn;
    TaxValue            taxvaluePPN, taxvaluePPh;
    TaxAccountGroup     _taxgrouppph;
    NoYes               _NoYes;
    ;

    //cust Id
    taxppn = Salesparameters::find().Soltius_TaxCodePPN10;
    _taxgrouppph = salesparameters::find().Soltius_TaxGroupPPh22;
    _CustTrans = CustTrans::findVoucher(_VoucherId);
    /*Select firstonly _CustTrans where
        _CustTrans.Voucher        == _VoucherId &&
        _CustTrans.TransType      == LedgerTransType::Payment;
    */
    if (_CustTrans)
    {
        _CustAccount        = _CustTrans.AccountNum;
        _VoucherDate        = _CustTrans.TransDate;
        _CurrencyCode       = _CustTrans.CurrencyCode;

        if (_CustTrans.TransType    == LedgerTransType::Project || _CustTrans.TransType    == LedgerTransType::Sales || _CustTrans.TransType == LedgerTransType::Cust)
        {
            if (_CustTrans.AmountCur    >= 0)
                _FPJVoucherType     = GG_FPJVoucherType::Invoice;
            else
                _FPJVoucherType     = GG_FPJVoucherType::ReturnInv;
        }
        else
        {
            if (_CustTrans.AmountCur    <= 0)
                _FPJVoucherType     = GG_FPJVoucherType::CashReceipt;
            else
                _FPJVoucherType     = GG_FPJVoucherType::ReturnCR;
        }

        //_SalesId    = CustInvoiceJour::findFromCustTrans(_CustTrans.Invoice, _CustTrans.TransDate, _CustTrans.AccountNum).SalesId;
        _SalesId    = _CustTrans.Soltius_SalesId;
        IF (!_SalesID)
        {
            IF (_CustTrans.TransType    == LedgerTransType::Project)
            {
                _SalesId = SalesTable::findProjId(ProjTable::findProjInvoiceProjId(ProjInvoiceJour::find(_CustTrans.Voucher, _CustTrans.TransDate).ProjInvoiceProjId).ProjId).SalesId;
                //SELECT _ProjInvoiceJour WHERE _ProjInvoiceJour.ProjInvoiceId == _VoucherId;
            }
        }
    }

    //other from ledger transaction
    select firstonly Voucher, JournalNum from _LedgerJournalTrans
        group by Voucher, JournalNum where
        _LedgerJournalTrans.Voucher    == _VoucherId;

    if (_LedgerJournalTrans.Voucher != "")
    {
        _JournalNum         = _LedgerJournalTrans.JournalNum;

        while select _LedgerJournalTrans2 where
            _LedgerJournalTrans2.Voucher            == _LedgerJournalTrans.Voucher &&
          ((_LedgerJournalTrans2.AccountType        == LedgerJournalACType::Cust && _LedgerJournalTrans2.AccountNum != "")||
           (_LedgerJournalTrans2.OffsetAccountType  == LedgerJournalACType::Cust && _LedgerJournalTrans2.OffsetAccount != ""))
        {
            _TempAmt            = _LedgerJournalTrans2.amount();

            if (_PPNExchRate == 0)
            {
                _PPNExchRate        = _LedgerJournalTrans2.ExchRate;
                _PPhExchRate        = _LedgerJournalTrans2.ExchRate;
            }

            _VoucherTotalAmt    += _TempAmt;
        }
    }
    else
    {
        switch (_CustTrans.TransType)
        {
            Case LedgerTransType::Project:
                SELECT _ProjInvoiceJour WHERE _ProjInvoiceJour.ProjInvoiceId == _VoucherId;
                if (_ProjInvoiceJour)
                {
                    _PPNExchRate        = _ProjInvoiceJour.ExchRate;
                    _PPhExchRate        = _ProjInvoiceJour.ExchRate;

                    _VoucherTotalAmt    = _ProjInvoiceJour.InvoiceAmount;
                }
                Break;
            Default:
                select firstonly _CustInvoiceJour where
                //_CustInvoiceJour.InvoiceId  == _VoucherId;
                _CustInvoiceJour.LedgerVoucher  == _VoucherId;
                _VoucherDate        = _CustInvoiceJour.InvoiceDate;
                _CurrencyCode       = _CustInvoiceJour.CurrencyCode;
                _PPNExchRate        = _CustInvoiceJour.ExchRate;
                _PPhExchRate        = _CustInvoiceJour.ExchRate;

                _VoucherTotalAmt    = _CustInvoiceJour.InvoiceAmount;
                Break;
        }
        /*select firstonly _CustInvoiceJour where
            _CustInvoiceJour.InvoiceId  == _VoucherId;

        if (_CustInvoiceJour)
        {
            _VoucherDate        = _CustInvoiceJour.InvoiceDate;
            _CurrencyCode       = _CustInvoiceJour.CurrencyCode;
            _PPNExchRate        = _CustInvoiceJour.ExchRate;
            _PPhExchRate        = _CustInvoiceJour.ExchRate;

            _VoucherTotalAmt    = _CustInvoiceJour.InvoiceAmount;
        }
        ELSE
        {
            SELECT _ProjInvoiceJour WHERE _ProjInvoiceJour.ProjInvoiceId == _VoucherId;
            if (_ProjInvoiceJour)
            {
                _PPNExchRate        = _ProjInvoiceJour.ExchRate;
                _PPhExchRate        = _ProjInvoiceJour.ExchRate;

                _VoucherTotalAmt    = _ProjInvoiceJour.InvoiceAmount;
            }

        }*/
    }

    IF ((CustTable::find(_CustAccount).Soltius_CustTaxId == "070")||
        (CustTable::find(_CustAccount).Soltius_CustTaxId == "030"))
        _NoYes = NoYes::Yes;
    ELSE
        _NoYes = NoYes::No;

    select _taxtrans
    where _taxtrans.Voucher == _VoucherId
    && _taxtrans.TransDate  == _VoucherDate
    join _taxtable
        where _taxtable.TaxCode == _taxtrans.TaxCode
        && _taxtable.TaxType == TaxType::PPN
    Join _TaxData
        Where _TaxData.TaxCode == _taxtable.TaxCode;

    taxvaluePPN = _TaxData.TaxValue;

    select _taxtrans
    where _taxtrans.Voucher == _VoucherId
    && _taxtrans.TransDate  == _VoucherDate
    join _taxtable
        where _taxtable.TaxCode == _taxtrans.TaxCode
        && _taxtable.TaxType == TaxType::PPh
    Join _TaxData
        Where _TaxData.TaxCode == _taxtable.TaxCode;

    taxvaluePPh = _TaxData.TaxValue;

    IF (_FPJVoucherType == GG_FPJVoucherType::Invoice)
    {
        GRetensi.allowEdit(SalesTable::find(_SalesId).GGRetensi);
        //TotalAdv.visible(SalesTable::find(_SalesId).GGRetensi);
        TotalAdv.realValue(This.GetTotalAdv(_SalesId));
    }
    /*  // Remarkd by adit
    IF (_FPJVoucherType == GG_FPJVoucherType::CashReceipt)
        Advance.allowEdit(SalesTable::find(_SalesId).GGRetensi);
    */ // Remarkd by adit

    return [_CustAccount, _VoucherDate, _JournalNum, _CurrencyCode, _VoucherTotalAmt, _PPNExchRate, _PPhExchRate, _FPJVoucherType, _SalesID, taxvaluePPN, taxvaluePPh, _NoYes];
}



===================================================CARA PANGGILnya===============================================
public boolean modified()
{
    boolean     ret;
    Amount              _DPPFaktur, _PPNFaktur, _PPhFaktur;
    container   _Cont;

    ret = super();

    if (GG_FPJVoucher_Voucher.text() != "")
    {
        _Cont   = element.getVoucherInfo(GG_FPJVoucher_Voucher.text());
       
        GG_FPJVoucher_CustAccount.text(conpeek(_Cont, 1));
        GG_FPJVoucher_VoucherDate.dateValue(conpeek(_Cont, 2));
        GG_FPJVoucher_JournalId.text(conpeek(_Cont, 3));
        GG_FPJVoucher_CurrencyCode.text(conpeek(_Cont, 4));
        GG_FPJVoucher_TotalVoucherAmount.realValue(conpeek(_Cont, 5));
        GG_FPJVoucher_FPJExchRate.realValue(conpeek(_Cont, 6));
        GG_FPJVoucher_PPhExchRate.realValue(conpeek(_Cont, 7));
        GG_FPJVoucher_FPJVoucherType.selection(conpeek(_Cont, 8));
        GGSalesID.text(conpeek(_Cont, 9));
        PPNPercent.realValue(conpeek(_Cont, 10));
        PPhPercent.realValue(conpeek(_Cont, 11));
        Berikat.value(conpeek(_Cont, 12));

        [_DPPFaktur, _PPNFaktur, _PPhFaktur]    = element.calculateAmountFaktur(GG_FPJVoucher_Voucher.text(), conpeek(_Cont, 9));

        element.calculateDPP_VAT_PPh();

        OthFaktur.allowEdit(Element.GetOthFaktur(GG_FPJVoucher_Voucher.text()));

        // added by adit
            if(GG_Fpjvoucher::FindVoucher(GG_FPJVoucher_Voucher.text()).UangMuka == noyes::Yes)
            {
                    Advance.value(noyes::Yes);
                    Advance.allowEdit(false);
                    Retention.allowEdit(false);
                    Cash.allowEdit(false);
                    Credit.allowEdit(false);
            }

            if(GG_FPJVoucher::FindVoucher(GG_Fpjvoucher_voucher.text()).Retensi == noyes::Yes)
            {
                    Retention.value(noyes::Yes);
                    Advance.allowEdit(false);
                    Retention.allowEdit(false);
                    Cash.allowEdit(false);
                    Credit.allowEdit(false);
            }

            if(GG_FPJVoucher::FindVoucher(GG_FpjVoucher_voucher.text()).BIT_Cash == noyes::Yes)
            {
                    Cash.value(noyes::Yes);
                    Advance.allowEdit(false);
                    Retention.allowEdit(false);
                    Cash.allowEdit(false);
                    Credit.allowEdit(false);
            }

            if(GG_FPJVoucher::FindVoucher(GG_FPJVoucher_voucher.text()).BIT_Credit == noyes::Yes)
            {
                    Credit.value(noyes::Yes);
                    Advance.allowEdit(false);
                    Retention.allowEdit(false);
                    Cash.allowEdit(false);
                    Credit.allowEdit(false);
            }

         if(GG_FPJVoucher_FPJVoucherType.selection() == GG_FPJVoucherType::CashReceipt)
            {
                    Advance.allowEdit(true);
                    Retention.allowEdit(true);
                    Cash.allowEdit(true);
                    credit.allowEdit(false);
            }

           if(GG_FPJVoucher_FPJVoucherType.selection() != GG_FPJVoucherType::CashReceipt)
            {
                    Advance.allowEdit(false);
                    Retention.allowEdit(true);
                    Cash.allowEdit(false);
                    Credit.allowEdit(true);
            }
        // ended by adit

    }

    return ret;
}
Read more...

allowCreate in x++

0 comments
void AllowCreate(boolean _Status, boolean _StatusLine = _Status)
{
    ;
    PurchReqTable_ds.allowCreate(_Status);
    PurchReqLine_ds.allowCreate(_StatusLine);
    PurchReqLine_ds.allowEdit(_StatusLine);
}
Read more...

Dialog button noyes x++

0 comments
 boolean ret;

    ret = super();

    if(substr(BIT_KodePajak.valueStr(), 3, 1) == "1")
    {
        if(box::yesNo("Apakah anda yakin membuat Faktur Pajak Pengganti ?", dialogButton::No, "Confirmation")  == dialogButton::Yes)
        {
            return ret;
        }
        else
        {
            BIT_KodePajak.text("010");
        }
    }

    return ret;
Read more...

validateWrite x++

0 comments
public boolean validateWrite()
{
    boolean                 ret;
    boolean                 check = true;
    boolean                 IsExtraChargeModified;
    boolean                 isAllowDelete;
    SalesLine               SalesLineOriginal = SalesLine.orig();

    ;



    //Add by Yaya, Agreeya, Oct 27, 2010
    if ( salesline.SalesQty >= 0
         && !SalesTable.isSalesLineAllowNew()
         && showMsgWriteRestriction
         && isAdditionalRow
       )
    {

      showMsgWriteRestriction = CustConfirmJour::exist(SalesTable.SalesId) ? true : false;
      box::stop("For SO Item Contract, after confirmation you not allow to add qty positive again");
      showMsgWriteRestriction = false;
      isAllowDelete  = salesLine_DS.allowDelete();
      salesLine_DS.allowDelete(true);
      salesLine_DS.delete();
      salesLine_DS.allowDelete(isAllowDelete);
      isAdditionalRow = false;
      return false;
    }
    //


    if(!salestable.CheckCustConfirm())
        check = true;
    else
    {

        if (SalesLine == SalesLineOriginal )
        {
           check = true;
        }
        else
        {

           if (salestable.Soltius_ContractType    != Soltius_contractType::ItemContract &&
               salesline.Soltius_AppMoneyContract != Soltius_AppMoneyContract::DeleteProcess   )
           {

               isExtraChargeModified = salesLine &&
                                       salesLine.Soltius_ExtraCharge != salesLine.orig().Soltius_ExtraCharge ? true : false;




               if ( isExtraChargeModified )
               {
                 check = true;
               }
               else
               {

                  if ( !salesLine.ItemId )
                     check = false;

                  if (box::yesNo("Are you sure want to save this line?", dialogbutton::No,"Confirmation", "Validate Confirmation") == dialogbutton::No)
                  {
                     salesLine_ds.reread();
                     check = false;

                     if ( !salesline.Soltius_ExtraCharge )
                        this.DeleteExtraCharge( salesLine.InventRefId );


                  }

               }

           }

        }
     }

    if(check)
    {

       salesTableForm.setTouched(salesTable);
       salesLine.InventDimId = InventDim::findOrCreate(inventDim).InventDimId;
       if (salesLine.RecId != 0
           &&  salesLine.InterCompanyInventTransId
           &&  salesTable.InterCompanyOrder)
       {
                salesLine.DeliveryDateControlType = SalesDeliveryDateControlType::None;

       }


        ret = super();



        if (!askingModifyInvoiced && ret)
        {
            askingModifyInvoiced = true;
            ret = salesTable.checkUpdate();
            if (!ret)
            {
                salesLine_ds.reread();
                salesTable_ds.reread();
            }
            askingModifyInvoiced = false;
        }

        if (ret)
        {
           ret = salesTableForm.salesLine_validateWrite(salesLine, inventDim);
        }

        if (ret && salesLine.DeliveryDateControlType)
        {
            ret = SalesCalcAvailableDlvDates::validateWritePrompt(salesLine,false,true,true,false);
        }
    }
    else
    {

        ret = false;
    }

    return ret;
}


=============================================================================
public void clicked()
{
    DialogButton        _DialogButton;
    ;
    //super();

     if(CustTable.BIT_Generate == noyes::No)
    {
        error("Anda tidak bisa generate manual");
        CustTable_ds.executeQuery();
        return;
    }

    if(CustTable.BIT_Generate == noyes::Yes)
    {
        _DialogButton = box::yesNo("Anda yakin Generate ulang ke CSV ?", dialogButton::Yes, "Generate To CSV", "Pilih Ya atau Tidak");

        if(_DialogButton == DialogButton::Yes)
        {
            ttsbegin;
            CustTable.BIT_Generate = noyes::No;
            CustTable.update();
            ttscommit;
            CustTable_ds.executeQuery();
        }

        else if(_dialogButton == dialogButton::No)
        {
            CustTable_ds.executeQuery();
            return;
        }
    }
}

Read more...

cursorNotify in x++

0 comments
public void cursorNotify(int _event)
{
    super(_event);
    IF (GG_FPJVoucher.FPJVoucherType == GG_FPJVoucherType::CashReceipt ||
        GG_FPJVoucher.FPJVoucherType == GG_FPJVoucherType::BBCR)
    {
        VoucherReceipt.visible(True);
        VoucherInv.visible(False);
    }
    Else
    {
        VoucherReceipt.visible(False);
        VoucherInv.visible(True);
    }

    FP.enabled(False);
    PPh22.enabled(False);
    NRFP.enabled(False);

    IF (GG_FPJVoucher.getFakturPajakNum())
        IF ((GG_FPJVoucher.FPJVoucherType == GG_FPJVoucherType::ReturnCR) ||
           (GG_FPJVoucher.FPJVoucherType == GG_FPJVoucherType::ReturnInv))
            NRFP.enabled(True);
        Else
            //NRFP.enabled(True);
            FP.enabled(True);
    IF (GG_FPJVoucher.getPPhNum())
        PPh22.enabled(True);

}
Read more...

Fetch in x++

0 comments
public boolean fetch()
{
    boolean                 abcd = true;
    Query                   _Query = new Query(this.query());
    QueryRun                _QueryRun;
    ;

    _Query.dataSourceTable(tableNum(PurchReqTable)).addRange(fieldNum(PurchReqTable, PurchReqId)).value(_getrecordPurchReqTable.PurchReqId);
    _QueryRun = new QueryRun(_Query);

    while(_QueryRun.next())
    {
        if(_QueryRun.changed(tableNum(PurchReqTable)))
        {
            _getrecordPurchReqTable = _QueryRun.get(tableNum(PurchReqTable));


            companyname           = CompanyInfo::find().Name;
            companyaddress        = CompanyInfo::find().postalAddress().Address;
            pagenumber            = element.page();
            datenow               = systemDateGet();

            no_indent             = _getrecordPurchReqTable.PurchReqId;
            tgl_ind               = _getrecordPurchReqTable.TransDate;
            dlvdate               = _getrecordPurchReqTable.RequiredDate;
            originator            = HcmWorker::find(_getrecordPurchReqTable.Originator).name();

            dateTime              = DateTimeUtil::utcNow();
            timeInUserTimeZone    = DateTimeUtil::time(DateTimeUtil::applyTimeZoneOffset(dateTime, DateTimeUtil::getUserPreferredTimeZone()));

            select firstOnly PurchReqBusJustification where PurchReqBusJustification.RefTableId == _getrecordPurchReqTable.TableId
                                                    && PurchReqBusJustification.RefRecId == _getrecordPurchReqTable.RecId;
            notes                 = PurchReqBusJustification.BusinessJustification;//_getrecordPurchReqTable.BusinessJustification;


            select _PurchTable where _PurchTable.dataAreaId == purchReqLine.PurchIdDataArea &&
            _Purchtable.PurchId == purchReqLine.PurchId;
            BIT_Jabatan1          = PurchParameters::find().BIT_Jabatan1_PR;
            BIT_Jabatan2          = PurchParameters::find().BIT_Jabatan2_PR;
            BIT_Jabatan3          = PurchParameters::find().BIT_Jabatan3_PR;
            BIT_Jabatan4          = PurchParameters::find().BIT_Jabatan4_PR;

            BIT_Nama1             = PurchParameters::find().BIT_NamaPegawai1_PR;
            BIT_Nama2             = PurchParameters::find().BIT_NamaPegawai2_PR;
            BIT_Nama3             = PurchParameters::find().BIT_NamaPegawai3_PR;
            BIT_Nama4             = PurchParameters::find().BIT_NamaPegawai4_PR;

            _purchreqline_DefaultDimension = PurchReqLine::find(_getrecordPurchReqTable.RecId);
            purchReqLine = _QueryRun.get(tableNum(PurchReqLine));

            class_dimStorage      = DimensionAttributeValueSetStorage::find(purchReqLine.DefaultDimension);
            deptcode              = class_dimStorage.getDisplayValueByDimensionAttribute(DimensionAttribute::findByName('Department').RecId);
            deptname              = (select Name from DimAttributeOMDepartment where DimAttributeOMDepartment.value == deptcode).name;


            element.send(_getrecordPurchReqTable);
        }


        if (_QueryRun.changed(tableNum(PurchReqLine)))
        {
            purchReqLine = _QueryRun.get(tableNum(PurchReqLine));

            run_number++;

            itemname              = purchReqLine.Name;
            itemidnoncatalog      = purchReqLine.ItemIdNonCatalog;

            qty                   = purchReqLine.PurchQty;
            purchprice            = purchReqLine.PurchPrice;
            itemid                = purchReqLine.ItemId;
            unit                  = UnitofMeasure::find(purchReqLine.PurchUnitOfMeasure).Symbol;

            select firstOnly _InventDim where _InventDim.dataAreaId == purchReqLine.InventDimIdDataArea
                && purchReqLine.InventDimId == _Inventdim.inventDimId;
            configid              = _inventdim.configId;
            sizeid                = _inventdim.InventSiteId;
            colorid               = _inventdim.InventColorId;

            select firstOnly EcoResConfiguration where EcoResConfiguration.Name == _inventDim.configId;
            configname            = _EcoResProductMasterDimValueTranslation.Name;

            select firstOnly PurchReqBusJustification where PurchReqBusJustification.RefTableId == purchreqline.TableId
                                                    && PurchReqBusJustification.RefRecId == Purchreqline.RecId;
            BusinessJustification = PurchReqBusJustification.BusinessJustification;

            element.send(purchReqLine);
        }

    }
        return abcd;
}

Read more...

ValidateDelete - Write - ModifiedField - Validate in x++

0 comments
ValidateDelete - Write - ModifiedField - Validate in x++ :

Table methods using ValidateWrite() ValidateDelete() initValue() ModifiedField() - Microsoft Dynamics AX

Table methods using ValidateWrite() ValidateDelete() initValue() ModifiedField()

initValue()This method file while creating new record to initialize a value, here I am assigning user id to the userID field.

public void initValue()
 {
 super();
 this.UserId = curuserid();
 }

ValidateDelete()While deleting a record if we want to put any validation we can use this method. Here once I delete a record populating a info that deleted record.

public boolean validateDelete()
 {
 boolean ret;
 ret = super();
 info(this.AccountNum);
 return ret;
 }

public boolean validateDelete()
{
    boolean ret;

    ret = super();

    if (this.TECClaimInStatus  == TECClaimInStatus::Posted ||
        this.TECClaimInStatus  == TECClaimInStatus::Received ||
        this.TECClaimOutStatus == TECClaimOutStatus::Posted ||
        this.TECClaimOutStatus == TECClaimOutStatus::Delivered)
    {
        ret = false;
        warning('Cannot delete lines!');
    }
    else
    {
        ret = true;
    }

    return ret;
}

ValidateWrite()

This method will get to fire when we update a record. here I am using to check mandatory field for address AccountNum

public boolean validateWrite()
 {
 boolean ret;
 ;
 if(this.Address != "")
 ret = super();
 else
 warning(" Please fill the address value");
 return ret;
 }

public boolean validateWrite()
{
    boolean ret;

    ret = super();

    if (!purchEditLinesForm.validateInventDimId(purchParmLine, inventDim))
    {
        ret = false;
    }

    // add by tyo
    //if (!purchparmLine.TIDRemark)
    if(!TIDCorrectPackingSlip_Remark.mandatory())
    {  
    ret = false;
    error("Remark harus diisi");
    }
    // end by tyo

    return ret;
}

public boolean validateWrite()
{
    boolean                 ret;
    boolean                 check = true;
    boolean                 IsExtraChargeModified;
    boolean                 isAllowDelete;
    SalesLine               SalesLineOriginal = SalesLine.orig();
    ;
       if ( salesline.SalesQty >= 0
         && !SalesTable.isSalesLineAllowNew()
         && showMsgWriteRestriction
         && isAdditionalRow
       )
    {

      showMsgWriteRestriction = CustConfirmJour::exist(SalesTable.SalesId) ? true : false;
      box::stop("For SO Item Contract, after confirmation you not allow to add qty positive again");
      showMsgWriteRestriction = false;
      isAllowDelete  = salesLine_DS.allowDelete();
      salesLine_DS.allowDelete(true);
      salesLine_DS.delete();
      salesLine_DS.allowDelete(isAllowDelete);
      isAdditionalRow = false;
      return false;
    }
    //


    if(!salestable.CheckCustConfirm())
        check = true;
    else
    {

        if (SalesLine == SalesLineOriginal )
        {
           check = true;
        }
        else
        {

           if (salestable.Soltius_ContractType    != Soltius_contractType::ItemContract &&
               salesline.Soltius_AppMoneyContract != Soltius_AppMoneyContract::DeleteProcess   )
           {

               isExtraChargeModified = salesLine &&
                                       salesLine.Soltius_ExtraCharge != salesLine.orig().Soltius_ExtraCharge ? true : false;

               if ( isExtraChargeModified )
               {
                 check = true;
               }
               else
               {

                  if ( !salesLine.ItemId )
                     check = false;

                //  if (box::yesNo("Are you sure want to save this line?", dialogbutton::No,"Confirmation", "Validate Confirmation") == dialogbutton::No)
                //  {
                //     salesLine_ds.reread();
                     //check = false;

                     if ( !salesline.Soltius_ExtraCharge )
                        this.DeleteExtraCharge( salesLine.InventRefId );
                //  }

               }

           }

        }
     }

    if(check)
    {

       salesTableForm.setTouched(salesTable);
       salesLine.InventDimId = InventDim::findOrCreate(inventDim).InventDimId;
       if (salesLine.RecId != 0
           &&  salesLine.InterCompanyInventTransId
           &&  salesTable.InterCompanyOrder)
       {
                salesLine.DeliveryDateControlType = SalesDeliveryDateControlType::None;

       }

        ret = super();

        if (!askingModifyInvoiced && ret)
        {
            askingModifyInvoiced = true;
            ret = salesTable.checkUpdate();
            if (!ret)
            {
                salesLine_ds.reread();
                salesTable_ds.reread();
            }
            askingModifyInvoiced = false;
        }

        if (ret)
        {
           ret = salesTableForm.salesLine_validateWrite(salesLine, inventDim);
        }

        if (ret && salesLine.DeliveryDateControlType)
        {
            ret = SalesCalcAvailableDlvDates::validateWritePrompt(salesLine,false,true,true,false);
        }
    }
    else
    {

        ret = false;
    }

    return ret;
}




ModifiedField()

This method will execute if modified a record value, this works based on the field value.
 Here I am using to fill the name field value according to the AccountNum

public void modifiedField(fieldId _fieldId)
 {
 CustTable ct;
 ;
 super(_fieldId);
 switch(_fieldId)
 {
 case fieldNum(Cust_new,AccountNum) :
 {
 this.Name = CustTable::find(this.AccountNum).Name;
 }
 break;
 }
 }

contoh lain di letakkan di form (bukan di table):
public boolean validate()
{
    boolean ret;

    ret = super();

    if (mthOfYr(ToDate.dateValue()) != mthOfYr(FromDate.dateValue()))
    {
        ret = false;
        warning('Bulan To Date harus sama dengan bulan From Date');
    }

    if (date2num(ToDate.dateValue()) < date2num(FromDate.dateValue()))
    {
        ret = false;
        warning('Tanggal To Date tidak boleh lebih kecil dari From Date');
    }

    return ret;
}

    if(PurchParmTable.TransDate < PurchLine.DeliveryDate && PurchLine.TECIsCancel==NoYes::No && documentStatus == documentStatus::PackingSlip)
    {
        throw error("Posting Date TIDAK BOLEH lebih kecil dari Delivery Date, harap menghubungi bagian Purchasing");
        return;
    }

====== ATAU tanpa return; juga bisa =======
 
   if(PurchParmTable.TransDate < PurchLine.DeliveryDate && PurchLine.TECIsCancel==NoYes::No && documentStatus == documentStatus::PackingSlip)
    {
        throw error("Posting Date TIDAK BOLEH lebih kecil dari Delivery Date, harap menghubungi bagian Purchasing");
    }

    else
    {
        brake;
    }


public boolean validate()
{
    boolean ret;

    ret = super();

    if (ret)
    {
        if (this.value() == true && logisticsElectronicAddress.otherPrimaryExists())
        {
            if (Box::yesNo("@SYS304427", DialogButton::No) == DialogButton::No)
            {
                ret = false;
            }
        }
    }

    return ret;
}


// added by adit
public boolean modified()
{
    Inventtrans         inventTransReturn;
    SalesOrderedQty     _SalesQty, a, b, c;
    InventSplitTrans    splitTrans;
    InventQty           qtyRemain;
    boolean             ret;

    ret = super();

    while select inventTransReturn where inventTransReturn.RecId == salesline.Soltius_InventReturnRecId
    {
        info(strfmt('%1 == %2',  inventTransReturn.RecId, salesline.Soltius_InventReturnRecId));

        b = salesline.SalesQty;
        info(strfmt('%1', b));
        select SalesQty from salesline where salesline.Soltius_InventReturnRecId == inventTransReturn.RecId;
        _SalesQty = a + salesline.SalesQty;

        c = b + _salesqty;
        info(strfmt('%1', c));

        info(strfmt('total _SalesQty = %1 dengan recid = %2', c, inventTransReturn.RecId));

        info(strfmt('total _SalesQty = %1 < inventtrans = %2', c, inventTransReturn.qty));
        if(c < inventTransReturn.Qty)
        {
         error("@SYS53004");
         ret = false;
        }
     }

    return ret;
}
//ended by adit


============================

public boolean validate()
{
    boolean ret;

    ret = super();

     if(Advance.value() == noyes::Yes || Cash.value() == noyes::Yes || Credit.value() == noyes::Yes)
    {      
        ret = false;
warning("Pilih salah satu");
    }

    return ret;
}

=========================================================
void OK_Button()
{
    GG_FPJVoucher       _GG_FPJVoucher1, GG_FPJVoucher2 ;
    str                 TempTxt1, TempTxt2;
    Args                _Args;
    ;

    // added by adit
    if(Retention.value() == noyes::No && Cash.value() == noyes::No && Credit.value() == noyes::No && Advance.value() == noyes::No)
    {
        error("Maaf, Anda belum memilih jenis transaksi");
        return;
    }
    // ended by adit

    if (GG_FPJVoucher_TotalVoucherAmount.realValue() != 0)
    {
            If ((PPNPercent.realValue() == 0 && Berikat.value() == NoYes::Yes) ||
                (PPNPercent.realValue() != 0 && Berikat.value() == NoYes::No)  ||
                (PPNPercent.realValue() == 0 && Element.CreateFaktur(GG_FPJVoucher2.Voucher)))
            {
                if (box::yesNo("Are you sure to save ?", dialogButton::No, "Confirmation")  == dialogButton::Yes)
                {
                    select _GG_FPJVoucher1 index hint voucheridx where _GG_FPJVoucher1.Voucher    == GG_FPJVoucher_Voucher.text();


                    // ================================== Untuk input voucher baru ============================================
                    if (!_GG_FPJVoucher1)
                    {
                        if (element.checkDateValidation(GG_FPJVoucher_CustAccount.text(), GGSalesID.text(), GG_FPJVoucher_VoucherDate.dateValue()))
                        {
                            //num seq
                            TempTxt2        = GG_FPJParameter::getnextStrId(1, OverwriteNextNum.value());
                            //
                            Try
                            {
                                ttsbegin;
                                GG_FPJVoucher2.clear();
                                GG_FPJVoucher2.Voucher              = GG_FPJVoucher_Voucher.text();
                                GG_FPJVoucher2.CurrencyCode         = GG_FPJVoucher_CurrencyCode.text();
                                GG_FPJVoucher2.JournalId            = GG_FPJVoucher_JournalId.text();
                                GG_FPJVoucher2.VoucherDate          = GG_FPJVoucher_VoucherDate.dateValue();
                                GG_FPJVoucher2.FPJVoucherId         = TempTxt2;
                                GG_FPJVoucher2.CustAccount          = GG_FPJVoucher_CustAccount.text();
                                GG_FPJVoucher2.TotalVoucherAmount   = GG_FPJVoucher_TotalVoucherAmount.realValue();
                                GG_FPJVoucher2.DPPBaseAmount        = GG_FPJVoucher_DPPBaseAmount.realValue();
                                GG_FPJVoucher2.PPNBaseAmount        = GG_FPJVoucher_PPNBaseAmount.realValue();
                                GG_FPJVoucher2.PPhBaseAmount        = GG_FPJVoucher_PPhBaseAmount.realValue();
                                GG_FPJVoucher2.FPJExchRate          = GG_FPJVoucher_FPJExchRate.realValue();
                                GG_FPJVoucher2.PPhExchRate          = GG_FPJVoucher_PPhExchRate.realValue();
                                GG_FPJVoucher2.FPJVoucherType       = GG_FPJVoucher_FPJVoucherType.selection();
                                GG_FPJVoucher2.SalesId              = GGSalesID.text();
                                GG_FPJVoucher2.VATPercent           = PPNPercent.realValue();
                                GG_FPJVoucher2.PPhPercent           = PPhPercent.realValue();
                                GG_FPJVoucher2.RetensiPercent       = RetensiPercent.realValue();
                                GG_FPJVoucher2.RetensiAmount        = RetensiAmount.realValue();
                                GG_FPJVoucher2.UangMuka             = Advance.value();

                                // added by adit
                                GG_FPJVoucher2.Retensi              = Retention.value();
                                GG_FPJVoucher2.BIT_Cash             = Cash.value();
                                GG_FPJVoucher2.BIT_Credit           = Credit.value();
                                GG_FPJVoucher2.BIT_KodePajak        = BIT_KodePajak.valueStr();
                                // ended by adit

                                GG_FPJVoucher2.AlocFPJNum           = OthFaktur.text();
                                GG_FPJVoucher2.Berikat              = Berikat.value();
                                //Breakpoint;
                                If ((Element.CreateFaktur(GG_FPJVoucher2.Voucher)) && ((GG_FPJVoucher2.VATPercent || GG_FPJVoucher2.PPhPercent) || Berikat.value()==NoYes::Yes))
                                    [GG_FPJVoucher2.AmountDPPFaktur, GG_FPJVoucher2.AmountPPNFaktur, GG_FPJVoucher2.AmountPPhFaktur]    = element.calculateAmountFakturTRY(GG_FPJVoucher2.Voucher, GG_FPJVoucher2.SalesId);
                                Else
                                    [GG_FPJVoucher2.AmountDPPFaktur, GG_FPJVoucher2.AmountPPNFaktur, GG_FPJVoucher2.AmountPPhFaktur]    = [0, 0, 0];

                                //Breakpoint;
                                IF ((GG_FPJVoucher2.AmountPPNFaktur > 0) && (GG_FPJVoucher2.AmountPPhFaktur == 0))
                                    GG_FPJVoucher2.Status       = GG_OpenClose::OpenVAT;

                                ELSE IF ((GG_FPJVoucher2.AmountPPNFaktur == 0) && (GG_FPJVoucher2.AmountPPhFaktur > 0))
                                {
                                    If (Berikat.value() != NoYes::Yes)
                                    GG_FPJVoucher2.Status       = GG_OpenClose::OpenPPh;
                                }
                                ELSE IF ((GG_FPJVoucher2.AmountPPNFaktur > 0) && (GG_FPJVoucher2.AmountPPhFaktur > 0))
                                    GG_FPJVoucher2.Status       = GG_OpenClose::Open;

                                ELSE IF ((GG_FPJVoucher2.AmountPPNFaktur == 0) && (GG_FPJVoucher2.AmountPPhFaktur == 0))
                                {
                                    GG_FPJVoucher2.Status       = GG_OpenClose::Closed;
                                }

                                If ((Berikat.value() == NoYes::Yes) && (GG_FPJVoucher2.AmountDPPFaktur != 0))
                                    GG_FPJVoucher2.Status       = GG_OpenClose::Open;

                                IF (SalesTable::find(GG_FPJVoucher2.SalesId).GGRetensi)
                                    GG_FPJVoucher2.calculateAmountFakturRetensi();

                                GG_FPJVoucher2.insert();
                                ttscommit;
                                info(strfmt("Data Inserted (Id : %1)", GG_FPJVoucher2.FPJVoucherId));
                                element.close();
                            }
                            catch
                            {
                                error("Process error");
                                ttsabort;
                            }

                        }
                        else
                            warning("Older Voucher date already exist in the same Customer account, please check transaction");
                    }
                    else
                    {
                            warning("Voucher Already Exist, Cannot Proceed !");
                    }







 //======== Untuk voucher yang sudah pernah di input dan ingin dibatalkan =========
                    if (_GG_FPJVoucher1 && GG_FpjVoucher::FindVoucher(GG_FPJVoucher_Voucher.valueStr()).BIT_Batal == noyes::Yes)
                    {
                        if (element.checkDateValidation(GG_FPJVoucher_CustAccount.text(), GGSalesID.text(), GG_FPJVoucher_VoucherDate.dateValue()))
                        {
                            //num seq
                            TempTxt2        = GG_FPJParameter::getnextStrId(1, OverwriteNextNum.value());
                            //
                            Try
                            {
                                ttsbegin;
                                GG_FPJVoucher2.clear();
                                GG_FPJVoucher2.Voucher              = GG_FPJVoucher_Voucher.text();
                                GG_FPJVoucher2.CurrencyCode         = GG_FPJVoucher_CurrencyCode.text();
                                GG_FPJVoucher2.JournalId            = GG_FPJVoucher_JournalId.text();
                                GG_FPJVoucher2.VoucherDate          = GG_FPJVoucher_VoucherDate.dateValue();
                                GG_FPJVoucher2.FPJVoucherId         = TempTxt2;
                                GG_FPJVoucher2.CustAccount          = GG_FPJVoucher_CustAccount.text();
                                GG_FPJVoucher2.TotalVoucherAmount   = GG_FPJVoucher_TotalVoucherAmount.realValue();
                                GG_FPJVoucher2.DPPBaseAmount        = GG_FPJVoucher_DPPBaseAmount.realValue();
                                GG_FPJVoucher2.PPNBaseAmount        = GG_FPJVoucher_PPNBaseAmount.realValue();
                                GG_FPJVoucher2.PPhBaseAmount        = GG_FPJVoucher_PPhBaseAmount.realValue();
                                GG_FPJVoucher2.FPJExchRate          = GG_FPJVoucher_FPJExchRate.realValue();
                                GG_FPJVoucher2.PPhExchRate          = GG_FPJVoucher_PPhExchRate.realValue();
                                GG_FPJVoucher2.FPJVoucherType       = GG_FPJVoucher_FPJVoucherType.selection();
                                GG_FPJVoucher2.SalesId              = GGSalesID.text();
                                GG_FPJVoucher2.VATPercent           = PPNPercent.realValue();
                                GG_FPJVoucher2.PPhPercent           = PPhPercent.realValue();
                                GG_FPJVoucher2.RetensiPercent       = RetensiPercent.realValue();
                                GG_FPJVoucher2.RetensiAmount        = RetensiAmount.realValue();
                                GG_FPJVoucher2.UangMuka             = Advance.value();

                                // added by adit
                                GG_FPJVoucher2.Retensi              = Retention.value();
                                GG_FPJVoucher2.BIT_Cash             = Cash.value();
                                GG_FPJVoucher2.BIT_Credit           = Credit.value();
                                GG_FPJVoucher2.BIT_KodePajak        = BIT_KodePajak.valueStr();
                                // ended by adit

                                GG_FPJVoucher2.AlocFPJNum           = OthFaktur.text();
                                GG_FPJVoucher2.Berikat              = Berikat.value();
                                //Breakpoint;
                                If ((Element.CreateFaktur(GG_FPJVoucher2.Voucher)) && ((GG_FPJVoucher2.VATPercent || GG_FPJVoucher2.PPhPercent) || Berikat.value()==NoYes::Yes))
                                    [GG_FPJVoucher2.AmountDPPFaktur, GG_FPJVoucher2.AmountPPNFaktur, GG_FPJVoucher2.AmountPPhFaktur]    = element.calculateAmountFakturTRY(GG_FPJVoucher2.Voucher, GG_FPJVoucher2.SalesId);
                                Else
                                    [GG_FPJVoucher2.AmountDPPFaktur, GG_FPJVoucher2.AmountPPNFaktur, GG_FPJVoucher2.AmountPPhFaktur]    = [0, 0, 0];

                                //Breakpoint;
                                IF ((GG_FPJVoucher2.AmountPPNFaktur > 0) && (GG_FPJVoucher2.AmountPPhFaktur == 0))
                                    GG_FPJVoucher2.Status       = GG_OpenClose::OpenVAT;

                                ELSE IF ((GG_FPJVoucher2.AmountPPNFaktur == 0) && (GG_FPJVoucher2.AmountPPhFaktur > 0))
                                {
                                    If (Berikat.value() != NoYes::Yes)
                                    GG_FPJVoucher2.Status       = GG_OpenClose::OpenPPh;
                                }
                                ELSE IF ((GG_FPJVoucher2.AmountPPNFaktur > 0) && (GG_FPJVoucher2.AmountPPhFaktur > 0))
                                    GG_FPJVoucher2.Status       = GG_OpenClose::Open;

                                ELSE IF ((GG_FPJVoucher2.AmountPPNFaktur == 0) && (GG_FPJVoucher2.AmountPPhFaktur == 0))
                                {
                                    GG_FPJVoucher2.Status       = GG_OpenClose::Closed;
                                }

                                If ((Berikat.value() == NoYes::Yes) && (GG_FPJVoucher2.AmountDPPFaktur != 0))
                                    GG_FPJVoucher2.Status       = GG_OpenClose::Open;

                                IF (SalesTable::find(GG_FPJVoucher2.SalesId).GGRetensi)
                                    GG_FPJVoucher2.calculateAmountFakturRetensi();

                                GG_FPJVoucher2.insert();
                                ttscommit;
                                info(strfmt("Data Inserted (Id : %1)", GG_FPJVoucher2.FPJVoucherId));
                                element.close();
                            }
                            catch
                            {
                                error("Process error");
                                ttsabort;
                            }

                        }
                        else
                            warning("Older Voucher date already exist in the same Customer account, please check transaction");
                    }
                    else
                    {
                        if(GG_FpjVoucher::FindVoucher(GG_FPJVoucher_Voucher.valueStr()).BIT_Batal == noyes::no)
                        {
                            info("Bukan Batal");
                            warning("Voucher Already Exist, Cannot Proceed !");
                        }
                    }





                }
            }
    else
        warning ("Cannot proceed, because PPNPercent for Berikat Customer, must be NULL");
    }
    else
        warning ("Cannot proceed because Voucher Amount is zero");
}

==========================================

// added by adit
// Order Quantity cannot more than Remain Quantity
public boolean validate()
{
    boolean ret;

    ret = super();
 
    if(SessionQty.valueStr() > remainQty.valueStr())
    {
ret = false;
        error("Order Quantity cannot more than Remain Quantity");      
    }

    return ret;
}

==============================================
Read more...

New line in x++

0 comments
New line in x++ :

=StrFmt("%1\r\n", PurchLine.PurchId);

example :
void CreatePR()
{
    Salesid                         Salesid;

    // Get Invendim
    Inventtable                     _Inventtable;
    InventItemOrdersetupType        setupType = InventItemOrderSetupType::Invent;
    Inventdim                       _Inventdim;

    QueryRun                        _QueryRun;
    Query                           _Query = new Query();

    //====================================== getItemName()
    ItemFreeTxt                     itemname;
    real                            length;
    ConfigId                        configId;
    Name                            ConfigName;
    Qty                             PCS;
    Qty                             KG_PCS;
    Real                            Real_KG_PCS;

    configTable                     _ConfigTable;
    Inventdimid                    inventdimid;

    InventSizeId                   inventSizeId;
    InventColorId                  inventColorId;
    InventTransId                  inventTransId;

    POCustomer                     POCustomer;
    //====================================== getItemName()
    ;

    _QueryRun = new QueryRUn(_Query);

    Salesid = Sales.valueStr();
    _salesline_pendek = Salesline::BIT_find_crosscompany(_salesline.SalesId, _salesline.LineNum);

    ttsbegin;
    _purchreqtable.BIT_SalesId = Salesid;
    _purchreqtable.update();
    ttscommit;

               ttsbegin;
    while select crosscompany * from _SalesLine
                          order by linenum asc
                            where _salesline.SalesId == Salesid
                            && _salesline.dataAreaId == Company.valueStr()
               {
               //============= GetItemName ==========
               _configtable= Configtable::BIT_find(_salesline.ItemId,  inventdim::BIT_find_crosscompany(_salesline.InventDimId).configId);
               configId    = inventdim::BIT_find_crosscompany(_salesline.InventDimId).configId;

               ConfigName  = _configtable.Name;

               inventSizeId =   inventdim::BIT_find_crosscompany(_salesline.InventDimId).InventSizeId;
               inventColorId =  inventdim::BIT_find_crosscompany(_salesline.InventDimId).InventColorId;

               InventTransId = _salesline.InventTransId;

               POCustomer =  Salesline::BIT_find_crosscompany(_salesline.SalesId, _salesline.LineNum).POCustomer;

               PCS     = _salesline.SalesQty;
               KG_PCS  = _salesline.QtyOrdered/ _salesline.SalesQty;

               length = Salesline::BIT_find_crosscompany(_salesline.SalesId, _salesline.LineNum).Soltius_LengthId;

                if(!strltrim(strrtrim((Salesline::BIT_find_crosscompany(_salesline.SalesId, _salesline.LineNum).Name))))
                        itemname = InventTable::BIT_Find_CrossCompany(Salesline::BIT_find_crosscompany(_salesline.SalesId, _salesline.LineNum).ItemId).ItemName;
                else
                        itemname = Salesline::BIT_find_crosscompany(_salesline.SalesId, _salesline.LineNum).Name;

                        if(Salesline::BIT_find_crosscompany(_salesline.SalesId, _salesline.LineNum).QtyOrdered == Salesline::BIT_find_crosscompany(_salesline.SalesId, _salesline.LineNum).Soltius_WeightedQty)
                        {

                                     If ((InventTable::find(Salesline::BIT_find_crosscompany(_salesline.SalesId, _salesline.LineNum).ItemId).ItemGroupId == 'Cons') ||
                                        (InventTable::find(Salesline::BIT_find_crosscompany(_salesline.SalesId, _salesline.LineNum).ItemId).ItemGroupId == 'SPR'))
                                         itemname += " - " + configname + " - " + configId;

                                     Else if(configId)
                                         itemname += " - " + configId;

                                       length = Salesline::BIT_find_crosscompany(_salesline.SalesId, _salesline.LineNum).Soltius_LengthId;
                                       if(inventSizeId  && strltrim(strrtrim(inventsizeid)) !=  "1")
                                       {
                                           if(Length || _salesline_pendek.ItemId == "PL/CO-REJECT" || InventTable::find(Salesline::BIT_find_crosscompany(_salesline.SalesId, _salesline.LineNum).ItemId).Soltius_DiffSize)
                                                itemname += "x" + InventSizeId;

                                           else
                                           {
                                                if(!inventcolorid)
                                                  itemname += "x" + num2str(str2num(InventSizeId)*1000,1,0,1,0);
                                                else
                                                 itemname += "x" + InventSizeId;
                                           }
                                        }
                                        else
                                        {
                                            if(inventsizeid)
                                            {
                                                if(!Length)
                                                {
                                                    if(!inventcolorid)
                                                    itemname += "x" + num2str(str2num(InventSizeId)*1000,1,0,1,0);
                                                }
                                             }
                                      }

                                      if(InventColorId)
                                            itemname += "x" + InventColorId;


                                       if(length)
                                       {
                                            if(Salesline::BIT_find_crosscompany(_salesline.SalesId, _salesline.LineNum).SalesUnit != "MTR")
                                               itemname += "x" + num2str(length * 1000, 1, 0, 1, 0);
                                            else
                                               itemname += "x" + num2str(length * 1000, 1, 0, 1, 0) + " MM";
                                       }
                             }

                             else
                            {
                                      if(!strltrim(strrtrim(Salesline::BIT_find_crosscompany(_salesline.SalesId, _salesline.LineNum).Name)))
                                      {
                                        if(configId)
                                            {
                                                itemname += " / " + configId;
                                            }

                                        if(InventSizeId)
                                        {
                                            if(Length)
                                                 itemname += "x" + InventSizeId;
                                            else
                                            {
                                                if(!InventColorId)
                                                  itemname += "x" + num2str(str2num(InventSizeId)*1000,1,0,1,0);
                                                else
                                                    itemname += "x" + InventSizeId;
                                            }
                                        }
                                        else
                                        {
                                          if(InventSizeId)
                                          {
                                            if(!length)
                                            {
                                                if(!InventColorId)
                                                    itemname += "x" + num2str(str2num(InventSizeId)*1000,1,0,1,0);
                                            }
                                          }
                                        }

                                        if(InventColorId)
                                            itemname += "x" + InventColorId;

                                        if(length)
                                        {
                                            if(Salesline::BIT_find_crosscompany(_salesline.SalesId, _salesline.LineNum).SalesUnit != "MTR")
                                            {
                                               itemname += "x" + num2str(length * 1000, 1, 0, 1, 0);
                                            }
                                            else
                                               itemname += "x" + num2str(length * 1000, 1, 0, 1, 0) + " MM";
                                        }
                               }
                         }


                //============= GetItemName ==========
                       _Purchreqline.clear();
                       _Purchreqline.initValue();
                       _Purchreqline.InventDimId        = _salesline.InventDimId;
                       _Purchreqline.initFromPurchReqTable(_PurchreqTable);
                       _Purchreqline.ItemId             = itemid.valueStr();
                       _purchreqline.RequisitionOrigin  = _purchreqtable.PurchOrigin;
                       _purchreqline.LineNum            = _salesline.LineNum;

                       if(POCustomer)
                       {
                        _purchreqline.externalitemid = strfmt("%1 \n-%2   \n%3Pcs@%4Kg",itemname, POCustomer, PCS, KG_PCS);
                       }

                       if(!POCustomer)
                       {
                        _purchreqline.externalitemid = strfmt("%1   \n%2Pcs@%3Kg",itemname, PCS, KG_PCS);
                       }

                       _Purchreqline.ActivityNumber = _salesline.ActivityNumber;
                       _Purchreqline.Name           = _SalesLine.Name;
                       _Purchreqline.PurchUnit      = inventtableModule::BIT_find_crosscompany(Salesline::BIT_find_crosscompany(_salesline.SalesId, _salesline.LineNum).ItemId, ModuleInventPurchSales::Invent).UnitId;

                       if(!_Purchreqline.PurchUnit)
                       {
                         _Purchreqline.PurchUnit = "Kg";
                       }

                       _Purchreqline.ConfigName();
                       _Purchreqline.PurchQty       = _salesline.QtyOrdered;
                       _PurchReqLine.QtyRemaining   = _salesline.QtyOrdered;

                       _Purchreqline.CurrencyCode   = _salesline.CurrencyCode;
                       _PurchReqLine.LedgerAccount  = _salesline.LedgerAccount;
                       _Purchreqline.ProjCategoryId = _salesline.ProjCategoryId;
                       _Purchreqline.CancelQty      = _salesline.Cancelqty();
                       _Purchreqline.ActivityNumber = activitynumber.valueStr();

                       _Inventdim.InventSiteId         = site.valueStr();
                       _Inventdim.InventLocationId     = location.valueStr();
                       _Inventdim                      = InventDim::findOrCreate(_Inventdim);
                       _Purchreqline.inventDimId       = _Inventdim.inventDimId;

                       _Purchreqline.LineType           = Purchreqlinetype::Item;
                       _Purchreqline.insert();
                }
                ttscommit;


              if(_Purchreqline.Name != "")
              {
                Info(strfmt("Press f5 - Import SOP : %1 (%2) to PR : %3 (%4) has been succesfully", Salesid, Company.valueStr(), _purchreqtable.PurchReqId, curExt()));
              }
     }

Read more...

A financial dimension value is based on the LAND-00013 record and has been used on a transaction. You cannot delete the LAND-00013 record AX 2012

 A financial dimension value is based on the LAND-00013 record and has been used on a  transaction. You cannot delete the LAND-00013 record ...