|
Jim: I would: 1. Scan (from right) the string for non-blanks, getting the length of the string. 2. Use that length to define a variable length field 3. Move the string into the variable length field 4. Move the variable length field into a numeric field You should be able to compile this & step through it so see how it works. +++++++++++++++++++ d input_field s 10 d fld_variable s 10a varying d numeric_fld s 10 0 * c move '1234 ' input_field c ' ' CHECKR(E) input_field Num 2 0 c eval %len(fld_variable) = Num c Num SUBST input_field:1 fld_variable c move(p) fld_variable numeric_fld * c seton lr +++++++++++++++++++ Hope this helps! -Anth -----Original Message----- From: Jim Langston [mailto:jlangston@conexfreight.com] Sent: Monday, February 07, 2000 11:27 AM To: RPG400-L@midrange.com Subject: String to Numeric V3R7M0 I have a field I am allowing my users to put in a string value (container number, in the format XXXX999999) or a numeric value (invoice number, 999999). I now have this variable that contains one or the other, but in either case, it is left justified. So I either have: 'ABCD123456 ' or '1234 ' Now I'm kinda stumped. I can figure out if it is numeric or a container number by using the Check opcode. But, once I know it's numeric, just how do I convert this thing to a numeric value? I tried a Data Structure, but no success. To map successfully, I think the value would have to be like: '00000001234' and I'm not really sure how to get it there. I know we have the DIGITS function in Query, but it doesn't work in RPG, and is going the wrong way anyway. Anyone have any ideas? I think I'm going to wind up building a string like '000000000000001234' using '00000000000' + %TRIM(InputVal) and SUBSTRing it. Regards, Jim Langston +--- | This is the RPG/400 Mailing List! | To submit a new message, send your mail to RPG400-L@midrange.com. | To subscribe to this list send email to RPG400-L-SUB@midrange.com. | To unsubscribe from this list send email to RPG400-L-UNSUB@midrange.com. | Questions should be directed to the list owner/operator: david@midrange.com +--- +--- | This is the RPG/400 Mailing List! | To submit a new message, send your mail to RPG400-L@midrange.com. | To subscribe to this list send email to RPG400-L-SUB@midrange.com. | To unsubscribe from this list send email to RPG400-L-UNSUB@midrange.com. | Questions should be directed to the list owner/operator: david@midrange.com +---
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.