Check for null in IF statement

Hi,
I have a variable of type char(8).
I want to check if this field is empty. This is the logic I use right now:
condense lv_date no-gaps.
if lv_date eq ''.
*then some default value
endif.
Is this the correct approach or there is a way to directly check for null values in a variable.
Thanks,
CD

Hello,
You have to check IS INITIAL.
condense lv_date no-gaps.
if lv_date IS INITIAL.
*then some default value
endif.
BR,
Suhas

Similar Messages

  • Check for null and empty - Arraylist

    Hello all,
    Can anyone tell me the best procedure to check for null and empty for an arraylist in a jsp using JSTL. I'm trying something like this;
    <c:if test="${!empty sampleList}">
    </c:if>
    Help is greatly appreciated.
    Thanks,
    Greeshma...

    A null check might not be you best option.  If your requirement is you must have both the date and time component supplied in order to populate EventDate, then I would use a Script Functoid that takes data and time as parameters.
    In the C# method, first check if either is an empty string, if so return an empty string.
    If not, TryParse the data, if successful, return a valid data string for EventDate.  If not, error or return empty string, whichever satsifies the requirement.

  • Check for null or empty in the functoid

    I want to check for null and empty values on input source node. If there exists a null or empty in the input source node, I should not pass that to output destination node. Does the
    following attachment work? I want to check for null or empty in the date and time and then concatenate them to send to output. If any of them is null or empty, the other should not fail. In the Not Equal Functoid I am checking for blank, but how to check for
    null?

    A null check might not be you best option.  If your requirement is you must have both the date and time component supplied in order to populate EventDate, then I would use a Script Functoid that takes data and time as parameters.
    In the C# method, first check if either is an empty string, if so return an empty string.
    If not, TryParse the data, if successful, return a valid data string for EventDate.  If not, error or return empty string, whichever satsifies the requirement.

  • Page Validation - Function Returning Boolean - Check for NULL

    I have 3 Page Validations which all fire on "When Button Pressed" = "Submit".
    <br><br>
    Number 1 is of type "Item specified is NOT NULL" for "P199_BUSINESS_UNIT1".
    <br>
    Number 2 is of type "Item specified is NOT NULL" for "P199_BUSINESS_UNIT2".
    <br>
    Number 3 is of type "Function Returning Boolean" and has the following code:
    <br><br>
    IF :P199_BUSINESS_UNIT1 IS NULL   AND
       :P199_BUSINESS_UNIT2 IS NULL  THEN
        RETURN FALSE ;
    ELSE
        RETURN TRUE  ;
    END IF ;<br>
    When P199_BUSINESS_UNIT1 is NULL and P199_BUSINESS_UNIT2 is NOT NULL, I get the Error from Validation 1. Perfect.
    <br>
    When P199_BUSINESS_UNIT1 is NOT NULL and P199_BUSINESS_UNIT2 is NULL, I get the Error from Validation 2. Perfect.
    <br>
    When P199_BUSINESS_UNIT1 is NOT NULL and P199_BUSINESS_UNIT2 is NOT NULL, I don't get an Error Message. Perfect.
    <br><br>
    When P199_BUSINESS_UNIT1 is NULL and P199_BUSINESS_UNIT2 is NULL, I get Error Message 1 & 2, <strong>but nothing from 3.</strong>
    <br><br>
    If I change the code to:
    <br><br>
    IF :P199_BUSINESS_UNIT1 = '01'   AND
       :P199_BUSINESS_UNIT2 = '01'  THEN
        RETURN FALSE ;
    ELSE
        RETURN TRUE  ;
    END IF ;<br>
    and change both values to '01', I get the appropriate Error Message.
    <br><br>
    What is going on? Is there some reason I can't check for NULL in a Function Returning Boolean?

    Scott,
    <br><br>
    Instead of adding the Validations, I changed my code from:
    <br><br>
    IF :P199_BUSINESS_UNIT1 IS NULL   AND
       :P199_BUSINESS_UNIT2 IS NULL  THEN
        RETURN FALSE ;
    ELSE
        RETURN TRUE  ;
    END IF ;
    <br>to the following and got the desired results:
    <br><br>
    IF  REPLACE(:P199_BUSINESS_UNIT1,<strong>'%null'</strong> || '%',NULL) IS NULL   AND
        REPLACE(:P199_BUSINESS_UNIT2,<strong>'%null'</strong> || '%',NULL) IS NULL  THEN
        RETURN FALSE ;
    ELSE
        RETURN TRUE  ;
    END IF ;<br>
    Note that I changed the word REPLACE to upper case and the second occurrence of the word NULL to upper case to accentuate the fact that the '%null' is case sensitive, using "%NULL' does not work, it has to be "%null' in lower case.
    <br><br>
    <strong>Thanks for your help.</strong>

  • How do I check for null date entires using custom JScript on a SharePoint NewForm.aspx?

    Hi,
    I have the below JScript:
    /*Function to convert the US Date format to UK date format */
    function parseDate(input) {
    var parts = input.split('/');
    // new Date(year, month [, date [, hours[, minutes[, seconds[, ms]]]]])
    return new Date(parts[2], parts[1]-1, parts[0]); // months are 0-based
    /*Function to check if end date is before the start date */
    function checkDates(){
    var sd = parseDate($("input[title='From']").val());
    var ed = parseDate($("input[title='Until']").val());
    if(sd > ed) {
    alert("Please check From and Until Date");
    $("input[value$='Save']").attr('disabled', true); //hide save button
    else
    $("input[value$='Save']").attr('disabled', false); //show save button
    The above works fine for checking sd > ed but I can't seem to check for null's, I have attempted the below which doesn't work:
    /*Function to convert the US Date format to UK date format */
    function parseDate(input) {
    var parts = input.split('/');
    // new Date(year, month [, date [, hours[, minutes[, seconds[, ms]]]]])
    return new Date(parts[2], parts[1]-1, parts[0]); // months are 0-based
    /*Function to check if end date is before the start date */
    function checkDates(){
    var sd = parseDate($("input[title='From']").val());
    var ed = parseDate($("input[title='Until']").val());
    if( (sd > ed) || (sd == null) || (ed == Null) ) {
    alert("Please check From and Until Date");
    $("input[value$='Save']").attr('disabled', true); //hide save button
    else
    $("input[value$='Save']").attr('disabled', false); //show save button
    Any help appreciated.

    Hi aspnet-scotland,
    Please post ASP.NET related questions in
    ASP.NET forums where you could receive better responses.
    Thanks for your understanding.
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • ViewCriteriaRow attribute to check for null or not null

    I Want to apply a view criteria to check for null or not null on a column , i see examples on how to set for value like
    vcRow.setAttribute("Sal", "> 2500")but i need to check for Sal is null or not null ,
    tried vcRow.setAttribute("Sal", null) and it is not working
    and vcRow.setAttribute("Sal", "is null") gives me error .
    can somebody help with correct syntax for this
    Thanks for your time

    looks like vcRow.setAttribute("Sal", "null") works

  • How does APEX check for null values in Text Fields on the forms?

    Hello all,
    How does APEX check for null values in Text Fields on the forms? This might sound trivial but I have a problem with a PL/SQL Validation that I have written.
    I have one select list (P108_CLUSTER_ID) and one Text field (P108_PRIVATE_IP). I made P108_CLUSTER_ID to return null value when nothing is selected and assumed P108_PRIVATE_IP to return null value too when nothign is entered in the text field.
    All that I need is to validate if P108_PRIVATE_IP is entered when a P108_CLUSTER_ID is selected. i.e it is mandatory to enter Private IP when a cluster is seelcted and following is my Pl/SQL code
    Declare
    v_valid boolean;
    Begin
    IF :P108_CLUSTER_ID is NULL and :P108_PRIVATE_IP is NULL THEN
    v_valid := TRUE;
    ELSIF :P108_CLUSTER_ID is NOT NULL and :P108_PRIVATE_IP is NOT NULL THEN
    v_valid := TRUE;
    ELSIF :P108_CLUSTER_ID is NOT NULL and :P108_PRIVATE_IP is NULL THEN
    v_valid := FALSE;
    ELSIF :P108_CLUSTER_ID is NULL and :P108_PRIVATE_IP is NOT NULL THEN
    v_valid := FALSE;
    END IF;
    return v_valid;
    END;
    My problem is it is returning FALSE for all the cases.It works fine in SQL Command though..When I tried to Debug and use Firebug, I found that Text fields are not stored a null by default but as empty strings "" . Now I tried modifying my PL/SQL to check Private_IP against an empty string. But doesn't help. Can someone please tell me how I need to proceed.
    Thanks

    See SQL report for LIKE SEARCH I have just explained how Select list return value works..
    Cheers,
    Hari

  • How to check for null values in bpel?? Please Help! very urgent!!!

    Hello Guys,
    I have a problem. I have an external webservice to which I have to post my request. My task is to create an Webservice and Service Assembly to which others would post request and get response. I have to create SA to deploy onto the bus.
    The problem is that there are optional elements in the request and response xsd's. In the Response sometimes certain feilds may come or they may not. for Example:- my response could contain a tag like this <firstName></firstName>
    I have to copy these feilds in my bpel process from one variable to another.(like in the mapper).
    My Question is , Is there any way in BPEL process or BPEL mapper where I could Check for null values in the request or response???
    Your inputs would be very helpful.
    Thanks
    Rajesh

    Thanks for replying man :)
    Ok I will be more clear.
    Here is a snippet of one of the xsd's that I am using.
    <xs:element name="returnUrl" nillable="false" minOccurs="0">
                        <xs:annotation>
                             <xs:documentation>Partner specifies the return URL to which responses need to be sent to, in case of
    Async message model.
    </xs:documentation>
                        </xs:annotation>
                        <xs:simpleType>
                             <xs:restriction base="xs:anyURI">
                                  <xs:maxLength value="300"/>
                                  <xs:whiteSpace value="collapse"/>
                             </xs:restriction>
                        </xs:simpleType>
                   </xs:element>
    This means that the return URL field can be there or it may not be there. But if it is there it cant be null because nillable=false. But the whole <returnURL> </returnURL> can be there or it may not be there because minOccurs=0.
    My requirement is , if returnURL is there in the response with a value, then in my BPEL mapper I should map it else I should not map it.
    Thats the issue.
    and Yes kiran, the node be non-existant.
    So can you please help me with this.
    Thanks
    Rajesh

  • Checking for null value in arraylist

    Hi
    i have an excel file which i i am reading into an arraylist row by row but not necesarrily that all columns in the row mite be filled. So how do i check for null values in the array list.
    try
                        int cellCount = 0;
                        int emptyRow = 0;
                        HSSFWorkbook workbook = new HSSFWorkbook(new FileInputStream(file));
                        HSSFSheet sheet = workbook.getSheetAt(0);
                        Iterator rows = sheet.rowIterator(); 
                        myRow = new ArrayList();
                        int r = 1;
                             while (rows.hasNext())
                                  System.out.println("Row # " + r);
                                  HSSFRow row = (HSSFRow) rows.next();
                                  Iterator cells = row.cellIterator();          
                                  cellCount = 0;
                                  boolean isValid = false;
                                  while (cells.hasNext())
                                       HSSFCell cell = (HSSFCell) cells.next();
                                       switch (cell.getCellType())
                                            case HSSFCell.CELL_TYPE_NUMERIC:
                                                 double num = cell.getNumericCellValue();     
                                                 DecimalFormat pattern = new DecimalFormat("###,###,###,###");     
                                                 NumberFormat testNumberFormat = NumberFormat.getNumberInstance();
                                                 String mob = testNumberFormat.format(num);               
                                                 Number n = null;
                                                 try
                                                      n = pattern.parse(mob);
                                                 catch ( ParseException e )
                                                      e.printStackTrace();
                                                 System.out.println(n);
                                                 myRow.add(n);                                             
                                                 //myRow.add(String.valueOf(cell.getNumericCellValue()).trim());
                                                 //System.out.println("numeric: " +cell.getNumericCellValue());
                                                 break;
                                            case HSSFCell.CELL_TYPE_STRING:
                                                 myRow.add(cell.getStringCellValue().trim());
                                                 System.out.println("string: " + cell.getStringCellValue().trim());
                                                 break;
                                            case HSSFCell.CELL_TYPE_BLANK:
                                                 myRow.add(" ");
                                                 System.out.println("add empty:");
                                                 break;
                                       } // end switch
                                       cellCount++;
                                  } // end while                    
                                  r++;
                             }// end while
                   } myRow is the arrayList i am adding the cells of the excel file to. I have checked for blank spaces in my coding so please help with how to check for the black spaces that has been added to my arraylist.
    I have tried checking by looping through the ArrayList and then checking for null values like this
    if(myRow.get(i)!=null)
      // do something
    // i have tried this also
    if(myRow.get(i)!="")
    //do something
    }Edited by: nb123 on Feb 3, 2008 11:23 PM

    From your post I see you are using a 3rd party package to access the Excel SpreadSheets, you will have to look in your API for you 3rd party package and see if there is a method that will identify a blank row, if there is and it does not work, then you have to take that problem up with them. I know this is a pain, but it is the price we pay for 3rd party object use.
    In the mean time, you can make a workaround by checking every column in your row and seeing if it is null, or perhaps even better: check and see if the trimmed value of each cell has a lenth of 0.

  • Can't check for nulls in a conditional?

    Hey everyone. Trying my hand at a text based game but I'm encountering many problems:
    I have this method in one class that (as you can see) has a conditional that checks to see if 'check' is null, this throws a null pointer exception whenever it is called.
    private void placeChars()
            String check = currentItem.getItemString();
            if(check.equals(null) && currentRoom.getShortDescription().equals("in the cafeteria"))
                josh.getSentence(0);
        }Here is the method that it is calling from:
    public String getItemString()
            String returnString = null;
            if(haveItems != 0 ){
            returnString = "Items:";
            Set<String> keys = items.keySet();
            for(String item : keys) {
                returnString += " " + item;
        return returnString;
        }I'm not sure what I am doing wrong here :/ and yes I know the code is extremely ugly :)

    if check is null, you can't invoke any methods on it, including equals.
    To check for null:
    if (check == null)

  • Checking for nulls

    I have a string variable and I need to check for null.
    What is the best way to do this?
    Thanks.

    You can also do it like this:
    } catch (NullPointerException e) {or like this:
    s==null ? <...> : <...>

  • Why must you check for null first?

    Post Author: sliese
    CA Forum: Data Connectivity and SQL
    Hi All -I am a bit confused.  If I have a record selection formula like this:isnull({Product.Size}) or ({Product.Size} <> "xlrg")I realize that the null condition must come first in order for nulls to be included in the recordset.  But, I don't understand why.  Even if it can just be explained away by saying "that's a bug," isn't this being done by the dbms anyways?  I thought the dbms looks at your SQL query strings, retrieves the appropriate records, then sends them back to Crystal.  The dbms should give us the null values whether or not it comes first in the or condition.  Am I missing something?  Does crystal do some additional processesing after the records are retrieved that causes it to throw away all the null value records?Thanks in advance to anyone who can shed light on this issue for me.-Stephanie

    Post Author: sliese
    CA Forum: Data Connectivity and SQL
    Right, I realize null values always return false.  Which is exactly why I don't understand why it has to come first in record selection criteria.  In other words, this works just fine:
    isnull(field) or field <> "xlrg"
    But, this does not, even though they are equivalent:
    field <> "xlrg" or isnull(field)
    When the DBMS first sees that I've checked if field <> xlrg, this will be false, thus it SHOULD go to the second criteria in my OR condition to determine whether or not to include the record.  But, it does not seem to do that.  Instead, it decides not to include the record at all even though the second part of the OR condition may still return true.  Does my wording make sense now?

  • Check for null

    Hi,
    Iam checking a id which is long, for null value.
    Checked for isNull( head.getEmpId()) but it throws me a error
    "The method isNull(long) is undefined for the type."
    I also tried it with == and .equals. Not sure about the error. Could you please help.

    nman wrote:
    ok, how can i check a emp id in the table for null values and populate with a value, where emp id is longIf you are using a ResultSet, you can call wasNull() after accessing the value to determine if it was null.
    Otherwise, long cannot be null, only Long can be null.

  • Check for Null in Mediator Static Routing filter

    Using Expression Builder for Mediator component how can I check the values for NULL in a particular XML element. In my case the XSD is
    <xs:complexType name="OdsCadDataSet">
    <xs:choice>
    <xs:element name="odsCadCase" type="OdsCadCase" minOccurs="0"
    maxOccurs="1"/>
    <xs:element name="odsCadEvent" type="OdsCadEvent" minOccurs="0"
    maxOccurs="1"/>
    <xs:element name="odsCadUnitStatus" type="OdsCadUnitStatus"
    minOccurs="0" maxOccurs="1"/>
    </xs:choice>
    </xs:complexType>
    I want to check in expression builder of mediator whether odsCase, odsCadEvent, odsCadUnitStatus is been processed. I have three static routing for each element and plan to put filter which checks is odsCadCase is null and so forth. How to have this use case.
    Thanks
    Edited by: user5108636 on 28/06/2010 00:15

    helo, i have same problem here...
    I have a xsd:choice on request like this:
    <message>
    <properties>
    <property name="tracking.compositeInstanceId" value="80003"/>
    <property name="tracking.ecid" value="0000J1MQVAZBDC^5lVg8yZ1DtZWJ000T5r"/>
    <property name="transport.http.remoteAddress" value="10.106.17.137"/>
    </properties>
    <parts>
    <part name="request">
    <ns1:parametrosConsultaGuia>
    <ns1:guiaCompensacaoRequest>
    <ns1:anoGuia>2011</ns1:anoGuia>
    <ns1:numeroGuia>314</ns1:numeroGuia>
    <ns1:codigoFatoGerador>6</ns1:codigoFatoGerador>
    <ns1:codigoPorte>77011</ns1:codigoPorte>
    </ns1:guiaCompensacaoRequest>
    <ns1:guiaComplementarRequest>
    <ns1:codigoEntidade/>
    <ns1:classeEmbarcacao/>
    <ns1:codigoPorte/>
    <ns1:codigoAssunto/>
    <ns1:fatoGerador/>
    <ns1:numeroTransacaoInternet/>
    </ns1:guiaComplementarRequest>
    <ns1:guiaDesarquivamentoRequest>
    <ns1:codigoAssunto/>
    <ns1:idPessoa/>
    </ns1:guiaDesarquivamentoRequest>
    <ns1:guiaDividaAtivaRequest>
    <ns1:numeroDebito/>
    <ns1:codigoUsuario/>
    </ns1:guiaDividaAtivaRequest>
    <ns1:guiaNormalRequest>
    <ns1:codigoEntidade/>
    <ns1:codigoAssunto/>
    <ns1:fatoGerador/>
    <ns1:numeroTransacaoInternet/>
    </ns1:guiaNormalRequest>
    <ns1:guiaReferenciaRequest>
    <ns1:numeroGuiaPai/>
    <ns1:anoGuiaPai/>
    <ns1:codigoEntidade/>
    <ns1:classeEmbarcacao/>
    <ns1:codigoAssunto/>
    </ns1:guiaReferenciaRequest>
    <ns1:guiaRemanescenteRequest>
    <ns1:numeroDebito/>
    <ns1:codigoUsuario/>
    </ns1:guiaRemanescenteRequest>
    <ns1:guiaMultaRequest>
    <ns1:codigoEntidade/>
    <ns1:dataVencimento/>
    <ns1:valorMulta/>
    <ns1:percentualDesconto/>
    <ns1:percentualAcrescimo/>
    </ns1:guiaMultaRequest>
    </ns1:parametrosConsultaGuia>
    </part>
    </parts>
    </message>
    I tried everything to check if some of the requests are filled but allways mediator returns null:
    03/06/2011 13:50:42MensagemEvaluation of xpath condition "string-length($in.request/guia:guiaRequest/guia:parametrosConsultaGuia/guia:guiaReferenciaRequest) > 0" resulted false
    <payload>
    Atividade03/06/2011 13:50:42MensagemonCase "GuiaCompensacao.getGuiaCompensacao"
    03/06/2011 13:50:42MensagemEvaluation of xpath condition "$in.request/guia:guiaRequest/guia:parametrosConsultaGuia/guia:guiaCompensacaoRequest != ''" resulted false
    <payload>
    Atividade03/06/2011 13:50:42MensagemonCase "GuiaRemanescenteService.getGuiaRemanescente"
    03/06/2011 13:50:42MensagemEvaluation of xpath condition "string-length($in.request/guia:guiaRequest/guia:parametrosConsultaGuia/guia:guiaRemanescenteRequest) > 0" resulted false
    <payload>
    Atividade03/06/2011 13:50:42MensagemonCase "GuiaMultaService.gerarBoleto"
    03/06/2011 13:50:42MensagemEvaluation of xpath condition "string-length($in.request/guia:guiaRequest/guia:parametrosConsultaGuia/guia:guiaMultaRequest) > 0" resulted false
    <payload>
    Atividade03/06/2011 13:50:42MensagemonCase "GuiaDividaAtiva.getGuiaDividaAtiva"
    03/06/2011 13:50:42MensagemEvaluation of xpath condition "string-length($in.request/guia:guiaRequest/guia:parametrosConsultaGuia/guia:guiaDividaAtivaRequest) > 0" resulted false
    <payload>
    Atividade03/06/2011 13:50:42MensagemonCase "GuiaDesarquivamento.getGuiaDesarquivamento"
    03/06/2011 13:50:42MensagemEvaluation of xpath condition "string-length($in.request/guia:guiaRequest/guia:parametrosConsultaGuia/guia:guiaDesarquivamentoRequest) > 0" resulted false
    <payload>
    Atividade03/06/2011 13:50:42MensagemonCase "GuiaComplementarService.gerarBoleto"
    03/06/2011 13:50:42MensagemEvaluation of xpath condition "string-length($in.request/guia:guiaRequest/guia:parametrosConsultaGuia/guia:guiaComplementarRequest) > 0" resulted false
    <payload>
    Atividade03/06/2011 13:50:42MensagemonCase "GuiaNormalService.gerarBoleto"
    03/06/2011 13:50:42MensagemEvaluation of xpath condition "string-length($in.request/guia:guiaRequest/guia:parametrosConsultaGuia/guia:guiaNormalRequest) > 0" resulted false
    <payload>

  • How to check for null int/null Date

    Heres the situation, there is an interface accepting an int value and a time/date that are not required(and are not set to anything automatically, i have no control over that part unfortunately), but I need to set up some sort of null/has value type of check to execute the setter when it does have a value, and ignore it when it doesnt. I am currently getting null pointers. here is my current set up:
    //throws null pointer as set up below, I am assuming I might want to eliminate the "getDate" off of the end and that might clear it up.
    if(data.getDate().getTime() != null)
              tempData.setDate(data.getDate().getTime());
    //Not sure on this one yet, the value doesn't get set to anything so I am assuming it automatically gets assigned something like -1.
    if(data.getId() >= 0){
              tempData.setId(data.getId());
              }

    tsdobbi wrote:
    I know data isnt null because it goes through a bunch of other tempData.set(data.get) items prior to hitting a snag on the above date I mentioned, when there is no value input for the date. and that particular null check I do there, does not work because it throws a null pointer in the if statement itself.
    i.e. it traces the null pointer to
    (if data.getDate().getTime != null) //this is the line the null pointer traces to.{color:#3D2B1F}if data is not null, then it must be the case that data.getDate() is null. Now that's what I call logic. W00t!{color}

Maybe you are looking for