cancel
Showing results for 
Search instead for 
Did you mean: 

How to get a VBA script to work for variable field?

0 Kudos
238

I have a requirement to change the date on work orders during Technical Completion and have written a script. The issue is with some work orders the field name is RIARCH-ADDAT & some other work orders use RIWO1-BEZDT for the close date.

How do I edit my script to work for either field name?

Session.findById("wnd[1]/usr/ctxtRIARCH-ADDAT").Text = B Session.findById("wnd[1]/usr/ctxtRIWO1-BEZDT").Text = B

Currently I run the script for 1 field, then change it and run it again. I just can't get it to work 😞

Thanks all!

former_member30
Community Manager
Community Manager
0 Kudos

Hi and welcome to the SAP Community!

Thank you for visiting SAP Community to get answers to your questions. Since you're asking a question here for the first time, I recommend that you familiarize yourself with https://community.sap.com/resources/questions-and-answers (if you haven't already), as it provides tips for preparing questions that draw responses from our members. For example, you can outline what steps you took to find answers (and why they weren't helpful) and share screenshots of what you've seen/done. The more details you provide, the more likely it is that members will be able to assist you.

Should you wish, you can revise your question by selecting Actions, then Edit (although once someone answers your question, you'll lose the ability to edit the question -- but if that happens, you can leave more details in a comment).

Finally, if you're hoping to connect with readers, please consider adding a picture to your profile. Here's how you do it: https://www.youtube.com/watch?v=F5JdUbyjfMA&list=PLpQebylHrdh5s3gwy-h6RtymfDpoz3vDS. By personalizing your profile with a photo of you, you encourage readers to respond.

Cheers,

Julia SAP Community Moderator

Accepted Solutions (0)

Answers (1)

Answers (1)

peter_atkin
Active Contributor
0 Kudos

Dan,

For future reference; you will get a better response if you also tag your posts with: PLM Enterprise Asset Management (EAM)/Plant Maintenance (PM).

I think the difference is because of a maintenance plan assignment. So the system uses RIWO1-BEZDT if there is no maintenance plan, and RIARCH-ADDAT/RIARCH-NPLDA if a maintenance plan is assigned. THis difference in dates is triggered via IMG settings in node Set Maintenance Plan Categories - specifically the Completion Data checkbox.

So try adding an "IF" statement checking if the CAUFVD-WARPL field is populated (i.e. a plan is assigned), assuming all of the checkboxes in the above IMG node re active. If they aren't, then you will need to readt table T399W to determine the MPCONFDATE value.

.

PeteA