You can use the set command to assign a variable to a specific table cell. In this case, we will assign values to the Materials and Order Quantity fields in the All items table on the overview screen of the VA01 transaction.
-
Open SAP and navigate to the VA01 intial screen.
-
Open the 'SAPMV45A.E0101.sjs' script file, and enter the following code. Create the file if it does not already exist.
set("cell[All items,Material,1]", "t-bw03-05");
set("cell[All items,Order Quantity,1]", "1");
-
Save your changes. The value will now appear in the table cells you specified as shown below:
-
You can also perform the reverse operation, or assign the value from a given table field to a variable. To assign the value contained in the Material cell in the first row of the All items table to the variable 'z_mat2', use the following code:
The offset option specifies how far from the box margin the new pushbuttons will be located.
set('V[z_mat2]', '&cell[Table,column,row]’);
In this case, the value contained in the actual table cell is being stored in the variable, which is why the ampersand precedes the cell specifications.
-
You can also assign a value to a cell in a new column of a native SAP table with the set command. To assign values to the first three cells in the new column, use the following code:
column("Mycol",{"table":"All Items","size":8,"name":"estcost","position":1});
set("V[estcost.1]","1");
set("V[estcost.2]","56");
set("V[estcost.3]","XXX");
The first line of code creates the new column, whle the ensuing three set commands place variables into the first three cells of the designated column.