Liquid UI - WS Reference Library

file operations


Purpose

The following scenario demonstrates the openfile(), readfile(), and closefile() command usage:

  1. On the SAP Easy Access screen, create 3 fields with the below labels:
    • Material
    • Item
    • Description
  2. Create a data file with the following data:
    1030,10,valve 1
    1030,20,15 inch TV
    1030,30,monitor
    2120,10,door handle
    2120,20,paper clips
    2120,30,mouse
    3650,10,TV set
    3650,20,remote control
    4400,10,round cable
    4400,20,starter
    5003,10,test
    5003,20,test
    
  3. Create script file as shown in the "Script".
  4. Save the file.


User Interface

The SAP Easy Access screen appears, as shown below:


 

Press Enter key. The data from the file appears in the fields as shown in the following figure:



Liquid UI Script

//SAPLSMTR_NAVIGATION.E0100.sjs

function isBlank(jvar){
return(jvar == null || jvar == "" || jvar == void(0));
}
for(a=firstChild; a!=null; a=a.nextSibling){
a.del();
}
pidx = 0;
idx=0;
text([0,0],"Material",{"size":20});
text([0,22],"Item",{"size":20});
text([0,44],"Description",{"size":20});
create:{ inputfield([pidx + 1,0],{"size":20,"readonly":true,"name":"z_first_&V[pidx]" ,"nolabel":true}); inputfield([pidx + 1,22],{"size":20,"readonly":true,"name":"z_second_&V[pidx]" ,"nolabel":true}); inputfield([pidx + 1,44],{"size":20,"readonly":true,"name":"z_third_&V[pidx]","nolabel":true});
}
pidx = pidx + 1;
set("V[z_checkfld]","&V[z_first_&V[pidx]]");
if(isBlank(z_checkfld)) {
println("<<<<<<<<<CHECK FIELD>>>>>>>>>>" + z_checkfld);
goto end_create;
}
goto create;
end_create:
onUIEvents['Enter'] = {"process":iw21_readfile, "fcode":"/niw21"};
function iw21_readfile(){
println("<<<<<<<<<<<<INITIAL VALUE>>>>>>>> :" + idx);
openfile('file.txt',{"delimiter":","});
read:{
println("<<<<<<<<<<<<READING VALUES>>>>>>>> :" );
readfile('file.txt',{"z_first_&V[idx]":true, "z_second_&V[idx]":true, "z_third_&V[idx]":true});
}
set("V[z_currField]","&V[z_first_&V[idx]]");
println("<<<<<<<<<<<<<<<<<Current Field>>>>>>>>>>>>>>" + z_currField);
if(isBlank(z_currField)) {
println("<<<<<<<<<<<<<<GOING END>>>>>>>>>>>>>>");
goto end;
}
idx++;
println("<<<<<<<<<<<<THE IDX VALUE>>>>>>>> :" + idx);
goto read;
end:
closefile('file.txt');
}