I've been banging my head against a wall and spent a couple hours searching online to try to figure out how to accomplish this with no luck. I am needing to make a cross reference table of customer part numbers to our part number. Since on each order, we enter the customer supplied part number in a note field, we do have a way to extract this data to create the reference table, however I'm struggling with some of the details.
Previously the script was written to find a string, start there and count out 10 characters. However this does not work in all cases. For instance, the string we are looking for, lets call it "0000" will be present in ALL of the customer part numbers, with the complete part number looking like "0000-00000".
In this instance that method works, however the customer part number could also look like:
"xxx-0000-00000" or even "0000-00000XXX", in which case we would be missing the beginning or end of the part number.
So, I need to be able to find the "0000" and then go back to the last space then forward one to find the starting character, and for the ending character find the "0000" then move forward until I find a space, ., or line return and then go back one to find the ending character of the string. This is what I am having trouble figuring out how to accomplish.
How exactly do I go about defining start_pos and end_pos as I have explained them?
note = odn.od_packing_slip_note
cust_pn = at2("0000",note,1)
start_pos = cust_pn then go back to last space and forward one
end_pos = # of characters from the st_pos until the next space, ., or line return
if cust_pn > 0 then
xref_no = SUBSTR(note,st_pos,end_pos)
end if
Previously the script was written to find a string, start there and count out 10 characters. However this does not work in all cases. For instance, the string we are looking for, lets call it "0000" will be present in ALL of the customer part numbers, with the complete part number looking like "0000-00000".
In this instance that method works, however the customer part number could also look like:
"xxx-0000-00000" or even "0000-00000XXX", in which case we would be missing the beginning or end of the part number.
So, I need to be able to find the "0000" and then go back to the last space then forward one to find the starting character, and for the ending character find the "0000" then move forward until I find a space, ., or line return and then go back one to find the ending character of the string. This is what I am having trouble figuring out how to accomplish.
How exactly do I go about defining start_pos and end_pos as I have explained them?
note = odn.od_packing_slip_note
cust_pn = at2("0000",note,1)
start_pos = cust_pn then go back to last space and forward one
end_pos = # of characters from the st_pos until the next space, ., or line return
if cust_pn > 0 then
xref_no = SUBSTR(note,st_pos,end_pos)
end if
Comment