Options

Purchase Invoice and subform Dimension Set Entry

youngmoonyoungmoon Member Posts: 4
edited 2014-01-15 in NAV Three Tier
We used the Document Dimension table to insert dimensions for Purchase Invoices in the past. With the new changes to Dimensions, we have to change the code to reflect the new way. I am trying to insert dimensions to the 480 Dimension Entry Set table object for new combinations of dimensions for the Purchase Invoice page line items. If they are already in the table, then I can set the Dimension Set ID and it is fine, but the problem is with new dimension combinations, I don’t know how to enter new dimension values for a document. Here is my old code how we inserted dimensions for lines in the Purchase Invoice records below. I am trying to replicate this code to work with the new 480 Dimension Set Entry table.


// test to see if it's a dimension value, and if so insert
IF STRPOS(FieldName, 'NavDim') > 0 THEN BEGIN

DimensionRef.OPEN(DATABASE::"Document Dimension");
strValue := 'WHERE (Document Type=FILTER(' + FORMAT(Rec."Document Type") +
'),Document No.=FILTER(' + Rec."No." + '),' +
'Line No.=FILTER(' + FORMAT((x + 1) * 10000) + '),' +
'Dimension Code=FILTER('+ FORMAT(StampValue.Value2) + '))';

DimensionRef.SETVIEW(strValue);
DimensionRef.DELETEALL(TRUE);
DimensionRef.GETTABLE(DimensionRec);

fieldNo := DimensionRec.FIELDNO("Table ID");
field := DimensionRef.FIELD(fieldNo);
field.VALIDATE(39); // purchase line table id

fieldNo := DimensionRec.FIELDNO("Document Type");
field := DimensionRef.FIELD(fieldNo);
field.VALIDATE( Rec."Document Type");

fieldNo := DimensionRec.FIELDNO("Document No.");
field := DimensionRef.FIELD(fieldNo);
field.VALIDATE( Rec."No.");

fieldNo := DimensionRec.FIELDNO("Line No.");
field := DimensionRef.FIELD(fieldNo);
field.VALIDATE((x + 1) * 10000);

fieldNo := DimensionRec.FIELDNO("Dimension Code");
field := DimensionRef.FIELD(fieldNo);
field.VALIDATE(StampValue.Value2);

fieldNo := DimensionRec.FIELDNO("Dimension Value Code");
field := DimensionRef.FIELD(fieldNo);
field.VALIDATE(StampValue.Value);

DimensionRef.INSERT(TRUE);
DimensionRef.CLOSE;

// if the dimension is one of the shortcut dimensions then insert the value
// in the purchase line

IF StampValue.Value2 = glSetup."Shortcut Dimension 1 Code" THEN BEGIN
fieldNo := lineRec.FIELDNO("Shortcut Dimension 1 Code");
field := lineref.FIELD(fieldNo);
field.VALUE := StampValue.Value;
END
ELSE IF StampValue.Value2 = glSetup."Shortcut Dimension 2 Code" THEN BEGIN
fieldNo := lineRec.FIELDNO("Shortcut Dimension 2 Code");
field := lineref.FIELD(fieldNo);
field.VALUE := StampValue.Value;
END;

END

Comments

  • Options
    youngmoonyoungmoon Member Posts: 4
    Actually, I got one dimension in the table now, and I can get a new Dimension Set ID. And now I can set, but now, I need to figure out how to do more than one dimensions and get one set ID. I'm currently working on it, and I think I'll be able to get it, but if you want to add to this, it would also be appreciated. Wish me luck. Here is my code now.


    IF STRPOS(FieldName, 'NavDim') > 0 THEN BEGIN

    DimensionRec.VALIDATE("Dimension Code",'AREA');
    DimensionRec.VALIDATE("Dimension Value Code",'10');

    DimensionRec.INSERT(TRUE);

    DimensionRec.GetDimensionSetID(DimensionRec);

    DimSetID_L := dimCodeUnit.GetDimensionSetID(DimensionRec);

    fieldNo := lineRec.FIELDNO("Dimension Set ID");
    field := lineref.FIELD(fieldNo);
    field.VALUE := DimSetID_L;
  • Options
    youngmoonyoungmoon Member Posts: 4
    Still having problems with adding multiple rows to the Dimension Entry Set table with one Dimension Set ID. I wanted to refine my question now. How do you add a combination of dimensions and have them all reference one Dimension Set ID? Right now, it just seems to take the last dimension and set only the last one by itself a Dimension Set ID. I need to enter three or more and then have that all be one set ID.

    thank you
  • Options
    BardurKnudsenBardurKnudsen Member, Microsoft Employee Posts: 137
    Hi YoungMoon:

    Don't *ever* directly insert or modify in tables 480 and 481.

    The way to obtain the correct, new Dimension Set ID is (in pseudo code):

    1) Declare a TempDimSetEntry as record 480, Temporary=Yes.
    2) Declare DimMgt as codeunit 408.
    3) Call DimMgt.GetDimensionSet(TempDimSetEntry,PurchLine."Dimension Set ID"); // now TempDimSetEntry contains the 'old' dimensions
    4) Add/remove the dimensions you want from TempDimSetEntry.
    5) Update the purchase line: PurchLine."Dimension Set ID" := DimMgt.GetDimensionSetID(TempDimSetEntry); // automatically creates new combinations if needed.
    Bardur Knudsen
    Microsoft - Dynamics NAV
  • Options
    geordiegeordie Member Posts: 655
    youngmoon wrote:
    Still having problems with adding multiple rows to the Dimension Entry Set table with one Dimension Set ID. I wanted to refine my question now. How do you add a combination of dimensions and have them all reference one Dimension Set ID? Right now, it just seems to take the last dimension and set only the last one by itself a Dimension Set ID. I need to enter three or more and then have that all be one set ID.

    thank you

    You need to use a temporary Dimension Set ID and call GetDimensionSetID function of DimensionManagement codeunit.
    Can you please check if this post can help you?
Sign In or Register to comment.