So my coding book still hasn’t come in yet but i’m desperately trying to figure this out. I currently have a report where I am trying to print out Item Dimensions associated with the item. I found all the tables and fields that would relate but i’m weak in C/AL code. Here is what I have so far
IF SalesLine.Type=SalesLine.Type::Item THEN BEGIN
Item.GET(SalesLine.“No.”);
Default Dimension.GET(Default Dimension.“No.”);
Item.CALCFIELDS(Dimension);
END ELSE
CLEAR(ITEM):
I know the above is totally wrong… i’m having trouble trying to figure out how to code this big time what i’m trying to look for is the following
If I have a Item.“No.” -----I would like to relate it to "Default Dimension.“No.” " and GET all related "Default Dimension.“Dimension Value Code” "
Next GET FOR EACH "Default Dimension.“Dimension Value Code” " WHERE “Dimension Value Code” = "Dimension Value.“Name” "
Return "Dimension Value. “Name” "
I’m sorry if that sounds a little confusing… took me a while to get it all straight in my head, but if this was SQL i could come up with a query but it’s not and its C/AL where i’m trying to learn as much as possible but until my book gets in, google searches just aren’t cutting it. If anyone can help I will be forever in debt!
You need to define a record variable for the Default Dimension table and set the appropriate filters using SETRANGE or SETFILTER. You can then use the FINDSET method and a REPEAT…UNTIL loop to get all of the records. Try translating that to code and see what you can come up with.
yup after i posted i notice that I didn’t have any sort of assignment statement… so I tried setting ItemDimVal;=“Dimension Value Code”.“Name” but it still gives me the warning of “A field from a record variable was expected.”
IF ItemDimVal.FINDSET THEN BEGIN
REPEAT
ItemDimVal.“Dimension Value Code” := ItemDimVal.“Dimension Value”.“Name”;
ItemDimVal.GET(“Dimension Value”.“Name”);
UNTIL ItemDimVal.NEXT =0;
END
so i got the warning to go away but nothing still show up in the report. After I set my variable to "ItemDimVal as a datatype Record and SubType to the table “Default Dimension” and my variable "Dimension Value as a datatype Record and subtype to the table Dimension Value, I began with the following code
ItemDimVal.SETRANGE(“No.” , “Sales Line”.“No.”); //Setting the range for ItemDimVal to only the No. = Sales Line.No
ItemDimVal.SETRANGE(“Dimension Value Code” , “Dimension Value”.“Code”); //Next setting field Dimension Value Code to the
// field “Code” in the Dimension Value table
//Next I run the method as the following :
IF ItemDimVal.FINDSET THEN BEGIN
REPEAT
ItemDimVal.GET(“Dimension Value”.“Name”); //Does this “GET” the NAME??? <<< if so how to output
UNTIL ItemDimVal.NEXT =0;
END;
Yet I still get nothing to show up… keep you guys posted… unless u just want me to stop and post the solution when i find it