cancel
Showing results for 
Search instead for 
Did you mean: 

Personas Status Bar error

babowden
Explorer
0 Kudos
592

Hello,

I am writing a script that enters a transaction and occasionally receives a `Status Bar` message. As there are two (or multiple) status bar messages, i would like particular messages to return an Error message on my original SMEN screen. For example i have the following part of my script that picks up the status bar message and then returns to SMEN screen and applies some text. How can i make sure only certain text is picked up on the status bar and then error returned? I.e. "2 usage period(s) exist for today's date"

if (session.findById("wnd[0]/sbar").text) {

session.findById("wnd[0]/tbar[0]/okcd").text = "/n";

session.findById("wnd[0]").sendVKey(0);

// An OnLoad or OnAfterRefresh script was executed.

session.findById("wnd[0]/usr/txtPersonas_164742379645856").text = "";

session.findById("wnd[0]/usr/lblPersonas_16474239778582").text = "Check Period Date";

return;

}

babowden
Explorer
0 Kudos

Hi,

Just to add to this, I am also having an issue with identifying a 'Display Log' box that can occasionally open in this particular transaction, and I would like to capture this on an 'if' basis and return it to my SMEN screen with a message saying "Material needs to be extended to this plant.". Can Display log box's be captured as an error?

I appreciate your help in this matter.

Many thanks,

Ben

View Entire Topic
kmagons
Advisor
Advisor

Hi Ben,

Here are the options that I see potentially feasible:

1) Determine the status message type rather than the text content.

This approach works when you are only interested in errors and want to ignore other status message types such as warnings:

if (session.findById("wnd[0]/sbar").text & session.findById("wnd[0]/sbar").messageType === "E" ) {...}

2) Determine the status message type and additional property from the screen state

Use this approach when you need to differentiate between multiple messages of the same type and your business logic gives you programmatically readable additional information on the cause of the error.

For example, you may use the currently focused control to make assumptions on the cause of the message

if (session.findById("wnd[0]/sbar").messageType === "E" && session.findById("wnd[0]").systemFocus.id === <SPECIFIC CONTROL ID> ) {...}

3) Match the status message text against specific pattern

Use this approach when you need to differentiate between multiple messages of the same type and there is no way of programmatically reading additional screen state properties that could reveal more information on the source of the message. However, mind the translations.

if (session.findById("wnd[0]/sbar").text & !!session.findById("wnd[0]/sbar").text.match(/\d usage period/g) {...}

I am not fully sure what do you mean by the "Log Box", therefore, I cannot comment on that. A screenshot may be helpful.

Hope, this clarifies your question!

Best regards,

Krists Magons

SAP Screen Personas Dev Team

babowden
Explorer
0 Kudos

Hi Krists,

Thank you very much for taking the time to reply and provide this resolution, it is really helpfull.

As for the `Display Log` box, please see attached image, this opens in transaction code MIGO when trying to perform a 303 movement, when the material master is not available at the receiving site. This is a `session.findById("wnd[1]").title` and does not have a `text` element.

It would be great (like above) to capture this message on a `IF` basis, and then return to my SMEN screen with whatever message i like.

Once again i appreciate your time on this 🙂

Many Thanks,

Ben

babowden
Explorer
0 Kudos

Hi Krists,

Just to add, i have tried option 1 above "Determine the status message type rather than the text content", and i keep receiving

the attached image error. Can you please advise?

Many Thanks,

Ben

kmagons
Advisor
Advisor
0 Kudos

The error message does not appear to be related to the status bar control which has the control ID of "wnd[0]/sbar" and therefore the problem most likely is caused by some other logic in your script.

Unfortunately, without seeing your script source and knowing the intended logic is really difficult to troubleshoot the problem. I suggest to start by looking in your code where do you set the focus for the control ID referenced in the error message. Apparently, the script tries to access control which is not present in the control tree while the script is being executed.

tamas_hoznek
Product and Topic Expert
Product and Topic Expert

The message in that 'Display logs' popup window is an ABAPlist. As such, you cannot capture its content with a script since it's not selectable.

However, you could convert this ABAPlist to an ALV (the option is in the 'Tables' tab of the flavor editor), and then read the content of the grid, parse it and grab the message text you are interested in. Of course if you have more than one log entry (which is possible), then you need to deal with this too.