infor.com
concierge
infor u
developer portal
documentation central
customer center
Posts
Categories
Groups
ERPs
CSD
FSM/HRT
LN
M3
Syteline/ CSI
Hubs
Developer
Healthcare
Hospitality
Public Sector
Onboarding
Release Center
CloudSuites
Aerospace & Defense (LN)
Automotive (LN)
Chemicals (M3)
Corporate (FSM/HRT)
Distribution (Sx.e/CSD)
Distribution Enterprise (M3)
Engineering & Construction (LN)
Fashion (M3)
Food & Beverage (M3)
Healthcare (FSM/HRT)
Industrial (Syteline/CSI)
Industrial Enterprise (LN)
Manufacturing (M3)
Public Sector (FSM/HRT)
Solutions
Supply Chain Management (SCM)
Human Capital Management (HCM)
Events
Groups
User Groups
Your Groups
About
Email Community Support
Infor News
Migrated Forums
Home
Clovertech
Clovertech Archive
Cloverleaf
Request - TCL script to remove NTE following OBX's targeted for removal
Lawrence Nelson
I'm wondering if anyone has a script, that they could please make available to me, to do the following action, or provide the instructions to meet the need.
I have a working script where I locate and removing qualifying OBX's from a result message. I've been given a twist where they (now) also want ALL the NTE's removed related to those same OBX's being removed. I haven't been able to target
just those NTE
- but instead, find that I'm just wiping out all the NTE in the entire message (not good) while I'm within the Foreach where I'm tapping out the OBX. I keep getting stuck in thinking Xlate and iteration mode with TCL and not coming up with a solution.
The messages I work with may look like this for example -
ORC |1
OBR|1
OBX|1
OBX|2
OBX |3 <<< targeted for removal
NTE |1 <this should go
NTE |2 <this should go
NTE|3 <this should go
OBX |4
NTE|1
OBX |5 <targeted for removal
NTE |1 <this should go
NTE |2 <this should go
NTE| 3 <this should go
OBX |6
NTE |1
NTE |2
NTE| 3
The message should end up like this :
ORC |1
OBR|1
OBX|
1
OBX|
2
OBX |
4
NTE|1
OBX |
6
NTE |1
NTE |2
NTE| 3
Thanks for any assistance you all may be a able to provide me.
Lawrence Nelson
Find more posts tagged with
Clovertech
Comments
Keith McLeod
An XLate makes this simple. Do you have the tcl code you are working with? I would speculate that when you remove the OBX segment that was targeted, you would remove NTE segments until you found a segment that is not an NTE. Would you consider doing with an Xlate?
Gene Millard
tcl code
switch -exact -- $mode {
run {
keylget args MSGID mh
set msg [msgget $mh]
set segmentList [split $msg \r]
set killNte 0 ; # set killNte to 0 to not kill NTE segments
foreach segment $segmentList {
set segmentId [crange $segment 0 2]
if {![string equal $segmentId NTE]} {
set killNte 0
}
switch -exact -- $segmentId {
OBX {
set line [split $segment |] ; # get segment
set obx2 [lindex [split [lindex $line 2] ^] 0]
if {[string equal $obx2 CWE] | [string equal $obx2 SN]} {
set killNte 1
continue
}
}
NTE {
if {$killNte} {
continue
}
}
}
lappend line3 $segment
}
msgset $mh [join $line3 \r]
lappend dispList "CONTINUE $mh"
}
}
Lawrence Nelson
Hi all -
We have reasons why we didn't go with an xlate - because there are SEVERAL xlates involved and the testing and regression testing we use - is extensive and time consuming so for this solution we are not using xlates.
I've attached the script I'm using to remove the OBX's
I'm looking to figure out how to remove the NTE POST the OBX's that are targeted for removal - but again - not effect NTE post OBX's that will not be removed.
tpsRemoveOBXS_combo_IF.tcl
Gene Millard
Attached is my code to do what you requested.
It is very short. I used what is in OBX-2 as the condition to kill the segments.
It is the code that is listed above but it is the entire tcl.
tpsTESTKillOBXandNTE.tcl
Charlie Bursell
Gene:
If I could make one small suggestion.
Since ALL segments should be terminated with CR including the last segment, I would lappend the empty string to your list just prior to the join.
Charlie Bursell
Sorry, my bad on the above, assuming the IB message ends all segments, including the last, with CR, a CR will be appended to the last.
The proc splits into a segment list in which the last item in the list will be the empty string so it will get appended. I should have looked a bit more closely.