Skip to Content

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)%

/wp-content/uploads/2014/10/split_577511.jpg

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:

OUTPUT.jpg

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:

/wp-content/uploads/2014/10/log_577513.jpg

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

To report this post you need to login first.

17 Comments

You must be Logged on to comment or reply to a post.

  1. Claude ROSSI

    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

    https://websmp107.sap-ag.de/~sapidb/011000358700000194852014E.PDF

    Best regards,

    Claude

    (0) 
    1. Reiner Markheiser Post author

      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

      (0) 
      1. Peter O'Leary

        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…

        Cheers

        Peter

        (0) 
  2. Rémi GODARD

    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,

    Rémi.

    (0) 
  3. Siva Kumar

    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,

    Siva

    (0) 
    1. Reiner Markheiser Post author

      Hi Siva,

      the only operators that are supported here are:

       = for “Equal to”

       < for “Less than”

       > for “Greater than”

       <= for “Less than or equal to”

       >= for “Greater than or equal to”

       <> for “Not equal to”

       {contains} for “Contains”

       {startsWith} for “Starts with”

       {endsWith} for “Ends with”

       {matches} for checking whether the value matches a regular expression. The regular expressions are expressed using the .NET syntax.

      Further information can be found via this link:

      https://support.sap.com/content/dam/library/SAP%20Support%20Portal/support-programs-services/solution-manager/processes/Media%20Library/Test%20Management/CBTA%203.0%20SP05%20-%20Runtime%20Library%20and%20Default%20Components.pdf

      Regards Reiner

      (0) 
  4. Aminata Diallo

    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.

    Thanks.

    Aminata.

    (0) 
    1. Reiner Markheiser Post author

      Hello Aminata,

      the answer from Siva is fully right and still works. The guide is based on an older Solution Manager Release. I just want to add a comment that in the current release you can also use the so called composite scripts as “master script” while the approach is exactly the same.

      @Siva: Thanks for your response.

      Regards Reiner

      (0) 
      1. Aminata Diallo

        Hi Reiner,

        Actually, we create that “Master script” and we put on it some single ECC script  and a CRM composite script. It was easy to manage the parameters between the ECC and the CRM script.


        Thank you.


        Regards,

        Aminata

        (0) 
  5. Bruce Torres

    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?

    (0) 
    1. Avijit Amitabh

      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.

      Thanks,

      Avijit.

      (0) 
      1. Claude ROSSI

        Hi,

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

        Hence, the 3 syntaxes below are equivalent:

        %VAR_$COUNTER$%

        %=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”.

        Regards,

        Claude

        (0) 
        1. Bruce Torres

          This worked for me: %=InterpretToken( “VAR_” & $COUNTER$ )%

          Thank you very much as I was dealing with this for almost the whole day trying to figure it out. Much appreciated!

          (0) 

Leave a Reply