Hi.
Here is the translation to J primitives. You can copy and paste it to a
new IJS window and just delete all the comments. :)
NB. NB. ======== START OF CODE ========
tomatrix=: ,:^:(1: = [EMAIL PROTECTED])
NB. NB. STEP 1d: Make copies of DUV by the number of destination
declared
NB. sids=. searchLOOKUP 'DUV'
sids=. temp i.~ LOOKUP_z_=: ~. LOOKUP_z_ ,~. temp=: <'DUV'
NB. masks=. (BOM_USAGE_CLASS colsfrom bomv) member sids
masks=. ((<:BOM_USAGE_CLASS) {"1 bomv) e. sids
NB. if. sum across masks do.
if. +/ masks do.
NB. NB. STEP 1b1: Work only with rows that matches
NB. wrkbom=. masks copy bomv
wrkbom=. masks # bomv
NB. wrkvbom=. (0,behead shape wrkbom) shape 0
wrkvbom=. (0,}.$ wrkbom) $ 0
NB. for_data. wrkbom do.
for_data. wrkbom do.
NB. NB. Check if we have a UV Summary defined for current GMC
NB. msk=. (atomize BOM_GEN_MAT_ID colsfrom data) = DUV_GEN_MAT_ID
colsfrom DUVV
msk=. (+/@,(<: BOM_GEN_MAT_ID) {"1 data) = (<:DUV_GEN_MAT_ID) {"1
DUVV
NB. if. tally where msk do.
if. # I. msk do.
NB. NB. Copy the current bom to the number of defined destination
NB. temp=. (tally where msk) copy tomatrix data
temp=. (#I. msk) # tomatrix data
NB. NB. Update the destination code to the ship to customer code
NB. wired=. DUV_CUSTOMER_CODE colsfrom DUVV selectrows where msk
wired=. (<:DUV_CUSTOMER_CODE) {"1 DUVV {~ I. msk
NB. if. 1 = shape wired do.
if. 1 = $ wired do.
NB. wired=. atomize wired
wired=. +/@, wired
NB. end.
end.
NB. temp=. temp replacecols BOM_DESTN_CODE;wired
temp=. wired (<:BOM_DESTN_CODE) } "1 temp
NB. NB. Now save the current bom
NB. wrkvbom=. wrkvbom atop temp
wrkvbom=. wrkvbom , tomatrix temp
NB. end.
end.
NB. end.
end.
NB. NB. Now remove the processed bom's then add the new BOM's
NB. bomv=. bomv selectrows where not masks
bomv=. (I. -. masks) { bomv
NB. bomv=. bomv atop wrkvbom
bomv=. bomv , tomatrix wrkvbom
NB. end.
end.
NB. NB. ======== END OF CODE ========
Here is the data for bomv, which is actually a local copy of the global
BOM (bill of materials) data:
NB. List of Materials
(<:BOM_USAGE_CLASS,BOM_GEN_MAT_ID,BOM_DESTN_CODE) { "1
BOM_FIELDNAMES,ADBOMDTLD
+---------------+--------------+--------------+
|BOM_USAGE_CLASS|BOM_GEN_MAT_ID|BOM_DESTN_CODE|
+---------------+--------------+--------------+
|DUV |1002091 | |
+---------------+--------------+--------------+
[bomv=. (<:BOM_USAGE_CLASS,BOM_GEN_MAT_ID,BOM_DESTN_CODE) { "1
ADBOMDTLV
139 1002091 0
The rest are the support data and the result. :)
NB. List of Destination by Generic Material ID:
DUV_FIELDNAMES,DUVD
+--------------+-------------+-----------------+
|DUV_GEN_MAT_ID|DUV_CITY_CODE|DUV_CUSTOMER_CODE|
+--------------+-------------+-----------------+
|1002091 |OSAKA |0000020071 |
+--------------+-------------+-----------------+
|1002091 |NODA - SHI |0000020073 |
+--------------+-------------+-----------------+
NB. The numeric equivalent of the data above is:
DUVV
1002091 195 156
1002091 196 157
NB. Result of operation
(<:BOM_USAGE_CLASS,BOM_GEN_MAT_ID,BOM_DESTN_CODE) { "1
BOM_FIELDNAMES,BCONSUMPD
+---------------+--------------+--------------+
|BOM_USAGE_CLASS|BOM_GEN_MAT_ID|BOM_DESTN_CODE|
+---------------+--------------+--------------+
|DUV |1002091 |0000020071 |
+---------------+--------------+--------------+
|DUV |1002091 |0000020073 |
+---------------+--------------+--------------+
(<:BOM_USAGE_CLASS,BOM_GEN_MAT_ID,BOM_DESTN_CODE) { "1 BCONSUMPV
139 1002091 156
139 1002091 157
NOTE: The only thing I can't show is the data for LOOKUP_z_ which is
HUGE! :P
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Raul Miller
Sent: Friday, September 19, 2008 9:53 PM
To: Programming forum
Subject: Re: [Jprogramming] Verb Sequence or Ranking problem?
On Fri, Sep 19, 2008 at 2:48 AM, Alex Rufon <[EMAIL PROTECTED]>
wrote:
> NB. ======== START OF CODE ========
> NB. STEP 1d: Make copies of DUV by the number of destination declared
> sids=. searchLOOKUP 'DUV'
> masks=. (BOM_USAGE_CLASS colsfrom bomv) member sids
> if. sum across masks do.
> NB. STEP 1b1: Work only with rows that matches
> wrkbom=. masks copy bomv
> wrkvbom=. (0,behead shape wrkbom) shape 0
> for_data. wrkbom do.
> NB. Check if we have a UV Summary defined for current GMC
> msk=. (atomize BOM_GEN_MAT_ID colsfrom data) = DUV_GEN_MAT_ID
..
Before I can understand anything in any language, including J, I need to
understand every word that's being used. (Except the irrelevant words
--
those can be removed, instead.)
Unfortunately, the comments, here, do not help me understand what's
happening -- mostly they tell me what the words that I already do
understand
mean. That's not completely the case, but I am pretty lost here.
If you can provide example definitions of each of those words, that
would
help, a lot. Also, I imagine that some words have only one definition
which in turn is not much longer than the word itself -- if you have any
of
those, please replace those words with their definitions.
Thanks,
--
Raul
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm