Options

How to insert values in a table from three tables?

thankeshthankesh Member Posts: 170
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***

Answers

  • vijay_gvijay_g Member Posts: 884
    what error you are getting?
    First insert PK value(which one table has from in three) and then modify other fields(with remaning two).
  • kash387kash387 Member Posts: 111
    thankesh wrote:
    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>

    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..????
    Thanks,

    Kashyap
  • thankeshthankesh Member Posts: 170
    kash387 wrote:
    thankesh wrote:
    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>

    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..????

    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~
    With warm regards,

    Thankesh

    ***Learn to lead***
  • vijay_gvijay_g Member Posts: 884
    Try it...

    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);
  • thankeshthankesh Member Posts: 170
    edited 2010-07-23
    vijay_g wrote:
    Try it...

    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;
    With warm regards,

    Thankesh

    ***Learn to lead***
  • kash387kash387 Member Posts: 111
    You just need to edit your own code with the code given from Vijay, so just find out the same lines of your codes and edit them with the comments of vijay's code.
    Thanks,

    Kashyap
  • thankeshthankesh Member Posts: 170
    kash387 wrote:
    You just need to edit your own code with the code given from Vijay, so just find out the same lines of your codes and edit them with the comments of vijay's code.
    Thank you so much kashyap. I did debugging but the Qualityline table does not gets populated. kindly see my previous reply. FY reference.
    With warm regards,

    Thankesh

    ***Learn to lead***
  • kash387kash387 Member Posts: 111
    Hi Thankesh,

    I am little confused here.... are you getting the record (Quality Line), when system runs your code,
    QualityLine.SETRANGE("Document No.",QualityHeader."No.");
    if QualityLine.findfirst then
    .
    .
    .
    Thanks,

    Kashyap
  • vijay_gvijay_g Member Posts: 884
    edited 2010-07-23
    Now try this....

    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;
  • thankeshthankesh Member Posts: 170
    kash387 wrote:
    Hi Thankesh,

    I am little confused here.... are you getting the record (Quality Line), when system runs your code,

    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.
    With warm regards,

    Thankesh

    ***Learn to lead***
  • thankeshthankesh Member Posts: 170
    edited 2010-07-23
    vijay_g wrote:
    Now try this....

    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 vijay,

    After pasting your code I get the error like this.

    Item no. '' does not exist.
    With warm regards,

    Thankesh

    ***Learn to lead***
  • vijay_gvijay_g Member Posts: 884
    Check TPheader and TPline and also check "est plan" define or not for item.
    TPHeader.SETRANGE(TPHeader."No.",Item."Test Plan");
    
  • thankeshthankesh Member Posts: 170
    vijay_g wrote:
    Check TPheader and TPline and also check "est plan" define or not for item.
    TPHeader.SETRANGE(TPHeader."No.",Item."Test Plan");
    
    Hi vijay,

    Item '' does not exist.


    error comes once i replace with the new code given by you.
    With warm regards,

    Thankesh

    ***Learn to lead***
  • kash387kash387 Member Posts: 111
    Item '' does not exist.

    I hope you are not out of your

    with WRHeader Do Begin
    .
    .
    .
    .
    end statement.
    Thanks,

    Kashyap
  • thankeshthankesh Member Posts: 170
    kash387 wrote:
    Item '' does not exist.

    I hope you are not out of your

    with WRHeader Do Begin
    .
    .
    .
    .
    end statement.


    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;
    With warm regards,

    Thankesh

    ***Learn to lead***
  • kash387kash387 Member Posts: 111
    But where is
    WRLine.setrange("Document No.",WRHeader."No.");
    ...??????
    Thanks,

    Kashyap
  • thankeshthankesh Member Posts: 170
    kash387 wrote:
    Item '' does not exist.

    I hope you are not out of your

    with WRHeader Do Begin
    .
    .
    .
    .
    end statement.

    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;
    With warm regards,

    Thankesh

    ***Learn to lead***
  • thankeshthankesh Member Posts: 170
    Hi kashyap,

    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.
    With warm regards,

    Thankesh

    ***Learn to lead***
  • kash387kash387 Member Posts: 111
    WITH WRHeader DO BEGIN
    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;
    Thanks,

    Kashyap
  • thankeshthankesh Member Posts: 170
    kash387 wrote:
    WITH WRHeader DO BEGIN
    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;


    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??
    With warm regards,

    Thankesh

    ***Learn to lead***
  • kash387kash387 Member Posts: 111
    Yes. This works. Thank you so much Kashyap & vijay. :thumbsup:

    Well, you are welcome....

    But How can we control the multiple times of creating quality order from a single warehouse receipt??

    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.....
    Thanks,

    Kashyap
  • thankeshthankesh Member Posts: 170
    Hi kashyap/vijay,

    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;
    With warm regards,

    Thankesh

    ***Learn to lead***
  • thankeshthankesh Member Posts: 170
    thankesh wrote:
    Hi kashyap/vijay,

    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;


    Hi kashyap/vijay,

    I could not solve this issue. Kindly do help me. =D>
    With warm regards,

    Thankesh

    ***Learn to lead***
  • kash387kash387 Member Posts: 111
    Hi Thankesh,

    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...!!!
    Thanks,

    Kashyap
  • thankeshthankesh Member Posts: 170
    kash387 wrote:
    Hi Thankesh,

    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...!!!


    Finished already!!! =D>
    With warm regards,

    Thankesh

    ***Learn to lead***
Sign In or Register to comment.