0% found this document useful (0 votes)
69 views

Creating A Command Field Widget For SAP

This document explains a step by step approach in how to create a Command Field Widget for sap. It Applies to: SAP ECC 6.0, SAP NetWeaver 7. (2004s)
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
69 views

Creating A Command Field Widget For SAP

This document explains a step by step approach in how to create a Command Field Widget for sap. It Applies to: SAP ECC 6.0, SAP NetWeaver 7. (2004s)
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Enterprise Widget for SAP Command Field

Enterprise Widget for SAP Command Field

Applies to:
SAP ECC 6.0, SAP NetWeaver 7.0 (2004s).

Summary
This document explains a step by step approach in how to create a Command Field Widget for SAP. In order
to proceed with this article, you should have a basic idea about widgets. You can find the Command Field
Widget here.

Author: Jaideep Srinivasan


Company: EDS
Created on: 25 July 2007

Author Bio

Jaideep Srinivasan is an Abaper in EDS (India). He is more interested in developing tools for
Web applications and SAP.

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com

© 2007 SAP AG 1
Enterprise Widget for SAP Command Field

Table of Contents

Applies to: ........................................................................................................................................ 1


Summary.......................................................................................................................................... 1
Author Bio ........................................................................................................................................ 1
Objectives ........................................................................................................................................ 2
Credits.............................................................................................................................................. 2
Steps in Creating the widget :.......................................................................................................... 2
1. Creating .SAP file..................................................................................................................... 2
2. Creating .KON file .................................................................................................................... 3
3. Creating Java Script(sap.JS) file.............................................................................................. 5
Screen Shots................................................................................................................................ 6
Related Content............................................................................................................................... 7
Disclaimer and Liability Notice......................................................................................................... 8

Objectives

The main objective is to provide SAP Users with a simple Widget which is similar to the Command Field in
SAP.(ie.user can call SAP R/3 transactions from the Command Field Widget)

Credits

Special thanks to Tarun Telang & Abesh Bhattacharjee for introducing about the concepts of Widgets and
SAP GUI for Windows.

Steps in creating the widget:


1. Creating .SAP file

Create a text file with the following conten with .sap extension.

[System]
Name=NSP
Client=000
Description=NSP1
[User]
Name=BCUSER
Password=minisap
Language=EN

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com

© 2007 SAP AG 2
Enterprise Widget for SAP Command Field

[Function]
Command=se38
Title=ABAP Editor
Type=Transaction
[Configuration]
WorkDir=D:\Documents and Settings\abcdef\SapWorkDir
[Options]
Reuse=1

Save the file with extension .SAP (for eg : "main.SAP"). This will create a SAP Shortcut (For more details
view Tarun Telang blog about SAP GUI for Windows.)

2. Creating .KON file

Create another text file with extension .kon (for example "Command_Field.kon").

<?xml version="1.0" encoding="utf-8"?>


<?konfabulator xml-strict="true"?>
<widget version="0.1" minimumVersion="2.1.1">
<debug>off</debug>
<about-box>
<image>images/about.png</image>
</about-box>

//preferences are created for user customization.


<!--Define Preferences -->
<preference>
<name>Server</name>
<title>Server:</title>
<type>text</type>
<defaultValue>NSP</defaultValue>
</preference>
<preference>
<name>Client</name>
<title>Client :</title>
<type>text</type>
<defaultValue>000</defaultValue>
</preference>

<preference>
<name>Description</name>
<title>Description:</title>
<type>text</type>
<defaultValue>NSP1</defaultValue>
</preference>

<preference>
<name>User</name>
<title>User:</title>
SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com

© 2007 SAP AG 3
Enterprise Widget for SAP Command Field

<type>text</type>
<defaultValue>BCUSER</defaultValue>
</preference>

<preference>
<name>Password</name>
<title>Password:</title>
<type>text</type>
<defaultValue>minisap</defaultValue>
<secure>yes</secure>
</preference>

<window>
<name>main_window</name>
<title>SAP Command LINE</title>
<height>102</height>
<width>230</width>
<visible>yes</visible>
<opacity>95%</opacity>
<onGainFocus>
searchText.focus();
</onGainFocus>
</window>

<image src="images/sap.png" opacity="95%"/>

//For command field(i.e input field)


<textArea>
<name>searchText</name>
<hOffset>14</hOffset>
<vOffset>64</vOffset>
<size>14</size>
<font>Verdana</font>
<lines>1</lines>
<columns>20</columns>
<data></data>
<color>#000000</color>
<scrollbar>false</scrollbar>
<bgColor>#ffffff</bgColor>
<bgOpacity>0%%</bgOpacity>
<opacity>95%%</opacity>
<onKeyPress>
if (system.event.keyString == 'Return' || system.event.keyString =
'Enter')
{
searchText.rejectKeyPress();
doRetrieve();
searchText.data = "";
}
</onKeyPress>

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com

© 2007 SAP AG 4
Enterprise Widget for SAP Command Field

</textArea>
<preference name="windowLevel">
<hidden>true</hidden>
</preference>

//initialization event
<action trigger="onLoad" >
<![CDATA[
include("sap.js");
]]>
</action>

<action trigger="onPreferencesChanged">
doRetrieve();
</action>

</widget>

3. Creating Java Script(sap.JS) file

//initialize the variables


var tcode = "";
var lines = "";
var Server = "";
var Client = "";
var Description = "";
var Password = "";
var replace_tcode = "";
var replace_Server = "";
var replace_Client = "";
var replace_Description = "";
var replace_User = "";
var replace_Password = "";

searchText.focus();
function doRetrieve()
{
tcode = searchText.data;
lines = filesystem.readFile( "main.sap");
replace_tcode = lines.replace("se38",tcode);
Server = preferences.Server.value;
replace_Server = replace_tcode.replace("NSP",Server);
Client = preferences.Client.value;
replace_Client = replace_Server.replace("000",Client);
Description = preferences.Description.value;
replace_Description = replace_Client.replace("NSP1",Description);
User = preferences.User.value;
replace_User = replace_Description.replace("BCUSER",User);
Password = preferences.Password.value;

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com

© 2007 SAP AG 5
Enterprise Widget for SAP Command Field

replace_Password = replace_User.replace("minisap",Password);
filesystem.writeFile( "c:/temp.sap",replace_Password);
filesystem.open( "c:/temp.sap"); //new file has been created and
opened.

The widget is now ready to execute. Double click on the main.kon to execute the Widget or right click and
open with Yahoo! Widget Engine.

This saves you from login into the SAP system and typing the transaction code every time to start the
corresponding SAP Screen.

Screen Shots

Command Field Widget(sap.png)

Preferences

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com

© 2007 SAP AG 6
Enterprise Widget for SAP Command Field

About window(about.png)

This is my first widget for SAP applications. Please post your comments to [email protected]

Related Content
.
• About Widgets
• Create First Yahoo widget
• Enterprise Widget Foundation
• SAP GUI Basics

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com

© 2007 SAP AG 7
Enterprise Widget for SAP Command Field

Disclaimer and Liability Notice


This document may discuss sample coding or other information that does not include SAP official interfaces
and therefore is not supported by SAP. Changes made based on this information are not supported and can
be overwritten during an upgrade.
SAP will not be held liable for any damages caused by using or misusing the information, code or methods
suggested in this document, and anyone using these methods does so at his/her own risk.
SAP offers no guarantees and assumes no responsibility or liability of any type with respect to the content of
this technical article or code sample, including any liability resulting from incompatibility between the content
within this document and the materials and services offered by SAP. You agree that you will not hold, or
seek to hold, SAP responsible or liable with respect to the content of this document.

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com

© 2007 SAP AG 8

You might also like