IF CusShM.FINDSET THEN BEGIN REPEAT CLEAR(Salesheader); IF Salesheader.GET(CusShM."Document Type", CusShM."No.") THEN BEGIN CusShM2 := CusShM; //the copy of CusShM could be avoided with parameters on FINDSET, //but personally I had bad experience with them, so using the workaround here CusShM2.VALIDATE("Sell-to Customer No.", Salesheader."Sell-to Customer No."); CusShM2.VALIDATE("Ship-to Name", Salesheader."Ship-to Name"); CusShM2.MODIFY(TRUE); END; UNTIL CusShM.NEXT = 0; END;
Answers
Please guide me for the above requirement, this is my custom table:
I want to populate the remaining field of custom table based on order no that is in sales order(ie from Sales table).
Thanks,
Mani.
A quick explanation on what went wrong with your code:
Thanks for the reply,
but its not populating the remaining fields of my custom table.
Please, guide me regarding this. I am not able to get,where and what i am doing wrong.
Thanks,
Mani.
If you have more, just keep adding them (VALIDATE) inside the code.
Yes, besides the primary key, only have 2 fields - "Sell-to Customer No." and "Ship-to Name".
but as I attached table,that multiple lines have to populate.Even its not populating a single line. where i am doing mistake. Please guide me.
Thanks,
Mani.
You need to write a logic that would loop through Sales Headers that you are interested in and then within that loop, put in the code I wrote. Otherwise, Salesheader will not have anything on it.
For inspiration:
I tried the below code, its not populating the custom table field.
CLEAR(Salesheader);
Salesheader.SETRANGE("No.",CusShM."No.");
Salesheader.SETFILTER("Document Type", 'Order');
IF Salesheader.FINDSET THEN BEGIN
REPEAT
IF CusShM.GET(Salesheader."No.",Salesheader."Document Type") THEN BEGIN
CusShM.VALIDATE("Sell-to Customer No.", Salesheader."Sell-to Customer No.");
CusShM.VALIDATE("Ship-to Name", Salesheader."Ship-to Name");
CusShM.MODIFY(TRUE);
END;
UNTIL Salesheader.NEXT = 0;
END;
Please check and guide.
Thanks,
Mani.
if CusShM.findset then begin
repeat
IF Salesheader.get(CusShM."Document Type",CusShM."No.") then begin
CusShM.VALIDATE("Sell-to Customer No.", Salesheader."Sell-to Customer No.");
CusShM.VALIDATE("Ship-to Name", Salesheader."Ship-to Name");
CusShM.MODIFY(TRUE);
end;
until CusShM.next = 0;
end;
This will repeat your CusShM and find the correlating orders and update the fields.
Thank you for the reply,
I tried your code also, but its not working.Please guide or suggest me what is the mistake or any alternate way to do this.
Thanks,
Mani.
Anyway, then the code changes a little bit:
thanks alot.
Its done.........
Thanks,
Mani.