We haven't used this in a long time, but it was being used because an automated
routine was generating labels for a complete order, and then our shipping dept
would short ship at the last second, and wind up with extra UCC-128 labels. We
would scan them into a labels text file, and the script would look through that
file, and strip the segments out for those cases, and renumber the HLs
afterward.
It's not very big, so I'm just going to post it as opposed to uploading the
file...don't laugh- it served it's purpose.
Good luck - No guarantees! ;)
<code>
var sourceDocIx = getDocumentIndex("labels.txt");
if(sourceDocIx!=-1){
strip_bad_labels();
reshuffle_the_deck();
}
function reshuffle_the_deck() {
var current_HL = 1;
var current_shipment;
var current_order;
var current_pack;
var order_count = 0;
var pack_count = 0;
var cartons;
var order_weight;
var start_point;
var weight_length;
var total_weight = 0;
//var total_volume;
UltraEdit.activeDocument.top();
var o_msg = "Reshuffling.";
UltraEdit.outputWindow.write(o_msg);
while (UltraEdit.activeDocument.findReplace.find("HL ")) {
if (UltraEdit.activeDocument.isFound() == true) {
var g_msg = "Found. Target Line # " + UltraEdit.activeDocument.currentLineNum;
UltraEdit.outputWindow.write(g_msg);
UltraEdit.activeDocument.gotoLine(UltraEdit.activeDocument.currentLineNum, 28);
//goto the level indicator.
UltraEdit.overStrikeMode = true;
switch(UltraEdit.activeDocument.currentChar) { //test the level indicator.
case "S" :
UltraEdit.outputWindow.write("Shipment"); //debugging.
current_shipment = current_HL; //save the parent shipment.
break;
case "O" :
UltraEdit.outputWindow.write("Order"); //debugging.
current_order = current_HL; //save the parent order.
++order_count;
UltraEdit.activeDocument.gotoLine(UltraEdit.activeDocument.currentLineNum, 4);
UltraEdit.activeDocument.deleteToEndOfLine();
UltraEdit.activeDocument.write(" ");
UltraEdit.activeDocument.gotoLine(UltraEdit.activeDocument.currentLineNum, 4);
UltraEdit.activeDocument.write(String(current_HL));
UltraEdit.activeDocument.gotoLine(UltraEdit.activeDocument.currentLineNum, 16);
UltraEdit.activeDocument.write(String(current_shipment));
UltraEdit.activeDocument.gotoLine(UltraEdit.activeDocument.currentLineNum, 28);
UltraEdit.activeDocument.write("O");
UltraEdit.activeDocument.gotoLine(UltraEdit.activeDocument.currentLineNum + 2,
16);
UltraEdit.activeDocument.selectWord();
cartons = UltraEdit.activeDocument.selection;
total_weight = total_weight + (cartons * 6);
order_weight = String(cartons * 6) + ".000";
UltraEdit.outputWindow.write("Weight: " + order_weight);
weight_length = order_weight.length;
start_point = 13 - order_weight.length;
UltraEdit.activeDocument.gotoLine(0, (99 + start_point));
UltraEdit.activeDocument.deleteToEndOfLine();
UltraEdit.activeDocument.write(order_weight + "LB");
break;
case "P" :
UltraEdit.outputWindow.write("Pack"); //debugging.
current_pack = current_HL; //save the parent pack.
++pack_count;
UltraEdit.activeDocument.gotoLine(UltraEdit.activeDocument.currentLineNum, 4);
UltraEdit.activeDocument.deleteToEndOfLine();
UltraEdit.activeDocument.write(" ");
UltraEdit.activeDocument.gotoLine(UltraEdit.activeDocument.currentLineNum, 4);
UltraEdit.activeDocument.write(String(current_HL));
UltraEdit.activeDocument.gotoLine(UltraEdit.activeDocument.currentLineNum, 16);
UltraEdit.activeDocument.write(String(current_order));
UltraEdit.activeDocument.gotoLine(UltraEdit.activeDocument.currentLineNum, 28);
UltraEdit.activeDocument.write("P");
break;
case "I" :
UltraEdit.outputWindow.write("Item");
UltraEdit.activeDocument.gotoLine(UltraEdit.activeDocument.currentLineNum, 4);
UltraEdit.activeDocument.deleteToEndOfLine();
UltraEdit.activeDocument.write(" ");
UltraEdit.activeDocument.gotoLine(UltraEdit.activeDocument.currentLineNum, 4);
UltraEdit.activeDocument.write(String(current_HL));
UltraEdit.activeDocument.gotoLine(UltraEdit.activeDocument.currentLineNum, 16);
UltraEdit.activeDocument.write(String(current_pack));
UltraEdit.activeDocument.gotoLine(UltraEdit.activeDocument.currentLineNum, 28);
UltraEdit.activeDocument.write("I");
break;
}
UltraEdit.overStrikeMode = false;
++current_HL;
}
}
--current_HL;
UltraEdit.outputWindow.write("CTT total HLs : " + String(current_HL));
UltraEdit.outputWindow.write("Order Count : " + String(order_count));
UltraEdit.outputWindow.write("Pack Count : " + String(pack_count));
UltraEdit.outputWindow.write("Total Weight : " + String(total_weight));
UltraEdit.activeDocument.findReplace.find("CTT");
UltraEdit.activeDocument.deleteLine();
UltraEdit.activeDocument.write("CTT " + String(current_HL));
}
function strip_bad_labels() {
var sourceDoc = UltraEdit.document[sourceDocIx];
sourceDoc.findReplace.regExp = false;
sourceDoc.findReplace.selectText = true;
sourceDoc.findReplace.matchWord = false;
sourceDoc.top();
UltraEdit.activeDocument.top();
while ( ! sourceDoc.isEof() ) {
sourceDoc.selectWord();
var label = sourceDoc.selection;
var o_msg = "Searching for UCC # " + label + ".";
UltraEdit.outputWindow.write(o_msg);
UltraEdit.activeDocument.findReplace.find(label);
if (UltraEdit.activeDocument.isFound() == true) {
UltraEdit.activeDocument.gotoLine(UltraEdit.activeDocument.currentLineNum - 2);
//Jump up to the HL segment.
UltraEdit.activeDocument.deleteLine(); //HL (pack)
UltraEdit.activeDocument.deleteLine(); //PO4 (pack)
UltraEdit.activeDocument.deleteLine(); //MAN (pack)
UltraEdit.activeDocument.deleteLine(); //HL (item)
UltraEdit.activeDocument.deleteLine(); //LIN (item)
UltraEdit.activeDocument.deleteLine(); //SN1 (item)
UltraEdit.activeDocument.deleteLine(); //PID (item)
UltraEdit.activeDocument.deleteLine(); //TD5 (item)
var g_msg = "Found. Target Line # " + UltraEdit.activeDocument.currentLineNum;
UltraEdit.outputWindow.write(g_msg);
} else {
var g_msg = "Not found.";
UltraEdit.outputWindow.write(g_msg);
}
UltraEdit.activeDocument.top();
sourceDoc.gotoLine(sourceDoc.currentLineNum + 1); // Get the next bad label to
strip from the source file.
}
}
//--------------------------------------------------------------------------------------------------
function getDocumentIndex(filepath) {
var tabindex = -1;
for (i = 0; i < UltraEdit.document.length; i++)
{
if(filepath) {
if (UltraEdit.document[i].path.toLowerCase().indexOf(filepath.toLowerCase())>0)
{
tabindex = i;
break;
}
}
else {
if (UltraEdit.activeDocument.path==UltraEdit.document[i].path) {
tabindex = i;
break;
}
}
}
return tabindex;
}
</code>
----- Original Message -----
From: "John" <[email protected]>
To: "Travis Truax" <[email protected]>, [email protected]
Sent: Wednesday, February 13, 2013 11:07:51 AM
Subject: Re: 856 HL level removal
Travis,
Thanks for the reply. I use UltraEdit and a script was going to be my first
choice for a home grown solution. Not ever being interested in reinventing the
wheel, if you could pass it on, I would be most grateful.
John
--- In [email protected], Travis Truax wrote:
>
> I'm embarrassed to say we have a script written for UltraEdit that rips
> through an 856, strips some screwed up stuff out, and renumbers the HLs.
> You can have it, but it would have to be modified to strip the right stuff
> out.
>
> Yes, I know this is awful. We do what we have to do in a pinch...
>
> Travis-
>
> ----- Original Message -----
>
> From: "John"
> To: [email protected]
> Sent: Wednesday, February 13, 2013 10:54:37 AM
> Subject: [EDI-L] 856 HL level removal
>
> I have a (hopefully) short term requirement to edit rejected 856s to Honda,
> remove bad HL levels that are missing information, causing Honda to reject
> the 856. Obviously, this is a simple matter using Notepad. What is not so
> simple is renumbering all the HL levels below the deleted one. I have checked
> the current version of EDI Notepad, it does not do this. Any suggestions?
>
> We are using Gentran Windows and this is a band-aid, not a permanent
> solution! An no, I cannot just make the missing information Mandatory since
> there are times when not sending it is perfectly valid.
>
> We are working on the root cause resolution but I am looking for something
> that will make my job of editing the 856 at 1:00 am easier!
>
> Thanks,
>
> John
>
>
>
> ------------------------------------
>
> ...
> Please use the following Message Identifiers as your subject prefix: , , , ,
> , ,
>
> Job postings are welcome, but for job postings or requests for work: IS
> REQUIRED in the subject line as a prefix.Yahoo! Groups Links
>
>
>
>
>
>
> [Non-text portions of this message have been removed]
>
[Non-text portions of this message have been removed]
------------------------------------
...
Please use the following Message Identifiers as your subject prefix: <SALES>,
<JOBS>, <LIST>, <TECH>, <MISC>, <EVENT>, <OFF-TOPIC>
Job postings are welcome, but for job postings or requests for work: <JOBS> IS
REQUIRED in the subject line as a prefix.Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/EDI-L/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/EDI-L/join
(Yahoo! ID required)
<*> To change settings via email:
[email protected]
[email protected]
<*> To unsubscribe from this group, send an email to:
[email protected]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/