Creating Purch Order With Different No Series from REQ WSH

DDLDDL Member Posts: 41
Hi Experts !

I want to Create Purchase Order With Different No Series from Requisition Work Sheet Based On Item Category Code.
I will setup the Item Category Code & Order No. in a Setup so that item falling under the "Item category Code" Specifed in Setup will have different No Series.


Please Help me how to Proceed.
I Have Wriiten the Code in Code Unit 333 "Req. Wksh.-Make Order"
Functions InsertPurchOrderLine(),InsertHeader(),

Is this Correct Can you Please Help Me Out.


InsertPurchOrderLine()
ASetup.GET;
IF "Item Category Code"=ASetup."Item Category Code" THEN BEGIN
ASetup.TESTFIELD("Order Nos.");
IF (PurchOrderHeader."Buy-from Vendor No." <> "Vendor No.") OR
(PurchOrderHeader."Sell-to Customer No." <> "Sell-to Customer No.") OR
(PrevShipToCode <> "Ship-to Code") OR
(PurchOrderHeader."Order Address Code" <> "Order Address Code") OR
(PurchOrderHeader."Currency Code" <> "Currency Code") OR
(PrevPurchCode <> "Purchasing Code") OR
(PurchOrderHeader."No. Series"<>ASetup."Order Nos.")
THEN BEGIN
InsertHeader(ReqLine2);
LineCount := 0;
NextLineNo := 0;
PrevPurchCode := "Purchasing Code";
PrevShipToCode := "Ship-to Code";
END;
END ELSE BEGIN
IF (PurchOrderHeader."Buy-from Vendor No." <> "Vendor No.") OR
(PurchOrderHeader."Sell-to Customer No." <> "Sell-to Customer No.") OR
(PrevShipToCode <> "Ship-to Code") OR
(PurchOrderHeader."Order Address Code" <> "Order Address Code") OR
(PurchOrderHeader."Currency Code" <> "Currency Code") OR
(PrevPurchCode <> "Purchasing Code") OR
(PurchOrderHeader."No. Series"=ASetup."Order Nos.")
THEN BEGIN
InsertHeader(ReqLine2);
LineCount := 0;
NextLineNo := 0;
PrevPurchCode := "Purchasing Code";
PrevShipToCode := "Ship-to Code";
END;
END;


InsertHeader(),

ASetup.GET;
IF "Item Category Code"=ASetup."Item Category Code" THEN BEGIN
ASetup.TESTFIELD("Order Nos.");
PurchOrderHeader.INIT;
PurchOrderHeader."Document Type" := PurchOrderHeader."Document Type"::Order;
PurchOrderHeader."No." :=NoSeriesMgmt.GetNextNo(ASetup."Order Nos.",PostingDateReq,TRUE);
PurchOrderHeader."Posting Date" := PostingDateReq;
PurchOrderHeader."No. Series":=ASetup."Order Nos.";
PurchOrderHeader.INSERT(TRUE);
END ELSE BEGIN
PurchSetup.GET;
PurchSetup.TESTFIELD("Order Nos.");
PurchOrderHeader.INIT;
PurchOrderHeader."Document Type" := PurchOrderHeader."Document Type"::Order;
PurchOrderHeader."No." := '';
PurchOrderHeader."Posting Date" := PostingDateReq;
PurchOrderHeader.INSERT(TRUE);
END;

Thanks in advance.

Comments

  • matttraxmatttrax Member Posts: 2,309
    The easiest way to know if something is correct is to test it :D What happens when you run the code?

    My first thought is that it is not correct, or even easy to do.

    You are creating an order with a number series based on an item category code. Order can have multiple items on them, and thus multiple item category codes.

    Your code gets the first record from your setup table and looks to see if Order Nos. is filled out if it matches your record. Even if it's not a match the code keeps going.
  • DDLDDL Member Posts: 41
    Hi matttrax, Thanks for you Reponse .

    I have tested it But Dont Know How the Requisition Works.
    Some times it creates New Purchase Order if there is already an item with the same "Item Category Code".

    My Requirement is Only to Create Purchase Order With Different Number Series Specifed in a Setup Table, If the Item Category Code Matches the Requisition Line "Item Category Code" Else Create Purchase Order With Deafult Navision Number Series.

    I have added new code in the Function Code() to Groupt Item Category Wise.

    //SETCURRENTKEY(
    //"Worksheet Template Name","Journal Batch Name","Vendor No.",
    //"Sell-to Customer No.","Ship-to Code","Order Address Code","Currency Code",
    //"Location Code","Transfer-from Code");
    }//1540_001 - ... Commented the code

    SETCURRENTKEY(
    "Worksheet Template Name","Journal Batch Name","Vendor No.",
    "Sell-to Customer No.","Ship-to Code","Order Address Code","Currency Code",
    "Location Code","Transfer-from Code","Item Category Code");


    Can you please help me.

    Thanks in Advance.
  • matttraxmatttrax Member Posts: 2,309
    It's pretty hard to modify something when you don't know how the base system works...we all start somewhere, though.

    Read the Trade documentation and learn how the Requisition Worksheet works on a functional level. In a nutshell it looks at open sales orders and sees if you have a demand for something, but no supply. It then comes up with a way for you to get that supply, whether it be purchase, transfer, whatever. You should definitely understand it at a little deeper level, though.

    You are correct to do a GET on the setup table. You are also correct to compare the item category code from the requisition line to the setup table (assuming there is only one item category code that you have a special number series for). I don't think you need that code in the InsertPurchaseLine function, though.
  • DDLDDL Member Posts: 41
    Hi matttrax, Thanks a lot for the Valuable reply.

    To Update you. The requirement is clear to Create Purchase Order with Different No Series if the Item falls under one particular category.

    Can you please tell me wat i did is correct ?

    I have another question. I have added new field Some thing Line "L Code" in Purchase Line,Sales Order Line & Requisition Line. I want this field to flow from Sales Order Line to Requistion Line. When i run Calculate Plan function from Requistion Worksheet.
    After analysis i found that i need to add the to "Inventory Profile" Table to flow from Sales Order>>Requistion Line>>Purchase Line.

    I have found the function "MaintainPlanningLine()" in Code Unit "99000854"- "Inventory Profile Offsetting" . Is this right place to Subsitute the Field ?

    Thanks a lot in Advance.
Sign In or Register to comment.