Desktop version

Main > Forum > Learning > 1C Junior Developer Course > Common Module Function Error

Forum

Search UsersRules
Common Module Function Error
#1
Interested
Points:: 0
Joined:: Sep 30, 2020

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

Profile
#2
Active user
Points:: 0
Joined:: May 8, 2013

Hi Mesut,

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.

Profile
#3
Interested
Points:: 0
Joined:: Sep 30, 2020

Yes,The problem has solved.

But System says one line should be added to detail tabular section.I have added a line Detail Tabular section.
What is the  problem?

Profile
#4
Active user
Points:: 0
Joined:: May 8, 2013

Quote
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.

Profile
#5
Interested
Points:: 0
Joined:: Sep 30, 2020

I have checked and saw the error: incomes=<?>documents.income.select(satrtdate,enddate) , variable is not defined.

I can not understand?

Profile
#6
Active user
Points:: 0
Joined:: May 8, 2013

Mesut, I wanted you to:

  • Set a breakpoint in the beginning of the ProcessIncomeDocs procedure
  • Run the application and click the Run The Test button
  • After the debugger stops the execution at the breakpoint, trace the procedure step by step and see what it does and what it does not do

Do you know how to use the debugger? Please, check out this episode as an example.

Profile
#7
Interested
Points:: 0
Joined:: Sep 30, 2020

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!

Profile
Subscribe
Users browsing this topic (guests: 1, registered: 0, hidden: 0)



© 1C LLC. All rights reserved
1C Company respects the privacy of our customers and visitors
to our Web-site.