Insert Data from 1 table to another 1(data exist already)

abhinavmehraabhinavmehra Member Posts: 34
Hello

I am Abhinav Mehra...

I have more confusion.....
I have 2 tables.
1) Branch Plant - Cutomized (Fields are -> Branch Plant Code,Distributor code,Default Branch Plant,Branch Plant, Company Name)
2) Location

In a branch plant Table already some data is there. I want to enter the data from Location table to Branch Plant Table but after the existing data. There is no any Line No. & Serial No....So how i can match...

Thanks In advance......Please Reply Soon....

If u help me to give the code so Please.....

Comments

  • mohana_cse06mohana_cse06 Member Posts: 5,504
    What is the Primary key in Brach Planet table?
  • abhinavmehraabhinavmehra Member Posts: 34
    Branch Plant Table :-

    Primary Key are :- Branch plaant Code & Distributor code

    Bcoz 1 Branch plant code has many distributors.....
  • mohana_cse06mohana_cse06 Member Posts: 5,504
    What is the relation between Location table and branch Planet table?

    Which fields you want to fill from Location table to Branch Planet table?
  • abhinavmehraabhinavmehra Member Posts: 34
    Exactly in my customize table(Branch Plant) there are define the branch plant code for every distributor as default. I have that data in my Branch plant table.....but i also need the branch plant code those are not define for any distributor.

    So i want to show default branch plant for that distributor plus All branch plant those are in Location table.

    I want to match this branch plant code to location's code field if its matched i dont need it otherwise i need those branch plant from location table to branch plant customized table...
  • SogSog Member Posts: 1,023
    could you sketch an ERD? Because the relations are still not quite clear.
    |Pressing F1 is so much faster than opening your browser|
    |To-Increase|
  • abhinavmehraabhinavmehra Member Posts: 34
    ERP Diagram :-


    [Location Table] [Branch Plant Table]

    Fields: Fields:
    1)CODE (IN1001,IN1003) 1)Branch Plant Code (IN1001,IN1002)
    2)Branch Plant (Yes) 2)Distributor Code (ABC warehouse,Roodkie Warehouse)
    3)Company Name 3)Default Branch Plant(Yes)
    4)Branch Plant(Yes)

    Primary Key: CODE Primary Key: Branch Plant Code & Distributor Code


    I need

    Form:

    Branch Plant Code Distributor Code Default Branch Plant Branch Plant

    IN1001 ABC WH Yes Yes
    IN1002 ABC WH Yes Yes
    IN1003 No yes
    IN1004 No yes
    IN1005 NO yes


    I need this form format

    where all branch plant code yes in Location Table & In Branch Plant Table Default yes & also Branch Plant yes

    If Branch Plant Code set in Branch Plant Table then I don't i don't want to put in Branch Plant Table except this i need to show all branch Plant code in Location table in a from.

    I hope this will help....

    I have a problem to solve to how i can compare to Default & Branch Plant for distinct it..

    Thanks in advance....

    I wrote a code


    Location.RESET;

    Location.SETRANGE(Location."Branch Plant",TRUE);
    IF Location.FINDFIRST THEN BEGIN
    REPEAT


    BranchPlantMapping.INIT;
    BranchPlantMapping."Branch/Plant Code":= Location.Code;
    BranchPlantMapping."State Code":=Location."State Code";
    BranchPlantMapping."Branch/Plant":=Location."Branch Plant";
    BranchPlantMapping.INSERT;
    UNTIL Location.NEXT=0;
    END;

    Can u please help to modify it.....

    Thanks
Sign In or Register to comment.