Common Module Function Error

For students who study 1C Junior course.

#1
People who like this:0Yes/0No
Interested
Rating: 10
Joined: Sep 30, 2020
Company: Nortek Bilişim

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

 
#2
People who like this:0Yes/0No
Active user
1C:Professional
Rating: 8
Joined: May 8, 2013
Company: 1C Company

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.

Edited: Konstantin Rupasov - Oct 09, 2020 01:02 AM
 
#3
People who like this:0Yes/0No
Interested
Rating: 10
Joined: Sep 30, 2020
Company: Nortek Bilişim

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?

 
#4
People who like this:0Yes/0No
Active user
1C:Professional
Rating: 8
Joined: May 8, 2013
Company: 1C Company

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.

 
#5
People who like this:0Yes/0No
Interested
Rating: 10
Joined: Sep 30, 2020
Company: Nortek Bilişim

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

I can not understand?

 
#6
People who like this:0Yes/0No
Active user
1C:Professional
Rating: 8
Joined: May 8, 2013
Company: 1C Company

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.

 
#7
People who like this:0Yes/0No
Interested
Rating: 10
Joined: Sep 30, 2020
Company: Nortek Bilişim

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!

 
Subscribe
Be the first to know tips & trick on business application development!

A confirmation e-mail has been sent to the e-mail address you provided .

Click the link in the e-mail to confirm and activate the subscription.