Returns the dozens and single units of an integer quantity

/* This function is written en OpenEdge ABL 11.6.3 */ /* It receives an integer that represents a quantity in units, */ /* and returns a character string that expresses the quantity */ /* in dozens and single units. */ /* Ezequiel Montoya Saldaña - Lima - Perú - 2019 */ FUNCTION _InDozens RETURNS CHARACTER ( iInUnits AS int64 ) FORWARD. MESSAGE _InDozens (50). FUNCTION _InDozens RETURNS CHARACTER ( iInUnits AS INT64 ) : DEFINE VARIABLE fModDoz AS DECIMAL NO-UNDO. DEFINE VARIABLE fTotDoc AS DECIMAL NO-UNDO. DEFINE VARIABLE cDozen AS CHARACTER NO-UNDO. fModDoz = iInUnits MODULO 12. fTotDoc = (iInUnits - fModDoz) / 12. IF fModDoz = 0 THEN cDozen = STRING(fTotDoc, ">>>9"). ELSE cDozen = STRING(fTotDoc, ">>>>9") + " dozens and " + STRING(fModDoz, ">9") + " units". RETURN cDozen. END FUNCTION.
This function receives an integer that represents a quantity in units, and returns a character string that expresses the quantity in dozens and single units.
I wrote it because I work in a textile business, and, although our stock is in units, main customers ussually want to see their invoice expressed in dozens.

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.