Thursday, October 10, 2024

cache a display method

[SysClientCacheDataMethodAttribute(true)]


Copy Data From One Table To Another Table By Using buf2buf- Ax 2012 BUF2BUF buf2buf

/// <summary>

/// Global class used for generic methods.

/// added by santhosh 

/// </summary>

class LSGlobal

{

    public static void buf2buf(Common  _from, Common  _to)

    {

        DictTable   dictTableFrom   = new DictTable(_from.TableId);

        DictTable   dictTableTo     = new DictTable(_to.TableId);

        DictField   dictFieldFrom;

        FieldId     fieldIdFrom     = dictTableFrom.fieldNext(0);

        FieldId     fieldIdTo;


        while (fieldIdFrom && ! isSysId(fieldIdFrom))

        {

            dictFieldFrom   = new DictField(_from.TableId, fieldIdFrom);


            if(dictFieldFrom)

            {

                fieldIdTo = dictTableTo.fieldName2Id(dictFieldFrom.name());


                if(fieldIdTo)

                _to.(fieldIdTo) = _from.(fieldIdFrom);

            }

            fieldIdFrom = dictTableFrom.fieldNext(fieldIdFrom);

        }

    }



}




Link https://rahulmsdax.blogspot.com/2015/04/copy-data-from-one-table-to-another.html?m=1

Entity Relationship Diagram in D365F&O

Entity Relationship Diagram in D365F&O




https://community.dynamics.com/blogs/post/?postid=f842e954-bac2-437b-9f01-579096c25876

Invoice capture OCR copilot automater invoices from vendor

https://learn.microsoft.com/en-us/dynamics365/finance/accounts-payable/invoice-capture-overview

Data storage Azure Data Lake Azure Data Lake Storage (ADLS) Azure Synapse Analytics Bring Your Own Database (BYOD) Azure Blob Storage

Azure Data Lake: Scalable storage service optimized for big data analytics. It stores both structured and unstructured data at any scale.


Azure Data Lake Storage (ADLS): Enhanced version of Azure Blob storage, optimized for analytics and providing hierarchical namespaces for data organization.


Azure Synapse Analytics: Integrated analytics service combining big data and data warehousing. It allows querying both relational and non-relational data.


Bring Your Own Database (BYOD): Concept where organizations use their own databases in Azure, integrating them with other services like Dynamics 365 for better flexibility and control.


Azure Blob Storage: Object storage solution optimized for storing massive amounts of unstructured data like text, images, and videos.

DB restore in d365 fo dev environment ssms bak

https://support.managed.com/kb/a1788/how-to-manually-restore-an-mssql-database-in-sql-management-studio-ssms.aspx#:~:text=Log%20into%20SQL%20Server%20Management%20Studio.%20N%20avigate,to%20the%20correct%20database.%20Select%20the%20Options%20tab

Unified Experience dev d365 fo development server

https://devblogs.microsoft.com/powerplatform/the-public-preview-for-the-unified-experience-is-live/

SSRS report with query D365 fo dynamics query with records to include in report

DP CLASS

/// <summary>
/// RDP class for SCRF Export report
/// </summary>
[
    SRSReportQueryAttribute(queryStr(LSSCRFExportQuery))
]
public final class LSSCRFExportDP extends SRSReportDataProviderPreProcessTempDB
{
    LSSCRFExportReportTmp   scrfExportReportTmp;
    NoYes                   scrfEnhancementFeature;

    /// <summary>
    /// Method to get report data for LSSCRFExportReportTmp table
    /// </summary>
    /// <returns>LSSCRFExportReportTmp</returns>
    [SRSReportDataSetAttribute(tableStr(LSSCRFExportReportTmp))]
    public LSSCRFExportReportTmp getLSSCRFExportReportTmp()
    {
        select scrfExportReportTmp;
        return scrfExportReportTmp;
    }

    /// <summary>
    /// Method to process report data
    /// </summary>
    public void processReport()
    {
        Query                   query       = this.parmQuery();
        QueryRun                queryRun    = new QueryRun(query);
        LSSCRFMainTable         scrfMainTable;
        LSSCRFLine              scrfLine;
        LSSCRFFeatureLine       featureLine;

        scrfEnhancementFeature = LSEnableDisableFeaturesSetup::find(LSFeaturesList::SCRFEnhancement).Enabled;
        scrfExportReportTmp.setConnection(this.parmUserConnection());

        while (queryRun.next())
        {
            scrfMainTable   = queryRun.get(tableNum(LSSCRFMainTable));
            scrfLine        = queryRun.get(tableNum(LSSCRFLine));
            featureLine     = queryRun.get(tableNum(LSSCRFFeatureLine));

            this.insertData(scrfMainTable, scrfLine, featureLine);
        }
    }

    /// <summary>
    /// Method to insert report data into temp table
    /// </summary>
    /// <param name = "_scrfMainTable">_scrfMainTable</param>
    /// <param name = "_scrfLine">_scrfLine</param>
    /// <param name = "_featureLine">_featureLine</param>
    public void insertData(LSSCRFMainTable _scrfMainTable, LSSCRFLine _scrfLine, LSSCRFFeatureLine _featureLine)
    {
        LSSCRFPackagingLine primaryPackagingLine, secondaryPackagingLine, tertiaryPackagingLine, quarternaryPackagingLine;

        select firstonly primaryPackagingLine
            where primaryPackagingLine.LinePackagingType == LSLinePackagingType::Primary
            && primaryPackagingLine.FeatureLineRecId == _featureLine.RecId;

        select firstonly secondaryPackagingLine
            where secondaryPackagingLine.LinePackagingType == LSLinePackagingType::Secondary
            && secondaryPackagingLine.FeatureLineRecId == _featureLine.RecId;

        select firstonly tertiaryPackagingLine
            where tertiaryPackagingLine.LinePackagingType == LSLinePackagingType::Tertiary
            && tertiaryPackagingLine.FeatureLineRecId == _featureLine.RecId;

        select firstonly quarternaryPackagingLine
            where quarternaryPackagingLine.LinePackagingType == LSLinePackagingType::Quartenary
            && quarternaryPackagingLine.FeatureLineRecId == _featureLine.RecId;

        scrfExportReportTmp.clear();

        scrfExportReportTmp.SCRFId                                  = _scrfMainTable.SCRFId;
        scrfExportReportTmp.Description                             = _scrfMainTable.Description;
        scrfExportReportTmp.SCRFStatus                              = _scrfMainTable.SCRFStatus;
        scrfExportReportTmp.SCRFWorkflowStatus                      = _scrfMainTable.SCRFWorkflowStatus;
        scrfExportReportTmp.SubmittedBy                             = _scrfMainTable.SubmittedBy;
        scrfExportReportTmp.SubmittedDate                           = _scrfMainTable.SubmittedDate;
        scrfExportReportTmp.EffectiveDate                           = _scrfMainTable.EffectiveDate;
        scrfExportReportTmp.CreatedFor                              = _scrfMainTable.CreatedFor;
        scrfExportReportTmp.ReleaseNo                               = _scrfMainTable.ReleaseNo;
        // strmin() - Former type
        scrfExportReportTmp.ProductSubGroup                         = _scrfMainTable.ProductSubGroup;
        scrfExportReportTmp.ReasonForChange                         = _scrfMainTable.ReasonForChange;
        scrfExportReportTmp.HoldReason                              = _scrfMainTable.HoldReason;
        scrfExportReportTmp.Provisional                             = _scrfMainTable.Provisional;
        scrfExportReportTmp.CustAccount                             = _scrfMainTable.CustAccount;
        scrfExportReportTmp.CountryOfSaleMulti                      = _scrfMainTable.CountryOfSaleMulti;
        // strmin() - Machine
        scrfExportReportTmp.RegionCode                              = _scrfMainTable.RegionCode;
        scrfExportReportTmp.Standard                                = _scrfMainTable.Standard;
        scrfExportReportTmp.Standard2                               = _scrfMainTable.Standard2;
        scrfExportReportTmp.Standard3                               = _scrfMainTable.Standard3;
        scrfExportReportTmp.BatchSizeId                             = _scrfMainTable.BatchSizeId;
        [
            scrfExportReportTmp.PreprintCode,
            scrfExportReportTmp.BodySamplingCode,
            scrfExportReportTmp.ExtBodyLabName
        ]                                                           = this.getBodySampling(_scrfMainTable.SCRFId);
        scrfExportReportTmp.Thai501K                                = _scrfMainTable.Thai501K;
        scrfExportReportTmp.AdditionalTestReq                       = strRem('\'' + _scrfMainTable.AdditionalTestReq, '\'-');
            
        scrfExportReportTmp.ProductSelection                        = _scrfLine.ProductSelection;

        scrfExportReportTmp.FactoryProductCode                      = _featureLine.FactoryProductCode;
        scrfExportReportTmp.LatexType                               = _featureLine.LatexType;
        scrfExportReportTmp.Shape                                   = _featureLine.Shape;
        scrfExportReportTmp.Texture                                 = _featureLine.Texture;
        scrfExportReportTmp.ThicknessFeature                        = _featureLine.ThicknessFeature;
        scrfExportReportTmp.DimesionSpecification                   = _featureLine.DimesionSpecification;
        scrfExportReportTmp.Size                                    = _featureLine.Size;
        scrfExportReportTmp.Length                                  = _featureLine.Length;
        scrfExportReportTmp.Thickness                               = _featureLine.Thickness;
        scrfExportReportTmp.Width                                   = _featureLine.Width;
        scrfExportReportTmp.LubricantType                           = _featureLine.LubricantType;
        scrfExportReportTmp.LubricantQty                            = _featureLine.LubricantQty;
        scrfExportReportTmp.Color                                   = _featureLine.Color;
        scrfExportReportTmp.Flavour                                 = _featureLine.Flavour;
        scrfExportReportTmp.Masking                                 = _featureLine.Masking;
        scrfExportReportTmp.ExpiryDate                              = _featureLine.ExpiryDate;
        scrfExportReportTmp.FoilType                                = _featureLine.FoilType;

        scrfExportReportTmp.FilmType_Primary                        = primaryPackagingLine.FilmType;
        scrfExportReportTmp.PrintingOn_Primary                      = primaryPackagingLine.RecId ? enum2Str(primaryPackagingLine.PrintingOn) : '';
        scrfExportReportTmp.LotType_Primary                         = primaryPackagingLine.RecId ? enum2Str(primaryPackagingLine.LotType) : '';
        scrfExportReportTmp.ExpDateFormat_Primary                   = primaryPackagingLine.ExpDateFormat;
        scrfExportReportTmp.AdditionalPrinting_Primary              = primaryPackagingLine.AdditionalPrinting;
        scrfExportReportTmp.AdditionalPrintText_Primary             = primaryPackagingLine.AdditionalPrintText;
        scrfExportReportTmp.TopPk_Primary                           = primaryPackagingLine.TopPk;
        scrfExportReportTmp.BottomPk_Primary                        = primaryPackagingLine.BottomPk;
        scrfExportReportTmp.TopPk1_Primary                          = primaryPackagingLine.TopPk1;
        scrfExportReportTmp.BottomPk1_Primary                       = primaryPackagingLine.BottomPk1;
        scrfExportReportTmp.StripLength_Primary                     = primaryPackagingLine.StripLength;

        scrfExportReportTmp.PartialStripAllowed_Primary             = primaryPackagingLine.RecId ? enum2Str(primaryPackagingLine.PartialStripAllowed) : '';
        scrfExportReportTmp.AllowableStrips_Primary                 = strLRTrim(strReplace(primaryPackagingLine.AllowableStrips, 'Max. partial strip allowed', strMin()));
        scrfExportReportTmp.PartialStrips_Primary                   = primaryPackagingLine.RecId ? enum2Str(primaryPackagingLine.PartialStripsPacking) : '';
        scrfExportReportTmp.BulkStripsOrFullyPacked_Primary         = primaryPackagingLine.RecId ? enum2Str(primaryPackagingLine.BulkStripsOrFullyPacked) : '';
        scrfExportReportTmp.PackingInfo_Primary                     = primaryPackagingLine.PackingInfo;
        scrfExportReportTmp.AddPKNum_Primary                        = this.getAdditionalPkNum(primaryPackagingLine.RecId);
            
        scrfExportReportTmp.Type_Secondary                          = secondaryPackagingLine.Type;
        scrfExportReportTmp.PKNumber_Secondary                      = secondaryPackagingLine.PKNumber;
        scrfExportReportTmp.AddPkNum_Secondary                      = this.getAdditionalPkNum(secondaryPackagingLine.RecId);
        scrfExportReportTmp.CondomQtyIn2ndPack_Secondary            = secondaryPackagingLine.CondomQtyIn2ndPack;
        scrfExportReportTmp.PackingInfo_Secondary                   = secondaryPackagingLine.PackingInfo;
        scrfExportReportTmp.AdditionalPrintText_Secondary           = secondaryPackagingLine.AdditionalPrintText;

        scrfExportReportTmp.Type_Tertiary                           = tertiaryPackagingLine.Type;
        scrfExportReportTmp.PKNumber_Tertiary                       = tertiaryPackagingLine.PKNumber;
        scrfExportReportTmp.AddPkNum_Tertiary                       = this.getAdditionalPkNum(tertiaryPackagingLine.RecId);
        scrfExportReportTmp.CondomQtyIn3rdPack_Tertiary             = tertiaryPackagingLine.CondomQtyIn3rdPack;
        scrfExportReportTmp.PackingInfo_Tertiary                    = tertiaryPackagingLine.PackingInfo;
        scrfExportReportTmp.AdditionalPrintText_Tertiary            = tertiaryPackagingLine.AdditionalPrintText;

        scrfExportReportTmp.Type_Quarternary                        = quarternaryPackagingLine.Type;
        scrfExportReportTmp.PKNumber_Quarternary                    = quarternaryPackagingLine.PKNumber;
        scrfExportReportTmp.AddPkNum_Quarternary                    = this.getAdditionalPkNum(quarternaryPackagingLine.RecId);
        scrfExportReportTmp.CondomQtyInMasterCarton_Quarternary     = quarternaryPackagingLine.CondomQtyInMasterCarton;
        scrfExportReportTmp.PartialCartonAllowed_Quarternary        = quarternaryPackagingLine.RecId ? enum2Str(quarternaryPackagingLine.PartialCartonAllowed) : '';
        scrfExportReportTmp.PackingInfo_Quarternary                 = quarternaryPackagingLine.PackingInfo;

        scrfExportReportTmp.SCRFEnhancementFeature                  = scrfEnhancementFeature;
        scrfExportReportTmp.insert();
    }

    /// <summary>
    /// Method to get additional PK numbers
    /// </summary>
    /// <param name = "_recId">_recId</param>
    /// <returns>Additional PK numbers</returns>
    public str getAdditionalPkNum(RecId _recId)
    {
        LSSCRFPackAdditionalReq primaryAddReq;
        str                     addPKNum;

        while select PKNumber from primaryAddReq
            where primaryAddReq.LSSCRFPackagingLine == _recId && primaryAddReq.PKNumber
        {
            addPKNum += primaryAddReq.PKNumber + ',';
        }

        return addPKNum;
    }

    /// <summary>
    /// Method to get the body sampling data
    /// </summary>
    /// <param name = "_scrfId">_scrfId</param>
    /// <returns>Body sampling data</returns>
    public container getBodySampling(LSSCRFId _scrfId)
    {
        LSSCRFApprovalPreprintBodySampling  bodySampling;
        LSPreprintCode                      prePrintCode;
        LSBodySamplingCode                  bodySamplingCode;
        LSExtBodyLabName                    extBodyLabName;

        while select PreprintCode, BodySamplingCode, ExtBodyLabName from bodySampling
            where bodySampling.SCRFId == _scrfId
        {
            if(bodySampling.PreprintCode != strMin())
            {
                prePrintCode += bodySampling.PreprintCode + ',';
            }
            if(bodySampling.BodySamplingCode != strMin())
            {
                bodySamplingCode += bodySampling.BodySamplingCode + ',';
            }
            if(bodySampling.ExtBodyLabName != strMin())
            {
                extBodyLabName += bodySampling.ExtBodyLabName + ',';
            }
        }

        return [prePrintCode, bodySamplingCode, extBodyLabName];
    }

}


Controller

/// <summary>
/// Controller class for Export SCRF report
/// </summary>
public class LSSCRFExportReportController extends SrsReportRunController implements BatchRetryable
{
    /// <summary>
    /// Main method
    /// </summary>
    /// <param name = "_args">_args</param>
    public static void main(Args _args)
    {
        LSSCRFExportReportController controller = new LSSCRFExportReportController();

        controller.parmReportName(ssrsReportStr(LSSCRFExportReport, DesginV1));
        controller.parmArgs(_args);
        controller.startOperation();
    }

    public ClassDescription caption()
    {
        return "@LS_HISOL:ExportSCRFReport";
    }

    /// <summary>
    /// Specifies if the batch task is retryable for transient exceptions or not.
    /// </summary>
    /// <returns>
    /// If true is returned, the batch task is retryable, otherwise it is not.
    /// </returns>
    [Hookable(false)]
    final boolean isRetryable()
    {
        return true;
    }

}


Find Current Exchange rate using X++ / Ax

/// <summary>

/// Global class used for generic methods.

/// added by santhosh 

/// </summary>

class LSGlobal

{

    public static real LSexchangeRate(

                                        CurrencyCode fromCurrency,

                                        CurrencyCode toCurrency,

                                        TransDate    transDate = today())

    {

        ExchangeRate                exchangeRate;

        ExchangeRateType            ExchangeRateType;

        ExchangeRateCurrencyPair    exchangeRateCurrencyPair;

        real                        exchRate;

    

        select firstonly exchangeRateCurrencyPair

            where exchangeRateCurrencyPair.ExchangeRateType == Ledger::find(Ledger::current()).DefaultExchangeRateType

            &&  exchangeRateCurrencyPair.FromCurrencyCode   == fromCurrency

            &&  exchangeRateCurrencyPair.ToCurrencyCode     == toCurrency;


        exchRate = exchangeRate::findByDate(exchangeRateCurrencyPair.RecId,transDate).ExchangeRate;

        return exchRate/100;

    }


}

Wednesday, October 9, 2024

Planned order in d365

What is Planned Transfer Orders in d365


In Dynamics 365 Finance and Operations (D365 F&O), Planned Transfer Orders are part of the Master Planning module, which is used to handle intercompany or intersite transfers of goods based on planned demand. Essentially, they represent a forecasted or planned movement of inventory between two different warehouses, sites, or legal entities within an organization.


Key Features of Planned Transfer Orders:

1. Demand-Driven: They are generated when there is a forecast or demand for a product at a particular location, but the inventory needs to be transferred from another location to meet that demand.

  

2. Generated by Master Planning: When Master Planning runs, it analyzes current stock levels, future demand, and supply, and it generates planned transfer orders if there’s a need to move inventory between different sites or warehouses.


3. Conversion to Transfer Orders: Planned transfer orders are not actual transactions. They are suggestions or plans that need to be reviewed and converted into actual transfer orders, which can then be processed for execution.


4. Optimization of Stock Levels: By using planned transfer orders, a company can ensure optimal stock levels across different locations, reducing the risk of stockouts in some locations while preventing overstock in others.


5. Lead Time Consideration: When creating planned transfer orders, D365 F&O takes into account lead times, transportation methods, and other logistical details to ensure that the stock will arrive in time to meet demand.


In short, Planned Transfer Orders help streamline internal logistics and stock movements across different locations within an organization, making sure that goods are in the right place at the right time.






Understanding the Planned Order Process in Dynamics 365 F&O

The process of handling Planned Orders in Dynamics 365 F&O starts with Master Planning and ends with the firming of the order. Let’s break down this process step by step:


1. Master Planning Setup

- Define planning parameters such as lead times, item coverage, safety stock, and replenishment rules (like make-to-order or make-to-stock).


2. Demand Forecasting and Supply Analysis

- Master planning runs based on sales orders, demand forecasts, or safety stock levels.

- The system analyzes the demand and supply requirements for the products.


3. Master Planning Run

- Execute Master Planning or Forecast Planning to create suggestions for fulfilling demands.

- The system generates Planned Orders for production, purchase, or transfer.


4. Review Planned Orders

- Users can review the Planned Production Orders, Planned Purchase Orders, or Planned Transfer Orders generated.

- The planner checks if the planned orders align with business needs and adjusts any quantities, dates, or other parameters if necessary.


5. Firming the Planned Order

- Once the planner is satisfied with the suggested orders, they firm the planned orders.

- Firming converts the planned order into an actionable order:

  - Planned Purchase Order → Purchase Order

  - Planned Production Order → Production Order

  - Planned Transfer Order → Transfer Order


6. Execution of Firmed Orders

- After firming, the purchase orders are sent to suppliers, production orders are sent to manufacturing, and transfer orders are processed for moving goods between warehouses.


7. Completion of Order

- The process ends when the firmed orders are completed (products are produced, purchased, or transferred as required).