Showing posts with label ERP LN. Show all posts
Showing posts with label ERP LN. Show all posts

Thursday, 18 June 2015

Sql Server datetime timezone handling

SQL Server made modifications in 2005 onward where the internal timezone is saved in UTC. This was largely due to geo-replication and HA projectors involving log shipping, and having the log shipping times saved in different time zones made it impossible for the old method to restore them.
Thus, saving everything internally in UTC time allowed SQL Server to work well globally. This is one of the reasons why daylight savings is kind of a pain to deal with in Windows, because other MS products such as Outlook also save the date/time internally as UTC and create a offset that needs to be patched.
I work in a company where we have thousands of servers (not MS SQL Servers though, but all kinds of servers) spread out all across the world, and if we didn't specifically force everything to go by UTC, we would all go insane very quickly.

UTC is generally not very meaningful to a user.  You could theoretically convert the times to the end user’s local time zone.

A DATETIMEOFFSET gives you the ability to store local time and UTC time in one field. This allows for very simple and efficient reporting in local or UTC time without the need to process the data for display in any way.

These are the two most common requirements -
1. local time for local reports and
2. UTC time for group reports.

The local time is stored in the DATETIME portion of the DATETIMEOFFSET and the OFFSET from UTC is stored in the OFFSET portion, thus conversion is simple and, since it requires no knowledge of the timezone the data came from, can all be done at database level.

If you don't require times down to milliseconds, e.g. just to minutes or seconds, you can use DATETIMEOFFSET(0). The DATETIMEOFFSET field will then only require 8 bytes of storage - the same as a DATETIME.

Using a DATETIMEOFFSET rather than a UTC DATETIME therefore gives more flexibility, efficiency and simplicity for reporting.

Example:
SELECT t_odat As 'Order Date stored in SQL Server', CONVERT(datetime,
               SWITCHOFFSET(CONVERT(datetimeoffset,
                                    t_odat),
                            DATENAME(TzOffset, SYSDATETIMEOFFSET())))
       AS 'Order Date In LN'

from ttdsls401101

Thursday, 28 May 2015

SO Sequencing


To add to my earlier Blog on PO Sequencing, I did some study on when all the SO sequence is generated and what  is the Significance of “Order Line Type” for the SO Line Sequences.

This is what I found-

Note: There is no “Back Orders Allowed” checkbox in SO Parameters. You can only Control if Back Orders is confirmed Automatically with “Confirm Back Order Automatically” flag in SO Parameters.

Generally when there is only one sequence associated with a SO Line, the sequence number of SO Line is 0  with Order Line as tdsls.oltp.detail.

Sequence
Order Line Type
Ordered Quantity
Delivered Quantity
0
tdsls.oltp.detail
5
0

Sequences can be generated in 2 ways-

1. Split Delivery Line in the Sales Order Planned Delivery Lines (tdsls4101m100) session. Main Sequence with Line Type as tdsls.oltp.total and its sub seqences with Line Type as tdsls.oltp.detail (s)

2. Partial Delivery of SO Line, were new sequence gets generated with Order Line Type as tdsls.oltp.backorder

Split Delivery Line in the Sales Order Planned Delivery Lines (tdsls4101m100):

As soon as you split the SO Line two more sequences are added to your SO Line, making the total sequences to be 3 (i.e.  0, 1, 2)

Sequence
Delivery Type
Order Line Type
Ordered Quantity
Delivered Quantity
0
not.applicable
tdsls.oltp.total
5
0
1
warehousing
tdsls.oltp.detail
4
0
2
warehousing
tdsls.oltp.detail
1
0

Now you can do “Print SO Acknowledgements”/”Release SO to Warehousing” for each tdsls.oltp.detail sequence separately.


Now let’s Partially Ship 3 qty from sequence 1

Sequence
Delivery Type
Order Line Type
Ordered Quantity
Delivered Quantity
Back Order Qty
Backorder Confirmed?
0
not.applicable
tdsls.oltp.total
5
3
1
No
1
warehousing
tdsls.oltp.detail
4
3
1
No
2
warehousing
tdsls.oltp.detail
1
0
0
No


Now we have to Confirm the Back Order against sequence 1, so that it can be received. When Back Order is confirmed, the data in the system is as follows:

Sequence
Delivery Type
Order Line Type
Ordered Quantity
Delivered Quantity
Back Order Qty
Backorder Confirmed?
Linked Sequence
0
not.applicable
tdsls.oltp.total
5
3
1
No
0
1
warehousing
tdsls.oltp.detail
4
3
1
Yes
3
2
warehousing
tdsls.oltp.detail
1
0
0
No
0
3
warehousing
tdsls.oltp.backorder
1
0
0
No
0

Now I ship Sequence 3.

Sequence
Delivery Type
Order Line Type
Ordered Quantity
Delivered Quantity
Back Order Qty
Backorder Confirmed?
Linked Sequence
0
not.applicable
tdsls.oltp.total
5
4
0
No
0
1
warehousing
tdsls.oltp.detail
4
3
1
Yes
3
2
warehousing
tdsls.oltp.detail
1
0
0
No
0
3
warehousing
tdsls.oltp.backorder
1
1
0
No
0


***********************************************************************************


Let’s See how sequencing works for Partial Delivery of SO Line, were new sequence gets generated with Order Line Type as tdsls.oltp.backorder:

Sequence
Order Line Type
Ordered Quantity
Delivered Quantity
0
tdsls.oltp.detail
3
0

I ship 2 Qty:

Sequence
Delivery Type
Order Line Type
Ordered Quantity
Delivered Quantity
Back Order Qty
Backorder Confirmed?
Linked Sequence
0
warehousing
tdsls.oltp.detail
3
2
1
No
0

I Confirm the Back Order:

Sequence
Delivery Type
Order Line Type
Ordered Quantity
Delivered Quantity
Back Order Qty
Backorder Confirmed?
Linked Sequence
0
warehousing
tdsls.oltp.detail
3
2
1
Yes
1
1
warehousing
tdsls.oltp.backorder
1
0
0
No
0

I Shipped The 1 Qty for Sequence 1

Sequence
Delivery Type
Order Line Type
Ordered Quantity
Delivered Quantity
Back Order Qty
Backorder Confirmed?
Linked Sequence
0
warehousing
tdsls.oltp.detail
3
2
1
Yes
1
1
warehousing
tdsls.oltp.backorder
1
1
0
No
0