Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - umang@guixt.com

Pages: 1 2 [3]
31
The examples demonstrates the ability to embed Windows COM controls within SAPGUI

Liquid UI Scripts

1. User Interface
pushbutton([0,1],"Orders Since","/0" ,{"process":getOrders});
inputfield([0,20],"Date",[0,30],{"name":"z_date","size":"10"});

if (isBlank(Z_SCRN)) {
} else {
   if (Z_SCRN == 'LIST') {
      pushbutton([TOOLBAR],"Start Over","/0" ,{"process":closeOrders});
      box([1,1],[26,62],"&V[z_rowcount] Orders Since: &V[z_date]");

      var listview = new ActiveXObject('COMCTL.ListViewCtrl');
      addToScreen(listview, [2,2], [26,62], "container1");
      listview.View = 3;

      if(listview.ColumnHeaders.Count == 0) {
         listview.ColumnHeaders.Add(1, "colkey1", "Order No");
         listview.ColumnHeaders.Add(2, "colkey2", "PO Date");
         listview.ColumnHeaders.Add(3, "colkey3", "Customer");
         listview.ColumnHeaders.Add(4, "colkey4", "PO Number");
      }

      for (var idx = 0; idx < z_rowcount; idx++) {

         keyid = idx + 1;

         set('V[keynumber]','key&V[idx]'); 
         
         set('V[vbeln]','&V[vbeln_&V[idx]]');
         set('V[bstdk]','&V[bstdk_&V[idx]]');
         set('V[kunnr]','&V[kunnr_&V[idx]]');
         set('V[bstkd]','&V[bstkd_&V[idx]]');

         keyno = parseInt(keyid);
         keynumberjs = keynumber;
         keyvaluevbeln = vbeln;
         keyvaluebstdk = bstdk;
         keyvaluekunnr = kunnr;
         keyvaluebstkd = bstkd;

         listview.ListItems.Add(keyno,keynumberjs, keyvaluevbeln);
         listview.ListItems(keyno).SubItems(1) = keyvaluebstdk;
         listview.ListItems(keyno).SubItems(2) = keyvaluekunnr;
         listview.ListItems(keyno).SubItems(3) = keyvaluebstkd;

      }
   }
}

2. Function to Retrieve data using RFC Call to ABAP function module
function getOrders() {
   var selopt = [];
   var ordersTable = [];

   vmvaa = "VMVAA";
   bstdk = "BSTDK";
   i = "I";
   ge = "GE";
   from = z_date;

   z_queryOption = padString(vmvaa, 30, PADDING_RIGHT, " ");
   z_queryOption += padString(bstdk, 30, PADDING_RIGHT, " ");
   z_queryOption += i;
   z_queryOption += ge;
   z_queryOption += padString(from, 45, PADDING_RIGHT, " ");
   selopt.push(z_queryOption);

   call("Z_S10_SEARCHHELP", {
      "in.SEARCHHELP": "VMVAA", "in.COLUMNS":"VBELN(10),BSTDK(10),KUNNR(10),BSTKD(20)",
      "table.SELOPT": "selopt",
      "table.DATA(width:50)": "ordersTable"
   });

   for (var rowNumber = 0; rowNumber < ordersTable.length; rowNumber++) {
      var result = {
         vbeln: ordersTable[rowNumber].substring(0, 10),
         bstdk: ordersTable[rowNumber].substring(10, 20),
         kunnr: ordersTable[rowNumber].substring(20, 30),
         bstkd: ordersTable[rowNumber].substring(30, 50)
      };
      set("V[vbeln_&V[rowNumber]]", result.vbeln);
      set("V[bstdk_&V[rowNumber]]", result.bstdk);
      set("V[kunnr_&V[rowNumber]]", result.kunnr);
      set("V[bstkd_&V[rowNumber]]", result.bstkd);
   }
    Z_SCRN = 'LIST';
    set('V[z_rowcount]',ordersTable.length);
    return;
}




See attached documents for details

32
Integrating Word Spell Checker, for verifying the text entered within a long text control in SAPGUI using Liquid UI

Liquid UI Script

// Sample User Interface
box([1,0], [12,72], "Spelling Check - MS Word Automation");
textbox([2,1],[11,71],{'name':'sampletext'});
pushbutton([13,0],'@3V@MS Word Spell Check',{'process':spellCheck});

// Sample Function
function spellCheck() {
   var myWord = new ActiveXObject('Word.Application');

   myWord.Caption = "Spell Check";
   myWord.Visible = true;

   var doc = myWord.Documents.Add();
   doc.Activate();
   doc.Content.Text = sampletext;
   doc.CheckSpelling();

   newText = doc.Content.Text;
   doc.Saved = false;
   doc.Close(0);
   doc = null;

   myWord.Quit();
   myWord = null;

   onscreen '*'
      copytext({'fromstring':'newText', 'totext':'sampletext'});
      enter('?');

}

See Attachments for Samples

33
Liquid UI: Converting Word to PDF


Step 1: User Interface [ Create on Screen of your choice ]

//Button to initiate the process from SAP Transaction
// Code Sample: User Interface

pushbutton([1,1], 'Convert Word to PDF','?',{'process':convertWordToPDF});

Step 2: File Selection Dialog: Select File for PDF Conversion

// Code Sample: Open Windows File Selection Dialog
// Function to Show File Selection Dialog

function selectFileDialog(szPrompt) { 
    if(szPrompt==void 0)
        szPrompt = 'Select Valid Word Documnet';
    var dialog = new ActiveXObject('MsComDlg.CommonDialog'); 
    dialog.Filter='All Files(*.*)|*.*'; 
    dialog.MaxFileSize=32767; 
    dialog.DialogTitle=szPrompt;
    dialog.Flags=0x200|0x80000|0x800|0x4|0x200000 
    dialog.ShowOpen(); 
    var ret = dialog.FileName;
    dialog = void 0;
    return ret;
} 

// Calling the function
    if(myWord == void 0) {
        wordFileName = selectFileDialog('Select Word File for PDF Conversion');

 
Step 3: Successful PDF Conversion after file selection

 
Liquid UI Code [Script]

 
// Convert Word Document to PDF User Interface

function convertWordToPDF() {

    if(myWord == void 0) {
        wordFileName = selectFileDialog('Select Word File for PDF Conversion');
      
        if(wordFileName.length) {
         var wordFilePath = wordFileName.substr(0, wordFileName.lastIndexOf('\\'));
         var wordFileNameWithExtension = wordFileName.substr(wordFileName.lastIndexOf('\\'),wordFileName.length);
         var wordFileNameWithoutExtension = wordFileNameWithExtension.substr(0, wordFileNameWithExtension.lastIndexOf('.'));

         var PDFFileName = wordFilePath + wordFileNameWithoutExtension + '.pdf';
   
         wordToPDF(wordFileName,PDFFileName);
         message('S: Successfully Converted to PDF File: ' + PDFFileName);
        }
   }
}

 
// Function to convert contents of word file to PDF Format

function wordToPDF(wordFile, pdfFile) {
   myWord = new ActiveXObject('Word.Application');
//   myWord.Visible = true;    // if set, processes in foreground; otherwise the conversion is processed in the background
   myWord.DisplayAlerts = 0;
   
   myDoc = myWord.Documents.Open(wordFile);
   
   var pdfFormat = 17;
   myDoc.SaveAs(pdfFile,pdfFormat);
   
   myDoc.Close();
   myWord.Quit();
   delete myWord;
}

See attachments for code samples

Pages: 1 2 [3]