We all have encountered issues with Expand and collapse for standard t-codes ME51N,ME21N when automating SAPGUI scripts using Loadrunner
I always recommend and use conditional statements , it would also be useful to fix the layout for these screens prior to automation and use shortcuts as much possible with "Expand and collapse" , testing with more than one unique user to enable to develop a robust script and will work as long as there are no to minimal changes in the screens
if(!sapgui_is_object_available("") is quite handy
example is shown below
if(!sapgui_is_object_available"usr/subSUB0:SAPLMEGUI:0013/subSUB2:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1211/tblSAPLMEGUITC_1211")) { sapgui_press_button("Expand Items Ctrl+F3","usr/subSUB0:SAPLMEGUI:0013/subSUB2:SAPLMEVIEWS:1100/subSUB1:SAPLMEVIEWS:4001/btnDYN_4000- BUTTON", BEGIN_OPTIONAL, "AdditionalInfo=sapgui1098", END_OPTIONAL); }
Thanks Dilip