Thursday, December 27, 2007

Linked Server

Well add a linked server using the procedure sp_linkedserver and drop the same using sp_dropserver

Found an issue when data is being pushed from a Windows 2000 sql server to a Windows 2005 sql server using a link. The same would not succeed when the update statement used columns with spaces it seemed when the statement was passed to the remote server the square [] brackets around the field name were not getting carried this issue is confirmed as a bug on the microsoft site the work around for this could be to use a nested query for comparison with the field coz if compared with a memory variable it would generate an error.

Saturday, December 22, 2007

CRC Routine with VB

The CRC (Cyclic Redundancy Checksum) algorithm is a highly optimised and powerful way of checking whether a large number of bytes have been modified or not. The algorithm scans through all the bytes and generates a 32 bit number to represent the contents - small changes in the file contents result in large changes in the check sum, and there is a very low chance that two different streams of bytes will have the same CRC.

The implementation here uses a pre-calculated lookup table to do a lot of the heavy work of generating the polynomial. Once this has been calculated then the actual algorithm becomes relatively simple.

Option Explicit

' This code is taken from the VB.NET CRC32 algorithm
' provided by Paul (wpsjr1@succeed.net) - Excellent work!

Private crc32Table() As Long
Private Const BUFFER_SIZE As Long = 8192

Public Function GetByteArrayCrc32(ByRef buffer() As Byte) As Long

Dim crc32Result As Long
crc32Result = &HFFFFFFFF

Dim i As Integer
Dim iLookup As Integer

For i = LBound(buffer) To UBound(buffer)
iLookup = (crc32Result And &HFF) Xor buffer(i)
crc32Result = ((crc32Result And &HFFFFFF00) \ &H100) And 16777215 ' nasty shr 8 with vb :/
crc32Result = crc32Result Xor crc32Table(iLookup)
Next i

GetByteArrayCrc32 = Not (crc32Result)

End Function

Public Function GetFileCrc32(ByRef stream As cBinaryFileStream) As Long

Dim crc32Result As Long
crc32Result = &HFFFFFFFF

Dim buffer(0 To BUFFER_SIZE - 1) As Byte
Dim readSize As Long
readSize = BUFFER_SIZE

Dim count As Integer
count = stream.Read(buffer, readSize)

Dim i As Integer
Dim iLookup As Integer
Dim tot As Integer

Do While (count > 0)
For i = 0 To count - 1
iLookup = (crc32Result And &HFF) Xor buffer(i)
crc32Result = ((crc32Result And &HFFFFFF00) \ &H100) And 16777215 ' nasty shr 8 with vb :/
crc32Result = crc32Result Xor crc32Table(iLookup)
Next i
count = stream.Read(buffer, readSize)
Loop

GetFileCrc32 = Not (crc32Result)

End Function

Private Sub Class_Initialize()

' This is the official polynomial used by CRC32 in PKZip.
' Often the polynomial is shown reversed (04C11DB7).
Dim dwPolynomial As Long
dwPolynomial = &HEDB88320
Dim i As Integer, j As Integer

ReDim crc32Table(256)
Dim dwCrc As Long

For i = 0 To 255
dwCrc = i
For j = 8 To 1 Step -1
If (dwCrc And 1) Then
dwCrc = ((dwCrc And &HFFFFFFFE) \ 2&) And &H7FFFFFFF
dwCrc = dwCrc Xor dwPolynomial
Else
dwCrc = ((dwCrc And &HFFFFFFFE) \ 2&) And &H7FFFFFFF
End If
Next j
crc32Table(i) = dwCrc
Next i

End Sub

Sunday, December 09, 2007

Inventory Costing

Every Positive inventory quantity is applied against a negative quantity this is known as the item application and this information is maintained in Navision in a table called 339 - Item Application Entry

The Item Application Entry table has three columns which can be used to track the base of a entry these columns are:
1. Item Ledger Entry No.
2. Inbound Item Entry No.
3. Outbound Item Entry No.

The Item ledger entry is the base for this tracking in every line the item ledger entry no would be equal to one of the two columns "Inbound Item Entry No" or "Outbound Item Entry No" the column which is not equal is the column which resulted into the currenty entry.



Entries are usually applied according to the cost flow assumption that is defined by the costing method. However, if more accurate information about the cost flow exists, the user can overrule the general cost flow assumption by using a fixed application, which creates a link between an inventory decrease and a specific inventory increase and vice versa.

In the case of average cost items, a fixed application has the purpose of avoiding errors in the average cost calculation. Creating a fixed application can be useful, for example, when correcting an erroneous posting. Item ledger entries that are applied to each other are not valued by average. The two relevant entries serve to cancel each other, and the sum value of the Cost Amount (Actual) field for the transaction becomes zero. Thus, the program excludes it from the normal average cost calculation

Saturday, December 01, 2007

Creating Navision Shortcuts

Well we had this situation when the client wanted a given navision task to be schedule every night and they didn't have the license for the Navision Task Scheduler so it clicked we could use the navision shortcuts to launch navision using windows scheduler and execute the desired object.


Creating Navision Shortcuts

Client-Parameter:
servername=Name of the server

database=Database Name

company=Company Name

id=The name for the user setup file

nettype= Netb, TCP, TCPS

ntauthentication=[Yes/No]

dbreadonly=[Yes/No]
This program property allows you to specify that the database has read access only.
This prevents other users from entering data into the database

dbtest=[Min|Max|Normal]
You can use this program property to test the consistency and integrity of the
database.

commitcache=[Yes/No]
The Commit Cache program property allows Dynamics NAV to postpone writing the information stored in cache on the server to the database until later. Storing this information in cache allows Dynamics NAV to work faster.

cache=CacheInKB

objectcache=CacheInKB ( More than 0 KB and less than 1,000,000 KB )
The Object Cache property increases the speed of the program. Objects such as code,
descriptions and windows that will be used on the client computer are stored in the
object cache. This means that the client computer only needs to retrieve these objects once from the server, and then they will be stored in the object cache. The client computer must have enough memory to store the objects while they are being used in order to benefit from the object cache


temppath=TempPath
When Dynamics NAV is running it creates a number of temporary files, which are
automatically deleted when you close the program.

testtarget=[@screen|@eventlog|filepath]
You use this program property to specify how any error messages that are generated
during a database test are managed. They can be displayed on the screen or stored in
the Event Log or in a text file

ShowHelpID=[Yes/No]


Example
navision://client/run?servername=SANTOSH\MRMS&company=Global Link Communications LLC&database=GLC-2507&target=Form50061&servertype=MSSQL

if you are thinking how to launch the url using the command shell then its easy just use the command start as cmd.exe does not recognize commands with protocol

E.g.
start navision://client/run "servername=SANTOSH\MRMS&company=Global Link Communicatio
ns LLC&database=GLC-2507&target=Form50061&servertype=MSSQL&ntauthentication=1"