Sysytem says that EndDate should be greater than StartDate.Function looks like true.What is wrong? 3.Module 3.Task
Function ProcessIncomeDocs(StartDate = Undefined, EndDate = Undefined) Export
Message = "Error executing ServiceSrv.ProcessIncomeDocs"; EmptyString = ""; If StartDate <> Undefined Then If TypeOf(StartDate) <> Type("Date") Then Return Message + Chars.LF + "StartDate parameter has to have the Date type"; else Return EmptyString; EndIf;
EndIf;
If EndDate = Undefined Then EndDate = EndOfDay(CurrentDate()); Else If TypeOf(EndDate) <> Type("Date") Then Return Message + Chars.LF + "EndDate parameter has to have the Date type"; else Return EmptyString; EndIf; EndIf;
If StartDate <> Undefined Then If EndDate < StartDate Then Return Message + Chars.LF + "EndDate has to be greater than StartDate"; else Return EmptyString; EndIf; EndIf; EndProcedure
Your function does NOT check anything but the very first condition (if the StartdDate parameter has the Date type). As soon as this condition is successfully checked, the function finishes working, because of this string:
Code
Return EmptyString;
Please, note, that any Return operator executed anywhere in a Procedure or Function makes it to stop working and return control to a caller immediately and unconditionally. In other words, no procedure code is executed after the Return operator is executed in this procedure.
Mesut Kahraman wrote: I have added a line Detail Tabular section
No, Mesut, you have not. I suggest you put a breakpoint to the beginning of the ProcessIncomeDocs procedure and trace its execution step by step. This way, you will find you error in no time.
I have done what you say yesterday,I couldn't see the problem,but I see the problem now.Because of I put Return,the code jumps over Incomes code.I made comment line the Return code and the problem has solved.
Thank you very much!
Pages:1
Users browsing this topic (guests: 3, registered: 0, hidden: 0)