Purpose Read and write Excel interactively |
Solution Example Video
// Select Excel file
// done?
// Open file in Excel
// Row number
label
next_material
Enter
"/NMM02"
// Change Material (Initial Screen)
// Change screen title during processing
label
read_row_from_excel
//
status ok? then skip
this one, already done
Set
F[RMMG1-MATNR]
"&V[MM02_matnr]"
// Clear variables for material text and
current price
// Select View(s)
// Select 1st view
Screen
SAPLMGMM.4004
// Organizational Levels
// error popup for wrong plant
// error message on screen in this case
//
Change standard price
// Material text and current price
// Save changes
// Change Material (Initial Screen)
// Set status fields
// increase ok count
// process next material
// error occured
label
error
label
all_done
Enter
"/N" // Excel interface object
var XL = null; function XL_open(filename, caption) { XL = guixt.CreateObject("Excel.Application"); // show Excel in the foregound XL_window_foreground(); // display Excel window XL.Visible = true; // set caption XL.caption = caption; // open file XL.WorkBooks.Open(filename); }; // Read Excel row values into GuiXT variables function XL_getrow(k) { // Read Excel row into GuiXT variables guixt.Set("MM02_matnr", XL.Cells(k, 1).Value); // material guixt.Set("MM02_werks", XL.Cells(k, 2).Value); // plant guixt.Set("MM02_zkprs", XL.Cells(k, 3).Value); // price guixt.Set("MM02_zkdat", XL.Cells(k, 4).Value); // date guixt.Set("MM02_stats", XL.Cells(k, 5).Value); // status }; // Update Excel row from GuiXT variables function XL_updaterow(k) { // status OK or Error XL.Cells(k, 5).Value = guixt.Get("MM02_stats"); // color depending on status if (XL.Cells(k, 5).Value == "OK") { XL.Cells(k, 5).Interior.ColorIndex = 2; } else { XL.Cells(k, 5).Interior.ColorIndex = 46 }; // format date var today = new Date(); var dd = today.getDate(); var mm = today.getMonth() + 1; //January is 0! var yyyy = today.getFullYear(); XL.Cells(k, 6).Value = dd + "." + mm + "." + yyyy XL.Cells(k, 7).Value = guixt.Get("MM02_maktx"); XL.Cells(k, 8).Value = guixt.Get("MM02_stprs"); XL.Cells(k, 9).Value = guixt.Get("MM02_error"); }; function XL_window_foreground() { // constants for WindowState from MS documentation var xlMinimized = -4140; var xlNormal = -4143; // change window state to minimized and back to normal XL.WindowState = xlMinimized; XL.WindowState = xlNormal; }; |
Components |