Skip to Content

Desktop Studio Context fetch resulting in UNDEFINED value

Dear Community,

I am trying to fetch a context data collected from a gridview earlier in SAP and input them in a standard Multiple Selection SAP box. Unfortunately, instead of a list of values, I get UNDEFINED value inserted in the field.

What am I doing wrong?

Breakdown of the steps:

1. I collect the values from SE16N gridview table using below given code (inserted in a Custom block) and simultaneously I make it a context item called "Customers". As I can see in the Debugger's Tester, the numbers are collected correctly.

// Collect all customer numbers
rootData.Temp.Customers=SAPLogon750.pKNKKResults.oKNKKResults.getRowsByColumn('KUNNR');

SE16N gridview:

2. I create a context "Temp" folder with "Customers" item in it and make it an array. Is this step required at all?

3. I try to fetch the context data and set it in Multiple Selection box in Select Single Values tab in another tcode. I tried capturing the visible table field both as a single field and using Occurs method - below visible is the latter:

To fetch and set the context data I use the standard Set activity and try to link it with the aforementioned context item:

The generated code for this is visible below:

SAPLogon750.pMultipleCustomer.edValues.i(0).set(rootData.Temp.Customers[0], true);

4. If I run it, I end up with getting an UNDEFINED value instead of the customer numbers that were stored in the context:

I would really appreciate your advice!

Best regards,

Filip

se16n-gridview.jpg (51.8 kB)
context.jpg (18.2 kB)
set-context.jpg (34.8 kB)
undefined.jpg (35.6 kB)
Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • Best Answer
    Posted on Jun 20, 2020 at 06:25 PM

    Hi - Please output the customers context data using CTX.LOG and see what gets printed in the debugger mode. This will help you to understand if the value is really filled up in the context or not.

    Another observation is : you are trying to put the data of first row(customers[0]) in the popup and if you are expecting that all the records of the customers context will be populated in the popup since you made the target, then I am really not sure if that would work. I had tried doing something similar, but had to later adopt LOOP -- put the value --> click on insert --> ENDLOOP.

    I would be really interested to know if your approach worked as that will simplify the bot execution as well.

    Add a comment
    10|10000 characters needed characters exceeded

    • Hi Srinivas,

      I had a break from continuing with my project but I am back and here are my newest observations.

      I did add a log to check, what was in the context and it turned out that it was fine but the rootcause of my problem was that I forgot to set the used context data in different scenarios (I have a couple of them). When I have finally set it as visible below, it started to fetch correct data:

      When it comes to adding the values to the Multiple Selection screen, you are right, it didn't work using previously shared code. I had to create a loop that incorporated inserting a new line (code given below). It works like a charm now!

      for(var j=0;j<(rootData.Temp.Customers).length;j++){
          SAPLogon750.pMultipleCustomer.edValues.setFocus();
          SAPLogon750.pMultipleCustomer.edValues.set(rootData.Temp.Customers[j], true); 
          SAPLogon750.pMultipleCustomer.btInsertRows.click();
              }
      scenario-data.png (13.2 kB)

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.