By researching the web I came to make a conclusion that many people has the one question that how to get the tracking number from UPS.
So Here is the solution. As Under:::::
The easy overview for UPS shipping method for the Web Developers:
Create a Tracking number as the system that can be tracked.
The basic steps to create the number is as under.
Create a Tracking Number:
The following code is a generic method that can be used to calculate a check digit for a UPS Tracking Number. The input for the method is a String, but you could rework it to use a raw Char[] if wish. This method leaves the rest of the tracking number up to you. it takes a 15 character sequence, in this case a String, and calculates the check digit using this sequence. For information sake, I will describe how the company I work for generates tracking numbers. This is up to you, as only two portions are required by UPS, the rest you can make up on your own.
The first two characters must be "1Z".
The next 6 characters we fill with our UPS accout number "XXXXXX"
The next 2 characters denote the service type:
* "01" for Next Day Air shipments
* "02" for Second Day Air shipments
* "03" for Groud shipments
The next 5 characters is our invoice number (Our invoices are 6 digits, we drop the first digit e.g 123456 invoice would yield 23456 characters.
The next 2 digits is the package number, zero filled e.g. Package 1 is "01", 2 is "02"
The last and final character is the check digit.
First of all you will notice that the described sequence above gives is 17 characters, where as we only need 15 to calculate the check digit. To do this, we drop the "1Z" portion, and only use the last 15 characters in the method.
Next let me take a moment to outline the algorithm used to generate the check digit, then you'll see the method below the outline:
Start a running total
Examine each character in the sequence
If the character is in an odd position (e.g 1st,3rd,5th....) then
If the character is numeric then add the numeric value to the running total
If the character is alpha, then
Calculate n to be (ASCII value of character - 48)
Calculate x to be ((2 * n) - (9 * INT(n/5))) where INT(n/5) returns n/5 rounded down to the next integer (e.g 34.3 would be 34 but also 34.8 would be 34)
Add x to the running total
If the character is in an even position (e.g 2nd, 4th, 6th......) then
If the character is numeric then
Calculate n to be (2 * numeric value of character)
Add n to the running total
If the character is alpha then
Calculate n to be (ASCII value of character - 48)
Add n to the running total
Calculate x to be (Running total modulo 10)
If x = 0 then x is the check digit
If x > 0 then
Calculate y to be (10 - x)
y is the check digit
Source : Futuristic Gateway
4 comments:
Post a Comment