on 12-09-2014 12:12 PM
Hi,
I want use to use a custom function in CBTA e.g. for setting a value in text box(i.e. SAPGuiEdit) based on its attached text.
Say my simple function is as below-
Function Custom_SetText_AttachedText(ObjName, val)
SAPGuiSession("guicomponenttype:=12").SAPGuiWindow("type:=GuiMainWindow").SAPGuiEdit("attachedtext:="& ObjName).Set val
End Function
I understand that we can include error handling and other things to it but I would like concentrate on how to use such a custom code in CBTA.
I included this function in VBS file and stored that file in CBTA\Custom folder which got created once I opened RTL for Edit.
RTL Manager is showing this function in the list of function.
But when I used this function in "InvokeFuction" default component with following parameter-
library->Custom\filename.vbs
function-> Custom_SetText_AttachedText
Parameter1->Attached text of Text box
Parameter2->value to set in text box
This component did not work.
Note:-I have already gone through RTL Manager guide and CustomCodePattern guides.
If anybody has used custom functions in CBTA, It would be great help if you suggest something.
Solman Version->7.1 SP10
Hi All,
Custom functions for CBTA can be created using VB scripts or SAP GUI scripting only not with the QTP function.
Regards,
Sachin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Sachin,
I hope you have gone through this already.
Enhancing CBTA With Custom Code - SAP Solution Manager - SAP Library
Please let me know if you get an answer for this.
Regards,
Mohamed Ziavudeen
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This message was moderated.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Srinivasan,
The second document you refer to(Customization of CBASE) is obsolete and should not be used any more.
The RTL Manager should now be accessed from Test Management Work Center - Administration - CBTA Settings, and the valid user guide is available on the Test Management Wiki (SAP Solution Manager WIKI - Test Management - Solution Manager - SCN Wiki).
Moreover, Sachin had mentioned he had already gone through this document.
Sachin,
What do you mean by "The component does not work"?
Do you get any error in the CBTA Execution Log? Or a VBScript error?
As I am not an expert in VBScript nor in GUI Scripting API, I can hardly help you on this part:
Say my simple function is as below-
Function Custom_SetText_AttachedText(ObjName, val)
SAPGuiSession("guicomponenttype:=12").SAPGuiWindow("type:=GuiMainWindow").SAPGuiEdit("attachedtext:="& ObjName).Set val
End Function
But regarding what follows - the function appearing in the RTL Manager, the way you invoke it -, it seems correct.
N.B.: From my experience, I usually try to avoid using GUI Scripting API as much as possible, and rather keep custom functions for pure VBScript coding (e.g. generate random number, copy/move file, etc.).
Typically in this case, I would try to use the GetProperty and SetProperty components. Although I understand sometimes this is not applicable.
Regards,
Rémi.
Hello Rémi,
Above code I provided is just an example but I need to create custom functions for even modifying a txt file/copy/move a file.
For Invoke Function I am getting below error-
ERROR DETECTED *
Error: 1041
Description: The name is redefined
Source: There was a Microsoft VBScript compilation error
* LAST CONTROL URI *
label -> wnd [0]
type -> GuiMainWindow
id -> / app / con [1] / viewed [0] / wnd [0]
But if i run the function using QTP it works. I used to create custom component using funcions like above in TAO.
For pure vb script coding, if you have created a custom function for CBTA, could you plz share some information like-
what exact code structure should be and how to use it in Invoke Function.
Small simple example code if you don't have issue, will be helpful.
@Srinivasan, I followed the instruction as per the links provided by you.
Thanks,
Sachin
Hello Sachin,
My apologies for the delay to answer. I hope this message will still be useful to you.
Here is a simple function we use to copy files from a source folder to a target folder:
---------------------------------
Function CopyFileFromFolder(SourcePath, File_Name, TargetPath, Param3, Options)
Dim sourceFol, destFol, source_File, FullPath
sourceFol = SourcePath
destFol = TargetPath
source_File = File_Name
FullPath = sourceFol & source_File
Set obj = CreateObject("Scripting.FileSystemObject")
if obj.FileExists(FullPath) Then
obj.CopyFile FullPath,destFol
CopyFileFromFolder = "Done"
End if
End Function
---------------------------------
With 3 parameters which are self-descriptive.
Maybe you can try to copy/paste this function and see if it works?
Best regards,
Rémi.
User | Count |
---|---|
89 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.