Results 1 to 5 of 5
  1. #1
    Join Date
    Jul 2012
    Posts
    3
    Rep Power
    0

    Default Syntax Error in If statment

    Hi All,

    This is my first day in Java. I have to write a source code where the SAP requirement is to check when the field "PurchDocu_No" is empty it has to throw exception.

    Below is my line of code.

    public String BlankValues(String PurchDocu_No, Container container) throws StreamTransformationException

    {

    if(PurchDocu_No.equals("")) ;
    {
    throw new RuntimeException("PurchDocu_No is empty");
    }
    else
    {
    return PurchDocu_No;
    }

    }

    When executing, it throws error.

    Source text of object Message Mapping: MM_InboundShipAbyat | urn:integration has syntax errors:

    Function BlankValues, Line 6:
    'else' without 'if'
    else
    ^
    1 error


    Need guidance if some one call help me.

    Regards
    Robinson
    Last edited by robinsonth@gmail.com; 07-10-2012 at 03:31 PM. Reason: syntax

  2. #2
    eRaaaa is offline Senior Member
    Join Date
    Oct 2010
    Location
    Germany
    Posts
    787
    Rep Power
    6

    Default Re: Syntax Error in If statment

    Delete the semicolon in line
    if(PurchDocu_No.equals("")) ;
    ->
    if(PurchDocu_No.equals(""))
    otherwise it ends the if statement (empty block)

  3. #3
    Join Date
    Jul 2012
    Posts
    3
    Rep Power
    0

    Default Re: Syntax Error in If statment

    Hi Senior Member,

    Excellent !! Your help is working.

    1. I have 2 other fields which are mandatory i.e. <ItemNo> and <Name> and want to include in this piece of code showing
    that if any one of the 3 fields is having blank values then it should throw error.

    Regards
    Robinson

  4. #4
    Waflix is offline Member
    Join Date
    Jul 2012
    Location
    Zuid-Holland, The Netherlands
    Posts
    16
    Rep Power
    0

    Default Re: Syntax Error in If statment

    Robinsonth, I'd recommend posting your Java code inside [code]-tags. As a result your code will become easier to read and thus we can help you better.

  5. #5
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: Syntax Error in If statment

    Quote Originally Posted by robinsonth@gmail.com View Post
    1. I have 2 other fields which are mandatory i.e. <ItemNo> and <Name> and want to include in this piece of code showing
    that if any one of the 3 fields is having blank values then it should throw error.
    Please show us what you have tried so far, and how it isn't working.

Similar Threads

  1. sql select ,error in your SQL syntax
    By miko5054 in forum JDBC
    Replies: 13
    Last Post: 06-28-2010, 12:48 PM
  2. No more syntax error
    By ideyatech in forum Java Software
    Replies: 2
    Last Post: 04-22-2010, 05:20 AM
  3. Syntax error on token
    By egun in forum New To Java
    Replies: 4
    Last Post: 02-11-2010, 11:57 AM
  4. how to solve syntax error
    By pro85 in forum Java Applets
    Replies: 5
    Last Post: 04-06-2009, 12:20 PM
  5. syntax error
    By gabriel in forum New To Java
    Replies: 3
    Last Post: 08-03-2007, 04:26 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •