Modbus - Issues with Reading Holding Registers

I am trying to read the holding registers on a RS485 2 wire modbus power monitor (Veris Industries E50C2).I am receiving bytes from the device so there appears to be communication. However, the response string is the exact same string as my command string. For instance, I am sending the hexadecimal string 0103 0000 0005 in order to read the first 5 holding registers, but I am receiving this exact same string back via the read VISA read function. I have attached an image of my VI. I would expect to see the response as "0103 (the device ID and command) followed by the number of bytes to follow and the contents of the holding registers.
The VI is running on a cRIO 9012 with 9111 chassis. I am using the 9871 c-series RS485/RS422 interface module.
Any ideas what the issue may be?
Kind Regards
Adam
Attachments:
Modbus VI.png ‏15 KB

I indeed manage to fix the issue for myself.
I used the same method you are starting right now, i conencted the NI9871 to the rs485 adapter given by the supplier and tried sending and reading my own signals.
After much hassle and some changes to your (and my) initial vi setup as shown in your first post, everything worked out fine:
(see the attached picture)
1. I used the NI modbus VIs, but it worked as well with the normal visa commands and building the modbus command on your own, but  way easier with the NI VIs.
2. i added the function to resize the buffer to its maximum size (not sure if thats actually helping with anything, but better be safe then sorry).
3. Change the wire mode for the 9871 to rs485/wire2-auto with a property node.
4. remove the large delay between write and read
5. Last but not least, the one thing that changed the fact that i only received my own echo:
I changed the connection of the Rx+/Tx+ and Rx-/Tx- around, basically connecting the 2wire sensor the other way around the manufacturer said it should be connected to the master device.
(6. Recheck the amount of stop bits, all modbus device i use in my lab are using 2 stop bits, but that could be a coincidence)
Maybe  something of that list helps you
Attachments:
Modbustest01.jpg ‏95 KB

Similar Messages

  • Reading Holding Registers Float Modbus RTU

    I'm having an issue with ready any floating point number correctly off of a Shark 100 Power Meter.
    I can sucessifully read a block of registers containing the meter name and serial number as 16 bit characters.
    For example when I read registers 1-16 on the map and flattening them to a string, I get a fully working string returned.
    When I try and read holding registers 1012-1013 (Amps A) I get really funny numbers when I convert to a float.
    Here is my code so far
    With my front pannel settings:
    Expected Value I'm looking to have returned: 11.11 Amps
    but
    When I use an indicator to read the registers: 19265, 0
    Same value when I do a conversion
    When I do a type casting to a float: 1.26484E+7
    I've tried some different combinations such as reading only one register and joining the numbers, both in big-endian and little-endian order, still no luck.
    Please Help!
    Here is the modbus float definition as defined the owners manual:
    Solved!
    Go to Solution.

    The float format you posted is the same as LV uses, so if you put example values (Register 1 = C4E1, Register 2 = 1DB9) in the code below it will give you right result.
    What is the full value of your "Output Registers"? You should have two values in numeric array for this to work.

  • Modbus RTU - Reading Holding registers problem - Novus myPCLab

    Hello,
    I'm trying for a few days to read Holding registers in Novus myPCLab (it uses Modbus RTU protocol). I used both DSC module and Modbus library with no success (it appears to connect correctly but cant read).
    I need to read the given current.
    Does anyone have any idea about what am I doing wrong? 
    Here are my vi and the modbus address.
    Via DSC
    I used the PLC address at "HR Inicial" and 1 at "numero de registros"
    Via library
    I used the PLC address in "starting address"
    Solved!
    Go to Solution.

    My problem now is that my VI doesn't stops after I stop the while loop, it is necessary for a flat sequence implementation.
    Or my other best option is to read and write without closing the Modbus connection. Is that possible with a global variable? 
    I guess I do have to execute this "Modbus VI" to get my variables at a Main VI if they are in the same project. So, can I make my "Modbus VI" works in the background while the Main VI (who reads and write the addresses from the global variable) works, and when I finish running it, they stop together?
    ModBUS VI

  • Modbus tcp read holding registers not returning requested quantity

    Background:  I have a customer using an ELAU motion system - they are recording data to Holding Registers that they want to be able to read on a cRIO to match up with some analog data from FPGA (I have digital handshaking happening for that).
    LabVIEW 2010 SP1
    cRIO 9074
    Using the NI MOdbus.llb VI Library to communicate with the other system.  I can open the TCP communication no problem, and actually get SOME registers, just not ALL of the register data I want to read. 
    What I want to do is read 330 individual holding registers U16 values.  I know how the data is being split to represent various lengths (i.e. most data items are using 2 registers to represent one 32 bit number).  I just want to read all the individual registers and parse the data in another VI to convert it to the other data types.
    I provide the MB Ethernet Master Query (poly).vi with the starting address for the first register and then the quantity of 330.  The polymorphic instance selected the is "Read Holding Registers".  The array returned from this VI via "Holding Registers" is only 74 elements and not 330 requested.  I get no exception codes and no LV errors.  Is there some inherent limit on the number of Holding Registers that can be read?
    I am not using the MBAP Header input (not sure if that is needed).
    Thank you.
    Ryan Vallieu
    Automation System Architect
    Solved!
    Go to Solution.

    Simple solution once I dug into the MODBUS Serial protocol/TCP protocol documentation available out there via Google.
    Serial based modbus history is the limitation that carried over to TCP - the maximum amount of bytes in one data pack can only be 256 bytes.  Thus I was limited to around ~125 registers at once.
    256 bytes = 2048 bits.  Using 16 bit registers that gives 128 registers maximum.  I went with 125 to make keeping track of totals easier.
    Ryan Vallieu
    Automation System Architect

  • Dsc modbus - Serial communication input/holding registers

    Hello,
    I am trying to create a labview application to act as a Modbus master and control multiple stepper motors. I have the DSC module in labview and am using a serial communication with an RS-485 converter. I have followed this guide: http://www.ni.com/white-paper/13911/en/  However, the driver I am using does not support coils, it only uses input and holding registers and I have not found a guide or tutorial that shows me how to create a labview application that can read and write to a specific address. For now all I want to do is turn the motor on and off using labview. I have used a modbus simulator to communicate with the driver and can do everything I want to do through the simulator. I can not get labview to do anything for me. I would be very happy if someone could direct me to a tutorial that can help me understand labview dsc module for reading and writing to addresses using modbus. 
    Meesh

    Ok, so this is really strange. I solved my problem in a round about sort of way. I'm using a modbus simulator (mdbus) to help me communicate with the driver/stepper motor so I know which address to use. But after I use the simulator I get a communication port error when I try to use Labview. It's like the port is locked in with the simulator and I can't end the connection and let Labview use the same communication port. I can't find anyway to fix the problem except going to this NI site: http://www.ni.com/download/labview-run-time-engine-6.1/746/en/  downloading this software and using the "repair" function. Then I can do a system restart and cycle the power on the driver/motor and then Labview with work again through the correct port. But if I need to use the simulator again then I have to go through this whole process again. Does anyone know what the heck is going on? Or if there is a better way to clear the communication port?? 

  • Issue with "read by other session" and a parallel MERGE query

    Hi everyone,
    we have run into an issue with a batch process updating a large table (12 million rows / a few GB, so it's not that large). The process is quite simple - load the 'increment' from a file into a working table (INCREMENT_TABLE) and apply it to the main table using a MERGE. The increment is rather small (usually less than 10k rows), but the MERGE runs for hours (literally) although the execution plan seems quite reasonable (can post it tomorrow, if needed).
    The first thing we've checked is AWR report, and we've noticed this:
    Top 5 Timed Foreground Events
    Event     Waits     Time(s)     Avg wait (ms)     % DB time     Wait Class
    DB CPU           10,086           43.82     
    read by other session     3,968,673     9,179     2     39.88     User I/O
    db file scattered read     1,058,889     2,307     2     10.02     User I/O
    db file sequential read     408,499     600     1     2.61     User I/O
    direct path read     132,430     459     3     1.99     User I/OSo obviously most of the time was consumed by "read by other session" wait event. There were no other queries running at the server, so in this case "other session" actually means "parallel processes" used to execute the same query. The main table (the one that's updated by the batch process) has "PARALLEL DEGREE 4" so Oracle spawns 4 processes.
    I'm not sure how to fix this. I've read a lot of details about "read by other session" but I'm not sure it's the root cause - in the end, when two processes read the same block, it's quite natural that only one does the physical I/O while the other waits. What really seems suspicious is the number of waits - 4 million waits means 4 million blocks, 8kB each. That's about 32GB - the table has about 4GB, and there are less than 10k rows updated. So 32 GB is a bit overkill (OK, there are indexes etc. but still, that's 8x the size of the table).
    So I'm thinking that the buffer cache is too small - one process reads the data into cache, then it's removed and read again. And again ...
    One of the recommendations I've read was to increase the PCTFREE, to eliminate 'hot blocks' - but wouldn't that make the problem even worse (more blocks to read and keep in the cache)? Or am I completely wrong?
    The database is 11gR2, the buffer cache is about 4GB. The storage is a SAN (but I don't think this is the bottleneck - according to the iostat results it performs much better in case of other batch jobs).

    OK, so a bit more details - we've managed to significantly decrease the estimated cost and runtime. All we had to do was a small change in the SQL - instead of
    MERGE /*+ parallel(D DEFAULT)*/ INTO T_NOTUNIFIED_CLIENT D /*+ append */
      USING (SELECT
          FROM TMP_SODW_BB) S
      ON (D.NCLIENT_KEY = S.NCLIENT_KEY AND D.CURRENT_RECORD = 'Y' AND S.DIFF_FLAG IN ('U', 'D'))
      ...(which is the query listed above) we have done this
    MERGE /*+ parallel(D DEFAULT)*/ INTO T_NOTUNIFIED_CLIENT D /*+ append */
      USING (SELECT
          FROM TMP_SODW_BB AND DIFF_FLAG IN ('U', 'D')) S
      ON (D.NCLIENT_KEY = S.NCLIENT_KEY AND D.CURRENT_RECORD = 'Y')
      ...i.e. we have moved the condition from the MERGE ON clause to the SELECT. And suddenly, the execution plan is this
    OPERATION                           OBJECT_NAME             OPTIONS             COST
    MERGE STATEMENT                                                                 239
      MERGE                             T_NOTUNIFIED_CLIENT
        PX COORDINATOR
          PX SEND                       :TQ10000                QC (RANDOM)         239
            VIEW
              NESTED LOOPS                                      OUTER               239
                PX BLOCK                                        ITERATOR
                  TABLE ACCESS          TMP_SODW_BB             FULL                2
                    Filter Predicates
                      OR
                        DIFF_FLAG='D'
                        DIFF_FLAG='U'
                  TABLE ACCESS          T_NOTUNIFIED_CLIENT       BY INDEX ROWID    3
                    INDEX               AK_UQ_NOTUNIF_T_NOTUNI    RANGE SCAN        2
                      Access Predicates
                        AND
                          D.NCLIENT_KEY(+)=NCLIENT_KEY
                          D.CURRENT_RECORD(+)='Y'
                      Filter Predicates
                        D.CURRENT_RECORD(+)='Y' Yes, I know the queries are not exactly the same - but we can fix that. The point is that the TMP_SODW_BB table contains 1639 rows in total, and 284 of them match the moved 'IN' condition. Even if we remove the condition altogether (i.e. 1639 rows have to be merged), the execution plan does not change (the cost increases to about 1300, which is proportional to the number of rows).
    But with the original IN condition (that turns into an OR combination of predicates) in the MERGE ON clausule, the cost suddenly skyrockets to 990.000 and it's damn slow. It seems like a problem with cost estimation, because once we remove one of the values (so there's only one value in the IN clausule), it works fine again. So I guess it's a planner/estimator issue ...

  • Issue with reading emails state.

    Dear community,
    in my company, we have BB to bring a very good 24hrs service to our customer, but the thing is that we started to have an issue with our BB and the Microsoft Office 365 and Exchange service.
    We have BlackBerry Enterprise service activated on each blackberry, so we receive every email in our BBs.
    But, when we read an email, after you go back to the mailbox, it appears as un-read again. Then, if you read it again, and go back to the mailbox, it appears as read.
    DO you know why it's happening?.
    Thanks in advance,

    Hi,
    Use TRY & CATCH statements before OPEN DATASET...
    For exact syntax check F1 help on try & catch...
    TRY.
      CATCH.
        OPEN DATASET..
      endcatch.
    endtry.
    Hope it helps!!
    Rgds,
    Pavan

  • How can I download my issues with Reader's Digest when each time a pop appears and reads " the item you tried to buy is no longer available"?

    I can no longer download my purchased Reader's Digest magazine since August as it requires updating the RD app. So when i try to download the RD app a pop up appears and reads " the item you tried to buy is no longer available". What does this mean and what do I do? I have 2 pending reader's digest issues that needs to be downloaded.

    I don't have an answer for you but it may help to have a look at the "More Like This" section at the far right of this page. Reading those additional threads may get you some idea of the actual issue and how to resolve it. It could be that problems were found with the app and it was temporarily pulled for some reason which may be the reason for the "the item you tried to buy is no longer available" message.

  • Mac / Adobe Compatibility Issues with Reader X1 & Acrobat X1

    I'm using Acrobat X1  11.0.10 and Reader 11.0.10 with Mac OS X ( 10.8.5).
    In Reader, when I click the "show next page" down arrow, it takes around 5 seconds to jump to the next page. (scrolling to the next page via the scroll bar works fine).
    In Acrobat, when I use the text edit tools, it can take up to 10 seconds before I can edit a word (remove or add a letter).Oftentimes, Acrobat will highlight the whole paragraph rather than just the word I select. (I think this is due to the lag time.) When I backspace to remove a word, nothing happens ... for several seconds. Then letters begin disappearing.
    I reverted from Mavericks and Yosemite back to Lion (or Mountain Lion - I forget what they called 10.8.5) in the hopes of fixing this issue. When I say reverted back. I did a full install. Wiped the hard drive, loaded 10.8.5 and started this Mac as if it were new.
    Is there a version of Reader and Acrobat that work with Mac OS X ( 10.8.5)?

    Hi,
    Acrobat 11 is compatible with MAC 10.8.5. So, there are no compatibility issues.
    Please let me know if this happens with every PDF or some specific one?
    If specific, then please tell me what is the size of your PDF file.
    You might also try repairing Acrobat from the Help menu.
    Regards,
    Anubha

  • Issue with reading a xml file from xsl

    Hi,
    When I am trying to read a xml file from xsl, I am getting unwanted output.
    Following is the XSL:
    <?xml version="1.0" encoding="UTF-8" ?>
    <?oracle-xsl-mapper
      <!-- SPECIFICATION OF MAP SOURCES AND TARGETS, DO NOT MODIFY. -->
      <mapSources>
        <source type="XSD">
          <schema location="../xsd/B2BMarketProperties.xsd"/>
          <rootElement name="ReceipentIDType" namespace="http://www.example.org"/>
        </source>
      </mapSources>
      <mapTargets>
        <target type="XSD">
          <schema location="../xsd/B2BMarketProperties.xsd"/>
          <rootElement name="ReceipentIDType" namespace="http://www.example.org"/>
        </target>
      </mapTargets>
      <!-- GENERATED BY ORACLE XSL MAPPER 11.1.1.4.0(build 110106.1932.5682) AT [TUE DEC 03 16:06:03 EST 2013]. -->
    ?>
    <xsl:stylesheet version="1.0"
                    xmlns:bpws="http://schemas.xmlsoap.org/ws/2003/03/business-process/"
                    xmlns:xp20="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.Xpath20"
                    xmlns:mhdr="http://www.oracle.com/XSL/Transform/java/oracle.tip.mediator.service.common.functions.MediatorExtnFunction"
                    xmlns:bpel="http://docs.oasis-open.org/wsbpel/2.0/process/executable"
                    xmlns:oraext="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.ExtFunc"
                    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                    xmlns:ns0="http://www.example.org"
                    xmlns:dvm="http://www.oracle.com/XSL/Transform/java/oracle.tip.dvm.LookupValue"
                    xmlns:hwf="http://xmlns.oracle.com/bpel/workflow/xpath"
                    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                    xmlns:med="http://schemas.oracle.com/mediator/xpath"
                    xmlns:ids="http://xmlns.oracle.com/bpel/services/IdentityService/xpath"
                    xmlns:bpm="http://xmlns.oracle.com/bpmn20/extensions"
                    xmlns:xdk="http://schemas.oracle.com/bpel/extension/xpath/function/xdk"
                    xmlns:xref="http://www.oracle.com/XSL/Transform/java/oracle.tip.xref.xpath.XRefXPathFunctions"
                    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
                    xmlns:ora="http://schemas.oracle.com/xpath/extension"
                    xmlns:socket="http://www.oracle.com/XSL/Transform/java/oracle.tip.adapter.socket.ProtocolTranslator"
                    xmlns:ldap="http://schemas.oracle.com/xpath/extension/ldap"
                    exclude-result-prefixes="xsi xsl ns0 xsd bpws xp20 mhdr bpel oraext dvm hwf med ids bpm xdk xref ora socket ldap">
      <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
      <xsl:variable name="ReceipentID" select="document('../xsd/B2BMarketProperties.xml')"/>
      <xsl:template match="/">
        <ns0:ReceipentIDType>
        <xsl:for-each select="$ReceipentID">
          <ns0:ReceipentID>
            <xsl:value-of select="$ReceipentID"/>
          </ns0:ReceipentID>
          </xsl:for-each>
        </ns0:ReceipentIDType>
      </xsl:template>
    </xsl:stylesheet>
    Following is the XML ( B2BMarketProperties.xml)
    <?xml version="1.0" encoding="UTF-8" ?>
    <ReceipentIDType xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                     xsi:schemaLocation="http://www.example.org B2BMarketProperties.xsd"
                     xmlns="http://www.example.org">
      <ReceipentID>123</ReceipentID>
      <ReceipentID>345</ReceipentID>
    </ReceipentIDType>
    The output i am getting with this code is
    <?xml version="1.0" encoding="UTF-8"?>
    <ns0:ReceipentIDType xmlns:ns0="http://www.example.org">
        <ns0:ReceipentID>123345</ns0:ReceipentID>
    </ns0:ReceipentIDType>
    But, I need output in the following format
    <ns0:ReceipentIDType xmlns:ns0="http://www.example.org">
        <ns0:ReceipentID>123</ns0:ReceipentID>
         <ns0:ReceipentID>345</ns0:ReceipentID>
    </ns0:ReceipentIDType>
    Could you guys let me know what i am doing wrong. Any help would be appreciated.
    Thanks,

    This worked for me :
      <xsl:template match="/">
        <ns0:ReceipentIDType>
          <xsl:for-each select="document('B2BMarketProperties.xml')/*:ReceipentIDType/*:ReceipentID">
            <xsl:variable name="count" select="position()"/>
            <ns0:ReceipentID>
              <xsl:value-of select="document('B2BMarketProperties.xml')/*:ReceipentIDType/*:ReceipentID[$count]"/>
            </ns0:ReceipentID>
          </xsl:for-each>
        </ns0:ReceipentIDType>
      </xsl:template>

  • Issue with reading attachment in sender mail adapter

    Hi, I am working on Email to file scenario, where I have to connect to exchange server and take the attachment of the email (xml file) and save it on to PI server. I have configured sender mail communication channel with following details:
    Protocol: POP3
    Message protocol: XIPAYLOAD
    Mail attributes: keep attachments
    Module:
    1     localejbs/AF_Modules/PayloadSwapBean     Local Enterprise Bean     1
    2     localejbs/sap.com/com.sap.aii.adapter.mail.app/XIMailAdapterBean     Local Enterprise Bean     mail
    1     swap.keyName     Content-Description
    1     swap.keyName     Content-Description
    1     swap.keyValue     attachment,filename="MailAttachment-1.xml"
    1     swap.keyValue     MailAttachment-1
    Also, configured receiver file adapter.
    Since I donu2019t have to read mail content , I havenu2019t created any design components in ESR. I have just refrred to dummy namespace, interface (both sender and receiver). in receiver determination, interface determination, sender agreement and receiver agreements.
    It was working fine, not sure what changes happened. Now I could see the attachment payload in message monitor.
    Under Inbound message->payloads->
    MailMessage ( text/xml;charset=utf-8 )
    MailAttachment-1 ( text/xml;name="****************")
    But the fille that is getting created doesnu2019t have the contents of the attachment (xml file) .  It has some other information, shown below:
    Directory:  ******
    Name:       ********.xml
          =NextPart_002_01CB2C5B.B033B325#
    content-type:text/plain;charset="us-ascii"#
    content-length:30#
    content-transfer-encoding:quoted-printable#
    <<**********.xml>>=20#
          =NextPart_002_01CB2C5B.B033B325#
    content-type:text/html;charset="us-ascii"#
    content-length:#
    content-transfer-encoding:quoted-printable#
          =NextPart_002_01CB2C5B.B033B325  #
    Can you please let me know what is going wrong here.

    using following parameters in module resolved my problem:
    MOdule name                                                                           Type                                                            Module Key
    AF_Modules/PayloadSwapBean                                            Local Enterprise Bean                                      transform sap.com/com.sap.aii.adapter.mail.app/XIMailAdapterBean     Local Enterprise Bean                                      mail
    Module Key                                    Parameter Name                              Parameter value
    transform                                        swap.keyName                                Payload-Name
    transform                                        swap.keyName                                 MailAttachment-1

  • Issue with read statement with one more key missing in mapping

    Hi All ,
    I have such data in two internals table :
    IT_bdc
    vbeln            posnr
    90000593     10
    90000576     10
    90000672     10
    90000672     20
    90000672     30
    it_konv
    kbetr          vbeln
    6250          90000576
    12160000          90000593
    500000          90000672
    600000          90000672
    700000          90000672
    My current program statement is :
    LOOP AT it_bdc.
    READ TABLE it_konv WITH KEY
          vbeln = it_bdocs-vbeln.
      currency =   it_konv-waers.
    endloop.
    as you can see the posnr is missing in it_konv how can i modify this read statement so
    that vbeln posnr from it_bdc should get correct kbetr from it_konv.
    Kindly help in this mapping.

    Hi
    sort it_konv by vbeln
    then
    loop at it_bdc.
    read table it_konv with key vbeln = it_bdc-vbeln binary search.
    if sy-subrc = 0.
    perform your logic/task.
    endif.
    endloop.
    also it depends what you want to do after reading it_konv.
    in my logic if there is a vbeln in it_konv which s present in it_bdc then sy-subrc will be 0
    and you can perform your logic.
    and if there will be no matching vbeln in it_konv then sy-subrc will not be 0.
    check the values in debugging.
    Thanks
    Lalit

  • Issue with reading XLSX with multiple sheets file in application Server

    Hi,
    We're currently implementing SAP CRM 7.40.
    In one requirement we have to process an XLSX file and load its information to a set of Z tables.
    The file has 6 sheets of data to process, each sheet with distinct number of columns and types (each sheet will be upload to a different Z table).
    We're able to process the XLSX using the Desktop Office integration for local files.
    However, we must also be able to process files on the application server.
    We tried the following approaches without success
    - The DOI library doesn't seem to support remote files processing:
    - OPEN DATASET. with the dataset we're able to read a remote file, however since the file format is XLSX, the information we read in the dataset comes in an unreadable format
    - FTP. we tried to use FTP to download the remote file to a local folder so that we could then use the DOI library to process the file. However, the client only allows SFTP connections and SAPFTP doesn't provide SFTP
    There's another approache we're considering to try which is to have a perl script on the application server to split the Excel file into CSV files (one for each tab) and then use OPEN DATASET to read the contents of each file and work from there. This approach seems quite cumbersom
    The approach with DOI would be the best one but either we're missing a key configuration or it truly can't be used for files. Are there any special requirements that we should take into account for this option?
    We'd like to know if you have any other approach that proves successfull or if any of the above can work but with some aditional adjustments.
    Thanks in advance.
    Best regards.

    Hello Ricardo,
    Go through below link.
    to read Excel file from the application server in a BACKGROUND process
    You can try below approach if it is feasible for you.
    Turning ".XLSX" into XML & read XML file through application.
    XLSX Upload - a Unified Approach - SCN - SAP.com
    Thanks!
    Sameer

  • Issue with Read only VO Query bind parameters

    Hi Experts,
    Working in Jdev 11.1.1.3.0
    I am face one issue, probably its very common to all of us, bcoz i to do the same thing in N number of times.
    Issue:
    select count(*) as cnt from emp
    where
    ((:BindEmpId is NOT NULL AND EMP_ID = :BindEmpId) AND
    (DEPT_ID IS NULL OR DEPT_ID =: BindDeptId));
    when i run this query its giving correct result(count is 0) but usually i written like
    select count(*) as cnt from emp
    where
    ((:BindEmpId is NOT NULL AND EMP_ID = :BindEmpId) AND
    (BindDeptId IS NULL OR DEPT_ID =: BindDeptId));
    this time its giving count is 1, which is wrong.
    Data in data base:
    ID     DeptID     value EmpID
    226     1519     jh 601     
    So which one is correct?

    Well, the two select statements are for different use cases and we can't decide which is the correct one as we don't know the use case.
    Your data looks like
    ID   DeptID value EmpID
    226  1519   jh    601 There are some decisions we can't make with only one row in the table. We don't know if DepIt can be null in the table and/or EmpId can be null. This information is vital for your select statements.
    Next we don't know how you want to handle the query if one or both bind parameters are null.
    Should the query return 0 in this case or should the query just omit the part of the query if the bind variable is null (and then return the result found with the remaining query)?
    We can't possible answer this.
    You need to provide more information...
    Timo

  • Issue with Reading data with FOR EACH LOOP.

    Hi Guys,
    Scenario
    We Plan Sales of an Article on a half years(fiscal variant MQ with 2 periods of half year each). We also plan the
    number of Weeks in Sales as a Key figure.  The cummulative Sales for two half years in then distributed to number of weeks for which the Article is sold (0CALWEEK)
    In another Cube we plan a distribution profile. This cube contains just three elements.
    Characteristic = ZPROFILE
    TIme Char = 0CALWEEK
    Keyfigure = ZDIST
    (Note : You will notice The distribution profile is not stored per Article here)
    The logic of distribution is :
    1.  Sales of Article is cummulated for 1 years ( eg. for periods 001.2010 & 002.2010 )
    2.  Find the number of weeks in Sales for this Article ( eg. 14 weeks. ) [Technically we store this value on the first fiscal
    period. In our example it is stored in 001.2010
    3.  User choose a distribution profile in a variable ( e.g ZH55 )
    4   ZDIST is summed for number of Sale Weeks for this Article. in our case it is14 weeks.
    5. Distribution = Sales of Article (WEEK N) = [Sales Cummulated for 1 year] * [ZDIST(Week N) / ZDIST(sum of 24 weeks)]
    This loop is run 14 times. (N from 201001 to 201014.)
    TECHICAL DETAILS
    Cube 1 (0CM_SKU = Material, 0CPBAINSABU = SALES key figure, WEEKINSALE = Number of weeks for which Material will be
    sold). The Sales Planned data is stored as # for 0CALWEEK.
    0CM_SKU/0CALWEEK/0FISCPER/0FISCVARNT/0CPBAINSABU--/WEEKINSALE
    SHIRT/000000/2010001/ZP/100EUR--/24
    SHIRT/000000/2010002/ZP/200EUR--/00
    PANTS/000000/2010001/ZP/300EUR--/35
    PANTS/000000/2010002/ZP/200EUR--/00
    CUBE 2 ( the profile data is stored here )
    ZPROFILE/0CALWEEK/ZDIST
    ZH55/201001/10
    ZH55/201002/12
    ZH55/201003/8
    ZH55/201004/11
    ZH55/201005/10
    ..so on.
    9:11 PM
    Edited by: Dheeraj Gupta on Apr 5, 2010 9:20 PM

    My Sample CODE IS BELOW.
    DATA CW1 TYPE 0CALWEEK.
    DATA CW2 TYPE 0CALWEEK.
    DATA PER1 TYPE 0FISCPER.
    DATA PER2 TYPE 0FISCPER.
    DATA FVAR TYPE 0FISCVARNT.
    DATA PROV1 TYPE 0INFOPROV.
    DATA PROV2 TYPE 0INFOPROV.
    DATA SKU TYPE 0CM_SKU.
    DATA DPROF TYPE ZPROFILE.
    DATA CUMSALES TYPE F.
    DATA TEMP TYPE F.
    DATA PRO TYPE F.
    DATA COUNT TYPE I.
    *I WILL READ THE PROFILE VALUE FROM VARIABLE IN ACTUAL PROGRAM.
    HARDCODED FOR TEST PURPOSES. 
    DPROF = 'ZH55'.
    *FISCAL YR VARIANT
    FVAR = 'MQ'.
    *HARDCODED FOR TEST PURPOSES. 
    PER1 = 2010001.
    PER2 = TMVL(PER1, 1, FVAR).
    *CUBE FOR SALES
    PROV1 = 'ZCLARK'.
    *CUBE FOR PROFILE
    PROV2 = 'C_ZCLARK'.
    FOREACH SKU.
    *SUM UP SALES FOR ONE YEAR
    *Operand:{Key figure name, 0CALWEEK, 0CM_SKU, 0FISCPER, 0FISCVARNT, 0INFOPROV, ZPROFILE}
    CUMSALES = CUMSALES + {0CPBAINSABU,#,SKU,PER1, FVAR,PROV1,#} + {0CPBAINSABU,#,SKU,PER2, FVAR,PROV1,#}.
    *READ NUMBER OF WEEKS OF SALES
    COUNT = {ZNWEEK,#,SKU,PER1, FVAR,PROV1,#}.
    *HARDCODED FOR TEST PURPOSES. 
    Starting week of distrbution is first week of the year
    CW2 = 201001.
    CW1 = 201001.
    *HELP NEEDED HERE ***********
    *NOT ABLE TO READ THIS PROFILE DATA
    DO COUNT TIMES.
       PRO = PRO + {ZPROF,CW2,#,#,#,PROV2,ZPROFILE}.
       CW2 = TMVL(CW2, 1).
    ENDDO.
    DO COUNT TIMES.
    {0CPBAINSABU,CW1,SKU,#, #,PROV1,#} = CUMSALES * {ZPROF,CW1,#,#, #,PROV2,ZPROFILE} / PRO.
    CW1 = TMVL(CW1, 1).
    ENDDO.
    *RESET
    CUMSALES = 0.
    ENDFOR.

Maybe you are looking for

  • Public IP address requirerement for a Public facing SharePoint 2013 website.

    I am planning to implement a public facing website on SharePoint 2013 platform. Following are the proposed server setup. 2 x Web Front End (WFE) hosting SharePoint 2013 (Load Balanced) 2 x  Search and Application server hosting SharePoint 2013 (Load

  • What's wrong with my laptop? It keeps loading and turning off

    My laptop suddenly shut off while I was using I for almost the whole day (which I usually do every day). It felt hot so I had it turned off for 2 hours. I tried to turn it on again but it loads for a while, and then shuts off. I had it rest for almos

  • Problem in mapping from  import manager  to Data manager

    hi friend's....I got a problem while mapping the data from import manager  to Data manager .The problem is the data in import manager (i.e source hierarchy) will map to single filed in data manager ( i.e target hierarchy).. Help me it will be great f

  • FIFO Problem

    Hi Guys, I am currently trying to acquire voltage and current measurement data from an Analog Input Module 9201. The intention is to sample at 20kHz. I am using a Compact RIO 9022 with a 9113 chassis. I know I need to create a FIFO as a buffer betwee

  • Skipping changes in Streams

    We're using CDC (built on Streams from what I can tell) to replicate changes from OLTP system to a data warehouse. There is a need to correct a value in a column as a mass update which will affect many rows, but we don't want to send those changes to