Dataports and document dimensions

jeffb_r4jeffb_r4 Member Posts: 34
I have a situation where I'm trying to dataport some information in to create sales orders.
I initially set up my dataport to have two dataitems (sales header and sales lines), and set up some variables to assist with the validation.
The problem I'm having is that we are using 4 dimensions and I need all 4 in order to be able to post the sales order.
The first two dimensions (globals) are on the sales order header and line but the other two are on the document dimension table.
I don’t want to have to read in the information for the other two dimensions on the input file, as it is always the same.
I assume I will need to create a variable with the information for the document dimension table. This is no problem. However, where do I put the code to get the information populated into the document dimension table? Would it go in the OnAfterRecord section, and if so, for what dataitem?
Do I need to put document dimension into the dataitem area of the dataport, even though I am not reading in any fields related to it?
So far, all my experimentation has not worked.
Hope this makes sense, and thanks in advance for any help.

Comments

  • SavatageSavatage Member Posts: 7,142
    Where is the document dimention table? does it have a number?

    are these other two dimensions filled in on the sales header? If so & they are always the same just add it to you OnAfterGetRecord

    Dimension 3 := whaterver
    dimension 4 := whatever

    if it's on both sales line & sales header you can add it to both dataitems.
  • jeffb_r4jeffb_r4 Member Posts: 34
    the table is 357.
    the other two dimensions are not on the header. In the sales order form, they show on the lines, but they are actually on table 357, not on the sales order line.
  • David_CoxDavid_Cox Member Posts: 509
    Variables:
    GLSetup - Record -"General Ledger Setup"
    DimValue - Record - "Dimension Value"
    DocDims - Record - "Document Dimensions"
    DimCode - Code - 10 [Array Dimensions 8]
    LineDims - Code - 20 [Array Dimensions 8]
    i integer

    Pre Dataport Code:
    GLSetup.GET;
    DimCode[1] := GLSetup."Global Dimension 1 Code";
    DimCode[2] := GLSetup."Global Dimension 2 Code";
    DimCode[3] := GLSetup."Shortcut Dimension 3 Code";
    DimCode[4] := GLSetup."Shortcut Dimension 4 Code";
    DimCode[5] := GLSetup."Shortcut Dimension 5 Code";
    DimCode[6] := GLSetup."Shortcut Dimension 6 Code";
    DimCode[7] := GLSetup."Shortcut Dimension 7 Code";
    DimCode[8] := GLSetup."Shortcut Dimension 8 Code";
    

    Add LineDims[1] to LineDims[8] to the dataport Import line fields, it does not matter how many dimensions you bring in, and blanks will not error.

    On Before Import remember to INIT the sales line and CLEAR(LineDims);

    Sales Line After Import and after assigning the "line No."call the function CreateDims()

    Function:
    CreateDims()
    FOR i := 1 TO 8 DO BEGIN
       IF (LineDims[i] <> '')AND 
          (DimCode[i] <> '') THEN BEGIN
            //This GET errors if Input is Invalid
            DimValue.GET(DimCode[i],LineDims[i]);
            DocDim.INIT;
            DocDim."Table ID" := DATABASE::"Sales Line";
            DocDim."Document Type" := "Sales Line"."Document Type";
            DocDim."Document No." := "Sales Line"."Document No.";
            DocDim."Line No." := "Sales Line"."Line No";
            DocDim."Dimension Code" := DimCode[i];
            DocDim.VALIDATE("Dimension Value Code",LineDims[i]);
            IF DocDim.INSERT THEN;
       END;
    END;    
    

    We use the IF statement because when you validate the accounts some dims are created, and duplicate would cause an error, so optional Code:
    This could be changed to:
    IF NOT DocDim.INSERT THEN
    DocDim.MODIFY;

    That ends the lesson for today!

    David
    Analyst Developer with over 17 years Navision, Contract Status - Busy
    Mobile: +44(0)7854 842801
    Email: david.cox@adeptris.com
    Twitter: https://twitter.com/Adeptris
    Website: http://www.adeptris.com
  • David_CoxDavid_Cox Member Posts: 509
    Ooops! :oops:
    read your post again, if the data is static for all lines, and does not have to be in the Import then insert them into the Document Dimensions Table, DataItem "Sales Line" and OnAfterImportRecord(). use some the code above.
            DocDim.INIT; 
            DocDim."Table ID" := DATABASE::"Sales Line"; 
            DocDim."Document Type" := "Sales Line"."Document Type"; 
            DocDim."Document No." := "Sales Line"."Document No."; 
            DocDim."Line No." := "Sales Line"."Line No"; 
            DocDim."Dimension Code" := 'VALUE3DIM'; 
            DocDim.VALIDATE("Dimension Value Code",VALUE3CODE); 
            IF DocDim.INSERT THEN; 
            DocDim.INIT; 
            DocDim."Table ID" := DATABASE::"Sales Line"; 
            DocDim."Document Type" := "Sales Line"."Document Type"; 
            DocDim."Document No." := "Sales Line"."Document No."; 
            DocDim."Line No." := "Sales Line"."Line No"; 
            DocDim."Dimension Code" := 'VALUE4DIM'; 
            DocDim.VALIDATE("Dimension Value Code",VALUE4CODE); 
            IF DocDim.INSERT THEN; 
    


    I will leave the full previous post as it may help someone else! :)

    David
    Analyst Developer with over 17 years Navision, Contract Status - Busy
    Mobile: +44(0)7854 842801
    Email: david.cox@adeptris.com
    Twitter: https://twitter.com/Adeptris
    Website: http://www.adeptris.com
  • SavatageSavatage Member Posts: 7,142
    JUST A NOTE: I checked that table.
    I also import Sales Header & Sales Lines in one dataport. And I see all the dimensions in the table & i'm not even entering anything. Perhaps your not validating the proper fields on import????

    How are those other field usually filled in, manually?

    old version of my dataport is here
    http://www.mibuso.com/forum/viewtopic.php?t=8753
  • David_CoxDavid_Cox Member Posts: 509
    Savatage wrote:
    JUST A NOTE: I checked that table.
    I also import Sales Header & Sales Lines in one dataport. And I see all the dimensions in the table & i'm not even entering anything. Perhaps your not validating the proper fields on import????

    How are those other field usually filled in, manually?

    old version of my dataport is here
    http://www.mibuso.com/forum/viewtopic.php?t=8753

    Thats the way I read it, but if there is a dimension one to one, then setup the Defaults Dimensions on the various accounts, and you will not need to use any code.

    Note:
    The Customer Default Dimensions, will populate in the header as you validate the "Sell-to Customer", these will copy to the line, when you create the "Sales Line", when you Validate the line "No." field, this also copies Default Dimensions from Item, G/L Account etc:

    The code above is to add Non Default Dimensions that the user might do manually as they create the Sales Lines.

    This would be used more on the Purchase Side, for say a expenses or utillity bills that has several lines to the same "G/L Account" where you are using a mandatory dimension to assign values to different Departments (Cost Centres).

    David
    Analyst Developer with over 17 years Navision, Contract Status - Busy
    Mobile: +44(0)7854 842801
    Email: david.cox@adeptris.com
    Twitter: https://twitter.com/Adeptris
    Website: http://www.adeptris.com
Sign In or Register to comment.