I'm very new to progress (4GL) and I'm looking for building a function that will search for the most recent information in a table (thanks to a variable date) with some conditions. In my table (ecm_mstr) there is information about weight, item_number and historical_number (ID). Some items are stored several times in the table because there are update on the weight and its making a new line, not overwriting. I was inspired by existing functions but without any log error or console to execute my code it is difficult to solve the problem. There are probably some structure/syntax problems. I tried this but I currently don't now about how sort this date.. FUNCTION GetPdsSFtest2 returns decimal (pArticle as char): def var pLevel as char. pLevel = substring(pArticle,7,2). if pLevel = "PF" or pLevel = "NE" then do: find first ecd_det no-lock where ecd_domain = global_domain and ecd_part = pArticle no-error. *'Item_Number* if available ecd_det then do: find first ecm_mstr no-lock where ecm_domain = global_domain and ecm_nbr = ecd_nbr no-error. *'historical_number and treatment on the most recent date *'Searching for a 'sort' of my result to get the first one (so the most recent)* if available ecm_mstr then return ecm_cmmt[01]. *'Return my find else return 0. end. end END FUNCTION. Continue reading...