Options

PurchaseHeader and Requisition Line Problem in C/AL

Shibby01Shibby01 Member Posts: 17
edited 2012-04-16 in NAV Three Tier
Hey
iam new in microsoft dynamics nav and need help by developing in C/AL.

I want to create a purchase quote with the requisition worksheet.
This function does not exist in ms dynamics nav.
So how can i get the requisition line data from the requisition worksheet to a new purchase quote???

This is a cut out from ma source code, which create an new purchase quote with the last free data record.

// ++ START
PurchaseHeader.SETRANGE("No.",'1000');

IF PurchaseHeader.FIND('-') THEN
REPEAT
UNTIL PurchaseHeader.NEXT(+1)=0;

PurchaseHeader.INSERT(TRUE);

PurchaseQuote.RUN;
// --END

I would be grateful for an answer.

Answers

  • Options
    mohana_cse06mohana_cse06 Member Posts: 5,503
    If we call Carryout Action Message function from requision line then it will create Purchase Orders..

    Check the coding and you can try by changing Document type from Order to Quote..
  • Options
    SavatageSavatage Member Posts: 7,142
    That's where I would start also.

    Check out the code on the report 493 (Carry Out Action Msg. - Req.)
    It probably leads you to CU 333 (Req. Wksh.-Make Order).

    If you are going to make changes, once you figure out how it's determining the "Document Type" - you probably would be better off making an option from the report where the user can choose between "Order" & "Quote". that way you don't lose the original functionality but adding to it.
  • Options
    Shibby01Shibby01 Member Posts: 17
    Savatage wrote:
    That's where I would start also.

    Check out the code on the report 493 (Carry Out Action Msg. - Req.)
    It probably leads you to CU 333 (Req. Wksh.-Make Order).

    If you are going to make changes, once you figure out how it's determining the "Document Type" - you probably would be better off making an option from the report where the user can choose between "Order" & "Quote". that way you don't lose the original functionality but adding to it.


    Thanks for your help, it was a good idea.
    i changed the document type from Order to Quote and got quotes instead of orders as result.
    yes you´re right, a better solution is making an option to choose between both, but i dont know exactly how to make it.

    I made a new Page Action in the Requisition Worksheet 291 which is called "Create Quotes". My Question is how can i use the CodeUnit 333 for example if i press the button?




    [/color]
  • Options
    mohana_cse06mohana_cse06 Member Posts: 5,503
    You have to add a boolean field in Request form of report 493 like "Create Quotes"..and pass the boolean value to CU333 using a new function or parameter in Set function..

    If CU333, you have use this boolean to create Document type like
    IF CreateQuotes then
      Document Type := Document Type::Quote
    ELSE
      Document Type := Document Type::Order;
    
  • Options
    Shibby01Shibby01 Member Posts: 17
    You have to add a boolean field in Request form of report 493 like "Create Quotes"..and pass the boolean value to CU333 using a new function or parameter in Set function..

    If CU333, you have use this boolean to create Document type like
    IF CreateQuotes then
      Document Type := Document Type::Quote
    ELSE
      Document Type := Document Type::Order;
    

    thanks for your help,
    I followed your instructions, but i got quotes only.
    it is all the same whether the check box is active or not.

    i changed two entries in the UC 333
    from
    PurchOrderHeader."Document Type" := PurchOrderHeader."Document Type"::Quote;
    into
    PurchOrderHeader."Document Type" := DocumentType; //Create Quote001

    "DocumentType" is defined as an integer.

    have you an advice for me?
  • Options
    SavatageSavatage Member Posts: 7,142
    Shibby01 wrote:
    i changed the document type from Order to Quote and got quotes instead of orders as result.

    Mohana mentions "IF" cu 333.

    So based upon your first quote, can you tell use where you made the change so that you were getting quotes instead of orders?
  • Options
    Shibby01Shibby01 Member Posts: 17
    Savatage wrote:
    Shibby01 wrote:
    i changed the document type from Order to Quote and got quotes instead of orders as result.

    Mohana mentions "IF" cu 333.

    So based upon your first quote, can you tell use where you made the change so that you were getting quotes instead of orders?

    okay, here Step by step.
    1) First of all i added a new global variable "CreateQuotes" as boolean.

    2) i designed the report 493 (carry out action msg.) in request page and added a new group named "quotes" a new field "CreateQuotes"
    with SourceExpr "CreateQuotes".

    3) i designed the CU 333 (Req. Wksh.-Make Order) and create a new function "setCreateQuotes" in C/AL Globals.

    4) i changed into C/AL from the CU 333 and the function "setCreateQuotes" is filled with the following code:

    // ++Create Quote001
    IF CreateQuotes THEN
    DocumentType := PurchOrderHeader."Document Type"::Quote
    ELSE
    DocumentType := PurchOrderHeader."Document Type"::Order;
    // --Create Quote001


    5) DocumentType is unkown so i declared it as an integer.

    6) In the Function "insertHeader" i changed the entry
    PurchOrderHeader."Document Type" := PurchOrderHeader."Document Type"::Order;
    into
    PurchOrderHeader."Document Type" := DocumentType;

    7) In the Funcion "InsertPurchOrderLine i changed the entry
    PurchOrderHeader."Document Type" := PurchOrderHeader."Document Type"::Order;
    into
    PurchOrderHeader."Document Type" := DocumentType;

    8) i used the "requistion worksheet", clicked the "carry out action message" and press OK so i got Quotes instead of Orders, all the same whether the check box was clicked or not.

    Did i made a mistake?

    thats all.
  • Options
    SavatageSavatage Member Posts: 7,142
    Sounds like your vairable is not being passed from the report to the CU.

    You can test it by adding to CU333

    OnRun(VAR Rec : Record "Requisition Line")
    IF CONFIRM('Make Quote?',TRUE) THEN
    DocumentType := 0
    ELSE DocumentType := 1;

    InsertPurchOrderLine(VAR ReqLine2 : Record "Requisition Line";VAR PurchOrderHeader : Record "Purchase Header")
    PurchOrderLine."Document Type" := DocumentType;

    InsertHeader(VAR ReqLine2 : Record "Requisition Line")
    PurchOrderHeader."Document Type" := DocumentType;

    Then you know it working. I assume you want a checkbox or 2 RadioButtons (Make Order) (Make Quote) on the request form of the Carry Out Action Msg. - Req. report. Where you pass the values to the CU.
  • Options
    Shibby01Shibby01 Member Posts: 17
    Savatage wrote:
    Sounds like your vairable is not being passed from the report to the CU.

    You can test it by adding to CU333

    OnRun(VAR Rec : Record "Requisition Line")
    IF CONFIRM('Make Quote?',TRUE) THEN
    DocumentType := 0
    ELSE DocumentType := 1;

    InsertPurchOrderLine(VAR ReqLine2 : Record "Requisition Line";VAR PurchOrderHeader : Record "Purchase Header")
    PurchOrderLine."Document Type" := DocumentType;

    InsertHeader(VAR ReqLine2 : Record "Requisition Line")
    PurchOrderHeader."Document Type" := DocumentType;

    Then you know it working. I assume you want a checkbox or 2 RadioButtons (Make Order) (Make Quote) on the request form of the Carry Out Action Msg. - Req. report. Where you pass the values to the CU.


    Hi, thanks for your answer. i followed your instructions and added in function "OnRun(VAR Rec : Record "Requisition Line")" the following code:

    IF CONFIRM('Create Quotes',TRUE) THEN //CreateQuotes001
    DocumentType := 0
    ELSE DocumentType := 1;

    --> "Create Quotes" is my check box from the report "Carry Out Action Msg. - Req." but its the same problem.
    the variable is not being passed from the report to the CU.
  • Options
    mohana_cse06mohana_cse06 Member Posts: 5,503
    Shibby01 wrote:
    4) i changed into C/AL from the CU 333 and the function "setCreateQuotes" is filled with the following code:

    // ++Create Quote001
    IF CreateQuotes THEN
    DocumentType := PurchOrderHeader."Document Type"::Quote
    ELSE
    DocumentType := PurchOrderHeader."Document Type"::Order;
    // --Create Quote001
    Create New function with Parameter Boolean

    Call this function after

    ReqWkshMakeOrders.Set(PurchOrderHeader,EndOrderDate,PrintOrders);
    in report 493 by passing the newly added boolean field..
  • Options
    Shibby01Shibby01 Member Posts: 17
    Shibby01 wrote:
    4) i changed into C/AL from the CU 333 and the function "setCreateQuotes" is filled with the following code:

    // ++Create Quote001
    IF CreateQuotes THEN
    DocumentType := PurchOrderHeader."Document Type"::Quote
    ELSE
    DocumentType := PurchOrderHeader."Document Type"::Order;
    // --Create Quote001
    Create New function with Parameter Boolean

    Call this function after

    ReqWkshMakeOrders.Set(PurchOrderHeader,EndOrderDate,PrintOrders);
    in report 493 by passing the newly added boolean field..


    i am sorry but i dont know exactly what you mean.
    you´ve said create new function with parameter "boolean", or did you mean create a variable.......?
    please step-by-step. what i have to do next?

    thank you for your help
  • Options
    SavatageSavatage Member Posts: 7,142
    FYI - on the code I mentioned it does work but you have to also make the two changes also described. Then when you run the report it asks you if you want a quote else it makes an order. It has nothing to do with your function. When the cu is called the question is asked. Not as pretty as setting it on the request form of the report. But it can be used until you figure out how to pass the parameter.
  • Options
    mohana_cse06mohana_cse06 Member Posts: 5,503
    Savatage wrote:
    FYI - on the code I mentioned it does work but you have to also make the two changes also described. Then when you run the report it asks you if you want a quote else it makes an order. It has nothing to do with your function. When the cu is called the question is asked. Not as pretty as setting it on the request form of the report. But it can be used until you figure out how to pass the parameter.
    Follow Harry's suggestion.. :thumbsup:
  • Options
    Shibby01Shibby01 Member Posts: 17
    Yes it works, thanks for your help!!!
Sign In or Register to comment.