Report Matrix Problem
bangswit
Member Posts: 265
hai there
i want to create report like this
this is from table 39
if my code like this
i:=1;
SPH.FIND('-');
REPEAT
// SETRANGE("Shortcut Dimension 1 Code",SPH.Code);
// IF FIND('-') THEN
AmountLoc:=Quantity;
LocName := SPH.Code;
i:= i + 1;
UNTIL (SPH.NEXT = 0) OR (i > SPH.COUNT);
it gonna be
Category A Category B
Item A 15 20
Item B 15 20
Item C 15 20
Item D 15 20
Item E 15 20
Item F 15 20
--> All Lines in Purchase Lines will be showed
but if i Add the setrange
i:=1;
SPH.FIND('-');
REPEAT
SETRANGE("Shortcut Dimension 1 Code",SPH.Code);
IF FIND('-') THEN
AmountLoc:=Quantity;
LocName := SPH.Code;
i:= i + 1;
UNTIL (SPH.NEXT = 0) OR (i > SPH.COUNT);
the result is like this
Category A Category B
Item A 15 20
all I want is like this
Category A Category B
Item A 15 0
Item B 0 20
What mistaken I have made?
please help
i want to create report like this
this is from table 39
if my code like this
i:=1;
SPH.FIND('-');
REPEAT
// SETRANGE("Shortcut Dimension 1 Code",SPH.Code);
// IF FIND('-') THEN
AmountLoc:=Quantity;
LocName := SPH.Code;
i:= i + 1;
UNTIL (SPH.NEXT = 0) OR (i > SPH.COUNT);
it gonna be
Category A Category B
Item A 15 20
Item B 15 20
Item C 15 20
Item D 15 20
Item E 15 20
Item F 15 20
--> All Lines in Purchase Lines will be showed
but if i Add the setrange
i:=1;
SPH.FIND('-');
REPEAT
SETRANGE("Shortcut Dimension 1 Code",SPH.Code);
IF FIND('-') THEN
AmountLoc:=Quantity;
LocName := SPH.Code;
i:= i + 1;
UNTIL (SPH.NEXT = 0) OR (i > SPH.COUNT);
the result is like this
Category A Category B
Item A 15 20
all I want is like this
Category A Category B
Item A 15 0
Item B 0 20
What mistaken I have made?
please help
0
Comments
-
It is difficult to read your code, write it in Code tag for better readability.
You have to insert a repeat.. until loop after getting the first record. Otherwise you are only on the first record. Also you have to use THEN BEGIN..END; if your statements is more than one line. Otherwise code is executed starting from the second line below the if..then block.Ufuk Asci
Pargesoft0 -
--> this code display all records in Purchase linei:=1;
SPH.FIND('-');
REPEAT
// SETRANGE("Shortcut Dimension 1 Code",SPH.Code);
// IF FIND('-') THEN
AmountLoc:=Quantity;
LocName := SPH.Code;
i:= i + 1;
UNTIL (SPH.NEXT = 0) OR (i > SPH.COUNT);
--> this gonna be like thisi:=1;
SPH.FIND('-');
REPEAT
SETRANGE("Shortcut Dimension 1 Code",SPH.Code);
IF FIND('-') THEN
AmountLoc:=Quantity;
LocName := SPH.Code;
i:= i + 1;
UNTIL (SPH.NEXT = 0) OR (i > SPH.COUNT);
No Category A Category B
Item A 15 20
what i want is like this
No Category A Category B
Item A 15 0
Item B 0 200 -
It is difficult to understand the problem from the code part you sent but it seems like the problem is with the FIND part. This could cause getting out of dataset or returning back to the first one. Use a record variable instead of dataitem itself like.
varItem.GET("No.");
varItem.SETRANGE(...);
IF varItem.FIND('-')
...Ufuk Asci
Pargesoft0 -
so you mean, the code should be like this ?
FYI, SPH --> table dimension value
before this code, exactly in on pre dataitem , I already filter it
SPH.SETRANGE("Global Dimension Code",1);i:=1;
SPH.GET("Dimension Code",Code);
SPH.FIND('-');
REPEAT
SETRANGE("Shortcut Dimension 1 Code",SPH.Code);
IF FIND('-') THEN
AmountLoc:=Quantity;
LocName := SPH.Code;
i:= i + 1;
UNTIL (SPH.NEXT = 0) OR (i > SPH.COUNT);0 -
Bangwit, it seems there are many problems regarding your loop, array variable usage and value assignments. I recommend you work on development manuals. They could help you more than what I write here. It is important to understand what you are doing.bangswit wrote:i:=1;
SPH.GET("Dimension Code",Code);
SPH.FIND('-'); // not necessary to loop, because you used GET word above and it means you have only one record in your dataset.
REPEAT
SETRANGE("Shortcut Dimension 1 Code",SPH.Code); // which record you are filtering here?
IF FIND('-') THEN // which record do you want to loop through? if you have more than one record found, what will you do?
AmountLoc:=Quantity; // why do you use array here? you want to get only first value or sum all?
LocName := SPH.Code;
i:= i + 1;
UNTIL (SPH.NEXT = 0) OR (i > SPH.COUNT); // isn't next statement enough?
Maybe you can write something like:SPH.GET("Dimension Code",Code); varRecord.SETRANGE("Shortcut Dimension 1 Code",SPH.Code); IF varRecord.FIND('-') THEN BEGIN i:= i + 1; //assuming you increment i per SPH LocName[i] := SPH.Code; REPEAT AmountLoc[i]+=varRecord.Quantity; UNTIL varRecord.NEXT = 0; END;Ufuk Asci
Pargesoft0 -
actually, this is my codePurchase Line - OnPreDataItem()
SPH.SETRANGE(SPH."Global Dimension No.",1);
SPH.FIND('-');
Cylinder.SETRANGE(Cylinder."Global Dimension No.",2);
Cylinder.FIND('-');
i:= 1;
REPEAT
LocName := SPH.Code;
i:= i +1;
UNTIL
(SPH.NEXT = 0) OR (i > SPH.COUNT);
Purchase Line - OnAfterGetRecord()
{
i:=1;
SPH.FIND('-');
REPEAT
SETRANGE("Shortcut Dimension 1 Code",SPH.Code);
IF FIND('-') THEN
AmountLoc:=Quantity;
LocName := SPH.Code;
i:= i + 1;
SETRANGE("Shortcut Dimension 1 Code");
UNTIL (SPH.NEXT = 0) OR (i > SPH.COUNT);
}0 -
i:=1;
SPH.GET("Dimension Code",Code);
SPH.FIND('-'); // not necessary to loop, because you used GET word above and it means you have only one record in your dataset.
REPEAT
SETRANGE("Shortcut Dimension 1 Code",SPH.Code); // which record you are filtering here? --> Purchase Line records
IF FIND('-') THEN // which record do you want to loop through? if you have more than one record found, what will you do?
AmountLoc:=Quantity; // why do you use array here? you want to get only first value or sum all? --> this this the cross from matrix so, i use array
LocName := SPH.Code;
i:= i + 1;
UNTIL (SPH.NEXT = 0) OR (i > SPH.COUNT); // isn't next statement enough? --> yes0 -
Bangwit, you should read my posts above

There are many problems in that code and first of all you should study training manuals as I said before. We can correct your code here but it'll not be a permanent solution. You should better understand faults in code yourself and correct them by understanding what you are really doing.Ufuk Asci
Pargesoft0 -
I'm using 2 array
filtering array 1
SPH.SETRANGE(SPH."Global Dimension No.",1);
SPH.FIND('-');
filtering array 2
Cylinder.SETRANGE(Cylinder."Global Dimension No.",2);
Cylinder.FIND('-');
i:= 1;
REPEAT
LocName := SPH.Code;
i:= i +1;
UNTIL
(SPH.NEXT = 0) OR (i > SPH.COUNT);
my problem is... how to use those 2 arrays in execution
i:=1;
j:=1;
SPH.FIND('-');
Cylinder.FIND('-');
REPEAT
RL.SETRANGE(RL."Shortcut Dimension 1 Code",SPH.Code);
RL.SETRANGE(RL."Shortcut Dimension 2 Code",Cylinder.Code);
IF RL.FIND('-') THEN
AmountLoc:=RL.Quantity;
i:= i + 1;
RL.NEXT;
UNTIL (SPH.NEXT = 0);0
Categories
- All Categories
- 75 General
- 75 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 611 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 253 Dynamics CRM
- 103 Dynamics GP
- 6 Dynamics SL
- 1.5K Other
- 991 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 28 Design Patterns (General & Best Practices)
- Architectural Patterns
- 9 Design Patterns
- 4 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1K General Chat
- 1.6K Website
- 77 Testing
- 1.2K Download section
- 23 How Tos section
- 249 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions