I am trying to write define a results field. first I want to divide 2 qty’s on hand inventory/units. Then I want to drop the whole number and only keep the decimal. Goal is to find how much partial product is left.<\/p>\n
first expression is qtyinc. b.ifpic/c.igiord
\nsecond expression partial. substr(qtyinc,10,2)<\/p>\n
I get a substr value not allowed.<\/p>\n
I assume my second expression is incorrect but how do I write it to only keep the decimal numbers and throw out the whole<\/p>","upvoteCount":1,"answerCount":9,"datePublished":"2025-05-12T13:22:37.823Z","author":{"@type":"Person","name":"spiceuser-i0521","url":"https://community.spiceworks.com/u/spiceuser-i0521"},"suggestedAnswer":[{"@type":"Answer","text":"
I am trying to write define a results field. first I want to divide 2 qty’s on hand inventory/units. Then I want to drop the whole number and only keep the decimal. Goal is to find how much partial product is left.<\/p>\n
first expression is qtyinc. b.ifpic/c.igiord
\nsecond expression partial. substr(qtyinc,10,2)<\/p>\n
I get a substr value not allowed.<\/p>\n
I assume my second expression is incorrect but how do I write it to only keep the decimal numbers and throw out the whole<\/p>","upvoteCount":1,"datePublished":"2025-05-12T13:22:37.921Z","url":"https://community.spiceworks.com/t/wrkqry-help-as400/1204742/1","author":{"@type":"Person","name":"spiceuser-i0521","url":"https://community.spiceworks.com/u/spiceuser-i0521"}},{"@type":"Answer","text":"
What language? Most have a MOD operand that will return just the remainder of a division, in IBM landscape may also have a %REM operand for same.
\nThe problem in your post is that you are trying to use a string operation (substr) on a numeric result. Cast that numeric result as a string and then substr() would work.
\nBut that is irrelevant if you go the operand route and calc just the remainder in the first place.<\/p>","upvoteCount":0,"datePublished":"2025-05-12T14:22:48.302Z","url":"https://community.spiceworks.com/t/wrkqry-help-as400/1204742/2","author":{"@type":"Person","name":"craigrrr","url":"https://community.spiceworks.com/u/craigrrr"}},{"@type":"Answer","text":"
How would you write the expression for the %Rem? would it be %Rem qtyinc? This is in wrkqry/AS400<\/p>","upvoteCount":0,"datePublished":"2025-05-12T14:43:01.398Z","url":"https://community.spiceworks.com/t/wrkqry-help-as400/1204742/3","author":{"@type":"Person","name":"spiceuser-i0521","url":"https://community.spiceworks.com/u/spiceuser-i0521"}},{"@type":"Answer","text":"
%rem is not allowed in wrkqry. Returns error in expression at the %<\/p>","upvoteCount":0,"datePublished":"2025-05-12T15:00:34.771Z","url":"https://community.spiceworks.com/t/wrkqry-help-as400/1204742/4","author":{"@type":"Person","name":"spiceuser-i0521","url":"https://community.spiceworks.com/u/spiceuser-i0521"}},{"@type":"Answer","text":"
Yeah, that %rem isn’t sql or wrkqry but another ibm namespace, but depending on the database you are accessing, it probably DOES have the MOD (modulo) operator of some sort. At least it should if it is any flavor of sql database. On MSSQL server, though, the MOD operator is just ‘%’, so 5 % 2 = 1. Curious if that works in wrkqry, not really familiar with its eccentricities or how to escape the % sign if needed.
\nBut if it is, say, a mySQL database those will take MOD(x,y), x MOD y, or x % y. Any would work. You’ll have to check what the modulo operator is for your database queries.<\/p>","upvoteCount":0,"datePublished":"2025-05-12T15:32:29.984Z","url":"https://community.spiceworks.com/t/wrkqry-help-as400/1204742/5","author":{"@type":"Person","name":"craigrrr","url":"https://community.spiceworks.com/u/craigrrr"}},{"@type":"Answer","text":"
It’s DB2 if that means anything to you. It does not like the % sign.<\/p>","upvoteCount":0,"datePublished":"2025-05-12T16:06:53.866Z","url":"https://community.spiceworks.com/t/wrkqry-help-as400/1204742/6","author":{"@type":"Person","name":"spiceuser-i0521","url":"https://community.spiceworks.com/u/spiceuser-i0521"}},{"@type":"Answer","text":"
DB2 should be MOD(x,y) for the remainder.<\/p>","upvoteCount":0,"datePublished":"2025-05-12T17:26:04.364Z","url":"https://community.spiceworks.com/t/wrkqry-help-as400/1204742/7","author":{"@type":"Person","name":"craigrrr","url":"https://community.spiceworks.com/u/craigrrr"}},{"@type":"Answer","text":"
That does not work either<\/p>","upvoteCount":0,"datePublished":"2025-05-12T18:21:02.327Z","url":"https://community.spiceworks.com/t/wrkqry-help-as400/1204742/8","author":{"@type":"Person","name":"spiceuser-i0521","url":"https://community.spiceworks.com/u/spiceuser-i0521"}},{"@type":"Answer","text":"
Are you using RPG for programming in AS400 or is it a different language now?<\/p>\n
I don’t know if a contact I have is still active on here and help or if they have left it all behind.<\/p>","upvoteCount":0,"datePublished":"2025-05-12T18:25:11.229Z","url":"https://community.spiceworks.com/t/wrkqry-help-as400/1204742/9","author":{"@type":"Person","name":"moorebeers","url":"https://community.spiceworks.com/u/moorebeers"}}]}}