Hi all,
I want to insert values from three tables namely Test plan header, Test plan line and Warehouse receipt line to quality line . How to achieve this?? Give your replies. :roll: Thanks in advance =D>
With warm regards,
Thankesh
***Learn to lead***
0
Answers
First insert PK value(which one table has from in three) and then modify other fields(with remaning two).
If you want to insert the records into Quality line table, then why you want to insert Header table records in line table...???
Second thing, you can achieve this by creating PK of Quality line, either mixture of all the three table's PK or by adding QualityLineNo and TestPlanHeaderDocNo as keys...!!!
Have you tried for this or you want solution..????
Kashyap
This is the code I have tried as a function in the codeunit "CreateQO", but it does not create any quality order.
CreateFromWhseRcpt(WRHeader : Record "DT Warehouse Receipt Header")
WITH WRHeader DO BEGIN
WRLine.SETRANGE(WRLine."No.",WRHeader."No.");
IF WRLine.FINDFIRST THEN
QualityHeader.LOCKTABLE;
QualityHeader.INIT;
QualityHeader."No." := '';
QualityHeader."Item No." := WRLine."Item No.";
QualityHeader.INSERT(TRUE);
COMMIT;
ActivitiesCreated := ActivitiesCreated + 1;
QualityHeaderCreated := TRUE;
QualityLine.RESET;
QualityLine.SETRANGE(QualityLine."Document No.",QualityHeader."No.");
IF QualityLine.FINDFIRST THEN
Item.GET;
TPHeader.SETRANGE(TPHeader."No.",Item."Test Plan");
IF TPHeader.FINDFIRST THEN
IF TPLine.GET(TPHeader."No.") THEN
REPEAT
QualityLine.INIT;
QualityLine."Sample Quantity" := WRLine."DC Quantity";
QualityLine."Standard value" := TPLine."Standard value";
QualityLine."Minimum value" := TPLine."Minimum value";
QualityLine."Maximum value" := TPLine."Maximum value";
QualityLine.INSERT(TRUE);
COMMIT;
FORM.RUN(FORM::"Quality Order",QualityHeader);
UNTIL QualityLine.NEXT = 0;
END;
The requirement is,
• While executing the Create quality order from warehouse receipt function, system has to create new quality order for each item in the Warehouse receipt line;
o No. sequences has to come from Location card if not exist then from setup
o GRN Quantity and purchase order information has to flow from warehouse receipt line quantity field
o Test plan attached in item should flow automatically to the quality header
o Quality line has to create based on the Test plan lines
Thanks in advancce =P~
Thankesh
***Learn to lead***
IF QualityLine.FINDFIRST THEN
Item.GET;//// Item.GET(WRLine."Item No.");
TPHeader.SETRANGE(TPHeader."No.",Item."Test Plan");
and..
QualityLine.INIT;///Delete this line
QualityLine.INSERT(TRUE);///// QualityLine.MODIFY(TRUE);
Hi vijay/Kashyap,
Thank you so much for your kind reply. I tried with your codes, but still the quality order has not been created.
While I go for debugging the following codes, the Qualityline table does not gets populated.
QualityLine.RESET;
QualityLine.SETRANGE(QualityLine."Document No.",QualityHeader."No.");
IF QualityLine.FINDFIRST THEN //the Qualityline table does not gets populated.
Item.GET(WRLine."Item No.");
TPHeader.SETRANGE(TPHeader."No.",Item."Test Plan");
IF TPHeader.FINDFIRST THEN
IF TPLine.GET(TPHeader."No.") THEN
REPEAT
QualityLine."Sample Quantity" := WRLine."DC Quantity";
QualityLine."Standard value" := TPLine."Standard value";
QualityLine."Minimum value" := TPLine."Minimum value";
QualityLine."Maximum value" := TPLine."Maximum value";
QualityLine.MODIFY(TRUE);
COMMIT;
FORM.RUN(FORM::"Quality Order",QualityHeader);
UNTIL QualityLine.NEXT = 0;
Thankesh
***Learn to lead***
Kashyap
Thankesh
***Learn to lead***
I am little confused here.... are you getting the record (Quality Line), when system runs your code,
Kashyap
QualityLine.SETRANGE("Document No.",QualityHeader."No.");
if not QualityLine.findfirst then begin
QualityLine.init;
QualityLine."Document No." := QualityHeader."No.";
Item.GET(WRLine."Item No.");
TPHeader.SETRANGE(TPHeader."No.",Item."Test Plan");
IF TPHeader.FINDFIRST THEN
IF TPLine.GET(TPHeader."No.") THEN
QualityLine."Sample Quantity" := WRLine."DC Quantity";
QualityLine."Standard value" := TPLine."Standard value";
QualityLine."Minimum value" := TPLine."Minimum value";
QualityLine."Maximum value" := TPLine."Maximum value";
QualityLine.INSERT(TRUE);
COMMIT;
FORM.RUN(FORM::"Quality Order",QualityHeader);
END else
QualityLine."Document No." := QualityHeader."No.";
Item.GET(WRLine."Item No.");
TPHeader.SETRANGE(TPHeader."No.",Item."Test Plan");
IF TPHeader.FINDFIRST THEN
IF TPLine.GET(TPHeader."No.") THEN
QualityLine."Sample Quantity" := WRLine."DC Quantity";
QualityLine."Standard value" := TPLine."Standard value";
QualityLine."Minimum value" := TPLine."Minimum value";
QualityLine."Maximum value" := TPLine."Maximum value";
QualityLine.modify;
END;
Hi Kashyap,
Yes... You are right. While we select the menu "create quality order" from warehouse receipt form, the quality order should be created with the populated values.
Thankesh
***Learn to lead***
Hi vijay,
After pasting your code I get the error like this.
Item no. '' does not exist.
Thankesh
***Learn to lead***
Item '' does not exist.
error comes once i replace with the new code given by you.
Thankesh
***Learn to lead***
I hope you are not out of your
with WRHeader Do Begin
.
.
.
.
end statement.
Kashyap
yes.. I am inside these codes only.. This is the full code... Yet the "Item ' ' does not exist" error occurs
CreateFromWhseRcpt(WRHeader)//function
WITH WRHeader DO BEGIN
QualityLine.SETRANGE("Document No.",QualityHeader."No.");
IF NOT QualityLine.FINDFIRST THEN BEGIN
QualityLine.INIT;
QualityLine."Document No." := QualityHeader."No.";
Item.GET(WRLine."Item No.");
TPHeader.SETRANGE(TPHeader."No.",Item."Test Plan");
IF TPHeader.FINDFIRST THEN
IF TPLine.GET(TPHeader."No.") THEN
QualityLine."Sample Quantity" := WRLine."DC Quantity";
QualityLine."Standard value" := TPLine."Standard value";
QualityLine."Minimum value" := TPLine."Minimum value";
QualityLine."Maximum value" := TPLine."Maximum value";
QualityLine.INSERT(TRUE);
COMMIT;
FORM.RUN(FORM::"Quality Order",QualityHeader);
END ELSE
QualityLine."Document No." := QualityHeader."No.";
Item.GET(WRLine."Item No.");
TPHeader.SETRANGE(TPHeader."No.",Item."Test Plan");
IF TPHeader.FINDFIRST THEN
IF TPLine.GET(TPHeader."No.") THEN BEGIN
QualityLine."Sample Quantity" := WRLine."DC Quantity";
QualityLine."Standard value" := TPLine."Standard value";
QualityLine."Minimum value" := TPLine."Minimum value";
QualityLine."Maximum value" := TPLine."Maximum value";
QualityLine.MODIFY;
END;
END;
Thankesh
***Learn to lead***
...??????
Kashyap
Yes I'm not out of this statements. Yet I got the Item '' does not exist error.
Full code is here.
WITH WRHeader DO BEGIN
QualityLine.SETRANGE("Document No.",QualityHeader."No.");
IF NOT QualityLine.FINDFIRST THEN BEGIN
QualityLine.INIT;
QualityLine."Document No." := QualityHeader."No.";
Item.GET(WRLine."Item No.");
TPHeader.SETRANGE(TPHeader."No.",Item."Test Plan");
IF TPHeader.FINDFIRST THEN
IF TPLine.GET(TPHeader."No.") THEN
QualityLine."Sample Quantity" := WRLine."DC Quantity";
QualityLine."Standard value" := TPLine."Standard value";
QualityLine."Minimum value" := TPLine."Minimum value";
QualityLine."Maximum value" := TPLine."Maximum value";
QualityLine.INSERT(TRUE);
COMMIT;
FORM.RUN(FORM::"Quality Order",QualityHeader);
END ELSE
QualityLine."Document No." := QualityHeader."No.";
Item.GET(WRLine."Item No.");
TPHeader.SETRANGE(TPHeader."No.",Item."Test Plan");
IF TPHeader.FINDFIRST THEN
IF TPLine.GET(TPHeader."No.") THEN BEGIN
QualityLine."Sample Quantity" := WRLine."DC Quantity";
QualityLine."Standard value" := TPLine."Standard value";
QualityLine."Minimum value" := TPLine."Minimum value";
QualityLine."Maximum value" := TPLine."Maximum value";
QualityLine.MODIFY;
END;
END;
Thankesh
***Learn to lead***
Thank you so much for your reply.
can you please tell me where i have to include this?
WRLine.SETRANGE("No.",WRHeader."No.");
Otherwise give the full modified code.
Thankesh
***Learn to lead***
WRLine.SETRANGE("Document No.",WRHeader."No.");
if WRLine.FINDFIRST then repeat
// Here you have to write code for your Quality Header part
QualityLine.SETRANGE("Document No.",QualityHeader."No.");
IF NOT QualityLine.FINDFIRST THEN BEGIN
QualityLine.INIT;
QualityLine."Document No." := QualityHeader."No.";
Item.GET(WRLine."Item No.");
TPHeader.SETRANGE(TPHeader."No.",Item."Test Plan");
IF TPHeader.FINDFIRST THEN
IF TPLine.GET(TPHeader."No.") THEN
QualityLine."Sample Quantity" := WRLine."DC Quantity";
QualityLine."Standard value" := TPLine."Standard value";
QualityLine."Minimum value" := TPLine."Minimum value";
QualityLine."Maximum value" := TPLine."Maximum value";
QualityLine.INSERT(TRUE);
COMMIT;
FORM.RUN(FORM::"Quality Order",QualityHeader);
END ELSE
QualityLine."Document No." := QualityHeader."No.";
Item.GET(WRLine."Item No.");
TPHeader.SETRANGE(TPHeader."No.",Item."Test Plan");
IF TPHeader.FINDFIRST THEN
IF TPLine.GET(TPHeader."No.") THEN BEGIN
QualityLine."Sample Quantity" := WRLine."DC Quantity";
QualityLine."Standard value" := TPLine."Standard value";
QualityLine."Minimum value" := TPLine."Minimum value";
QualityLine."Maximum value" := TPLine."Maximum value";
QualityLine.MODIFY;
END;
until WRLine.next=0;
END;
Kashyap
Yes. This works. Thank you so much Kashyap & vijay. :thumbsup: But How can we control the multiple times of creating quality order from a single warehouse receipt??
Thankesh
***Learn to lead***
Well, you are welcome....
Try boolean field on Warehouse Receipt Form, that sets true after generation the complete Quality Order..!!!
So next time you click on it, it will prompt error...
Else, create one field on Quality Order(Header) and populate it with the Warehouse Receipt No. field.
Now, put the checkdoc(return boolean) function before your code start generating the Quality Orders.....
Kashyap
Thank you so much for your fruitful replies. I'm half way down in this functionality.
While creating quality order from warehouse receipt, the quality header has been created. But, the quality lines are not populated. Anyone can help me? #-o
Here is the code:
CreateFromWhseRcpt(WRHeader : Record "DT Warehouse Receipt Header") //
WITH WRHeader DO BEGIN
WRLine.SETRANGE("No.",WRHeader."No.");
IF WRLine.FINDFIRST THEN REPEAT
// code for Quality Header part
QualityHeader.LOCKTABLE;
QualityHeader.INIT;
QualityHeader."No." := '';
QualityHeader."Item No." := WRLine."Item No.";
QualityHeader.Description := WRLine.Description;
QualityHeader."Description 2" := WRLine."Description 2";
QualityHeader."Sample value" := WRLine.Quantity;
QualityHeader."DC Quantity" := WRLine."DC Quantity";
QualityHeader."Accepted Quantity" := WRLine."Act. Receipt Qty";
QualityHeader."Rejected Quantity" := WRLine."Shortage Qty";
QualityHeader."Assigned User ID" := USERID;
QualityHeader."Test Plan" := TPHeader."No.";
QualityHeader."Sampling Method" := TPHeader."Sampling Method";
QualityHeader."Document Status" := QualityHeader."Document Status"::Pass;
QualityHeader."Reference Order Type":= QualityHeader."Reference Order Type"::Purchase;
QualityHeader."Reference Order No." := WRHeader."Receiving No.";
TPHeader.SETRANGE(TPHeader."No.",Item."Test Plan");
IF TPHeader.FINDFIRST THEN
IF(TPHeader."Sampling Method" = TPHeader."Sampling Method" :: "Fixed Quantity") THEN
QualityHeader."Sample Quantity" := TPHeader."Sample value";
IF(TPHeader."Sampling Method" = TPHeader."Sampling Method" :: Percentage) THEN
QualityHeader."Sample Quantity" := WRLine."DC Quantity"* TPHeader."Sample value";
QualityHeader.INSERT(TRUE);
COMMIT;
ActivitiesCreated := ActivitiesCreated + 1;
QualityHeaderCreated := TRUE;
QualityLine.SETRANGE("Document No.",QualityHeader."No.");
IF NOT QualityLine.FINDFIRST THEN BEGIN
QualityLine.INIT;
QualityLine."Document No." := QualityHeader."No.";
Item.GET(WRLine."Item No.");
TPHeader.SETRANGE(TPHeader."No.",Item."Test Plan");
IF TPHeader.FINDFIRST THEN
IF TPLine.GET(TPHeader."No.") THEN
QualityLine."Sample Quantity" := WRLine."DC Quantity";
QualityLine."Standard value" := TPLine."Standard value";
QualityLine."Minimum value" := TPLine."Minimum value";
QualityLine."Maximum value" := TPLine."Maximum value";
QualityLine.Status := QualityLine.Status::Pass;
// Code for QualityHeader "Sample Quantity"
IF(TPHeader."Sampling Method" = TPHeader."Sampling Method" :: "Fixed Quantity") THEN
QualityLine."Sample Quantity":= TPHeader."Sample value";
IF(TPHeader."Sampling Method" = TPHeader."Sampling Method" :: Percentage) THEN
QualityLine."Sample Quantity":= WRLine."DC Quantity"* TPHeader."Sample value";
QualityLine.INSERT(TRUE);
COMMIT;
FORM.RUN(FORM::"Quality Order",QualityHeader);
END ELSE
QualityLine."Document No." := QualityHeader."No.";
Item.GET(WRLine."Item No.");
TPHeader.SETRANGE(TPHeader."No.",Item."Test Plan");
IF TPHeader.FINDFIRST THEN
QualityLine."Sample Quantity" := WRLine."DC Quantity";
QualityLine."Standard value" := TPLine."Standard value";
QualityLine."Minimum value" := TPLine."Minimum value";
QualityLine."Maximum value" := TPLine."Maximum value";
QualityLine.Status := QualityLine.Status::Pass;
//Code for QualityLine "Sample Quantity"
IF(TPHeader."Sampling Method" = TPHeader."Sampling Method" :: "Fixed Quantity") THEN
QualityLine."Sample Quantity":= TPHeader."Sample value";
IF(TPHeader."Sampling Method" = TPHeader."Sampling Method" :: Percentage) THEN
QualityLine."Sample Quantity":= WRLine."DC Quantity"* TPHeader."Sample value";
IF TPLine.GET(TPHeader."No.") THEN BEGIN
QualityLine.MODIFY;
END;
UNTIL WRLine.NEXT=0;
END;
Thankesh
***Learn to lead***
Hi kashyap/vijay,
I could not solve this issue. Kindly do help me. =D>
Thankesh
***Learn to lead***
The answer is hidden in your code only....
You just need to modify it...
Use debugger, keep the breakpoints on at trigger, and see which of the code is not getting executed.
You will come to know then what to do and where to do....!!!!
After doing that, if you are stuck somewhere, then let me know where...!!! but i m sure it will be done by you...!!!
Kashyap
Finished already!!! =D>
Thankesh
***Learn to lead***