cancel
Showing results for 
Search instead for 
Did you mean: 

Capturing the null row in a table

Pioneer
Pioneer

Hi community,

 

I have a table as in the attached model.

In the table there are null rows in between data.

I want to capture the null row number in a variable.

Please suggest the best method to do that.

 

Thanking you,

Regards,

Abhirath

 

10 REPLIES

Re: Capturing the null row in a table

Phenom
Phenom

if you use a list as variable, this should work:

 

var l:list[integer];
l.create

for var i:=1 to BOM.yDim loop
	if BOM[1,i]=void then
		l.append(i)
	end	
next

Steffen Bangsow
freelance simulation specialist  
web: www.bangsow.eu
mail: steffen@bangsow.net


Re: Capturing the null row in a table

Pioneer
Pioneer

Dear Steffen,

Thanks for the replay,

 

The main objective of mine is to create a nested BOM in this model.

In the attached model were a manually created table "required_table" is the output i need.

I have modified the method with your help, but not able to insert the data into second

nested table. Plese help me write the codes to do so.

 

Plese note that the table BOM will be dynamic.That is the number of child parts

and subparts will change 

 

Regards,

Abhirath.

Re: Capturing the null row in a table

Phenom
Phenom

you need a nested loop; in the outer loop you run though the table BOM and with the inner loop you copy the entries into the subtables. The number of entries you find by searching the empty cells. You have a lot of garbage in the table, this you need to skip over:

is 
	i,j,k,l:integer;
	
do
	
  nestedBOM.delete;
  for i:=1 to BOM.yDim loop
    if i=1 or BOM[1,i] = void then
      --start new nested list
      --skip the first row(s)	
      if i=1 then		
        nestedBOM.createNestedList(1,nestedBOM.yDim+1,BOM[1,i]);
        i:=i+2;
      else
        nestedBOM.createNestedList(1,nestedBOM.yDim+1,BOM[1,i+1]);
        i:=i+3;
      end;
			
      --look for the next empty cell
      BOM.setCursor(1,i);
      if (BOM.find({1,i}..{1,*},void)) then
        l:=BOM.cursorY;
      else
        --until the end
        l:=BOM.yDim;
      end;
      --copy all entries until the next empty cell
      --into the subtable
      for k:=i to l loop
	BOM.copyRangeTo({1,k}..{*,k},nestedBOM[1,nestedBOM.yDim],1,
         nestedBOM[1,nestedBOM.yDim].yDim+1);
      next;
      i:=l-1;
    end;		
  next;
	
end;

	


Steffen Bangsow
freelance simulation specialist  
web: www.bangsow.eu
mail: steffen@bangsow.net


Re: Capturing the null row in a table

Pioneer
Pioneer

Dear steffen

Thanks again for the replay..

 

But running with the new code, Main part and sub parts are coming in the same table along with main part. Although the child parts are coming in the nested table of main part,sub parts are not there in the next table.

 

Plese see the difference in "NestedBOM" and "required_output" in the attached model.

I have been trying to rectify it, please suggest the required corrections.

 

Regards,

ABHIRATH

 

Re: Capturing the null row in a table

Phenom
Phenom
Your template "required_output" doesn't make sense, if you have e.g. several main parts with the same sub parts, you will need the information about the subparts several times in your raw-data table.

Steffen Bangsow
freelance simulation specialist  
web: www.bangsow.eu
mail: steffen@bangsow.net


Re: Capturing the null row in a table

Pioneer
Pioneer

Dear Steffen,

 

I was planning to use the "nestedBOM" table for calculating the quantity requirement of the child parts. 

The main parts quantity requirement will be provided as in the attached model's table "required_output".

 

Based on the Main parts Qty(Sales Order), Child parts Qty will be calculated for N+3 months.

 

Is this the best way to approach such kind of calculations ??

If not, Please suggest the alternative. 

 

 

 

 

Re: Capturing the null row in a table

Phenom
Phenom

I dont know, if it is the best way. But redundant data are very bad.

I have changed the format of the NestedBOM. The part names now are in the row index.

And so you can read all parts, you need:
- starting from the mainpart read all partnames of the subframe; if the name is a row index of the nested BOM (getRowNo > -1 see help) --> it is a assembled part --> read all parts from the subframe --> check if the parts are assembled parts ....

 

 


Steffen Bangsow
freelance simulation specialist  
web: www.bangsow.eu
mail: steffen@bangsow.net


Re: Capturing the null row in a table

Pioneer
Pioneer

Thanks steffen for your suggestion..

I would like to do the calculation with the nested table as in the "required_output" table.

That is main part (nested table)  > Subassembly (nested table) > child parts of subassembly.

 

Plese help in writing the codes for the above scenario. 

Thanking you again,

Regards,

ABHIRATH

 

 

Re: Capturing the null row in a table

Phenom
Phenom

see method convert, you need to mark your main parts to have an entry point. This is fixed for two levels, but you can expand it...


Steffen Bangsow
freelance simulation specialist  
web: www.bangsow.eu
mail: steffen@bangsow.net