cancel
Showing results for 
Search instead for 
Did you mean: 

How to build looping constructs in Personas 2.0?

Former Member
0 Kudos

Hi,

Understood from blogs that, Personas 2.0 doesn’t support Looping constructs and Screen objects cannot be referred in Javascripts.

I have a requirement to execute the highlighted scripts in Tcode LT04, for which Loop construct is required.


1. When Overview of Transfer Requirement screen is displayed, the user has to click on Save button

2. Upon click on Save, the control goes to Generate Transfer Order Item screen, wherein the user has to click on Cancel button

    ses[0]/wnd[0]/tbar[0]/btn[12]

    Push

3. Responding to Cancel button, it displays a prompt wherein the user has to click on Yes button

    ses[0]/wnd[1]/usrUSRAREA/btnSPOPOPTION1

    Push

SAP repeats the Steps 2 & 3 depending upon the number of items displayed in Step 1.

I want to execute the scripts of Steps 2 & 3 depending upon the number of items displayed in Step1.

Could you please provide your best suggestions?


Thanks.

Panchpeer.

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

As you say, Personas 2 does not support looping, so there's no way to do this in general. Upgrading to Personas 3 is the only real solution.

However, if you are prepared to live with a solution that doesn't always work, you can try unrolling the loop. That is, have steps 2 and 3 occur in the script multiple times, each time protected by an IF that checks for the existence of line 1, line 2, line 3, etc. So, something like this:


if there is a line 1

     step 2

     step 3

if there is a line 2

     step 2

     step 3

etc.

If you can repeat this often enough to accommodate as many lines as you are likely to get on a transfer order, this will work fine. You need to protect against the possibility of somebody creating a transfer order with more lines that you can cope with, of course. If the maximum number of lines on a transfer order is too big, this isn't practical obviously.

This isn't pretty, but I don't know of a better way to achieve it in Personas 2. As I said, the only proper solution is to upgrade to Personas 3.

Steve.

Former Member
0 Kudos

Hi Steve,

Presently I have done as below. It works fine and should be ok Only if the iteration is for very small number of times.

If .....<screen object>

control exists

    ses[0]/wnd[0]/tbar[0]/btn[12]

    Push

    ses[0]/wnd[1]/usrUSRAREA/btnSPOPOPTION1

    Push

If .....<screen object>

control exists

    ses[0]/wnd[0]/tbar[0]/btn[12]

    Push

    ses[0]/wnd[1]/usrUSRAREA/btnSPOPOPTION1

    Push


Alternatively, I tried iteration by having 2 script buttons. First button will check the existence of a control and clicks the second button. The second button contains the scripts of step 2 and step 3. Upon execution, it clicks the First button. But this results with error.

Thanks.