cancel
Showing results for 
Search instead for 
Did you mean: 

Is there a way to represent table in Personas?

Former Member
0 Kudos

Hi All,

  I am working on automating Goods Issue (GI) for more than one reservation via SAP Personas and have stumbled on a situation where my result from MB25 transaction is a list of Reservations and this can be 1 or many. I want to know if we can represent the "TextBox:WebGUI" as a table?

Thanks in advance,

Aravindan K

Accepted Solutions (1)

Accepted Solutions (1)

TobiasQueck
Advisor
Advisor
0 Kudos

Hi Aravindan,

You can only add the controls in the image below as custom controls to the screen. So, it is not possible to add a TableView or ALV Grid. However, if you don't really need it as a table but just a big text box that contains multiple lines from a table, then yes this is possible. You need the CopyTable action to copy the content of a table and then you use a Calculate in JavaScript action to concatenate all table cells in a string (use \n for linebreaks) and last but not least you paste the string using the Paste Value action.

Cheers,
Tobias.

Former Member
0 Kudos

HI Tobias,

  Thanks for the idea and help on how to do. I also have another question in relation to "list of entries" or "table", when processing a list from table inside of script is it possible to loop through the values or something similar?

Thanks & regards,

Aravindan K

TobiasQueck
Advisor
Advisor
0 Kudos

Hi Aravindan,

Personas does not have a "loop" function for scripts. So, there is no simple way to loop a sequence of script actions. However, there are two approaches you could go which might have a similar effect.

  1. Have a script (button) that pushes x times the (script) button that contains your sequence of actions that you like to have in a loop. Limitation: you define x when creating the script, it is not dynamic
  2. You create something like an iterator. You extend the sequence of actions with something that pastes the next value in a custom text field. And when executing the script, always the value is taken from this custom field. Limitation: this would require that your user clicks on the button for each iteration.

Hope this helps.

Cheers,

Tobias.

PS: I will try to create a How To showing these two options and then post it on SCN but this will most likely happen after SAPPHIRE.

Former Member
0 Kudos

Hello,

In the scenario above, would there be any issue with creating a set of "looped" script buttons?

1.1) Script copies table to args.table

1.2) Script creates args.row_iterator with value 1

1.3) Script hits button 2

2.1) Button 2 checks if args.row_iterator >= args.table # of rows (javascript)

2.No.1) Write the table line

2.No.2) Push Button 3

2.Yes) No Action

3.1) args.row_iterator = args.row_iterator+1

3.2) Push Button 2

Admittedly, performance might be terrible, but it seems like that would create a looping function; would it not?

Rob

Former Member
0 Kudos

It is my experience that a button script does not stop executing when a secondary button is pushed within the script, even when the push is the last command in the sequence.  Therefore, a sequence like pushing Button1 -> Button2 -> Button3 -> Button 2 would fail because Button 2 is still executing from the first push.

Has anyone else had any luck creating a sort of "button-pushing loop" with scripting?

Former Member
0 Kudos

Good point - I'll test...

If it does, it may be possible by navigating between t-codes and using the "onCreateHandler" to bounce back and forth until all the lines are written.

Former Member
0 Kudos

Confirmed - I get an error when it tries to parse the script for execution if I do it in one transaction.

Part 2 - Also doesn't seem to work across transactions; even though I can pass back and forth, it looks like I can't access the buttons on the other screen to trigger this behaviour.

Former Member
0 Kudos

Hi,

I am trying hard for LOOP, but so far getting errors if I use buttons pushing each other..

Regards

Abhi

0 Kudos

Hi Abhi,

Personas will not allow to form a loop with script buttons.

A->B->C->A

Thats why you will see a error pop up.

BUT, can you let us know some scenarios you are looking for using "loops"?

Regards,

Sushant

Former Member
0 Kudos

Hi Sushant,

Currently I am working on HR module and working on address infotype. We have a scenario where the user can have multiple emergency addresses at a given point of time.If I could copy the table and then process it in a loop,I can save some efforts in displaying the data on screen.

I have yet to start actual work as I have to check whether I can achieve this.

Regards

Abhi

Former Member
0 Kudos

If you copy the table, you can manipulate it in javascript; that would let you display multiple entries, by using the join() function; unfortunately, I've found that I have to either reference the prototype object for the array, or load all the data into a new, declared array:

Something like:

ar ar = new Array();

while (ar.length<args.input_table.length) {

ar.push(args.input_table[parseInt(ar.length)][0].toString());

};

args.output_string = ar.join();

That will work for a one-dimensional string array; usually, I've found I need to use the first array to find the column I want, and a second array for the actual data:

ar ar = new Array();

while (ar.length<args.arg_table.length) {

ar.push(args.arg_table[parseInt(ar.length)][0].toString())

};

var len = ar.indexOf("FIELD_HEADER");

var ar2 = args.arg_table[len];

args.s2 = ar2.join();


Often, I'm trying to find a unique value (or return an error), so I modify slightly:

var ar = new Array();

while (ar.length<args.arg_table.length) {

ar.push(args.arg_table[parseInt(ar.length)][0].toString())

};

var len = ar.indexOf("FIELD_HEADER");

var ar2 = args.arg_table[len];

var out_val = ar2[1];

var i=1;

while( i<ar2.length) {

if (ar2[parseInt(i)].toString() != out_val.toString()) {

out_val = "Error!"};

i=i+1;

};

args.s2 = out_val.toString();

Hopefully that helps.

Former Member
0 Kudos

Hey Rob,

Thanks for the reply and the solution.

I hardly know ant JS....so I think I need to learn that if I have to manage something like that.

Regards

Abhi

Former Member
0 Kudos

Hi Sushant,

I tried using copy table with table control in PA30 (Addresses). The step where I put copy table gave me an error. Does it not work with table controls? If not then any work around?

Regards

Abhi

0 Kudos

Hi Abhit,

make sure you are selecting the correct control.

What is the Control ID you are putting in Copy Table step?

Regards,

Sushant

Former Member
0 Kudos

Hi,

The control id is ses[0]/wnd[0]/usrUSRAREA/tblMP000600TC3000

Regards

Abhi

Former Member
0 Kudos

Hi Sushant,

did you get a chance to have a look at the problem mentioned? Getting error when trying to copy table (Not ALV) ?

One more Q is, I am trying to do date calculations in Personas using JavaScript. However, if I use statement args.new_date = new Date(); new_date variable has a value System.Windows.Browser.ScriptObject naturally further steps fail. Anu suggestions on this?

Regards

Abhi

m4abrams
Participant
0 Kudos

HI Abhijit,

Have you been able to resolve the "System.Windows.Browser.ScriptObject" error you were getting?

After performing a string function in javascript, my variable output has this value "System.Windows.Browser.ScriptObject" instead of the expected equipment_number.

Thanks

Abraham

m4abrams
Participant
0 Kudos

Resolved :

Answers (0)