Skip to Content

How to use String Functions in CBTA

Use Case Description

Select a value from a message text to be used as output parameter

During test automating you might face the challenge that only a part of a string is required as output parameter for subsequent steps to be used as input parameter.

Example: Let’s assume when creating a sales order with VA01 you just get the message ‘’Standard Order 12695 has been saved’ and you would like to use only the number for subsequent steps, e.g. create delivery.

For most SAP standard transactions like VA01 you can capture the value directly from the standard message parameters in the status bar (e.g. MESSAGEPARAMETER1) via default components CBTA*GETMESSAGEPARAMS. But for some other transactions / applications and especially in the situation of custom code a number might not be available as an dedicated screen element but only as part of the complete message string. In this case the following procedure will help you to select the number and put it into an output parameter.

Although the better option for VA01 would be to use the message parameter directly via CBTA_GUI_SB_GetMessageParams I would like to use this as an example to outline the procedure.

A further requirement to this use case was that the number of digits of the output value should be flexible.

There is one option to change the string in 2 steps:

  1. Deleting the left part next to the number with VBScript Replace Function
  2. Deleting the right part next to the number with VBScript Replace Function

Another and simpler option is to use the VBScript Split Function, which can do the same in one step. (Thanks to Fabien Graille for the valuable input).

If the target value has a fixed number of characters the VBScript Mid Function could be used to do the same also in just one step.

For web applications there is an easier way to use the default component CBTA_WEB_A_GetMessageParams to extract parts of a message via message patterns.

For further VBSript Functions and Operators please check: VBScript Language Reference

To be able to follow this description I recommend to check the Standard How-To Guide for CBTA as well as the CBTA Default Component Reference in advance.

Reading the text message from screen

When ever you intend to check values or read values from the screen I recommend to use the Test Creation Wizard to capture the String from the screen via ‘Add Checkpoint’ during initial recording.

add checkpoint.jpg

and select the option ‘Get Data’:

get data.jpg

After finishing the recording and saving the script to SAP Solution Manager you need to edit the script in the Test Composition Environment (TCE).

Adjustment of Script after recording

In the TCE select the relevant Default Component that captures the text from the screen e.g. CBTA_GUI_GETPROPERTY. In the Parameters section select ‘Fixed’ in the Usage column and enter a meaningful name in the Value column for the Parameter ‘TARGETFIELD’:

Target field.jpg

With this action you provide the text string to the execution context as a token with name COMPLETE_TEXT.

Now you need to add new default component CBTA_A_SETINEXECUTIONCTXT to perform the string operation.

To do so please set both parameters to ‘Fixed’ and enter a new name of a token e.g. NUMBER_ONLY and the following VBScript command for value of the parameter ‘THEVALUE’:

%=Split($COMPLETE_TEXT$,” “)(2)%


This command splits the text into several parts (sub strings) using space (” “) as delimiter and returns the 3rd sub string. As the first sub string starts at count (0), (2) is required for this example.

As final step you need to add the default component CBTA_A_GETFROMEXECUTIONCTXT to read the number from the token in execution context and write to an output parameter which can be used as import parameter in subsequent scripts.

Set usage of parameter NAME to Fixed and for OUTPUT to Exposed

get context.jpg

For better transparency you should rename the generated parameter ‘OUTPUT’ to a more ‘speaking’ name like ORDER_NUMBER in Parameter tab strip:


If you now execute the script you can see in the log how the initial message text has been changed and the value populated as output parameter:


Now you can use the TCE to create a composite script and map this output parameter to the subsequent script as input parameter.

You must be Logged on to comment or reply to a post.
  • Hello Reiner,

    Your example is very interesting because it highlights the various possibilities that CBTA offers to evaluate VBScript expressions.

    It definitely makes sense for SAP GUI scenarios when a message is displayed in something else than the status bar (i.e.: the GuiStatusbar control).

    For Web applications the component CBTA_WEB_A_GETMESSAGEPARAMS can be used instead. This component has a built-in mechanism allowing the extraction of information from a text using patterns.

    The document providing a concrete example on how to use it can be found on the Test Management Wiki page at:

    SAP Solution Manager WIKI - Test Management - Solution Manager - SCN Wiki

    Direct link to CBTA 3.0 SP02 - Working with MessageParameters

    Best regards,


    • Thanks Claude for your comment. For sure in case of a web application this is much easier use that component. I updated the blog to make this more clear.

      Regards Reiner

      • HI Reiner

        A couple of more questions on CBTA

        How can we test a file upload scenario via CBTA (e.g Bulk Upload requirements for HR/PY scenarios we have for a specific customer)

        How can we find via CBTA script to take into a specific Work Item for the Universal  Work List?

        Really appreciate all your help....where is the location for all the How to Guides etc...



  • Hello Reiner,

    Interesting article, thank you for sharing!

    We had a similar requirement with transaction MIRO (Post Vendor Invoice), which concatenates the invoice type with the invoice number in GETMESSAGEPARAMS.

    I must admit we struggled a bit before we found out how to use SET and GET IN EXECUTION CONTEXT components (in GUI).

    Funny you mention Fabien, he has been a VBscript guru for us as well. 🙂

    Best regards,


  • Hello Reiner,

    Thanks for your post. It's very useful.

    Could you please share some information on how to use the logical operators ( AND, OR etc ) inside the conditional statements ( IF...ELSE ) in CBTA.

    Best regards,


  • Hi Reiner,

    Thanks for this blog.

    I have a question for you or someone knows, I am trying to customize a composite test based on 2 targets component ( ECC / CRM ), how do you customize that to enable the execution on both environment.



  • I have a question with CBTA. I saved multiple values in their own respective variables with the end of the variable incremented by 1. Example: VAR_1, VAR_2, VAR_3, VAR_4...., VAR_13.

    I want to be able to insert these values at a later step. Is there a quick way to do this using a loop? I have my DO LOOP set up using the following CBTA_GUI_SETTEXT where the value to insert into the text box is: %=VAR_$COUNTER$% but it is not working.

    Can this be done without creating a function?

    • Hi Bruce,

      Try using %VAR_$COUNTER$%

      We don't need an equal to (=) sign here since there is no operation involved. Please check and let me know if this works.



      • Hi,

        Avijit is right. The equal (=) is only used when you want to evaluate VBScript expressions.

        Hence, the 3 syntaxes below are equivalent:


        %=InterpretToken( "VAR_" & $COUNTER$ )%

        %=InterpretToken( "VAR" & InterpretToken("COUNTER") )%

        The InterpretToken function is the one used internally by the runtime library to resolve the %token% and $token$ syntaxes.

        Please also keep in mind that we also have a #token# syntax which is helpful to manipulate numbers. This is explained in the documentation:

        "CBTA - Runtime Library and Default Components" chapter "Execution Context".



  • HI Team,


    I am not able to use split function as suggested above, DO anyone tried split function is so can you add a screenshot of the script you recorded.

  • Hello Reiner,

    Thank you for sharing such an interesting article.

    I have done similar settings in my composite script but still output value is not getting exported to next script. Can anyone suggest here?



  • Hello Reiner,

    I was just needing to take a "reservation number"from MF60 result, and complete all the steps as is your example, but, in the field where put the result of split: NUMBER_ONLY, instead of keeping the result of the split, in NUMBER_ONLY I get the text of the instruction (in my case (% = [= Split ($ Msg- Full $, ”“) (3)]).
    Can you Help me  with what may be happening?

    Best regards