Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

How to define a public variable in webDynpro ?

Dear All,

I want use a variable between 2 methods.but don't know how to do , There are my part Error code ,

public class TestHtml 
{ 
  public String mystr1 = ""; 

  public void wdDoInit() 
  { 
    mystr1 = "0123"; 
  } 
  public void onActionExportIE(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent ) 
  { 
    String mystr2 = mystr1 + "b"; 
  } 

}

when I click save button ,

"public String mystr1 = ""; disappear .

can you help me ?

thanks!

Former Member
Former Member replied

Hi Doke,

The best way to declare public/private variable is to declare it on global area

Declare it at the end of view where you can see this begin and end part

Inside (As shown below) it will treated as golobal variable, which can reuseable

Anywhere within your iview.

//@@begin others

public String mystr1 = "";

//@@end

It will solve your problem.

Thanks

Anup

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question