How to Add the data dynamically in Tax Area Location table??

kishi_gkishi_g Member Posts: 162
Hi,
I had one doubt. I created locations. By using the below code Tax Area Locations(13761).

IF Loc.FIND('-') THEN
REPEAT
TaxAreaLoc.RESET;
TaxAreaLoc.SETRANGE(Type,TaxAreaLoc.Type::Customer);
TaxAreaLoc.SETRANGE(TaxAreaLoc."Dispatch / Receiving Location",Loc.Code);
IF NOT TaxAreaLoc.FIND('-') THEN BEGIN
TaxAreaLoc.Type := TaxAreaLoc.Type ::Customer;
TaxAreaLoc."VAT Applicable" := TRUE;
TaxAreaLoc."Dispatch / Receiving Location" :=Loc.Code;
TaxAreaLoc."Customer / Vendor Location" := '02';
TaxAreaLoc."Tax Area Code" := 'VAT';
TaxAreaLoc.INSERT;
END;
UNTIL Loc.NEXT = 0;

But how can i modify the data if some fields having data and some fields not having the data. i wrote the code TaxAreaLoc.modify . then i am getting the error.

because In the Tax Area Locations the Primary key is
"Type,Dispatch / Receiving Location,Customer / Vendor Location,VAT Applicable"

How can i modify the data(some fields not having the data).



Thanks & Regards,
kishore...

Comments

  • arindomarindom Member Posts: 52
    By study u'r code I understand that u just modify the taxarealoc table ,so u'have to modify the table not insert .write TaxAreaLoc.Modify .All data will be updataed .

    IF you want to insert then also udate the primary key values of table 13761.

    You have SETRANGE with Location If than it will give data set with that location .IF TaxAreaLoc."Dispatch / Receiving Location" is available that means data already available in table TaxAreaLoc . SO you have to modify .
    TaxAreaLoc.MODIFY;
  • kishi_gkishi_g Member Posts: 162
    Hi,
    Thanks for ur reply.
    if the all fields are empty then we will use TaxAreaLoc.INSERT . it is not a problem. some fileds having data not the all fields when i assign the data from the above code we will use TaxAreaLoc.modify. Here iam getting the error. because all fields are assigned as a primary key.


    Thanks & Regards,
    kishore...
  • arindomarindom Member Posts: 52
    Write bellow code I think it will work




    IF Loc.FIND('-') THEN
    REPEAT
    TaxAreaLoc.RESET;
    TaxAreaLoc.SETRANGE(Type,TaxAreaLoc.Type::Customer);
    TaxAreaLoc.SETRANGE(TaxAreaLoc."Dispatch / Receiving Location",Loc.Code);
    IF NOT TaxAreaLoc.FIND('-') THEN BEGIN
    TaxAreaLoc.Type := TaxAreaLoc.Type ::Customer;
    TaxAreaLoc."VAT Applicable" := TRUE;
    TaxAreaLoc."Dispatch / Receiving Location" :=Loc.Code;
    TaxAreaLoc."Customer / Vendor Location" := '02';
    TaxAreaLoc."Tax Area Code" := 'VAT';
    TaxAreaLoc.INSERT;
    END
    ELSE Begin

    TaxAreaLoc.Type := "data u want assign" TaxAreaLoc."VAT Applicable" := "data u want assign"
    TaxAreaLoc."Dispatch / Receiving Location" :="data u want assign"
    TaxAreaLoc."Customer / Vendor Location" := "data u want assign"
    TaxAreaLoc."Tax Area Code" := "data u want assign"
    TaxAreaLoc.MODIFY;


    UNTIL Loc.NEXT = 0
  • arindomarindom Member Posts: 52
    Write bellow code I think it will work




    IF Loc.FIND('-') THEN
    REPEAT
    TaxAreaLoc.RESET;
    TaxAreaLoc.SETRANGE(Type,TaxAreaLoc.Type::Customer);
    TaxAreaLoc.SETRANGE(TaxAreaLoc."Dispatch / Receiving Location",Loc.Code);
    IF NOT TaxAreaLoc.FIND('-') THEN BEGIN
    TaxAreaLoc.Type := TaxAreaLoc.Type ::Customer;
    TaxAreaLoc."VAT Applicable" := TRUE;
    TaxAreaLoc."Dispatch / Receiving Location" :=Loc.Code;
    TaxAreaLoc."Customer / Vendor Location" := '02';
    TaxAreaLoc."Tax Area Code" := 'VAT';
    TaxAreaLoc.INSERT;
    END
    ELSE Begin

    TaxAreaLoc.Type := "data u want assign"
    TaxAreaLoc."VAT Applicable" := "data u want assign"
    TaxAreaLoc."Dispatch / Receiving Location" :="data u want assign"
    TaxAreaLoc."Customer / Vendor Location" := "data u want assign"
    TaxAreaLoc."Tax Area Code" := "data u want assign"
    TaxAreaLoc.MODIFY;
    END;

    UNTIL Loc.NEXT = 0
  • arindomarindom Member Posts: 52
    Sorry my given code also not workable because there all are primary key .It not able to modify .
  • bappaditya44bappaditya44 Member Posts: 14
    You should rather use Rename function in that case .
  • arindomarindom Member Posts: 52
    TaxAreaLoc.RENAME;
Sign In or Register to comment.