Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Packing list Carton# counting question.
Message
From
28/09/2001 05:43:21
 
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00561824
Message ID:
00561830
Views:
29
>Hi!
>
>Well, I see no other way than a manual count, or use of custom function (UDF) to return a number of items in a single line. For example (did not tested, though you can get an idea):
>
>
>prodecure CountCartons
>lparameters pcCNums
>local i, lnCount, j, jLen
>local array achecks(999) && to track duplicated numbers
>alines(aa,chrtran(pcCNums,",",chr(13))) && get comma-separated items into array
>lnCount = 0
>* scan all items
>for i = 1 to alen(aa)
>  if '-' $ aa[i] && we have a range here
>    jLen = val(substr(aa[i],at('-',aa[i])+1))
>    for j = val(aa[i]) to jLen && scan through range items
>      if achecks[j]
>        * ERROR - such value already exists in this list
>      else
>        lnCount = lnCount + 1
>        achecks[j] = .T.
>      endif
>    endfor
>  else
>    if achecks[val(aa[i])]
>      * ERROR - such value already exists in this list
>    else
>      lnCount = lnCount + 1
>      achecks[val(aa[i])] = .T.
>    endif
>  endif
>endfor
>return lnCount
>
>
>You can call above function from SELECT statement or from the COUNT command to return count :
>
>SELECT SUM(CountCartons(MyTable.CTN_NOS))
>
>HTH.

Oh, Wonderful code! 8)

I got trap on comma ,
My first idea is using recursve procedure..

Procedure CTNCount
...
kCTN = Left...
iCount = iCount + CTNCount(kCTN...
...

Thus, I count out # but no error check.

now making array instead of recursive, the problem will be simply a lot.
At least easy maintain on error.

>
>>count the Orditems.CTN_NOS question
>>
>>Real Packing list case can be:
>>
>>
>>Sample Packing list:
>>
>>CTN_NOS	ITEM		DIMENSION	
>>001		CM-1234-T1-M	43x46x25cm.
>>001		CM-1238-T1-M	
>>001		CM-1467-T1-M
>>002-003		CM-1477-T1-M	27x25x26cm.
>>004,008,012	CM-1677-T1-M	26x24x22cm.
>>005-007,009-011	CM-1678-T1-M	26x25x22cm.
>>013		CM-1688-G1-M	28x29x30cm.
>>
>>
>>
>>I need to calculate the correct Carton # with calculate the Final cbm of whole shipment.
>>
>>In above example, repeating 001 mean same carton, user only fill one time on pklength, pkwidth, pkwidth.
>>Thus, the count would be 1 only if exist Volume.
>>
>>001 with DIMENSION give 1 as combine carton
>>001 with NO dimension give 0 as counted already
>>002-003 will be subtract the value and give 2 as count.
>>004,008,010 will be individual count, i.e. 3 as count
>>005-007,009-011 will also give 6 as result
>>013 give 1 as count because it represent one carton# only
>>
>>How can I count it? currently using manual count will be very poor.
>>
>>Second, how can I check out it is already counted and prompt user error?
>>
>>001-010
>>008-009 <~ it will be error, duplicate carton#
>>
>>Thanks. :)
The weak wait for chance, The strong bid for chance,
The clever notch up chance, but The merciful give you chance.
Previous
Reply
Map
View

Click here to load this message in the networking platform