Need to calculate return date automatically

I have transdate field that is today date, and have to be return date field.

If a book is subscribed today user need to return the book with in 4 weeks if the pages is more than 1000, if it is less user need to return with in 2 weeks.

How can i write my method for above condition in table level

Thanks in advance…

if (pages > 1000)
returnDate = transDate + (47);
else
returnDate = transDate + (2
7)

No its not getting the return date…
I write in validate write method as
public boolean validateWrite()
{
boolean ret;
AX_BookMaster axb;
AX_SubscriberLine axs;
;
ret = super();
if(axb.Pages>‘1000’)
this.TobeReturnDate= axs.TransDate+(47);
else
this.TobeReturnDate=axs.TransDate+(2
7);
return ret;
}

when I gave the transdate it is displaying as 15/11/90

You shouldn’t be doing it in validateWrite() method.
Override modified field on table and write a case for TransDate
if(axb.Pages>‘1000’)
this.TobeReturnDate= this.TransDate+(47);
else
this.TobeReturnDate=this.TransDate+(2
7);

You are not selecting axb record. So it will always goes to else, you need to find the axb record before doing it.

i already wrote one modified field method as
public void modifiedField(fieldId _fieldId)
{
AX_SubscriberLine axsl;
;
super(_fieldId);
if(_fieldId==fieldnum(AX_Transaction,Book_Id))
{
select axsl where axsl.Book_Id==this.Book_Id;
this.Sub_Id=axsl.Sub_Id;
this.TransDate=axsl.TransDate;
}
}

how can i override again in modifield field method.

check the example from standard table like CustTable.

ok!

Then you don’t have to override it. Modify it.
switch(_fieldId)
{
case fieldNum(fieldnum(AX_Transaction,Book_Id)):
select axsl where axsl.Book_Id==this.Book_Id;
this.Sub_Id=axsl.Sub_Id;
this.TransDate=axsl.TransDate;

break;
case fieldNum(AX_Transaction, TransDate):
// place your logic here
break;
}

public void modifiedField(fieldId _fieldId)
{
AX_SubscriberLine axsl;
AX_BookMaster axb;
;
super(_fieldId);
switch(_fieldId)
{
case fieldnum(AX_Transaction,Book_Id):
select axsl where axsl.Book_Id==this.Book_Id;
this.Sub_Id=axsl.Sub_Id;
this.TransDate=axsl.TransDate;

break;
case fieldNum(AX_Transaction, ToBeReturnDate):
if(axb.Pages>‘1000’)
this.TobeReturnDate= axsl.TransDate+(47);
else
this.TobeReturnDate=axsl.TransDate+(2
7);

break;
}
/*
if(_fieldId==fieldnum(AX_Transaction,Book_Id))
{
select axsl where axsl.Book_Id==this.Book_Id;
this.Sub_Id=axsl.Sub_Id;
this.TransDate=axsl.TransDate;
}*/
}

Again its not calculating:(((

case fieldNum(AX_Transaction, TransDate)

You are not selecting any record - axb

how to do tat??

You should be knowing the relation between current table and AX_BookMaster
Example - select firstonly pages from axb where axb.Book_Id == this.Book_Id;

stil i cant get the return date, Kranthi:(

I have following tables : AX_BookMaster with book name, id, author name, pages, isbn num

AX_Subscriber table with subscriber id, name and address
I have the subscriberlines in another table with fields SubscriberId,BookId and transdate as today date.

I create relation in subscriberline table to bookid and subscriber id.

Now I created another table as Transaction table to mention the tobereturndate of the book and status as checkin, checkout…
When the book is subscribed it need to change the status as checkout and when it is returned it need to change as checkin.

in transaction table i tried to write the modified field coding as you mentioned:
public void modifiedField(fieldId _fieldId)
{
AX_SubscriberLine axsl;
AX_BookMaster axb;
;
super(_fieldId);
switch(_fieldId)
{
case fieldnum(AX_Transaction,Book_Id):
select axsl where axsl.Book_Id==this.Book_Id;
this.Sub_Id=axsl.Sub_Id;
this.TransDate=axsl.TransDate;
break;

case fieldNum(AX_Transaction, ToBeReturnDate):
while select pages from axb where axb.Book_Id==this.Book_Id
{
if(axb.Pages>‘1000’)
this.TobeReturnDate= axsl.TransDate+(47);
else
this.TobeReturnDate=axsl.TransDate+(2
7);
}
break;
}
/*
if(_fieldId==fieldnum(AX_Transaction,Book_Id))
{
select axsl where axsl.Book_Id==this.Book_Id;
this.Sub_Id=axsl.Sub_Id;
this.TransDate=axsl.TransDate;
}*/
}

but it is not getting the return date please give me the exact coding…

You can debug and see why it is not calculating.

In subscriberline i need to give validation as customer can’t subscribe more than 4 books:

I write validatewrite method as follows:
public boolean validateWrite()
{
boolean ret;
AX_SubscriberLine axs;
;
ret = super();
while select count(Sub_Id) from axs
if(axs.Sub_Id>=‘4’)
warning(“User can’t subscriber more than 4 books”);
return ret;
}

But it’s storing the record of book_id i’m giving more than 4 times, please help

You are combining multiple issues and making it difficult to answer.

Hi, if you want to get return date based on trans date the case condition should be TransDate field instead of TobeReturnDate, try this:

public void modifiedField(fieldId _fieldId)
{
AX_SubscriberLine axsl;
AX_BookMaster axb;
;
super(_fieldId);
switch(_fieldId)
{

case fieldNum(AX_Transaction, TransDate):
while select pages from axb where axb.Book_Id==this.Book_Id
{
if(axb.Pages>‘1000’)
this.TobeReturnDate= axsl.TransDate+(47);
else
this.TobeReturnDate=axsl.TransDate+(2
7);
}
break;
}

}