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
Read Only Archives
Cloverleaf
Cloverleaf
Splitting a number
Kevin Crist
i have a tclproc that separates the order number is ORC and OBR 2 at the underscore. I just found out that the first set of numbers before the underscore can be either 6, 7, or 8 digits. How do i split that with the number varying so that i can put the number with the L in ORC2 and the number before underscore in the ORC3.
#########################################################################################
# Split the order format 999999_L12345-1 into two numbers 999999 and L12345-1
# and put orchard number in ORC2 & OBR2 and the Affinity order number in ORC3 & OBR3
#########################################################################################
set ORCList [split [lindex $segList $ORCpos] $fldSep]
set num1 [lindex $ORCList $ORCorchNum]
set orchNum [string range $num1 0 6]
set affiNum [string range $num1 8 15 ]
#echo orchNum: $orchNum
#echo affiNum: $affiNum
set OBRList [split [lindex $segList $OBRpos] $fldSep]
set num2 [lindex $OBRList $OBRorchNum]
set orchNum2 [string range $num2 0 6]
set affiNum2 [string range $num2 8 15 ]
lset ORCList $ORCorchNum $orchNum
lset ORCList $ORCaffiNum $affiNum
lset OBRList $OBRorchNum $orchNum2
lset OBRList $OBRaffiNum $affiNum2
lset segList $ORCpos [join $ORCList $fldSep]
lset segList $OBRpos [join $OBRList $fldSep]
msgset $mh [join $segList r]
Find more posts tagged with
Clovertech
Comments
Max Drown
Could you use the split command? Something like set var [split $var _]?
System
Originally posted by Levy Lazarre
Kevin,
Since the number of digits in the first number may vary, you shouldn't use "string range". Instead, you should just split the string into 2 pieces using the underscore "_" as the split character. The first piece will be your first number, and the second piece will be your L number.
This should work for you:
set orchNum [lindex [split $num1 _] 0]
set affiNum [lindex [split $num1 _] 1]
I do not see why you have to repeat the calculation for the OBR segment. Since the order number is the same in ORC and OBR, why not use the same values for the OBR segments?
lset OBRList $OBRorchNum $orchNum
lset OBRList $OBRaffiNum $affiNum
I hope this helps.
Kevin Crist
Thanks Max, Levy.
Makes sense and very understandable, thanks for your time.