2017年3月22日 星期三

How to import Excel's Salrs Budget into Navision

In Navision, we use dimension "Region","SalesCode" and "CustomerCode". if we use Navision import function, it's difficult . and Excel format for Sales is more easier. but excel format is different with Navision. so I tried to use stored procedures to convert format from column to row.

1. Original Excel Format. Fig1


2. Import Excel File into table of VFFSalesBudgetRawIn by SSMS . Fig2 & 3


3. After import, use select command to check. Fig4

4. Run Stored Procedures to convert data format from columns to rows table of  VFFSalesBudgetOut


USE [VFFnav2013]
GO
/****** Object: Convert the table of dbo.VFFSalesBudgetRawIn to dbo.VFFSalesBudgetOut, then copy & Paste into Navision ****/

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO



Delete from dbo.[VFFSalesBudgetOut]
Go

Declare        @id                 int,
@Item                Char(20),
@Region        Char(20),
@SalesCode        Char(10),
@Customer       Char(10),
@M1                Decimal(18,4),
@M2                Decimal(18,4),
@M3                Decimal(18,4),
@M4                Decimal(18,4),
@M5                Decimal(18,4),
@M6                Decimal(18,4),
@M7                Decimal(18,4),
@M8                Decimal(18,4),
@M9                Decimal(18,4),
@M10                Decimal(18,4),
@M11                Decimal(18,4),
@M12                Decimal(18,4),
@M1Q                Decimal(18,4),
@M2Q                Decimal(18,4),
@M3Q                Decimal(18,4),
@M4Q                Decimal(18,4),
@M5Q                Decimal(18,4),
@M6Q                Decimal(18,4),
@M7Q                Decimal(18,4),
@M8Q                Decimal(18,4),
@M9Q                Decimal(18,4),
@M10Q        Decimal(18,4),
@M11Q        Decimal(18,4),
@M12Q        Decimal(18,4),
@Descrip        Char(100),
@UPrice        Decimal(18, 4),
@IDCount        Int

Set        @id = 1
Set        @M1 = 0
set        @M2 = 0
Set        @M3 = 0
Set         @M4 = 0
Set        @M5 = 0
Set        @M6 = 0
set        @M7 = 0
Set        @M8 = 0
Set         @M9 = 0
Set        @M10 = 0
Set         @M11 = 0
Set        @M12 = 0
Set        @M1Q = 0
set        @M2Q = 0
Set        @M3Q = 0
Set         @M4Q = 0
Set        @M5Q = 0
Set        @M6Q = 0
set        @M7Q = 0
Set        @M8Q = 0
Set         @M9Q = 0
Set        @M10Q = 0
Set         @M11Q = 0
Set        @M12Q = 0
Set         @UPrice = 0



Select @IDCount = Max(IDNo) from dbo.[VFFSalesBudgetRawIn]

WHILE @id <= @IDCount
Begin
Select         @Item = Item,         @Region = Region, @SalesCode = SalesCode, @Customer = Customer
@M1 = M1Amt, @M2 = M2Amt, @M3 = M3Amt, @M4 = M4Amt, @M5 = M5Amt, @M6 = M6Amt, @M7 = M7Amt, @M8 = M8Amt, @M9 = M9Amt, @M10 = M10Amt, @M11 = M11Amt, @M12 = M12Amt,
@M1Q = M1Qty, @M2Q = M2Qty, @M3Q = M3Qty, @M4Q = M4Qty, @M5Q = M5Qty, @M6Q = M6Qty, @M7Q = M7Qty, @M8Q = M8Qty, @M9Q = M9Qty, @M10Q = M10Qty, @M11Q = M11Qty, @M12Q = M12Qty,
@Descrip = Description, @UPrice = Price
From         dbo.[VFFSalesBudgetRawIn]
where IDNo = @id

          INSERT INTO [dbo].[VFFSalesBudgetOut]
                   (Item, Region, SalesCode, Customer, Month, MonthAmt, MonthQty, Descrip, UPrice)
        VALUES        (@Item, @Region, @SalesCode, @Customer, '1/1/2015', @M1, @M1Q, @Descrip, @UPrice)

          INSERT INTO [dbo].[VFFSalesBudgetOut]
                   (Item, Region, SalesCode, Customer, Month, MonthAmt, MonthQty, Descrip, UPrice)
        VALUES        (@Item, @Region, @SalesCode, @Customer, '2/1/2015', @M2, @M2Q, @Descrip, @UPrice)

          INSERT INTO [dbo].[VFFSalesBudgetOut]
                   (Item, Region, SalesCode, Customer, Month, MonthAmt, MonthQty, Descrip, UPrice)
        VALUES        (@Item, @Region, @SalesCode, Customer, '3/1/2015', @M3, @M3Q, @Descrip, @UPrice)

          INSERT INTO [dbo].[VFFSalesBudgetOut]
                   (Item, Region, SalesCode, Customer, Month, MonthAmt, MonthQty, Descrip, UPrice)
        VALUES        (@Item, @Region, @SalesCode, Customer, '4/1/2015', @M4, @M4Q, @Descrip, @UPrice)

          INSERT INTO [dbo].[VFFSalesBudgetOut]
                   (Item, Region, SalesCode, Customer, Month, MonthAmt, MonthQty, Descrip, UPrice)
        VALUES        (@Item, @Region, @SalesCode, Customer, '5/1/2015', @M5, @M5Q, @Descrip, @UPrice)

          INSERT INTO [dbo].[VFFSalesBudgetOut]
                   (Item, Region, SalesCode, Customer, Month, MonthAmt, MonthQty, Descrip, UPrice)
        VALUES        (@Item, @Region, @SalesCode, Customer, '6/1/2015', @M6, @M6Q, @Descrip, @UPrice)

          INSERT INTO [dbo].[VFFSalesBudgetOut]
                   (Item, Region, SalesCode, Customer, Month, MonthAmt, MonthQty, Descrip, UPrice)
        VALUES        (@Item, @Region, @SalesCode, Customer, '7/1/2015', @M7, @M7Q, @Descrip, @UPrice)

          INSERT INTO [dbo].[VFFSalesBudgetOut]
                   (Item, Region, SalesCode, Customer, Month, MonthAmt, MonthQty, Descrip, UPrice)
        VALUES        (@Item, @Region, @SalesCode, Customer, '8/1/2015', @M8, @M8Q, @Descrip, @UPrice)

          INSERT INTO [dbo].[VFFSalesBudgetOut]
                   (Item, Region, SalesCode, Customer, Month, MonthAmt, MonthQty, Descrip, UPrice)
        VALUES        (@Item, @Region, @SalesCode, Customer, '9/1/2015', @M9, @M9Q, @Descrip, @UPrice)

          INSERT INTO [dbo].[VFFSalesBudgetOut]
                   (Item, Region, SalesCode, Customer, Month, MonthAmt, MonthQty, Descrip, UPrice)
        VALUES        (@Item, @Region, @SalesCode, Customer, '10/1/2015', @M10, @M10Q, @Descrip, @UPrice)

          INSERT INTO [dbo].[VFFSalesBudgetOut]
                   (Item, Region, SalesCode, Month, MonthAmt, MonthQty, Descrip, UPrice)
        VALUES        (@Item, @Region, @SalesCode, '11/1/2015', @M11, @M11Q, @Descrip, @UPrice)

          INSERT INTO [dbo].[VFFSalesBudgetOut]
                   (Item, Region, SalesCode, Customer, Month, MonthAmt, MonthQty, Descrip, UPrice)
        VALUES        (@Item, @Region, @SalesCode, Customer, '12/1/2015', @M12, @M12Q, @Descrip, @UPrice)

          Set @id = @id + 1
Print @id

End

5. Use Select command to check. Fig5

6. Copy All data and paste into excel ;Fig6

7. In Excel, Add 1st column to SALES2017

8. Open Navision then open Sales Budget >> New >> ; Fig7

9. Select "SALES2017" and click "Edit Budget", then click the Ellipsis icon that show Fig 8

A. Click "New" in "Item Budget Entries" page, select 1st line and right button . click "Paste Rows" Fig9

B. One time copy/paste 2000 records is better.









2015年3月27日 星期五

如何在Win Server 2012R2上面去裝SharePoint 2013

  1. 首先先建立一個帳號有local admin的權限。在本例中為sp_admin
  2. 有兩台伺服器分別是DBSVR & APSVR。資料庫是安裝在DBSVR(WIN SERVER 2012R2&SQL 2012 SP2).SP2013則會裝在APSVR(WIN SERVER 2012R2)
  3. 下載以下的程式分別置放於APSVR c:\STEP1&STEP2
  4. Step1.
    1. 1-sqlncli11_SQL2012
    2. 2-WcfDataServices
    3. 3-Setup_Msipc_x64
    4. 4-Synchronization
    5. 5-MicrosoftIdentityExtensions-64
  5. Step2
    1. AppFabric1.1-RTM-KB2671763-x64-ENU
    2. WindowsServerAppFabricSetup
  6. 使用Admin的身份開啓Windows Feature包括iis 以及App server(可從Sevrve managerAdd Role and Feature)安裝這功能
  7. cdstep1的目錄後一一執行該目錄下的程式.
  8. 完成後重開機
  9. 使用Admin的身份開啓Window Powershell.再切換到step2目錄.
  10. 執行下列命令去組態Appfabric.
  11. .\windowserverappfabricsetup_x64.exe /i cacheclient "," cachingservice "," cacheadmin /gac
  12. 等一段時間後程式執行完成後再執行KB2671763.
  13. 重開機後即可安裝share point 2013

2014年12月15日 星期一

install OneNote 2013 in Win Server 2012 R2

After installed the Office 2013 in Windows server 2012 R2, we can run oneNote 2013 in this server, but when we open the OneNote, system show error that we need to install "Desktop Experience" , feature, but this feature does not show in feature.what OneNote is looking for is "Ink and Handwriting Services ". after install this feature, need to restart .


2014年8月18日 星期一

在win8.1下安裝Hyper-V AD server 以便 SharePoint 2013 可在同一台PC上運行

買了一部 Surface Pro 3, 8G Ram + 256G SSD. 因此希望在這台機器上建立一個模擬的Domain + Client. 安裝步驟如下
1. 開啟 WiFi 的設定, 將 "Sharing" 啟動.因此 Hyper-V server 可以設為一個固定的 IP 以便AD Server 使用.
2. 開啟 Hyper-V Setting,在 Virtual Switch Manager 下產生一個 "Internal only" 的網路.此時 Win 8.1 會有一個 vEthernet 生成.並內定為 192.168.137.1
3.在 vEthernet TCP/IPv4 的 DNS 部分需指定為 192.168.137.*, 此處的 * 需與
Hyper-V AD server 的 IP 一致.
4. 開啟 Hyper-V 安裝 Windows 2008 R2 server & SP1 (試過安裝 WinSVR 2012, 但安裝 SP2013 有問題) .
5. 安裝 AD, DNS 等在此 Hyper-V server. 並指定 IP 為 192.168.137.*然後建立DOMAIN, 例如 Contoso.com from dos command "dcpromo".
6. 安裝 SQL 2012 & SP1.
7. 安裝 SharePoint 2013 + SP1
8. 在此AD server DNS 須設定正向及反向的解析.
9.

10. 回到 Win 8.1開啟 IE, 輸入 portal.contoso.com or my.contoso.com 成功.


2014年7月17日 星期四

SharePoint 2013 新設的網站無法登入

1. 參考 http://kumarcblog.blogspot.com/2012/12/cannot-login-to-sharepoint-2013-site.html
2. 當我依照 "Professional SharePoint 2013 Administration"(出版商WROX)的例子建立起新的網站 portal.contoso.com 並且也在 DNS建立 Host, 但是在IE下輸入三次login name & password,IE 顯示一個空白的網頁.
3. 參考 step 1 的方式,發現我應該在 Registry 作一些修改.
4. 使用 regedit to open Registry.
5. HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa\MSV1_0
6. 新增 "Multi-String" registy key, 並輸入名稱為 "BackConnectionHostNames".
7. 開啟modify 輸入新建網站名稱.

8. 開啟IE後即可登入新設的網站.
9. http://support.microsoft.com/kb/896861 .

2014年7月14日 星期一

SharePoint 2013 安裝 Search Application Service

1. 我在安裝SharePoint 2013 的 Search Application Service 時若是使用安裝精靈的話,資料庫會有GUID在DB Name 後端.非常不方便.因此使用指令的方式會清爽多了.
2. Open SharePoint 2013 Management Shell and type in or paste these command.
3. Copy from Todd Klindt Blogger .http://www.toddklindt.com/blog/Lists/Posts/Post.aspx?ID=378
4. # Based on scripts at http://www.harbar.net/articles/sp2013mt.aspx
# Thanks Spence!

# Get App Pool
$saAppPoolName = "Default SharePoint Service App Pool"

# Search Specifics, we are single server farm
$searchServerName = (Get-ChildItem env:computername).value
$serviceAppName = "Search Service Application"
$searchDBName = "SearchService_DB"


# Grab the Appplication Pool for Service Application Endpoint
$saAppPool = Get-SPServiceApplicationPool $saAppPoolName

# Start Search Service Instances
Write-Host "Starting Search Service Instances..."
Start-SPEnterpriseSearchServiceInstance $searchServerName
Start-SPEnterpriseSearchQueryAndSiteSettingsServiceInstance $searchServerName

# Create the Search Service Application and Proxy
Write-Host "Creating Search Service Application and Proxy..."
$searchServiceApp = New-SPEnterpriseSearchServiceApplication -Name $serviceAppName -ApplicationPool $saAppPoolName -DatabaseName $searchDBName
$searchProxy = New-SPEnterpriseSearchServiceApplicationProxy -Name "$serviceAppName Proxy" -SearchApplication $searchServiceApp

# Clone the default Topology (which is empty) and create a new one and then activate it
Write-Host "Configuring Search Component Topology..."
$clone = $searchServiceApp.ActiveTopology.Clone()
$searchServiceInstance = Get-SPEnterpriseSearchServiceInstance
New-SPEnterpriseSearchAdminComponent –SearchTopology $clone -SearchServiceInstance $searchServiceInstance
New-SPEnterpriseSearchContentProcessingComponent –SearchTopology $clone -SearchServiceInstance $searchServiceInstance
New-SPEnterpriseSearchAnalyticsProcessingComponent –SearchTopology $clone -SearchServiceInstance $searchServiceInstance 
New-SPEnterpriseSearchCrawlComponent –SearchTopology $clone -SearchServiceInstance $searchServiceInstance 
New-SPEnterpriseSearchIndexComponent –SearchTopology $clone -SearchServiceInstance $searchServiceInstance
New-SPEnterpriseSearchQueryProcessingComponent –SearchTopology $clone -SearchServiceInstance $searchServiceInstance
$clone.Activate()
5. after running, check SQL DB name.

2014年7月11日 星期五

SharePoint 2013 Installation

SharePoint 2013 提供了很多新的功能,因此想來試試看.之前MS提供了試用版本.因此下載後試著在Win server 2012 & SQL 2012 上安裝. 但是連 prerequisiteinstall 都沒成功.因此將系統改成 Win SVR 2008 R2 + SQL 2008R2. 安裝方式如下
1. PC 為 Surface Pro 3, 8G ram + 256G HD, i5 .
2. Hyper-V 80 G, ram 2G + Dynamics. Win SVR 2008 R2 .
3. Virtual Switch Manager 的 connection Type is "Internal network" .
4. Enable Surface Pro 3 WiFi properties's sharing function.
5. Hyper-V 開機後先設好 local administrator password.
6. update Win SVR 2008R2 SP 1.
7. add role ( Application, DNS, Web Server(IIS)) then restart.
8. Add role "Active Directory Domain Service" then restart.
9. run "DCPROMO" in cmd to enable the Domain.
A. 我使用 Contoso.com 當成AD Server 的網用名稱.
B. AD 完成後加入一些 user 的名字.
C. install SQL 2008 R2 and SP2. then restart.
D. 安裝 SharePoint 2013 Server prerequisteinstaller.exe .
E. 此程式會將SP2013需要的檔案先行安裝.
F. 在安裝的過程中會重開機數次.
G. 安裝完成後執行 SETUP.EXE .
H. 運氣不太好.沒有安裝成功.log 檔案在 "C:\Users\Administrator\AppData\Local\Temp"
I. Error code 是 1603(0x643). 上網查詢後發現 Maarten Onderwater 有篇文章在討論此錯誤訊息.http://www.dotnetquest.com/post/2013/02/16/SharePoint-2013-installation-error-oservermsi-error-code-1603(0x643)
J. 依照他的建議到 MS download 網站下載 msi SDK.網址是 http://www.microsoft.com/en-us/download/details.aspx?id=3138
K. 安裝ORCA 的方式如此網址 ㄡhttp://www.itninja.com/blog/view/downloading-installing-and-using-ms-orca
L. 依照 Maarten 的建議將ARPWRITE drop Row by Orca.
M. 完成重新執行安裝程式.Wow!! 成功了.
N. run MSTSC to open this servere by Costoso\administrator .