PR generated with different doc type in rollout porject ....why?

Dear Friends.
We have done rollout.
Earlier imlementation - c. code=A200 .
Using standard document type-NB for PR generation.
Latest Rollout - c. code =A100
Using copy of standard document type NB as ZNB for PR generation.
My problem is that when in A100 MRP runs it generates PR with doc. type-NB (NOT ZNB) why?
same way PR generated by Plant maintanace module(PM) in doc.type-NB(Not ZNB) why?
Regards,
Mahesh.

Hi,
Check the below path of configuration, PR created with MRP run have different document type.
SPROMM-Consumption based planningplanningprocurement proposalDefine external procurement.
Hope it will help you
Thanks

Similar Messages

  • Posting of cross company transaction with different doc types

    Hi,
    The scenario is:-
    We have two companies X and Y.
    X makes a payment to Y with the following FI entries:-
    Company Code X
    Dr Vendor Y
    Cr Bank HDFC
    Company Code Y
    Dr Bank ICICI
    Cr Customer X
    Now this needs to be a cross company transaction where the doc type for CC X should be vendor Payment 'KZ' while the doc type for CC Y should be a customer reciept with doc type 'DZ'.
    Although I am able to map the accounts in cross company code config I am not able to split the transaction of different company codes with different document types.
    Is there any way we can do this in standard SAP?
    Thanks in advance,
    Nitish

    Hi
    As per your issue ...There are no possibilities to post   in sap with different document types.
    If you want you can post cross company code transactions with one document types
    Regards
    vamsi

  • Reading fixed length file with different record types

    Hi,
    I need to read a fixed-length file with different record types, but the record identifier is in 31st position and not in 1st position.
    But if I give 31 as position in File adpater wizard, BPEL takes whole 1-31 as identifier.
    How we need to read such files.
    Thanks
    Ravdeep

    hi ,
    u cannot use the default wzard for this
    use some thing like this nxsd:lookAhead="30" nxsd:lookFor="S"have a look at the below link it has some examples
    http://download.oracle.com/docs/cd/B31017_01/integrate.1013/b28994/nfb.htm

  • Requisition has different doc. type NB and item cat

    hi all,
    i got one PR from project system account assignment category N  item category standard
    but i am converting that pr to subcontracting PO  i am getting following error" _Requisition has different doc. type NB and item cat"_

    Hi, I came across an alternative solution to do subcontracting with project stock. From the online documentation:
    Subcontracting for Sales Order Stock and Project Stock
    Purpose
    Subcontracting is also possible in conjunction with sales order stocks and project stocks. The subcontracting orders are account-assigned to a sales order or a WBS element. Thus, the components are not transferred (using a transfer posting) to the "stock of material provided to vendor" but are directly withdrawn from the sales order stock or the project stock at the time of the goods receipt. The material manufactured is also posted to the sales order stock or to the project stock. The cost of subcontracting is then debited to the sales order or WBS element.
    Since the components are not transferred to the "stock of material provided to vendor", we recommend that you use a transfer posting to transfer the provided components to a new storage location (for example, 9999). This enables you to obtain an overview of those stocks that are physically located at the subcontractor. This information is particularly important when you carry out a physical inventory of the sales order stocks and project stocks.
    Features
    Withdrawal from Stock of Mat. Provided or Sales Order/Project Stock
    For components that are managed in sales order stock or project stock, you can define whether the components are to be withdrawn directly from each sales order/project stock or from the stock of material provided to vendor. You manage this via the dependent requirements indicator for individual customer requirements and collective requirements (MARC-SBDKZ).
    You can maintain this indicator in the following places:
    in the MRP view of the material master record (MRP 4)
    in the explosion types for the BOM item (in Customizing for Production in the step Basic Data -> Bill of Material -> Item Data -> Define explosion types)
    Configuring the explosion types has priority over the configuration in Inventory Management.
    If the indicator is set at Collective requirements only (2), the materials are withdrawn from the stock of material provided to vendor. If this indicator is set any other way, the system withdraws materials from sales order stock or project stock
    Regards,
    Mario

  • Scheduling agreement with relase - doc type LPA with JIT

    Hi
    can any one give the steps for Scheduling agreement with relase - doc type LPA with JIT process.. and explain how the JIT will work in SA.
    Pls advise what are config required and what the user tcode needed to perform the SA with JIT concept.

    Dear Friend,
    Without release documentation(Document type LP)
    The delivery schedule lines have official character-that is to say,they are transmitted to the vendor as they are saved in the system.The system does not document in detail releases aganist the scheduling agreement that have been sent to the vendor.Therefore,in the case of the document type without release documentation,the message control facility should be set up in such a way that a message is immediately sent to vendor if any changes are made to the delivey schedule stored in the system.
    With release documnetation(Document type LPA)
    If you use scheduling agreement with release documentation,the delivery schedule lines are not transmitted directly to the vendor.Intially ,the lines of the delivery schedule stored in the system for an LPA scheduling agreement for an internal information only.A message informing the vendor of your material requirements cannot be transmitted to the vendor until you explicitly create an SA release,that is forecast (FRC) or Just in Time(JIT) delivey schedule.Through this process,you can change the way schedule lines are represented.With release documentation,you can disply the SA releases(delivery schedules) transmitted to a vendor over a certain period of any time.This enables you to trace precisely when you sent which information to vendor.
    Regards
    Pramod

  • Vendor Payment with different document types

    Dear Sapguru,
    We have a scenario where a particular vendor payable is in two different document types for example, RE and KZ.
    When we execute TC F110, the payment proposal is grouping the payments by document type. I.e. it grouped all the documents under type RE and grouped all the documents under type KZ and created two line items in the payment proposal.
    Actually, we want to have a single group consisting of all the document types payable to the vendor.
    We have checked different SAP notes and also verified out system settings, but the problem still remains.
    Can somebody let us know how to group all the open items in a single line item in F110 irrespective of document types.
    Thanks in Advance.
    Regards.,
    Rama

    Dear Naravi,
    the main factor which affects the grouping of items is the Structure ZHLG1:
    ZBUKR
    ABSBU
    LIFNR
    KUNNR
    EMPFG
    WAERS
    ZLSCH
    HBKID
    HKTID
    BVTYP
    SRTGB
    SRTBP
    XINVE
    PAYGR
    UZAWE
    DTWS1
    DTWS2
    DTWS3
    DTWS4
    KIDNO
    All these fields have to coincide, to have a single payment.
    Please check why two documents with different document type are paid into two different payments.
    Read the SAP notes 109233 and 164835 and 305414 as well.
    I hope this helps.
    Mauri

  • Different Doc.Types for Cash Payment & Cash Receipt

    Dear All,
    Is it possible to have different doc. type & no.ranges for different plants for cash receipts & cash payments?
    Regards
    Marcus.

    Hi
    It is possible to have seperate document types for cash payment & cash receipts.
    If you are using normal documetn psoting transaction you can define the document type on your own while posting to the doucment.
    If you are using the cash journal, documetn types hv to be specified in the configuration.
    VVR

  • Text determination procedure with sales doc type

    For the Sales Doc type 'OR' , I am getting TEXT automatically in the Sales Order Header data , TEXT tab page.
    Can Any one tell me how can I remove the text, when i create sales order.
    Or please can any one give me the document or link or explain how the text determination procedure with sales doc type.

    Hi Sanjay,
    Thanks for your help.
    I managed to go there but I am really confused of what changes I have to do there.
    If you dont mind can you explain a bit in detail.
    Sorry for the trouble

  • By default - in STO P.O with UB doc type

    Hi,
    Experts
    When am creating a purchase order with NB doc. type in ITEM level Delivery Tab is there,if i check stock type field it is showing as quality inspection stockas bu default, bcz my material is totally activated with quality management , its ok but in case of STO with UB document type with same material its showing as by default unrestricted stock , why? Manually i can change to quality stock but i want by default it should come as quality stock in my STO Purcase order.
    My query is - why in case of  UB doc stock type field is showing as unrestricted stock instead of
    quality inspection stock
    Note- Material is toatally activated with QUALITY MANAGEMENT with both of PLANT.
    Thanks
    Sunil
    09878996821

    Hi Sunil
    As you are doing STO and you are doing quality check also then first of all check in the NB document type details that by default quality check has to be triggered .Also maintain quality check at delivery level also as you are doing STO
    Check in UB document type wheather the first option is unrestricted use, 2nd option is unrestricted and quality check and 3rd one is quality check  has been maintained. And in UB document type that feild might have been kept blank that is the reason you can scroll down and see all options. So maintain in UB document type the option Unrestricted use and quality check.
    Regards
    Srinath

  • BDC for MM with different material types.

    Hi, Can anyone explain me how the MM01 tcode can be handled in BDC, when material with different material types are present in the flat file. Different material types have different views and hence different recordings....How to handle this scenario?

    Based on different types of material, you can able to find out which all views are required to call through BDC. Try to find out views by using tables MARA, MAKT, MARD, MARC etc. Once it is confirmed you can call views using screen numbers.
    Here I don't think so more than one recording is required. Record MM01 transaction using Basic Data1, once you go inside the transaction select all the views required to complete the MM01 transaction. It will record all the views (hence screen numbers), then you can switch/call views based on screen numbers.
    Hope this helps you to resolve your query.

  • Create different doc type with me59n

    Hi all!
    I have a question. We have 2 types of PO - ZNS - for items with item category L - subcontracting and ZNB for items with standard item category. When we convert NB purchase requisitions with me59n we need to create PO's ZNB or ZNS depending of item category of PR. How can we do it?

    With PO customizing in the IMG.  But if the source of the PR's is a sales order schedule line, then you can better control the process with a differen type of requisition on the schedule line category.

  • VF11 wrongly created with RV Doc type and with not clear status.

    Hi All
    Issue: There are 2 billing documents which were created(VF01) in March are canceled (VF11) in May. Cancel document is saved with a message (No automatic clearing of billing document XXXXXXXXX) and message diagnosis saying that u201CThe Automatic clearing of billing document and reversal is not possible. This may be, for example, because the line item update is deactivatedu201D
      In the SD document flow cancel billing document is created and it's posted to accounting with Document type RV(which is not configured in the billing  types) and it is in not clear status.
    2 Sales order types are ZNRC(No Rebate u2013 Credit)    second is ZCR (CM Req With Refer).
    Order Type  : ZNRC , Billing type :ZG2, Cancel billing type :Z5, Accounting document in billing type for ZG2: is DG and accounting document in cancel billing type Z5 is :(_) blank.
    Order type:  ZCR Billing type :G2, Cancel billing type :S2, Accounting document in billing type for G2: is DG and accounting document in cancel billing type S2 is :(_) blank.                                                
          FI document type Not maintained in the cancel billing type configuration because this should be determine by reversal document type DA which is maintained in DG document type from FI side. It will be triggered in VF11)
    The above configuration is working with the order created VA01,billing VF01 and cancelling VF11 done in same period. If the order and billing done in old period and canceling(VF11) done in current period than FI document creating with RV document type and with not clear status in the document flow.
    I reviewed similar issues with SAP Note and with below explanation:
              "There are 2 procedures that are possible when Vf11 is posted.
              Old Procedure - An FI "Reversal" document was created that was not connected with the orignal.
              New Procedure - A Real FI reversal was carried out with clearing."
    In this case, our system is following with new procedure except above mentioned orders created in previous period and and canceled in current period.
      My Questions are: How the RV document is getting triggered here? why the cancel document (Reversal FI Doc) is not clearing?
         Appreciate your answers or suggestions.
    Thanks in advance,
    Sunil
    Edited by: Sunil kumar Matta on Jun 9, 2011 3:40 PM

    Thank you Ivano.
      I referred SAP note 1259505 and 339928. But initially we thought of none of the symptoms mentioned in the SAP note are matching with our issue. Then we contacted SAP online support and they suggested checking one SAP note (Mentioned above).
      Our system is following new cancellation procedure, but itu2019s failing only for some few documents.
      Finally we identified several reasons for the issue. One is profitability segment in the billing document and cancelled document is different due to some changes in segment assignments. Another one is consolidation- consolidation document does not exist in the billing document list but it is getting created in Canceled document (VF11).(Consolidation postings are switched off some time back and now itu2019s on)
      After some discussions it is decided to include accounting document type (Reversal) in cancel billing types to avoid default RV document type in canceled billing document accounting document. And non-cleared documents need to be created manually in F-32.
      Thread is closed.
    Sunil

  • Same Input name with different data type cause the reflection exception

    I have a proxy contains couple RFCs. Two RFCs contain an argument named IN_COMPANY_CODE with data type of ZTRE_FX_BUKRSTable. Another RFC contains the same argument name of IN_COMPANY_CODE but hold different data type (String). All RFCs are in the same proxy. Complie and build the application with no issue.
    But when I ran the RFC, it generates the reflection exception below:
    Method SAPProxy1.Z_F_Tre_R_Pre_Trade_Fx can not be reflected. --> There was an error reflecting 'In_Company_Code'. > The XML element named 'IN_5fCOMPANY_--5fCODE' from namespace '' references distinct types System.String and MSTRFOREX.ZTRE_FX_BUKRSTable. Use XML attributes to specify another XML name or namespace for the element or types.
    I realize the conflict introduced by the same name with difference data type. But I would like to know if this is fixable as a bug or if there is any best practice and/or some manual intervention to make it work.

    Please install fix from OSS note 506603. After this, right-click .sapwsdl file and select "Run custom tool".

  • Customisation for PO Release (different Values for different Doc Types)

    Dear Experts,
    I need to configure for PO release procedure where in the Characteristics would be Plant (2 Plants), Doc Type (3 types - Standard PO, Imports PO & Capital PO) and Value (2 stage release: 0-100000 & >100000 INR for Std PO, 0-200000 & >200000 INR for Imports PO and 0-300000 & >300000 INR for Capital PO).
    Please let me know where I shoud define the different Values for different Docs for the Release procedure to work properly.
    Or let me know the entire procedure for achieving the same.
    Regards,
    MNP

    Hi MNP,
    You have to create different CLASSes in IMG with the possible combination of different characteristics,
    EX. CLASS EKKO11 - Plant A, Doc type- Std PO, Value- 0-100000 & >100000 INR
          CLASS EKKO22-  Plant A, Doc type- Import PO, Value-  0-200000 & >200000 INR
          CLASS EKKO33-  Plant A, Doc type- Capital PO, Value-  0-300000 & >300000 INR  and same for other plant
    then assign these classes to the respective Release group.
    regards,
    Pravin

  • Path Finder in a 2D Grid Map With Different Terrain Types

         I have been thinking for a while on path finding game algoritms and I can up with one idea witch I want to publish. The goal of my project is when I have a 2 dimensional grid map where squares can have different movement cost, like in Civilization II, to find the shortest way from one point in the map to another. I've used the Breathed First Search Engine. If you are not familiar to this search engine it is better to read about it first because I am not fcusing on it and I assume that you now how it works. You can read about it at the book "Practical Artificial Intelligence Programming in Java" writen by Mark Watson, witch is freely distributed at www.markwatson.com.
         Actually the idea of this 2D grid path finder is to use a third dimension witch have a size equal to the highest movement cost among all terrain types. This helps solving the problem with the different movement cost of the squates. By adding this abstract third dimension it is posible to use the Breadth First Search Engine.
         I this example the movementcost of a terrain type is always the same, no matter from witch square to with are you going (like in Civilization II but I haven't included roads or railroads). For example if you want to go from one square A to another square B with movement cost X (A and B are attached) you must go "up stairs" in the third dimension X - 1 times and then move to square B. But when you step on square B you are again at the lowest floor. So if you want to come back to the previous square A and it have movement cost Y first you must go floor Y and then jump in square A. And now you are again at the lowest floor at square A. When you move from one square to another you go always at the lowest floor. This is the way I handle with different movement costs.
         When you find the path to the goal point it is in 3 dimensions. So you must just project it in the 2D map and that's all you have the shortest path.
         I am sure this is not the best way to code this search engine but this is just the first scratch with no optimisation and so on. If I make a 100x100 randomly generated map it takes on my configuration(400Mhz Pentium II CPU with ASUS P2B MotherBoard on 100 MHz and 256 MB SD RAM on 133 MHz but because of my MB on 100MHz) around 1000 miliseconds (1000 miliseconds = 1 second) to find the shortest path from (1, 1) to (100, 100) witch is pretty good compare to the goTo function in Civilization II witch does not finds the shortest path at all and have made hundrets of gamers angry. This is amazing that nowadays there are so many games with bad path finding.
         This project includes:
    1. The PathFinder class witch does the jub.
    2. The Map class witch has a generator for a random map in it.
    3. The class TerrainType, every square on the map is based on this class.
    4. The class TerrainTypes witch is the set of all terrain types used in the map.
    5. The class PathFinderTest witch just test the path finder.
    To test this project put all files in one directory and run PathFinderTest.java.
    Map.java:
    import java.util.Vector;
    import java.util.Random;
    //This class just creates a random map and keeps it. I will not comment on this.
    class Map {
      //here is kept the information about the terrain types placed in the map. Where
      //every terrain type has a specific movement cost.
      private int[][] terrain;
      public TerrainTypes terrainTypes;
      private int landMass;
      private int width;
      private int height;
      private int highestMovementCost;
      public Map(int aWidth, int aHeight) {
        width = aWidth;
        height = aHeight;
        terrainTypes = new TerrainTypes();
        highestMovementCost = terrainTypes.getHighestMovementCost();
        terrain = new int[width][height];
        landMass = 0;
        generateRandomMap();
      public void clearGoalAndStartLocFromWater(int sx, int sy, int gx, int gy) {
        terrain[gx][gy] = 0;
        terrain[sx][sy] = 0;
      private void expandWater() {
        int waterConstant = 40;
        int waterExpansion = 2;
        int[][] moreWater = new int[width][height];
        Random randomizer = new Random();
        for (int t = 0; waterExpansion > t; t++) {
          for (int i = 0; i < width; i++) {
            for (int j = 0; j < height; j++) {
              if (i + 1 >= 0 && j >= 0 && i + 1 < width && j < height) {
                if (terrain[i + 1][j] != 4) {
                  if (randomizer.nextInt(waterConstant) == 0)
                    moreWater[i + 1][j] = 1;
              if (i + 1 >= 0 && j - 1 >= 0 && i + 1 < width && j - 1 < height) {
                if (terrain[i + 1][j - 1] != 4) {
                  if (randomizer.nextInt(waterConstant) == 0)
                    moreWater[i + 1][j - 1] = 1;
              if (i >= 0 && j - 1 >= 0 && i < width && j - 1 < height) {
                if (terrain[i][j - 1] != 4) {
                  if (randomizer.nextInt(waterConstant) == 0)
                    moreWater[i][j - 1] = 1;
              if (i - 1 >= 0 && j - 1 >= 0 && i - 1 < width && j - 1 < height) {
                if (terrain[i - 1][j - 1] != 4) {
                  if (randomizer.nextInt(waterConstant) == 0)
                    moreWater[i - 1][j - 1] = 1;
              if (i - 1 >= 0 && j >= 0 && i - 1 < width && j < height) {
                if (terrain[i - 1][j] != 4) {
                  if (randomizer.nextInt(waterConstant) == 0)
                    moreWater[i - 1][j] = 1;
              if (i - 1 >= 0 && j + 1 >= 0 && i - 1 < width && j + 1 < height) {
                if (terrain[i - 1][j + 1] != 4) {
                  if (randomizer.nextInt(waterConstant) == 0)
                    moreWater[i - 1][j + 1] = 1;
              if (i >= 0 && j + 1 >= 0 && i < width && j + 1 < height) {
                if (terrain[i][j + 1] != 4) {
                  if (randomizer.nextInt(waterConstant) == 0)
                    moreWater[i][j + 1] = 1;
              if (i + 1 >= 0 && j + 1 >= 0 && i + 1 < width && j + 1 < height) {
                if (terrain[i + 1][j + 1] != 4) {
                  if (randomizer.nextInt(waterConstant) == 0)
                    moreWater[i + 1][j + 1] = 1;
        for (int i = 0; i < width; i++) {
          for (int j = 0; j < height; j++) {
            if (moreWater[i][j] == 1) {
              terrain[i][j] = 4;
      private void generateRandomMap() {
        Random randomizer = new Random();
        for (int i = 0; i < width; i++) {
          for (int j = 0; j < height; j++) {
            if (randomizer.nextInt(3) == 1)
              terrain[i][j] = 0;
            else if (randomizer.nextInt(2) == 1)
              terrain[i][j] = 1;
            else if (randomizer.nextInt(2) == 1)
              terrain[i][j] = 3;
            else if (randomizer.nextInt(2) == 1)
              terrain[i][j] = 2;
            else if (randomizer.nextInt(2) == 1)
              terrain[i][j] = 2;
            else if (randomizer.nextInt(2) == 1)
              terrain[i][j] = 1;
            else if (randomizer.nextInt(2) == 1)
              terrain[i][j] = 3;
            else
              terrain[i][j] = randomizer.nextInt(5);
        expandWater();
        for (int i = 0; i < width; i++) {
          for (int j = 0; j < height; j++) {
            if (terrain[i][j] != 0)
              landMass++;
      public int getMapHeight() {
        return height;
      public int getMapWidth() {
        return width;
      public int getSquareID(int x, int y) {
        return terrain[x][y];
      public int getSquareMovementCost(int x, int y) {
        return terrainTypes.getMovementCost(terrain[x][y]);
    }PathFinder.java:
    import java.io.BufferedReader;
    import java.io.InputStreamReader;
    import java.util.Vector;
    public class PathFinder {
      private BufferedReader consoleReader = new BufferedReader(new InputStreamReader(System.in));
      //The array t3D[][] represents the 2D square map where t3D.leght = map width
      //and t3D[x].lenght = map width (-1 < x < t3D.leght). The third dimension
      //is refered to the square's movement cost, witch is definite by terrain.
      //The fourth dimension will be with lenght = 3. When running the search engine
      //(expanding the explored squares) this 3 values will keep the position of
      //the previous square in 3 dimension, witch are width, height and the maximum
      //movement cost among all squares.
      private int[][][][] squares3DReference;
      //Keeps information witch squares are visited.
      private boolean[][][] visitedSquares;
      private Map map;
      //this is the queue used in the Breathed First Seatch.
      private Vector queue3D;
      //Here is saved the shortest path
      private Vector path2D;
      private int highestMovementCost;
      public PathFinder(Map aMap) {
        map = aMap;
        queue3D = new Vector();
        path2D = new Vector();
        squares3DReference = new int[map.getMapWidth()][map.getMapHeight()][][];
        visitedSquares = new boolean[map.getMapWidth()][map.getMapHeight()][];
        highestMovementCost = map.terrainTypes.getHighestMovementCost();
        buildAbstract3DTerrain();
      private void buildAbstract3DTerrain() {
        for (int x = 0; x < map.getMapWidth(); x++) {
          for (int y = 0; y <map.getMapHeight(); y++) {
            int movementCost = map.terrainTypes.getMovementCost(map.getSquareID(x, y));
            if ( movementCost > 0) {
              visitedSquares[x][y] = new boolean[highestMovementCost];
              squares3DReference[x][y] = new int[highestMovementCost][3];
              for (int z = 0; z < highestMovementCost; z++) {
                for (int t = 0; t < 3; t++) {
                  squares3DReference[x][y][z][t] = -1;
      private boolean isMoveValid(int x, int y, int z, int x2, int y2, int z2) {
        if ( x < 0 || y < 0 || z < 0 || x2 < 0 || y2 < 0 || z2 < 0 || x >= map.getMapWidth() || y >= map.getMapHeight() || z >= highestMovementCost ||  x2 >= map.getMapWidth() || y2 >= map.getMapHeight() || z2 >= highestMovementCost)
          return false;
        if (map.terrainTypes.getMovementCost(map.getSquareID(x2, y2)) < 1)
          return false;
        if (visitedSquares[x2][y2][z2])
          return false;
        if (x == x2 && y == y2)
          return true;
        else {
          if (z == map.terrainTypes.getMovementCost(map.getSquareID(x2, y2)) - 1)
            return true;
          else
            return false;
      private void clearPreviousSearchData() {
        queue3D.clear();
        path2D.clear();
        for (int x = 0; x < map.getMapWidth(); x++) {
          for (int y = 0; y < map.getMapHeight(); y++) {
            if (squares3DReference[x][y] != null) {
              for (int z = 0; z < highestMovementCost; z++) {
                visitedSquares[x][y][z] = false;
                for (int t = 0; t < 3; t++) {
                  squares3DReference[x][y][z][t] = -1;
      private Vector copyPath2D() {
        Vector path = new Vector();
        for (int i = 0; i < path2D.size(); i++) {
          path.add(path2D.get(i));
        return path;
      public Vector findPath(int sX, int sY, int gX, int gY) {
        int head = 0;
        int tail = 0;
        int x = sX;
        int y = sY;
        int z = 0;
        visitedSquares[x][y][z] = true;
        mainLoop: {
          while (tail <= head) {
            int[][] moves = getPosibleMoves(x, y, z);
            for (int i = 0; i < 9; i++) {
              if (moves[i] != null) {
                squares3DReference[moves[0]][moves[i][1]][moves[i][2]][0] = x;
    squares3DReference[moves[i][0]][moves[i][1]][moves[i][2]][1] = y;
    squares3DReference[moves[i][0]][moves[i][1]][moves[i][2]][2] = z;
    queue3D.add(moves[i]);
    if (moves[i][0] == gX && moves[i][1] == gY) {
    break mainLoop;
    visitedSquares[moves[i][0]][moves[i][1]][moves[i][2]] = true;
    head++;
    if (queue3D.size() == 0 || queue3D.size() == tail)
    break mainLoop;
    int[] nextInQueue = ((int[]) queue3D.get(tail));
    x = nextInQueue[0];
    y = nextInQueue[1];
    z = nextInQueue[2];
    tail++;
    if (squares3DReference[gX][gY][0][0] == -1) {
    clearPreviousSearchData();
    return path2D;
    fillpath2D(sX, sY, gX, gY);
    Vector path = copyPath2D();
    clearPreviousSearchData();
    return path;
    private int[][] getPosibleMoves(int x, int y, int z) {
    int[][] moves = new int[9][3];
    if (isMoveValid(x, y, z, x + 1, y, 0)) {
    moves[0][0] = x + 1;
    moves[0][1] = y;
    moves[0][2] = 0;
    else
    moves[0] = null;
    if (isMoveValid(x, y, z, x + 1, y - 1, 0)) {
    moves[1][0] = x + 1;
    moves[1][1] = y - 1;
    moves[1][2] = 0;
    else
    moves[1] = null;
    if (isMoveValid(x, y, z, x, y - 1, 0)) {
    moves[2][0] = x;
    moves[2][1] = y - 1;
    moves[2][2] = 0;
    else
    moves[2] = null;
    if (isMoveValid(x, y, z, x - 1, y - 1, 0)) {
    moves[3][0] = x - 1;
    moves[3][1] = y - 1;
    moves[3][2] = 0;
    else
    moves[3] = null;
    if (isMoveValid(x, y, z, x - 1, y, 0)) {
    moves[4][0] = x - 1;
    moves[4][1] = y;
    moves[4][2] = 0;
    else
    moves[4] = null;
    if (isMoveValid(x, y, z, x - 1, y + 1, 0)) {
    moves[5][0] = x - 1;
    moves[5][1] = y + 1;
    moves[5][2] = 0;
    else
    moves[5] = null;
    if (isMoveValid(x, y, z, x, y + 1, 0)) {
    moves[6][0] = x;
    moves[6][1] = y + 1;
    moves[6][2] = 0;
    else
    moves[6] = null;
    if (isMoveValid(x, y, z, x + 1, y + 1, 0)) {
    moves[7][0] = x + 1;
    moves[7][1] = y + 1;
    moves[7][2] = 0;
    else
    moves[7] = null;
    if (isMoveValid(x, y, z, x, y, z + 1)) {
    moves[8][0] = x;
    moves[8][1] = y;
    moves[8][2] = z + 1;
    else
    moves[8] = null;
    return moves;
    private void fillpath2D(int sX, int sY, int gX, int gY) {
    int[] gLoc = {gX, gY};
    path2D.add(gLoc);
    int x = gX;
    int y = gY;
    int z = 0;
    while (x != sX || y != sY) {
    int x2 = squares3DReference[x][y][z][0];
    int y2 = squares3DReference[x][y][z][1];
    int z2 = squares3DReference[x][y][z][2];
    x = x2;
    y = y2;
    z = z2;
    if (z == 0) {
    int[] loc = {x, y};
    path2D.insertElementAt(loc, 0);
    PathFinderTest.java
    import java.io.BufferedReader;
    import java.io.InputStreamReader;
    import java.util.Vector;
    public class PathFinderTest {
      static BufferedReader consoleReader = new BufferedReader(new InputStreamReader(System.in));
      static Map map;
      static int startX;
      static int startY;
      static int goalX;
      static int goalY;
      public static void main(String[] args) throws Exception {
        System.out.print("Enter map size.\nx = ");
        int width = Integer.parseInt(consoleReader.readLine());
        System.out.print("y = ");
        int height = Integer.parseInt(consoleReader.readLine());
        System.out.print("Enter strting location.\nx = ");
        startX = Integer.parseInt(consoleReader.readLine()) - 1;
        System.out.print("y = ");
        startY = Integer.parseInt(consoleReader.readLine()) - 1;
        System.out.print("Enter goal location.\nx = ");
        goalX = Integer.parseInt(consoleReader.readLine()) - 1;
        System.out.print("y = ");
        goalY = Integer.parseInt(consoleReader.readLine()) - 1;
        if (goalX < 0 || goalY < 0 || startX < 0 || startY < 0 || goalX >= width || goalY >= height || startX >= width || startY >= height) {
          System.out.println("Invalid parameters found. Program will exit");
          System.exit(0);
        map = new Map(width, height);
        map.clearGoalAndStartLocFromWater(startX, startY, goalX, goalY);
        printSolution(new Vector());
        PathFinder pathFinder = new PathFinder(map);
        long before = System.currentTimeMillis();
        Vector path = pathFinder.findPath(startX, startY, goalX, goalY);
        long after = System.currentTimeMillis();
        long time = after - before;
        printSolution(path);
        if (path.size() == 0)
          System.out.println("No path found.");
        else
          System.out.println("Path found.");
        System.out.println("Finding the path took " + time + " milliseconds");
      static void printSolution(Vector path) {
        boolean[][] pathOnMap = new boolean[map.getMapWidth()][map.getMapHeight()];
        for (int i = 0; path.size() > i; i++) {
          int[] move = (int[]) path.get(i);
          pathOnMap[move[0]][move[1]] = true;
        for (int y = 0; y < map.getMapHeight(); y++) {
          for (int x = 0; x < map.getMapWidth(); x++) {
            System.out.print(" ");
            if (pathOnMap[x][y] == false)
              System.out.print(" ");
            else
              System.out.print("0");
            if (x == startX && y == startY)
              System.out.print("S");
            else if (x == goalX && y == goalY)
              System.out.print("G");
            else
              System.out.print(map.terrainTypes.getNameFirstLetter(map.getSquareID(x, y)));
          System.out.println();
        System.out.println();
    }TerrainType.java:
    public class TerrainType {
      private int movementCost;
      private String name;
      TerrainType(int aMovementCost, String aName) {
        movementCost = aMovementCost;
        name = aName;
      public int getMovementCost() {
        return movementCost;
      public String getName() {
        return name;
      public String getNameFirstLetter() {
        return name.substring(0, 1).toUpperCase();
    }TerrainTypes.java:
    import java.util.Vector;
    public class TerrainTypes {
      //Here are saved the terrain types with the map has. ElementAt 'i' in
      //setOfTypes is represented by the number in Map.terrain[x][y] witch is
      //equal to i, were x, y are random integer as soon as they do not
      //throw ArrayIndexOutOfBoundsException. Actually this is a coding to know
      //a specific square in the map to witch terrain type is refered in setOfTypes.
      private Vector setOfTypes;
      public TerrainTypes() {
        setOfTypes = new Vector();
        setOfTypes.add(new TerrainType(1, "Plains"));
        setOfTypes.add(new TerrainType(2, "Forst"));
        setOfTypes.add(new TerrainType(3, "Jungle"));
        setOfTypes.add(new TerrainType(4, "Mountain"));
        setOfTypes.add(new TerrainType(-1, "X"));
      public int getMovementCost(int i) {
        return ((TerrainType) setOfTypes.get(i)).getMovementCost();
      public String getName(int i) {
        return ((TerrainType) setOfTypes.get(i)).getName();
      public String getNameFirstLetter(int i) {
        return ((TerrainType) setOfTypes.get(i)).getNameFirstLetter();
      public int getHighestMovementCost() {
        int max = 1;
        for (int i = 0; setOfTypes.size() > i; i++) {
          int movementCost = ((TerrainType) setOfTypes.get(i)).getMovementCost();
          if ( movementCost > 0) {
            if (max < movementCost)
              max = movementCost;
        return max;
    }I hope this program will be helpful.
    Sogartar

    Why is such a smart guy like you not using A*
    It is a general known algorithm which will find the
    optimal solution in a finite search-space (within a minimal time).
    The calculation time for the A* algorithm is influenced by two parameters:
    1 - cumulative cost
    2 - minimal expected additional cost
    The calculation of these two costs has a great influence on the
    solution.
    I think the actual problems most games experience with shortest path calculatoin are
    1 - very little time to spent calculating the shortest path
    The quickest solution might be the best for the game
    If your solution takes 1 second for the calculation of a path for one element on the board (100x100)
    What would it take for the game to calculate the path for all elements controlled by the computer ??
    If the computer controls two players which each have 50 elements to control, it would take forever...
    Don't even consider the usage of a larger board (200x200 would take 4 seconds/element when
    algorithm has complexity O(n))
    2 - low priority.
    Users tend to forgive a bad shortest path-algorithm most of the time,
    but not a bad display, bad pictures,...
    This is why most shortest-path algorithms within games were
    developed as a depth first search,
    within some earlier games this was even developed as
    a rule which went straight to the endlocation and
    takes a right/left turn when blocked by water/wall/...
    So the actual steps you should take are:
    1 - develop a normal breath-first search (to get going)
    2 - develop a normal depth-first search (to compare speed and solution with)
    3 - develop a normal dijkstra algorithm (sometimes called A)
    4 - develop a best first algorithm (called A*)
    5 - develop other AI-algorithms building upon A* (tabu-search, limited memory A*,...)
    6 - develop some other AI-algorithms (Genetic Algorithms, Simulated Annealing,...)
    7 - compare and tweak/change all search-algorithms for
    7 - a - size of maps (small versus huge)
    7 - b - optimality of the solution
    7 - c - actual usage for your game
    8 - !!! very important !!!
    Share the developed path algorithms along with remarks about speed, map-size,...
    with the rest of us. I would be very interested in such library.
    kind regards,

Maybe you are looking for

  • SUP Hybrid Web container Offline Mode

    Hello, I tried out a workflow example on blackberry simulator(using hybrid web container),but when i am in offline mode,the example doesnot work,so i had a doubt whether hybrid webcontainer supports offline mode,or do we need to do anything in the co

  • In 4.0, I don't see the icon for Home anymore. Why not?

    I just installed 4.0 but I cannot see the Home icon at the top anymore because it quickly allowed me to do so with earlier versions. All I see now is the address line and the webpage that is open. If I want to go to my home page, I either have to typ

  • Debugging a plugin

    I am having trouble with a plugin. When I access it from the menu I get the message box "Could not complete the Export command because there is not enough memory (RAM)". The message box appears before my PluginMain is called. It seems to be related t

  • ZBUS2009 .significantlyChanged Workflow Restarts

    Hi All, BUS2009 implementation uses event significantlyChanged. I would prefer that any change restarts the workflow. The root of the problem is a price change. We would prefer if the price is changed the WF is restarted rather than having to move be

  • How do I rename Trackpad in Mavericks 10.9.5?

    I'm unable to rename my new Trackpad according to the instructions in the User Guide. There's no Action pop-up menu in the lower left corner of the Bluetooth pane in System Preferences. Does anyone know what to do?