E9 .txt record

,

Good morning, classmates.
I have this code to save a field to a .txt file in Epicor9, but I need to pass it to Epicor10, someone who can help me ?? I would appreciate it

--------------Code E9--------------------------------------------------------

for each ttOrderHed no-lock  where  ttOrderHed.Company = 'HERMTY' and ttOrderHed.OrderNum > 0.
	for each OrderHed no-lock  where ttOrderHed.Company = OrderHed.Company and ttOrderHed.OrderNum = OrderHed.OrderNum .  		
			output to 'F:\Epicor Software\EpicorData\CorreoRechazo.txt' APPEND.
			PUT ttOrderHed.OrderNum skip.
			OUTPUT CLOSE.
	end .
end.

Here you go, not sure why you have an extra loop in there you don’t need it.

foreach(var x in ttOrderHed.Where(oh=>oh.Company=="HERMTY" && oh.OrderNum > 0))
{
          System.IO.File.AppendAllText(@"F:\Epicor Software\EpicorData\CorreoRechazo.txt", x.OrderNum);
}
2 Likes

I don’t think it will make much of a difference, in this case, but I would use something that will perform better due to not opening and closing the file each time through the loop.

         using (var file = new System.IO.StreamWriter(@"F:\Epicor Software\EpicorData\CorreoRechazo.txt", true))
         {
             foreach(var x in ttOrderHed.Where(oh=>oh.Company=="HERMTY" && oh.OrderNum > 0))
             {
                 file.WriteLine(x.OrderNum);
             }
         }
1 Like