Martin, I do look at what the compiler is telling me, but it isn’t very specific just says there is a syntax error. I’ve only been developing in X++ for a couple of months so I’m still learning. I have read the documentation, as I said I’m still learning so it doesn’t all make sense and it seemed to me that I was following the documentation, that’s why I am confused. I have tried several things in trying to get the errors to go away, but I’ve not found the solution yet.
I am the IT for my plant and there isn’t anyone else that I can go to in my company as I’m it. I do have a sister company that has a dev too and I’ve gone to him several times, but he doesn’t have the time to train me extensively in X++ as he has his plant to worry about and his development. He has helped me get to the point that I’m at, but he is busy with projects himself and cannot spend the time I need to figure this out.
I have searched online for help with this particular problem (and others), I don’t post much because I can usually find a solution that works, even if it isn’t elegant. This one I’ve not been able to figure out yet, that’s why I’m posting a question.
I have tried rewriting my code to follow what you wrote, but I am not getting another error that I don’t understand. The reason I wrote it the way I did, to begin with, is because of the documentation that I found that seemed to support me. In the doc Select Statement Syntax, I searched for “Group By” and found the example about halfway down the page for it that looks like:
CustTable custTable;
;
while select sum(CreditMax) from custTable
group by CustGroup
{
print custTable.CustGroup, " ",custTable.CreditMax;
}
Right below that is an example for using “Index” that looks like this:
CustTable custTable;
;
while select AccountNum, Name from custTable
index AccountIdx
{
print custTable.AccountNum, " ", custTable.Name;
}
Combining what I found in them I came up with the while select
that I posted originally. Now with your help, I have made changes, but I have other errors and don’t have any clue where to even look to find a solution. What I changed my code to it this:
InventDim invDim, invDimCoils;
InventTrans invTran, invTranCoils;
PdsBatchAttributes batAttrib, noBatAttrib;
InventJournalTable invJorTable;
InventJournalTrans invJorTrans, invJorTransC;
InventTransOrigin invTransOrig, invTranOrigCoils;
while select noBatAttrib
group by noBatAttrib.InventBatchId
where noBatAttrib.PdsBatchAttribId != "CoilBatch1"
&& noBatAttrib.InventBatchId like "B-20*"
{//Get the parent coils for the found wire boxes
while select count(InventBatchId) from invDim
group by InventBatchId
where invDim.InventBatchId == noBatAttrib.InventBatchId
join invTran
where invTran.inventDimId == invDim.inventDimId
join invTransOrig
where invTransOrig.RecId == invTran.InventTransOrigin
&& invTransOrig.ItemId == invTran.ItemId
&& invTransOrig.ReferenceCategory == InventTransType::BOMMain
join ItemId invTranOrigCoils
where invTranOrigCoils.ReferenceId == invTransOrig.ReferenceId
&& invTranOrigCoils.ReferenceCategory == InventTransType::BOMLine
join invTranCoils
where invTranCoils.InventTransOrigin == invTranOrigCoils.RecId
&& invTranCoils.ItemId == invTranOrigCoils.ItemId
join InventBatchId invDimCoils
//I forgot to include this last time
where invDimCoils.InventDimId == invTranCoils.InventDimId
{}
}
Where I am not running into errors is on the line: Join ItemId invTranOrigCoils.
The compiler is now telling me that ItemId is a variable that has not been declared. Why is it now telling me that the ItemId
is a variable? It should be the column that I want to use from the invTransOrigCoils table that I am using.
And I’m sure that I will get the same error when I get to the line: join InventBatchId invDimCoils,
as it is in the same format. I have not seen this format before so I don’t understand it yet.