Data Mining – Mining Model Prediction

Time Series Query

SELECT
([DC Cust Product Model].[DC Cust Product Model]) as [ModelDCCustProduct],
(PredictTimeSeries([DC Cust Product Model].[Revenue],3,18,EXTEND_MODEL_CASES)) as [PredictedRevenue],
PredictTimeSeries([DC Cust Product Model].[Quantity],3,18,EXTEND_MODEL_CASES) as [PredictedQuantity],
(SELECT
$Time,
PredictVariance([Revenue]) AS [VARIANCE_REV],
PredictStdev([Revenue]) AS [STDEV_REV]
FROM
PredictTimeSeries([DC Cust Product Model].[Revenue],3,18,EXTEND_MODEL_CASES) AS t
) AS t
From
[DC Cust Product Model]
PREDICTION JOIN
OPENQUERY([MLMagDW],
‘SELECT
[NumOfWeek],
[ReportingMonth],
[DCCustProductModel],
[Revenue],
[Quantity]
FROM
[dbo].[NewTrainData_DCCustProductModel]
‘) AS t
ON
[DC Cust Product Model].[Num Of Week] = t.[NumOfWeek] AND
[DC Cust Product Model].[Reporting Month] = t.[ReportingMonth] AND
[DC Cust Product Model].[DC Cust Product Model] = t.[DCCustProductModel] AND
[DC Cust Product Model].[Revenue] = t.[Revenue] AND
[DC Cust Product Model].[Quantity] = t.[Quantity]

Posted in Data Mining, Machine Learning | Leave a comment

Python – Data Processing – Get data from SQL Table

# -*- coding: utf-8 -*-
“””
Created on Thu Sep 26 09:33:17 2019
Magnussen Machine Learning – Forecast Time Series
@author: Jake
“””
import numpy as np
import pandas as pd
#import pandas.io.sql as psql
import matplotlib.pyplot
import pyodbc

def getData():

conn = pyodbc.connect(‘Driver={SQL Server};’
‘Server=localhost;’
‘Database=MLMagDW;’
‘Trusted_Connection=yes;’)
try:
query = ‘SELECT * FROM dbo.TrainData_DCCustProductModel’
traindata = pd.read_sql(query,conn)
except ConnectionError(‘Unable to connect’):
“””
cursor = conn.cursor()
cursor.execute(‘SELECT * FROM dbo.TrainData_DCCustProductModel’)
for row in cursor:
print(row)
returnfirstrow = cursor.fetchone()
print(returnfirstrow)
“””
#returnall = cursor.fetchall()
#print(returnall)
#only print head
“””
title = [i[0] for i in cursor.description]
print(title)
returnfirstrow = cursor.fetchone()
print(returnfirstrow)
traindata = pd.DataFrame(cursor.fetchall(),title)

finally:
cursor.close()
“””

if __name__ == “__main__”:
getData();

Posted in Machine Learning, Python | Leave a comment

GENTRAN/GIS/SI DOCUMENTATION, TUTORIALS AND OTHER STUFF

I see a lot of requests about training/documentation/tutorials for Gentran/GIS/SI. Maybe, one day I post some basic things about SI/GIS administration and maps, but now I’d like to share some links to very useful documents from IBM. Now they have a very good online documentation, but I’m also using PDF files from FTP:

Thanks to https://edigkim.wordpress.com/2014/03/19/gentrangissi-documentation-tutorials-and-other-stuff/

Posted in EDI | Tagged , , | Leave a comment

Keep the Filter section always expanded in AxGridView

If you add the below javascript code to your user control at the bottom of the markup file ( .ascx file) then the filter section will always be in expanded mode both during initial load as well as during subsequent postbacks. Since the below code uses lot’s of internals such as ids and stylesheet names, it is not guaranteed to work in subsequent releases of EP. But if you need this capability in  Ax 2009 and specific pages, this may be useful.

<script type=”text/javascript”>

function ExpandFilter(sender, args) {

var elem = document.getElementById(‘div_<%=this.AxGridView1.FilterControl.ClientID%>’);

var parentDiv = elem.parentNode;

var filterArea = DynamicsFilter.GetFilterArea(elem);

if (DynamicsCommon.IsNull(filterArea)) return;

elem.style.display = ”;

var applylink = DynamicsCommon.FindInstance(parentDiv, “applyfilter”);

var resetlink = DynamicsCommon.FindInstance(parentDiv, “resetfilter”);

var editfilterlink = DynamicsCommon.FindInstance(parentDiv, “editfilter”);

if (!DynamicsCommon.IsNull(applylink) && !DynamicsCommon.IsNull(resetlink) && !DynamicsCommon.IsNull(editfilterlink)) {

editfilterlink.style.display = ‘none’;

applylink.style.display = ”;

resetlink.style.display = ”;

}

}

Sys.WebForms.PageRequestManager.getInstance().add_endRequest(ExpandFilter);

ExpandFilter();

</script>

 

Replace AXGridView1 with your AX Grid view.

http://community.dynamics.com/ax/b/axsolutionsmonkey/archive/2009/04/02/always-keep-the-filter-section-expanded-in-axgridview.aspx

Posted in Uncategorized | Leave a comment

Enterprise portal datepicker gives an error on second click

Enterprise Portal – strange behaviour with date-picker

Basically from same site quoted:

In the web.config file you will probably find a similar line: . When you change the debug parameter to false () and execute a iisreset, this issue is solved. You will typically find this issue only in DEV-environments because debug should be turned off in a live environment.
Unfortunately Microsoft won’t create a Hotfix for Ax 2009 to solve this issue permanent. They ported the issue to Ax 6.0 and in the mean time we’ll have to use the work-around.

Posted in Uncategorized | Leave a comment

Advanced AXGridview with customs fields

grid

<dynamics:AxGridView ID=”gridEPPurchTableEdit” runat=”server” DataKeyNames=”RecId”
DataMember=”TmpPurchLine” DataSourceID=”dsItemArrival” AllowEdit=”false”
AllowPaging=”False” GroupField=”InventDimId” ShowFilter=”false” AllowSelection=”false”
GroupFieldDisplayName=”Site”
ExpandEditableRow=”True” >
<HeaderStyle BackColor=”#507CD1″ ForeColor=”White”/>
<EditRowStyle Height=”15px” />
<SelectedRowStyle Height=”15px” Wrap=”False” />
<AlternatingRowStyle BackColor=”#F3F3F3″/>
<Columns>
<asp:TemplateField HeaderText=”RecId” Visible=”false”>
<HeaderStyle HorizontalAlign=”Center” ForeColor=”white” Font-Bold=”true” BorderColor=”#D2D2D2″ BorderStyle=”Solid” BorderWidth=”1″ Width=”60px” Height=”23px”/>
<ItemStyle BorderColor=”#D2D2D2″ BorderStyle=”Solid” BorderWidth=”1″ HorizontalAlign=”Center” Width=”60px” />
<ItemTemplate>
<asp:Label runat=”server” ID=”txtRecid” Width=”57px” Text='<%#Eval(“RecId”) %>’ style=’text-align:center’ />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText=”Select”>
<HeaderStyle HorizontalAlign=”Center” ForeColor=”white” Font-Bold=”true” BorderColor=”#D2D2D2″ BorderStyle=”Solid” BorderWidth=”1″ Width=”30px” Height=”23px”/>
<ItemStyle BorderColor=”#D2D2D2″ BorderStyle=”Solid” BorderWidth=”1″ HorizontalAlign=”Center” Width=”20px” />
<ItemTemplate>
<asp:CheckBox runat=”server” ID=”chkbxSelectLine” Width=”30px” Checked=”True” OnCheckedChanged=”chkbxSelectLine_checkedChanged” AutoPostBack=”true”/>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText=”Ship Qty.”>
<HeaderStyle HorizontalAlign=”Center” ForeColor=”white” Font-Bold=”true” BorderColor=”#D2D2D2″ BorderStyle=”Solid” BorderWidth=”1″ Width=”60px” Height=”23px”/>
<ItemStyle BorderColor=”#D2D2D2″ BorderStyle=”Solid” BorderWidth=”1″ HorizontalAlign=”Center” Width=”60px” />
<ItemTemplate>
<asp:TextBox runat=”server” ID=”txtShipQty” Width=”57px” Text='<%#Eval(“getRemainQty**”) %>’ style=’text-align:center’/>
</ItemTemplate>
</asp:TemplateField>
<dynamics:AxBoundField DataSet=”VTVEPItemArrivalEdit” DataSetView=”TmpPurchLine” DataField=”ItemId” ReadOnly=”true” >
<ItemStyle HorizontalAlign=”Left” BorderColor=”#D2D2D2″ BorderStyle=”Solid” BorderWidth=”1″ Width=”80px” />
<HeaderStyle HorizontalAlign=”Center” Font-Bold=”true” BorderColor=”#D2D2D2″ BorderStyle=”Solid” BorderWidth=”1″ ForeColor=”White” Width=”80px”/>
</dynamics:AxBoundField>
<dynamics:AxBoundField DataField=”ExternalItemId**” DataSet=”VTVEPItemArrivalEdit” DataSetView=”TmpPurchLine”
SortExpression=”ExternalItemId” ReadOnly=”true” ItemStyle-Width=”30″ Visible=”false”>
<ItemStyle HorizontalAlign=”Center” BorderColor=”#D2D2D2″ BorderStyle=”Solid” BorderWidth=”1″ Width=”80px” />
<HeaderStyle HorizontalAlign=”Center” Font-Bold=”true” BorderColor=”#D2D2D2″ BorderStyle=”Solid” BorderWidth=”1″ ForeColor=”White” Width=”80px”/>
</dynamics:AxBoundField>

<asp:TemplateField HeaderText=”Site”>
<HeaderStyle HorizontalAlign=”Center” ForeColor=”white” Font-Bold=”true” BorderColor=”#D2D2D2″ BorderStyle=”Solid” BorderWidth=”1″ Width=”30px” Height=”23px”/>
<ItemStyle BorderColor=”#D2D2D2″ BorderStyle=”Solid” BorderWidth=”1″ HorizontalAlign=”Center” Width=”30px” />
<ItemTemplate>
<asp:Label runat=”server” ID=”txtInventSite” Width=”30px” Text='<%#Eval(“getInventSiteId**”) %>’ style=’text-align:center’ ReadOnly=”true”/>
</ItemTemplate>
</asp:TemplateField>
…

Using in .CS

protected void chkbxSelectLine_checkedChanged(object sender, System.EventArgs e)
{

CheckBox selectLine = (CheckBox)sender;
for(int i = 0; i<gridEPPurchTableEdit.Rows.Count;i++)
{
Label site = (Label)gridEPPurchTableEdit.Rows[i].FindControl(“txtInventSite”);
if (site.Text == “D”)
{
CheckBox lines = (CheckBox)gridEPPurchTableEdit.Rows[i].FindControl(“chkbxSelectLine”);
lines.Checked = selectLine.Checked;
Label recId = (Label)gridEPPurchTableEdit.Rows[i].FindControl(“txtRecId”);
}
}

}

Posted in Enterprise Portal Development | Leave a comment

Method ‘item’ in COM object of class ‘Range’ returned error code 0x800A03EC ()

We need delete the export definition group (only delete the definition group we use to export and import). Create a new one and try different type of Export to or Import to.

Posted in Uncategorized | Leave a comment

How to select largest records in a group from a table

Theory is:

– We need a field with unique value (such as: CreatedDateTime, Voucher Num, or an amount – select top 1)

– Use Max (or Min) function to get what value you want.

– Group by fields

Example:

Select salesid, confirmdate, MAX(CONFIRMID) as ConfirmID
from CUSTCONFIRMTRANS
group by SALESID, CONFIRMDATE

Then, we join with the master table.

Select
a.SALESID,
a.CONFIRMID,
a.CONFIRMDATE,
a.CREATEDDATETIME,
QTY
from CUSTCONFIRMTRANS a
join (Select salesid, confirmdate, MAX(createddatetime) as CreatedDateTime from CUSTCONFIRMTRANS group by SALESID, CONFIRMDATE)b
on a.SALESID = b.SALESID and a.CREATEDDATETIME = b.CreatedDateTime
where a.DATAAREAID = ‘m03x’ and a.SALESID = ‘751730’

Select
a.SALESID,
a.CONFIRMID,
a.CONFIRMDATE,
a.CREATEDDATETIME,
QTY
from CUSTCONFIRMTRANS a
join (Select salesid, confirmdate, MAX(CONFIRMID) as ConfirmID from CUSTCONFIRMTRANS group by SALESID, CONFIRMDATE)b
on a.SALESID = b.SALESID and a.CONFIRMID = b.ConfirmID
where a.DATAAREAID = ‘m03x’ and a.SALESID = ‘751730’

Posted in Select stament, SQL | Tagged , | 1 Comment

The request failed with HTTP status 405: Method Not Allowed

The request failed with HTTP status 405: Method Not Allowed.

11122009

Recently on the Axapta-Knowledge-Village discussion board, the following workflow issue was raised, the user had an error when trying to validate his workflow url with the following message being displayed: “The request failed with HTTP status 405: Method Not Allowed.” He was running on the following System configuration:
1. Windows 2008 R2 64 bit.
2. SQL Server 2008
3. IIS 7

To resolve this error. I believe the simple solution suggested by manoj is to set your IIS application Pool’s 32bit property to true

IIS –>Application pool of WF–> rightclick advanced settings and change 32 bit to TRUE.

 

Source: http://workflowax.wordpress.com/2009/12/11/the-request-failed-with-http-status-405-method-not-allowed/?year=2009&monthnum=12&day=11&like=1&_wpnonce=20893f8569&wpl_rand=8e26575dad

Posted in Uncategorized | 1 Comment

Failed to find workflow configuration.

Error :  Failed to find workflow configuration.

This error comes when a configuration is deleted from the workflow, but refrence is still there in the workflowworkitem table so we have to delete it by running a job.

//Jake – Aug 10, 2012
// Fixe error Failed to find the workflow configuration
static void deleteJunkWorkflowWorkItem(Args _args)
{

WorkflowWorkItemTable wrkItem, wrkItem1;
WorkflowConfigurationTable workFlowCon;
;

while select wrkItem
{
select workFlowCon where workFlowCon.ConfigurationId == wrkItem.ConfigurationId;
if(!workFlowCon)
{
info(strfmt(‘%1’, wrkItem.ConfigurationId));
delete_from wrkItem1 where wrkItem1.RecId == wrkItem.RecId;
}

       }
}

Posted in Enterprise Portal Development | Leave a comment