Can I assign a default value to a parameter like C++ ?

My question is whether I can assign a default value to a parameter in Java? Let's say : public void myMethod(int p1, int p2=3){...} Is this syntax acceptable ?
Regards,
WenBin

I don't think so (the easiest way to find out is to try), but if you want something like that, most people do it like so:
private static final int DEFAULT_P2 = 3;
public void myMethod(int p1)
    myMethod(p1, DEFAULT_P2);
public void myMethod(int p1, int p2){...}Hope this helps,
Radish21

Similar Messages

  • How to assign the default value to search parameter

    Hi Experts,
    I am using search view , In this I have 5 parameter lets say Transaction Type, Partner No. etc... Now I want to assign a default value to transaction type ( lets say TA) . User should be able to see this default value in the transaction type field before pressing search button.
    How can I do it?
    My second problem is: I have configured this search view using configuration tool but I want to assign only one value to transaction type (i.e. user should not be able to add new row in the search criteria for the transaction type by using + sign)  but in rest 4 fields he can add new row and search based on that.
    Note: I am using only "Is" criteria .
    Any pointer will be helpful for me
    Thanks and regards,
    Sandeep

    Hi Sandeep,
    For the default search values, here is a solution. You have to redefine the method GET_VALUE1 of the context node
    For example if it is the BP search (component BP_HEAD_SEARCH) context node is your enhanced class: ZL_BP_HEAD__MAINSEARCH_CN00
    METHOD get_value1.
      CALL METHOD super->get_value1
        EXPORTING
          attribute_path = attribute_path
          iterator       = iterator
        RECEIVING
          value          = value.
      TRY.
    *     Delegate operation to selection parameter
          DATA: current TYPE REF TO if_bol_bo_property_access.
          IF iterator IS BOUND.
            current = iterator->get_current( ).
          ELSE.
            current = me->parameter_collection->get_current( ).
          ENDIF.
          IF current->get_property_as_string( iv_attr_name = 'ATTR_NAME' ) EQ 'XXX'.
            IF value IS INITIAL.
              value = 'Your default value'.
            ENDIF.
          ENDIF.
        CATCH cx_root.
      ENDTRY.
    ENDMETHOD.
    where XXX is the name of the field.
    Default value will then appear in your search field, but you are still able to modify it if you want...
    Regards,
    Fabian

  • A question about assigning a default value

    Hi guys, I have a question about assigning a default value to a Numeric Decision CO. This Co needs 2 parameters to compare with each other. I wanna assign para1 during runtime and para2 during design time, but I have no idea how to assign a default value to para2 during design time. Can anyone help me solve this question? Thx a lot.
    BTW I`m searching an article about Time-off example`s "details". I have read several articles about time-off example, but those are not detailed enough. I wanna know about all details of COs. Can anyone forward such article to me, plz.  Thx again.^^

    Hi,
    You can assign a default value to the parameter of a callable object.
    First attach your CO to an Action.At the action level you can assign default values to the CO Parameters.
    Select the action in the design time.
    Select the parameters tab for that action.
    Select the required paramter. At the top, you can find Default value tab, with that you can assign default value.
    I think you can achieve your requirements with Business logic CO better.
    [Business Logic CO|http://help.sap.com/saphelp_nwce10/helpdata/en/44/3d3936c5c14a8fe10000000a1553f6/content.htm]
    Thanks

  • Assigning a default value to a user property

    Hi everyone,
    do you know how can I assign a default value to a user property? It would be great if I should be able to assign it from the administration without writing any code (like profile web services...).
    Thank you!
    Alberto Marchiaro

    Hi Alberto,
    I don't think you can currently do this. In other words you can't set a default value for some object property and have it subbed in when no better value is available.
    You can however create a default profile, and set values for the object properties assigned to users (You do this by going to the "Default Profiles" manager). You can then edit the "Default Profile" that is already there (or create a new one), and edit the "Properties and Names". Set the value field to whatever you'd like to be copied by default.
    Once done, all new users that are created via a User Synchronization job will have this default profile. The changes will not apply to users that were previously created. If you created a new Default Profile in the Default Profiles Manager, then you need to goto the Authentication Source that you are doing your sync's from and pick which profile you'd like to use for All Groups. You can also create custom Default Profiles for various groups.
    Hope this helps,
    Akash

  • Problem using default value of report parameter 1 to validate parameter 2 passed in to report

    I am having a problem with an SSRS report using the default value of report parameter 1 to validate parameter 2 passed in to report (via C#) instead of using the value of parameter 1 that is also passed into the report.  Here are the
    simplified details:
    Using SSDT, SQL Server 2008 R2
    SSRS report has 2 parameters:
    P1 -- text, hidden, default value 'R1', ... front-end C# code can pass 'R2' or 'R1'
    P2 -- text, allows multiple values, list of available values provided by stored procedure (sproc_list) that takes P1 value as a parameter.  Hence, sproc_list either provides a list for P1 = 'R1' or P1 = 'R2'.
    List for P1 = 'R1' is 'A', 'B', 'C'
    List for P1 = 'R2' is 'A', 'B', 'D'
    Values for P1 and P2 can be passed in via C# to the report.
    The C# front-end displays 2 report choices to the user, R1 and R2, where both choices call the same RDL; but choice R1 passes in 'R1' for P1, and the choice R2 passes in 'R2' for P1.
    Upon a users 1st time use of the report no parameters are passed in.  Then when the user exits the report, the parameter value for P2 that was chosen is saved off to a file for R1 or R2, and used the next time the user selects the report.
    Everything always works fine for report R1 since the default value for P1 is 'R1'.
    When R2 is chosen and the user selects 'D' as the value for P2, runs the report, then exits, the P2 value of 'D' for R2 is saved to a file.  When the user returns the next day to run report R2, 'R2' is passed for P1, and 'D' is passed for P2.
    This is when the problem occurs.  The value of 'D' for P2 is validated against a list generated for P2 based on the default value of 'R1' for parameter P1.  Hence, SSRS considers 'D' an invalid value for P2 and blanks out the P2 parameter. 
    The user can then use the drop down list for P2 and choose 'D', but this defeats the purpose of saving the parameter values to be used the next time.
    Why is the stored procedure that provides a list of available values for parameter P2 using the default value of 'R1' for parameter P1 instead of using the value of 'R2' passed into the report for parameter P1?

    Hi Tom,
    Sorry for my delay.
    If I understand correctly, you have two parameter in your report. It is a couple of cascading parameter. If we have choose ‘R1’ of P1, the P2 values is A, B, C. ‘R2’ of P1, corresponding P2 values is A, B, D. What your requirement is to save the end use
    select option of these two parameters.
    In SSRS, if we have configure the parameter with default value. When we run the report, the parameter will fill with the default value to filter data. If we want to save the last status we are render the report, we need to update the default value of P1.
    If we are query the default value from database, if possible, we can
    update the database try to resolve the issue.  Alternatively, we can set the dynamic default value for the parameter.
    Hope this helps.
    Regards,
    Alisa Tang
    Alisa Tang
    TechNet Community Support

  • Oracle how to assign a date value in a parameter declaration

    How can I assign a date value to a parameter declaration in SQL?
    Here's my existing script.
    CURRENT:
    select distinct summary as "iCash EAD Error Summary",count(*)
    from AAA.BKS_ICASH_EAD_ERRORS
    where creation_date > to_date('5/26/12 8:50','mm/dd/yy HH24:MI')
    group by summary
    I'd like to assign the date I'm searching for into a parameter and use the parameter in my query.
    GOAL:
    DECLARE
    pCreateDate DATE;
    exec :pCreateDate := '5/26/12 8:50';
    select distinct summary as "iCash EAD Error Summary",count(*)
    from AAA.BKS_ICASH_EAD_ERRORS
    where creation_date > to_date(:pCreateDate,'mm/dd/yy HH24:MI')
    group by summary

    Hi,
    In SQL*Plus, you can do this:
    VARIABLE     pcreatdate     VARCHAR2 (20)
    EXEC           :pcreatedate := '5/26/12 8:50';
    SELECT    summary          AS "iCash EAD Error Summary"
    ,       COUNT (*)          AS "Total Count"
    FROM        aaa.bks_icash_ead_errors
    WHERE       creation_date  > TO_DATE (:pcreatedate, 'MM/DD/RRRR HH24:MI')
    GROUP BY  summary
    ;"GROUP BY summary" means you'll get one output row for each distinct value of summary. There's no need to SELECT DISTINCT since the GROUP BY is already making sure the rows are distinct.
    There are no DATE bind variables in SQL*Plus, so you have to use a VARCHAR2.
    If you do something similar in PL/SQL, then you can use a DATE variable. Make sure you don't call TO_DATE on something that's already a DATE.
    Edited by: Frank Kulash on Jun 26, 2012 2:01 PM

  • Assigning a default value to a field

    Hello Everyone,
           Could you please tell me how to assign a default value to a field in a transparent table, so that while creating an entry even if we don't enter the value, a default value will be assigned.
    Thanks,
    Anbu.

    Like this
    DATA: BEGIN OF itab OCCURS 0,
            field1 TYPE c VALUE 'X'
            field2 TYPE c,
          END OF itab.
    append itab.
    append itab.
    You will have by default X set in both rows for field1.
    Regards
    Marcin
    PS: Ooops I just noticed you meant transparent table but I wrote about internal one. As long as you maintain that table using maintenance view you can use event 05 - When Creating a New Entry and set fixed value for a field there. So whenever you create new entry it will receive that value.
    Edited by: Marcin Pciak on Jun 23, 2010 8:57 AM

  • How to assign a default value to a column ?

    Hi
    In the Object browser is it possible to modifiy a column in order to assign a defalut value to the column ?
    I have a table FICHE in which I want to assign a default value 0 to a column which type is NUMBER.
    Thank you for your kind answers.
    Christian.

    Hi Christian
    For one reason or the other you can't do that using 'Create Column' or 'Modify Column'. You can only do that by issuing a SQL command : alter table fiche modify column( <column name> default 0)
    HTH
    Roel

  • How to assign a default value when there is no prompted value

    Dear all,
    I create a filter and it's value is relate to a prompt.If the prompt is not fill I found that all record is selected.
    How did I assign a default value so that when I didn't fill some value in to the prompt and still can get the result by
    the default value I set?
    Thanks a lot!

    Are you using dates for between or some character column?
    Post your example.
    Instead of between use to is equal prompts, so u will have then 2 fields one for date from a nd one for date to. Everything is the same as I wrote just repeat steps...
    You must put 2 separate fields if you are using date between and you want to have default variable for both.
    Column formula for the first calendar date prompt:
    case when 1=2 then TIMES.TIME_ID else cast ('1.1.1900' as date) end
    and for the second:
    case when 1=2 then TIMES.TIME_ID else cast ('1.1.2900' as date) end
    Now you set up default repository variable for both prompts.
    Presentation variable you put in the set presentation variable on each prompt:
    p_date_from
    p_date_to
    And in Answers filter will be like this:
    *TIMES.TIME_ID between @{p_date_from}{VALUEOF("rv_test_date_to_char")} and @{p_date_to}{VALUEOF("rv_test_date_to_char")}*
    or you can put a different default variables
    *TIMES.TIME_ID between @{p_date_from}{VALUEOF("rv_test_date_to_char_from")} and @{p_date_to}{VALUEOF("rv_test_date_to_char_to")}*
    I posted similar in my blog:
    Date between in filter and title when using presentation variable from calendar dashboard prompt or drop-down list in OBIEE
    http://108obiee.blogspot.com/2009/03/date-between-in-filter-and-title-when.html
    Regards,
    Goran O
    http://108obiee.blogspot.com
    Edited by: Goran O on 2009.04.23 03:37

  • Is it possible to assign a DEFAULT VALUE to [%1]?

    Dear All,
    Let's suppose I write a code like this:
    SELECT T0.Ref1 AS 'Doc Num'
    FROM JDT1 T0
    WHERE T0.RefDate = [%1]
    When I run this query, it gives the foll. dialog box asking me to enter the Posting Date.
    Query Selection Criteria
    Posting Date       Equal     .........
    OK   Cancel
    Is it possible to make SQL assign a DEFAULT VALUE (say '31-12-10') to [%1] so that:
         If I do not type in any date and press OK, SQL will accept the default of '31-12-10' and
         If I do type in a date, say '24-07-11', and press OK, SQL will overwrite the default and use this date instead?
    I use SAP B1 8.8.
    Thanks
    LEON LAI
    Why I need this?
    This is my previous thread reduced to its minimum essentials.
    Is it possible to combine 2 different reports in a single Query?

    Hi Floyola,
    Thanks for your reply.
    Your code works only if I input a date e.g 31.07.11 (31 July 2011):
    Query Selection Criteria
    Posting Date         31.07.11
    OK   Cancel
    It does not work when I leave the Posting Date field blank. It gives this error msg:
    System Message
    No data was found as a result of the selection criteria
    OK
    Maybe as a newbie I am expecting too much from SQL.
    If it is too much a worry, please forget it. I have alternative solutions, for example: Instead of leaving the field blank, I can type in the fictitious date 31.12.10.
    I will leave this thread open for 1 or 2 days, then close it.
    Best Regards,
    Leon Lai

  • How to assign a default value to a SelectOneChoice

    Hi,
    I'm working with ADF 11g: WebLogic 10.3 and JDeveloper 11.1.1.3.0.
    I wonder how to assign a default value to a SelectOneChoice.
    In a ViewObject I have a field defined as Combo Box. Then drawing the combo in my jspx page:
    +<af:selectOneChoice value="#{bindings.Circularidad.inputValue}"+
    +label="#{bindings.Circularidad.label}:"+
    +required="#{bindings.Circularidad.hints.mandatory}"+
    +shortDesc="#{bindings.Circularidad.hints.tooltip}"+
    +id="soc2">+
    +<f:selectItems value="#{bindings.Circularidad.items}"+
    +id="si2"/>+
    +</af:selectOneChoice>+
    Can anyone help me?
    Thanks.

    Assume u have an LOV relation associated with VO attribute.
    1. Go to Edit List of Values window
    2. Click UI Hints tab
    3. Check Include no selection item check box.
    4. Select Labeled Item ( First of the list) entry form right combo box.
    5. Give ur default value in right text box.
    Regards,
    Dinil Mithra

  • Can we set a default value for the container variable in BPM?

    Can we set a default value for the container variable.?
    Suppose if i have a loop step and i have given a container variable i=5 as end condition.What value will it take during its first execution?Can we set the value for container before a recieve step?

    Hi
    Define Container Variable of Type integer and Category Simple Type .Use Condtion in Loop.
    In Container Operation Step Assign value and Use Expression to
    Increase or Decrease Valus according to your operation.
    look Pattern 4 in this blog to understand Container Operation
    /people/sharathchandra.girmaji/blog/2008/09/11/bpm-with-patterns-explained-part-1

  • Can I assign my default settings in Publish?

    Hi,
    Each time when we publish, we need to assign some parameters again.
    For example,  I need to change Flash Player Version from "Flash Player 10" (default) to "Flash Player 9"
    and change eLearning output from "None" to "SCORM 2004" (Enable Quiz/reporting then choose SCORM and set Manifest).
    Can I assign these default settings in Publish? (Because they don't exist in Preferences)
    I suppose I can modify these default values in some external files - xml, ini, etc.
    Hope somebody can suggest.
    Thanks.
    Joseph

    Sorry. I need to mofidy my saying.
    We installed CP5.5 in each standalone computer without using any external share storage.
    So it's true. The setting will be preserved in same project.
    However, we want to have a method to pre-set publish setting.
    So whenever we create a new project, its default publish settings must be Flash Player 9 (in Flash Player version) and SCORM 2004 (in eLearning output).
    Thanks.
    Thanks
    Joseph

  • HOW CAN I PASS A DEFAULT VALUE IN INTERNAL TABLE

    HOW CAN I PASS A DEFAULT VALUE IN INTERNAL TABLE.
    DATA : BEGIN OF ITAB OCCURS 0,
               FIELD1(2) TYPC C DEFAULT   '12',
               FIELD2     TYPE C ,
               END OF ITAB1.
    IT'S GIVING ERROR MESSAGE.
    PLZ LOOK INTO THIS AND GIVE ME CORRECT SOLUTION.
    THANKS
    SURI

    DATA : BEGIN OF ITAB OCCURS 0,
    FIELD1(2) TYPC C,
    FIELD2 TYPE C ,
    END OF ITAB1.
    itab-field1 = '12'.
    itab-field2 = 'A'.
    append itab.
    clear itab-field2.
    itab-field1 = '12'.
    itab-field2 = 'B'.
    append itab.
    clear itab-field2.
    Now everytime u'll have the value for field1 = '12'.
    Regards
    Vasu

  • How can I get the default value of a particular preference programatically. I know I can see the default value for some of the preferences in about:config but, I need a programatic way to get the default value.

    <blockquote>Locked by Moderator as a duplicate/re-post.
    Please continue the discussion in this thread: [tiki-view_forum_thread.php?comments_parentId=702631&forumId=1]
    Thanks - c</blockquote>
    == Issue
    ==
    I have a problem with my bookmarks, cookies, history or settings
    == Description
    ==
    How can I get the default value of a particular preference in FireFox?.
    I know I can see the default value for some of the preferences in about:config but, I need a programatic way to get the default value.
    I see some that there are values for preferences in firefox.cs but I am not certain that these are being used as the default values for preferences. prefs.js in user's profile only has the updated values and not the default values.
    Any help towards acheiving this programtically is greatly appreciated.
    If the default values are stored in a file, kindly let me know the format in which it is stored for me to parse it programatically.
    == User Agent
    ==
    Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Win64; x64; Trident/4.0; .NET CLR 2.0.50727; SLCC2; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0)

    Dear Friend,
    Here when you have the callableSattement as ?=proc(?), the first ? is an output parameter. So you should register it as out parameter using registeroutparameter.
    Then you can get the value from the outparameter using callablestatement.getXXX().
    Try that way.
    For free tral versions of JDBC Drivers go to www.Atinav.com

Maybe you are looking for

  • How to use a function module in a subroutine

    Hi,   I am working on a report where i have to create list boxes for 5 fields.Instead of using the function module VRM_SET_VALUES for each field can i use subroutine? If so, can anyone tell me the procedure for that?Its very urgent. Thanks and Regard

  • Trouble building an installer with NI-DAQmx and tasks

    I am having trouble getting an installer that includes my tasks for NI-DAQmx.  I select the configuration wizard from the hardware tab, it shows my tasks with checkboxes but i cannot 'check' the task I want, it says "the item cannot be checked becaus

  • Connection reset by peer (jdk/jre 1.5.0_06, oracle 10.2.0.2)

    I keep getting the "Oracle says: Io exception: Connection reset by peer: socket write error" to my jdbc thin client connection. I have talked to our dba's and they don't see anything wrong on the oracle side. Network people say the network is good. W

  • Sounds Familiar? Apple, Compaq, Sony

    A lot of space that is taken up by the great 'logic board' debate here. For those of you have somehow managed to miss it there are two camps. 1. Unlucky people with dead laptops who believe there is some ongoing deficiency in the manufacture of G4 iB

  • Edit the new mail account wizzard?

    I want to change how the "new email account" wizzard works. Currently, if you see this wizzard, it trys to get you to make a .Mac email account and you have to change it to POP. (For the average user that stumbles over this {bad} wizzard, they do not