2

fairly new to ABL here. I have a question where I just cannot figure out the answer.

I have job numbers in sequence such 99999-0, 99999-2, 99999-3 and could go well into 99999-150. However, I need to interpret jobs 99999-0 through 99999-9 as 99999-00 through 99999-09 where I am writing these interpreted values to a UD field. I'm sure it is simple but being a newb, I cannot figure it out.

Thank you in advance.

Chris

Tom Bascom
  • 13,405
  • 2
  • 27
  • 33
  • I think I figured it out. How does this look? if JobAsmbl.AssemblySeq < 10 then Substring(JobHead.JobNum, 1, 5) + "-" + '0' + String(JobAsmbl.AssemblySeq) else Substring(JobHead.JobNum, 1, 5) + "-" + String(JobAsmbl.AssemblySeq, '00') – Chris Simpson May 15 '18 at 18:48
  • That doesn't look like it has much to do with the sample job numbers shown in your question. – Tom Bascom May 15 '18 at 19:02
  • Are you asking how to format the number with leading digits? Or how to select numbers matching a value? If you're building logic based on substrings of this ID, consider breaking the value into fields in your schema so you can access them more readily. – David Hempy May 15 '18 at 19:51
  • Good point - if you have control over this schema you should break the job numbers into 2 fields. Composite fields are a horrible hack. It's one thing to work with them if someone else forced it on you but if you have control you would be much better off breaking it up. – Tom Bascom May 15 '18 at 20:09

1 Answers1

2

This is a little light on error checking etc and I haven't actually syntax checked it but:

function X returns character ( jobNum as character ):
  return( string( integer( entry( 2, jobNum, "-" )), "99" ).
end.
Tom Bascom
  • 13,405
  • 2
  • 27
  • 33