cancel
Showing results for 
Search instead for 
Did you mean: 

Sapscript to check if a field contains something.

Former Member
0 Kudos

Hello,

I have a Excel/SAPscript macro that closes WBS elements in CJ20N. This macro will fail upon trying to close a WBS that is already closed, because the close alternative is faded and unavailable in the menus. Therefore I want the macro to check the WBS element system status field if it contains the "CLSD" status before setting the status.

I have tried this which does not work, the .Contains("CLSD")-part, I have also tried .Text.Contains("CLSD"), .Text = "CLSD", and no one of those are working. If it finds CLSD in this field in the code, it should move on to "Redanstangdhoppaover" in my code (this skips the actual setting of the status).

If session.findById("wnd[0]/usr/subDETAIL_AREA:SAPLCNPB_M:1010/subVIEW_AREA:SAPLCJWB:3999/tabsTABCJWB/tabpGRND/ssubSUBSCR1:SAPLCJWB:1210/subSTATUS:SAPLCJWB:0700/txtCNJ_STAT-STTXT_INT").Contains("CLSD") Then GoTo Redanstangdhoppaover

What else is there left to try?

Thanks, Mattias

Accepted Solutions (0)

Answers (1)

Answers (1)

stefan_schnell
Active Contributor
0 Kudos

Hello Mattias,

try this:

Dim oName
Set oName = session.findById("wnd[0]/usr/subDETAIL_AREA:SAPLCNPB_M:1010/subVIEW_AREA:SAPLCJWB:3999/tabsTABCJWB/tabpGRND/ssubSUBSCR1:SAPLCJWB:1210/subSTATUS:SAPLCJWB:0700/txtCNJ_STAT-STTXT_INT")
If InStr(oName.text, "CLSD", 1) > 0 Then
  MsgBox "Found"
Else
  MsgBox "Not found"
End If

Hope it helps.

Cheers

Stefan

Former Member
0 Kudos

Hi and thanks for the answer.

Got it to work with this edit:

Dim oName
Set oName = session.findById("wnd[0]/usr/subDETAIL_AREA:SAPLCNPB_M:1010/subVIEW_AREA:SAPLCJWB:3999/tabsTABCJWB/tabpGRND/ssubSUBSCR1:SAPLCJWB:1210/subSTATUS:SAPLCJWB:0700/txtCNJ_STAT-STTXT_INT")
If InStr(oName.Text, "CLSD") > 0 Then session.findById("wnd[0]/tbar[0]/btn[3]").press
GoTo Redanstangdhoppaover

Thanks again :]

Mattias