cancel
Showing results for 
Search instead for 
Did you mean: 

How to use/create custom functions in CBTA?

Former Member
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi All,

Custom functions for CBTA can be created using VB scripts or SAP GUI scripting only not with the QTP function.

Regards,

Sachin

Answers (2)

Answers (2)

0 Kudos

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

Former Member
0 Kudos

Hi Mohamed,

This link has already been provided by Srinivasan (see above)...

Kind regards,

Rémi.

srinivasan_vinayagam
Active Contributor
0 Kudos

This message was moderated.

Former Member
0 Kudos

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.

Former Member
0 Kudos

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

Former Member
0 Kudos

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.