Declare a variable in an Interface
hi all
can i declare a variable in a interface , something like
public static final String dsn=" // something";
so that i dont have to declare the same thing in all the classes that implement this interface
regards
You don't need the public, static, or final. All fields in interfaces are implictly public static final fields.
Similar Messages
-
Would like to declare a variable Public/Global in an IF statement
Is there way to declare a variable as Public in an IF statement. My goal is to declare the variable as global (since this variable is used somewhere in the code and should not get initialized when there is loop back to the top of the code, hence using IF statement to control the initialization) based on the IF condition and then use it elsewhere in the code.
I have it like this
if (!sei_second_jsp.equals("1"))
public int[] mecitem;
public String[] sei_mfg_prod_cat;
public String[] sei_part_number;
public String[] sei_descrip;
public String[] sei_price;
public int[] sei_onhand;
public int[] sei_demand;
mecitem = new int[20000];
sei_mfg_prod_cat = new String[20000];
sei_part_number = new String[20000];
sei_descrip = new String[20000];
sei_price = new String[20000];
sei_onhand = new int[20000];
sei_demand = new int[20000];
for (int i=0; i<=19999; i++)
mecitem[i] = 0;
sei_mfg_prod_cat[i] = " ";
sei_part_number[i] = " ";
sei_descrip[i] = " ";
sei_price[i] = " ";
sei_onhand[i] = 0;
sei_demand[i] = 0;
Your guess is right, I am using this code in JSP - since this is a Java related question, thought of posting it in JAVA forum.
When I use the above code, I get the following error
1809 }' expected. {
1811 Statement expected. public int[] mecitem;
1827 Identifier expected. mecitem = new int[20000];
1827 Can't specify array dimension in a declaration. mecitem = new int[20000];
1827 Identifier expected. mecitem = new int[20000];
1837 Can't specify array dimension in a declaration. sei_onhand = new int[20000];
1837 Identifier expected. sei_onhand = new int[20000];
1839 Can't specify array dimension in a declaration. sei_demand = new int[20000];
1839 Identifier expected. sei_demand = new int[20000];
3117 Class or interface declaration expected. }Please note the above code in the JSP is submitting to itself and I donot want it to get initialized if the IF statement is not successful..
thnks a lot for your time.. !!! -
How do I use a variable from an Interface class?
Right now I have three classes. First class is called Game and it extends my second class call Parent and also implements my third class call Source. Source is an interface class. I have a variable that I want to use in my Source class named Checker. Now, How do I go among using that variable from my Game class? What should the code look like?
ex.
public class Game extends Parent implements Source
need help badly....ok, what I forgot to tell you guys is that my variable
in my interface class is a boolean type(true or
false). It is set to true now. But I want it to change
to false when a user triggers a button in the Game
class. How do I do this? You don't because you can't. If you have a varaible declared in an interface it must be static and final. It cannot, therefore, be changed. Better head back to the drawing board. -
Why do we declare the variables private in a bean
Hi,
when we create a bean in the MVC architecture why do we declare the variables private. Also when do we use the access specifier private.
Regards,
Prashantpksingh79 wrote:
Hi ^^,
thanks for replying.I had a discussion with one of my trainers and he was of the opinion that the variables should generally be declared private. In this way we prevent classes from accessing and setting illegal values to those variables.
Say for instance we have the class person as follows:
public class Person
int age;
setAge(int age)
if (age < 0)
return null
Person p = new Person() ;
p.age = -2;
//this would be perfectly legal
//where as if we declare the variable as private as follows:
public class Person
private int age;
setAge(int age)
if (age < 0)
return null
Person p = new Person() ;
// P.age = -2; this would be illegal as age is private and would have to be accessed by the method defined above.
p.setAge(-2);
//the cbove line would retun null values.
public class Person {
private int age;
public void setAge(int age) {
if (age < 0) {
throw new IllegalArgumentException("...");
this.age = age;
} -
How to declare local variables in PL/SQL stored programs
Where do I declare local variables in a PL/SQL stored program?
I get compiler errors with either of the options below:
FUNCTION GET_PRINCIPAL_BALANCE (CUT_OFF_DATE IN DATE, TITLE_SN IN DATE, TOTAL_BALANCE OUT NUMBER) RETURN NUMBER IS
TOTAL_BALANCE NUMBER;
BEGIN
RETURN TOTAL_BALANCE;
END;
FUNCTION GET_PRINCIPAL_BALANCE (CUT_OFF_DATE IN DATE, TITLE_SN IN DATE, TOTAL_BALANCE OUT NUMBER) RETURN NUMBER IS
BEGIN
TOTAL_BALANCE NUMBER;
RETURN TOTAL_BALANCE;
END;Your local variable cannot have the same name as the formal out parameter. This is a procedure example, but since functions should not have out parameters anyway ...
session2> CREATE PROCEDURE p (p_id IN NUMBER, p_did OUT NUMBER) AS
2 p_did NUMBER;
3 BEGIN
4 p_did := p_id * 2;
5 END;
6 /
Warning: Procedure created with compilation errors.
session2> show error
Errors for PROCEDURE P:
LINE/COL ERROR
0/0 PL/SQL: Compilation unit analysis terminated
1/1 PLS-00410: duplicate fields in RECORD,TABLE or argument list are
not permittedThe proper way to create a function would be something like:
CREATE FUNCTION f (p_id IN NUMBER) RETURN NUMBER AS
l_did NUMBER;
BEGIN
l_did := p_id * 2;
RETURN l_did;
END;You should really assign a value to the variable before you return it.
John -
How to declare a variable in form
how to declare a variable in form?
Hi,
do you want to create variable in script or smartform?
In scripts to define a variable use the following declaration statement.
DEFINE &<VARIABLE_NAME>&
place this statement as command. we can assign initial value for this by adding VALUE ' ' to above statement.
If your requirement is for smartforms go to global declaration, create a variable there that will be applicable only for smartform.
Hope this will help you,
Regards,
Aswini. -
How can I use a variable for an interface log and error fle
I want to use a variable for the interface's log and error file so that when I migrate from Dev to QA to Prod I don't have to do a lot of editing.
Specifically on the "flow" tab for the "target", I want a variable to be the first part of the path for the log (\\sundev1\fnd1-hypd1) and join this with the rest (\update\log\logfile.log) within the LOG_FILE_NAME field.
Thank you!Hi,
It is quite simple....
just use the <%=odiRef.getSchemaName("D")%> before the file name and configure both path in the topology linked to each context. -
Can anyone help me with this?
I have a set of Cue Points in an FLV I'm playing. It's an interactive quiz, so the idea is that flash will change a variable, theAnswer, to a different letter depending on which question it is. The answer to question 1 is B, question 2 is D, etc.
Either the cue point event listener isn't working, or else it is working and Flash isn't declaring the variables. Can someone help?
The error message I get is:
1120: Access of undefined property theAnswer.
I literally can't find a single problem with my code. I have an almost identical Event Listener further down which works.
var theAnswer;
vid.addEventListener(MetadataEvent.CUE_POINT, cueAnswers);
function cueAnswers(e:MetadataEvent):void{
var cuePointNames = e.info.name;
if (cuePointNames =="start")
theAnswer = "C";
else if (cuePointNames =="q2")
theAnswer = "A";
else if (cuePointNames =="q3")
theAnswer = "C";
else if (cuePointNames =="q4")
theAnswer = "A";
else if (cuePointNames =="q5")
theAnswer = "D";
else if (cuePointNames =="q6")
theAnswer = "C";
else if (cuePointNames =="q7")
theAnswer = "A";
else if (cuePointNames =="q8")
theAnswer = "D";
else if (cuePointNames =="q9")
theAnswer ="B"
else if (cuePointNames =="q10")
theAnswer ="B";
The function is called by this later:
function nkAinfo(e:MouseEvent):void {
if (theAnswer=="C")
trace("You clicked right");
else
trace("You clicked wrong");
What's going on? Is the function not being called or are my variable declarations wrong?Probably not the answer to your question, but it could help anyways....
First there is another command that, to me at least, is much easier to read that a bunch of nested if/if elses. And that is the switch.
switch (e.info.name){
case "start":
theAnswer="C";
break;
case "q2":
theAnswer="A"
break;
//and so on
To me that is easier to maintain and read. But I don't think that is really what you need here. So just file that one away for the future.
In this case, what I think you need is an array.
var currentAnswer:String;
var correctAnswers:Array=new Array();
correctAnswers["start"]="C"
correctAnswers["q2"]="A"
// and so on.
Then your cuepoint handler function becomes something like this:
function cueAnswers(e:MetadataEvent):void{
currentAnswer=correctAnswers[e.info.name];
And I'm a little confused by your mouse click handler. It would seem to suggest that the answer is always "C"? But I"m guessing that it is supposed to compare what the user clicked on to what the cuePoint has told it is the correct answer? Well if that is the case then it would probably look something like:
function nkAinfo(e:MouseEvent):void {
if(e.currentTarget.clickedProperty==currentAnswer){
trace("Correct");
} else {
trace("Incorrect");
With the way you are currently doing this I'm guessing that you have a bunch of repeated functions for each time there is a mouse click and that your code is a lot more complicated that it needs to be. And that somewhere hiding in all those lines there is an error that would be simple to fix if you could see it.
What the error is telling you is that somewhere your are trying to assign or retrieve theAnswer and it hasn't been defined yet. -
Syntax for declaring global variable in report
Hello all,
Kindly let me know syntax for declaring global variable in report?
Thnks,
SUnnyHi Sunny,
All data declaration in the main program is global.
Only if you do some data declaration withtin the subroutines then the scope of the variable is limited to that FORM ....ENDFORM.
As you read in the above reply for a global variable in FM you need to declare in the top include.
This means that you want this variable to be made available to all the Function Modules in that Function Group.
If you want to make the variabe be available only within that FM then do the declaration in the source code itself.
hope this explaination helps,
Taher. -
Declare global variable and retrive?
Hi,
we are working in live project in webtool, we wants to create global variable,
calling that variable in a required pages, our questions is that where to declare global variable and how to declare in which page we have to declare? pls guide us its very urgent and send the code.
Regards
Kannan.D
Edited by: kannan desikan on Jan 14, 2008 8:07 AMHi Kannan,
I would suggest using a comma delimied list or putting it in the database.
ArrayList myList = new ArrayList();
myList.Add("one");
myList.Add("two");
myList.Add("three");
string comma = "";
// store the array in the session state
foreach (string s in myList){
Session["persistedArray"] += comma + s;
comma = ",";
To get the array back
if (Session["persistedArray"] != null){
ArrayList myList = Session["persistedArray"].ToString().Split(new char[1] {','});
If your array is storing objects, you should use the database. -
Declare @p1 variable error when creating multiple search form to show database info
Hi, all help is incredibly appreciated,
i have been trying to make a multiple filtered search form for a database in asp / vbscript. I want to be able to select from THIS database table, all info on the rows which id is BETWEEN x and x AND date is BETWEEN x and x AND securitynumber is BETWEEN x and x
what would be the best way to do this?
this is what ive got so far, which gives me the error:
Microsoft OLE DB Provider for ODBC Drivers error '80040e14'
[Microsoft][ODBC SQL Server Driver][SQL Server]Must declare the variable '@P1'.
<%
Dim rsBundleR__p_selectedDB
rsBundleR__p_selectedDB = request.form("selectedDataBase")
If (request.form("selectedDataBase") <> "") Then
rsBundleR__p_selectedDB = request.form("selectedDataBase")
End If
%>
<%
Dim rsBundleR__p_idFrom
rsBundleR__p_idFrom = request.form("bundleIdFrom")
If (request.form("bundleIdFrom") <> "") Then
rsBundleR__p_idFrom = request.form("bundleIdFrom")
End If
%>
<%
Dim rsBundleR__p_idTo
rsBundleR__p_idTo = request.form("bundleIdTo")
If (request.form("bundleIdTo") <> "") Then
rsBundleR__p_idTo = request.form("bundleIdTo")
End If
%>
<%
Dim rsBundleR__p_dateFrom
rsBundleR__p_dateFrom = request.form("fromDate")
If (request.form("fromDate") <> "") Then
rsBundleR__p_dateFrom = request.form("fromDate")
End If
%>
<%
Dim rsBundleR__p_dateTo
rsBundleR__p_dateTo = request.form("toDate")
If (request.form("toDate") <> "") Then
rsBundleR__p_dateTo = request.form("toDate")
End If
%>
<%
Dim rsBundleR__p_ssFrom
rsBundleR__p_ssFrom = request.form("fromSS")
If (request.form("fromSS") <> "") Then
rsBundleR__p_ssFrom = request.form("fromSS")
End If
%>
<%
Dim rsBundleR__p_ssTo
rsBundleR__p_ssTo = request.form("toSS")
If (request.form("toSS") <> "") Then
rsBundleR__p_ssTo = request.form("toSS")
End If
%>
<%
Dim rsBundleR
Dim rsBundleR_cmd
Dim rsBundleR_numRows
Set rsBundleR_cmd = Server.CreateObject ("ADODB.Command")
rsBundleR_cmd.ActiveConnection = MM_PHPSQL_STRING
rsBundleR_cmd.CommandText = "SELECT * FROM ? WHERE id BETWEEN ? AND ? AND fecha_solicitado BETWEEN ? AND ? AND seguro_social BETWEEN ? AND ? ORDER BY id ASC"
rsBundleR_cmd.Prepared = true
rsBundleR_cmd.Parameters.Append rsBundleR_cmd.CreateParameter("param1", 200, 1, 255, rsBundleR__p_selectedDB) ' adVarChar
rsBundleR_cmd.Parameters.Append rsBundleR_cmd.CreateParameter("param2", 5, 1, -1, rsBundleR__p_idFrom) ' adDouble
rsBundleR_cmd.Parameters.Append rsBundleR_cmd.CreateParameter("param3", 5, 1, -1, rsBundleR__p_idTo) ' adDouble
rsBundleR_cmd.Parameters.Append rsBundleR_cmd.CreateParameter("param4", 135, 1, -1, rsBundleR__p_dateFrom) ' adDBTimeStamp
rsBundleR_cmd.Parameters.Append rsBundleR_cmd.CreateParameter("param5", 135, 1, -1, rsBundleR__p_dateTo) ' adDBTimeStamp
rsBundleR_cmd.Parameters.Append rsBundleR_cmd.CreateParameter("param6", 200, 1, 255, rsBundleR__p_ssFrom) ' adVarChar
rsBundleR_cmd.Parameters.Append rsBundleR_cmd.CreateParameter("param7", 200, 1, 255, rsBundleR__p_ssTo) ' adVarChar
Set rsBundleR = rsBundleR_cmd.Execute
rsBundleR_numRows = 0
%>
someone, please help, this is very important!allright i think thats what i did here:
<% While ((Repeat1__numRows <> 0) AND (NOT rsBundleR.EOF)) %>
<table align="center" border="1">
<tr>
<td align="left" width="50%">id</td>
<td align="left" width="50%"><%=(rsBundleR.Fields.Item("id").Value)%></td>
</tr>
<tr>
<td align="left" width="50%">seguro_social</td>
<td align="left" width="50%"><%=(rsBundleR.Fields.Item("seguro_social").Value)%></td>
</tr>
<tr>
<td align="left" width="50%">numero_estudiante</td>
<td align="left" width="50%"><%=(rsBundleR.Fields.Item("numero_estudiante").Value)%></td>
</tr>
<tr>
<td align="left" width="50%">nombre</td>
<td align="left" width="50%"><%=(rsBundleR.Fields.Item("nombre").Value)%></td>
</tr>
<tr>
<td align="left" width="50%">apellido</td>
<td align="left" width="50%"><%=(rsBundleR.Fields.Item("apellido").Value)%></td>
</tr>
<tr>
<td align="left" width="50%">telefono</td>
<td align="left" width="50%"><%=(rsBundleR.Fields.Item("telefono").Value)%></td>
</tr>
<tr>
<td align="left" width="50%">celular</td>
<td align="left" width="50%"><%=(rsBundleR.Fields.Item("celular").Value)%></td>
</tr>
<tr>
<td align="left" width="50%">direccion_postal</td>
<td align="left" width="50%"><%=(rsBundleR.Fields.Item("direccion_postal").Value)%></td>
</tr>
<tr>
<td align="left" width="50%">direccion_postal_2</td>
<td align="left" width="50%"><%=(rsBundleR.Fields.Item("direccion_postal_2").Value)%></td>
</tr>
<tr>
<td align="left" width="50%">email_pupr</td>
<td align="left" width="50%"><%=(rsBundleR.Fields.Item("email_pupr").Value)%></td>
</tr>
<tr>
<td align="left" width="50%">ciudad</td>
<td align="left" width="50%"><%=(rsBundleR.Fields.Item("ciudad").Value)%></td>
</tr>
<tr>
<td align="left" width="50%">estado</td>
<td align="left" width="50%"><%=(rsBundleR.Fields.Item("estado").Value)%></td>
</tr>
<tr>
<td align="left" width="50%">zona_postal</td>
<td align="left" width="50%"><%=(rsBundleR.Fields.Item("zona_postal").Value)%></td>
</tr>
<tr>
<td align="left" width="50%">direccion_fisica</td>
<td align="left" width="50%"><%=(rsBundleR.Fields.Item("direccion_fisica").Value)%></td>
</tr>
<tr>
<td align="left" width="50%">direccion_fisica_2</td>
<td align="left" width="50%"><%=(rsBundleR.Fields.Item("direccion_fisica_2").Value)%></td>
</tr>
<tr>
<td align="left" width="50%">email_personal</td>
<td align="left" width="50%"><%=(rsBundleR.Fields.Item("email_personal").Value)%></td>
</tr>
<tr>
<td align="left" width="50%">ciudad_fisica</td>
<td align="left" width="50%"><%=(rsBundleR.Fields.Item("ciudad_fisica").Value)%></td>
</tr>
<tr>
<td align="left" width="50%">estado_fisica</td>
<td align="left" width="50%"><%=(rsBundleR.Fields.Item("estado_fisica").Value)%></td>
</tr>
<tr>
<td align="left" width="50%">zona_postal_fisica</td>
<td align="left" width="50%"><%=(rsBundleR.Fields.Item("zona_postal_fisica").Value)%></td>
</tr>
<tr>
<td align="left" width="50%">tipo_estudiante</td>
<td align="left" width="50%"><%=(rsBundleR.Fields.Item("tipo_estudiante").Value)%></td>
</tr>
<tr>
<td align="left" width="50%">termino_prestamo</td>
<td align="left" width="50%"><%=(rsBundleR.Fields.Item("termino_prestamo").Value)%></td>
</tr>
<tr>
<td align="left" width="50%">nombre_referencia_1</td>
<td align="left" width="50%"><%=(rsBundleR.Fields.Item("nombre_referencia_1").Value)%></td>
</tr>
<tr>
<td align="left" width="50%">apellido_referencia_1</td>
<td align="left" width="50%"><%=(rsBundleR.Fields.Item("apellido_referencia_1").Value)%></td>
</tr>
<tr>
<td align="left" width="50%">telefono_referencia_1</td>
<td align="left" width="50%"><%=(rsBundleR.Fields.Item("telefono_referencia_1").Value)%></td>
</tr>
<tr>
<td align="left" width="50%">direccion_postal_1_referencia_1</td>
<td align="left" width="50%"><%=(rsBundleR.Fields.Item("direccion_postal_1_referencia_1").Value)%></td>
</tr>
<tr>
<td align="left" width="50%">direccion_postal_2_referencia_1</td>
<td align="left" width="50%"><%=(rsBundleR.Fields.Item("direccion_postal_2_referencia_1").Value)%></td>
</tr>
<tr>
<td align="left" width="50%">ciudad_referencia_1</td>
<td align="left" width="50%"><%=(rsBundleR.Fields.Item("ciudad_referencia_1").Value)%></td>
</tr>
<tr>
<td align="left" width="50%">estado_referencia_1</td>
<td align="left" width="50%"><%=(rsBundleR.Fields.Item("estado_referencia_1").Value)%></td>
</tr>
<tr>
<td align="left" width="50%">zona_postal_referencia_1</td>
<td align="left" width="50%"><%=(rsBundleR.Fields.Item("zona_postal_referencia_1").Value)%></td>
</tr>
<tr>
<td align="left" width="50%">nombre_referencia_2</td>
<td align="left" width="50%"><%=(rsBundleR.Fields.Item("nombre_referencia_2").Value)%></td>
</tr>
<tr>
<td align="left" width="50%">apllido_refencia_2</td>
<td align="left" width="50%"><%=(rsBundleR.Fields.Item("apllido_refencia_2").Value)%></td>
</tr>
<tr>
<td align="left" width="50%">telefono_referencia_2</td>
<td align="left" width="50%"><%=(rsBundleR.Fields.Item("telefono_referencia_2").Value)%></td>
</tr>
<tr>
<td align="left" width="50%">direccion_postal_1_referencia_2</td>
<td align="left" width="50%"><%=(rsBundleR.Fields.Item("direccion_postal_1_referencia_2").Value)%></td>
</tr>
<tr>
<td align="left" width="50%">direccion_postal_2_referencia_2</td>
<td align="left" width="50%"><%=(rsBundleR.Fields.Item("direccion_postal_2_referencia_2").Value)%></td>
</tr>
<tr>
<td align="left" width="50%">ciudad_referencia_2</td>
<td align="left" width="50%"><%=(rsBundleR.Fields.Item("ciudad_referencia_2").Value)%></td>
</tr>
<tr>
<td align="left" width="50%">estado_referencia_2</td>
<td align="left" width="50%"><%=(rsBundleR.Fields.Item("estado_referencia_2").Value)%></td>
</tr>
<tr>
<td align="left" width="50%">zona_postal_referencia_2</td>
<td align="left" width="50%"><%=(rsBundleR.Fields.Item("zona_postal_referencia_2").Value)%></td>
</tr>
<tr>
<td align="left" width="50%">tipo_de_prestamo</td>
<td align="left" width="50%"><%=(rsBundleR.Fields.Item("tipo_de_prestamo").Value)%></td>
</tr>
<tr>
<td align="left" width="50%">cantidad_prestamo</td>
<td align="left" width="50%"><%=(rsBundleR.Fields.Item("cantidad_prestamo").Value)%></td>
</tr>
<tr>
<td align="left" width="50%">subsidiado</td>
<td align="left" width="50%"><%=(rsBundleR.Fields.Item("subsidiado").Value)%></td>
</tr>
<tr>
<td align="left" width="50%">no_subsidiado</td>
<td align="left" width="50%"><%=(rsBundleR.Fields.Item("no_subsidiado").Value)%></td>
</tr>
<tr>
<td align="left" width="50%">autorizo_pupr</td>
<td align="left" width="50%"><%=(rsBundleR.Fields.Item("autorizo_pupr").Value)%></td>
</tr>
<tr>
<td align="left" width="50%">fecha_solicitado</td>
<td align="left" width="50%"><%=(rsBundleR.Fields.Item("fecha_solicitado").Value)%></td>
</tr>
<tr>
<td align="left" width="50%">estatus</td>
<td align="left" width="50%"><%=(rsBundleR.Fields.Item("estatus").Value)%></td>
</tr>
<tr>
<td align="left" width="50%">revisado_por</td>
<td align="left" width="50%"><%=(rsBundleR.Fields.Item("revisado_por").Value)%></td>
</tr>
<tr>
<td align="left" width="50%">nota_personal</td>
<td align="left" width="50%"><%=(rsBundleR.Fields.Item("nota_personal").Value)%></td>
</tr>
</table>
<br /><br />
<%
Repeat1__index=Repeat1__index+1
Repeat1__numRows=Repeat1__numRows-1
rsBundleR.MoveNext()
Wend
%>
, no error is given BUT still, no information is showing.
However, i dont see the "." either :/
I made it create a table for each record,
is it the way i called the information?
or is the query not finding anything?
( there is information in the database ) -
Dynamic declaration for variable.
Can we declare a variable dynamic with varing data type.
My req is i have to define a variable to store output from a dynamic select statement. Now since SELECT is dynamic, its output type changes each time and for the same I need a variable defined dynamically.
Regards,
ArpitHi Arpit Gattani,
To store output of an dynamic Select statement you can use dynamic data objects and field symbols.
To create a data object dynamically during a program, you need a data reference variable and the following statement:
CREATE DATA <dref> TYPE <type>|LIKE <obj>.
This statement creates a data object in the internal session of the current ABAP program. After the statement, the data reference in the data reference variable <dref> points to the object. The data object that you create does not have its own name. You can only address it using a data reference variable. To access the contents of the data object, you must dereference the data reference.
You must specify the data type of the object using the TYPE or LIKE addition. In the TYPE addition, you can specify the data type dynamically as the contents of a field (this is not possible with other uses of TYPE).
CREATE DATA <dref> TYPE (<name>).
Here, <name> is the name of a field that contains the name of the required data type.
<b>Example:</b>
A specific field is read from database table X031L. Neither the field name nor the table name is known until runtime:
Read a field from the table X031L
PARAMETERS:
TAB_NAME LIKE SY-TNAME, "Table name
TAB_COMP LIKE X031L-FIELDNAME, "Field name
ANZAHL TYPE I DEFAULT 10. Number of lines
FIELD-SYMBOLS: <WA> TYPE ANY,
<COMP> TYPE ANY.
DATA: WA_REF TYPE REF TO DATA.
CREATE DATA WA_REF TYPE (TAB_NAME). "Suitable work area
ASSIGN WA_REF->* TO <WA>.
SELECT * FROM (TAB_NAME) INTO <WA>
UP TO anzahl ROWS.
WRITE: / TAB_COMP, <COMP>.
ENDSELECT.
Dont Forget to give points if it helps ;>)
Regards
Rakesh. -
HOWTO: Declare a variable within a function.
I'm having a hard time declaring a variable within a function. This is my code:
CREATE OR REPLACE FUNCTION schemaName.functionName (inParam VARCHAR2(20))
RETURN VARCHAR2 IS VARCHAR2(10)
BEGIN
DECLARE paramLength NUMBER; --This is not working. The docs do not state what the size of the number returned by LENGTH is.
SELECT LENGTH(inParam) INTO paramLength FROM DUAL;
IF paramLength < 10 THEN
RETURN '';
ELSE
/* Clean up the value */
RETURN inParam
END IF;
END;In relation to your own code...
CREATE OR REPLACE FUNCTION schemaName.functionName (inParam VARCHAR2(20)) RETURN VARCHAR2 IS
paramLength NUMBER;
BEGIN
/* Clean up the value */
paramLength = LENGTH(inParam);
IF paramLength < 10 THEN
RETURN NULL;
ELSE
RETURN inParam
END IF;
END; You don't need to use SQL to determine the length of a string. -
Syntax to declare a variable in native sql
Hi Experts,
Please let me know the syntax to declare a variable in Native SQL.
Vivek GuptaHello
Check this link: http://help.sap.com/saphelp_47x200/helpdata/en/7b/0bdea252d746429420007a69bd06c7/frameset.htm
There is example of native SQL.
Also read this:
http://help.sap.com/saphelp_nw04/helpdata/EN/fc/eb3b8b358411d1829f0000e829fbfe/content.htm
http://help.sap.com/saphelp_nw04/helpdata/EN/a3/74caa1d9c411d1950e0000e8353423/content.htm -
Is there any reason (laziness aside) to declare instance variables public?
Why would you declare one public, save for the fact that object.field is quicker to type than object.getField()? It is a pain to have to write get/set methods for private variables, but later on, if you ever need to do something with a variable when it's been accessed or modified, it's much easier to go back and edit just those methods, instead of everywhere the variable's been directly accessed. On the other hand, I see no benefit of declaring a variable public. Is there one?
Never, Never, Never !!!That's a tad extreme.
In most cases, you'll want get and set, and even then you need to examine whether you really want another class to have that direct control over your object's state.
But there are cases where you can make your instance variables public. If it's a pure data container, with no behavior, and you don't expect it to ever be used in a multithreaded context or to be used as a JavaBean, then you can make the instance variables public.
Maybe you are looking for
-
Does anyone know a finacial proram for iMac that will allow me to reconcile a checkbook from a brokerage account> Quicken Essentials for Mac does not.
-
How to make a categories in FAQ's
I want to make my question in category. Example. 1. Adobe What is Adobe Dreamwever ? What is Abobe Business Catalyst? soon....
-
Can't connect to/sync using new Server setup
Hi all, I have set up a new Server and cannot seem to use it to sync, which is its purpose -- requests time out. I also cannot "Connect to server" from the Mac it resides on (suggested troubleshooting step someone gave me). Here's the background: I'm
-
Using Dynamic SQL to populate ALV
Hi, Does anyone know if it is possible to use the Runtime Type Services to obtain the structure definition for the results a dynamic select statement? I am looking to create a simple web dynpro app that that will populate an ALV grid with the results
-
Link delivery to production order
Hello, Production order is created from planned order (created for a stock transfer order) in CO40 and then parts are ready to be delivered. How can i link delivery with production order ?