Efficient Way to calculate percentage value

Hi all
I need to calculate x % of y using ABAP coding .
I am not sure what code i can use..can anyone
help me ?

You can just use normal calculation, like X divide by Y times 100.  or ues the function within query. 
Good Luck,
CL

Similar Messages

  • Efficient way to modify control values?

    Hello,
    I have been using LabVIEW somewhat casually at work for the past couple of years, and have read at least a few times that there is usually a better way than using Local Variables.
    In this case I have a setup file with ten different numeric controls for various power levels and frequencies. By choosing from a text ring I want to automatically fill in the "default" values for these numeric controls for each given value of the text ring.
    The way I have this implemented now is I just have a case structure with multiple values. Based on the chosen value in the text ring I load ten constants into the ten local variable references.
    Is there an easier/more efficient way to do this?
    Thanks,
    Steven
    Solved!
    Go to Solution.

    To me this seems to be 'the' valid approach.
    References can offer more flexebility, but suffer from worse performance. Performance won't be an issue for 10 numerics, only if you have somwhat larger arrays (a typical graph with 100 points you can notice the performance loss).
    Only a terminal is faster than the local (assuming that you need to display the value, otherwise of course just use a wire). Some exotic usage of Control Val Set invoke note has shown a very good perormance, but I think this is a bit over-coded for just initializing controls.
    Felix
    www.aescusoft.de
    My latest community nugget on producer/consumer design
    My current blog: A journey through uml

  • [11g] most efficient way to calculate size of xmltype type column

    I need to check the current size of some xmltype column in a BIU trigger.
    I don't think it's good to use
      length(:new.xml_data.GetStringVal());
    or
      dbms_lob.GetLength(:new.xml_data.GetClobVal());
    What's the most efficient way to get the storage size?
    I don't need the string serialized size.
    It could also be the internal storage size (incl. administration data overhead).
    - thanks!
    regards,
    Frank

    > May I ask for what reason you need to know it?
    I need to handle very large XML document output, which currently hits the internal xmltype limitation of 4GByte, when aggregating XML document fragments for this.
    > You'll get a relevant answer if you give us relevant information :
    > - exact db version
    SELECT * FROM PRODUCT_COMPONENT_VERSION;
    product
    version
    status
    1
    NLSRTL
    11.2.0.3.0
    Production
    2
    Oracle Database 11g Enterprise Edition
    11.2.0.3.0
    64bit Production
    3
    PL/SQL
    11.2.0.3.0
    Production
    4
    TNS for Linux:
    11.2.0.3.0
    Production
    > - DDL of your table
    > XML stored as XMLType datatype can use different storage models, depending on the version.
    I don't use dedicated storage clause.
    But i am hitting the problem already for aggregation into some xmltype variable in PL/SQL
    - BEFORE writing back to a result table.
    Can i avoid such problems, when writing to a table DIRECTLY w/o intermediate xmltype PL/SQL variable
    - depending on the storage clause?
    The reason why asking how to get the size of some xmltype (in table column and/or in PL/SQL variable) is, that i am thinking of a threshold detection.
    In case threshold is reached: outsource XML fragment so far to some separate CLOB storage, and insert a smaller meta-information reference representing that in the output document.
    Finally leave up to the client system to use <xs:include> (or alike) to construct the complete document.
    rgds,
    Frank

  • A more efficient way to assure that a string value contains only numbers?

    Hi ,
    I'm using Oracle 9.2.0.6.
    I was curious to know if there was any way I could write a more efficient query to determine if a string value contains only numbers.
    Here's my current query. This SQL is from a sub query in a Join clause.
    select distinct cta.CUSTOMER_TRX_ID, to_number(cta.SALES_ORDER) SALES_ORDER
                from ra_customer_trx_lines_all cta
                where length(cta.SALES_ORDER) = 6
                and cta.SALES_ORDER is not null
                and substr(cta.SALES_ORDER,1,1) in('1','2','3','4','5','6','7','8','9','0')
                and substr(cta.SALES_ORDER,2,1) in('1','2','3','4','5','6','7','8','9','0')
                and substr(cta.SALES_ORDER,3,1) in('1','2','3','4','5','6','7','8','9','0')
                and substr(cta.SALES_ORDER,4,1) in('1','2','3','4','5','6','7','8','9','0')
                and substr(cta.SALES_ORDER,5,1) in('1','2','3','4','5','6','7','8','9','0')
                and substr(cta.SALES_ORDER,6,1) in('1','2','3','4','5','6','7','8','9','0')This is a string where I'm finding A-Z-a-z characters and '/' and '-' characters in all 6 positions, plus there are values that are longer than 6 characters. That's what the length(cta.SALES_ORDER) = 6 is for. Also, of course. some cells are NULL.
    So the question is, is there a more efficient way to screen out only the values in this field that are 6 character numbers or is what I have the best I can do?
    Thanks,

    I appreciate all of your very helpfull workarounds. The cost is a little better in all cases than my original where clause.
    To address the discussion that's popped up about design from this question, I can say a few things that should clear , at least, my situation up.
    First of all this custom quoting , purchase order , and sales order entry system WAS written by a bunch a of 'bad' coders who didn't document their work and then left. We don't even have an ER diagram
    The whole project that I'm only a small part of is literally trying to put Humpty Dumpty together again and then move it from a bad custom solution into Oracle Applications.
    We're rebuilding, documenting, and doing ETL. This is one of your prototypical projects from hell.
    It's a huge database project so we're taking small bites as a time. Hopefully, somewhere right before Armageddon hits, this thing will be complete.
    But until then,..., well,..., you know the drill.
    Thanks Again.

  • How to get the max value of a set of percentage values?

    Hi,
    I've tried to get the max and min value of a set of calculated percentage values. Such as
    Jan Feb March Apr May Jun    Min  Average   Max
    0,5 0,8  1,1      0,4 1      0,6     0,4   0,7         1,1
    The average value works fine. But with "min" and "max" I have a problem.
    I've tried to get the value with the following ways:
    - Create a new calc. keyfigure and make a sum of all values: (Jan + Feb + ...) and set the calculation in key figure properties to Min/Max.
    - Create a new calc. keyfigure and make a sum of all values and set the aggregation to Min/Max
    - Create a selected keyfigure with a filter to the necessary periods and set a calculation to Min (Aggregation is not possible here)
    - Create a new cal. keyfigure with all periods and the function Min. e.g. min(Jan, (min Feb, (min (....)
    None of this solutions provides the right min and max value. When I use an amount value (e.g. Euro) instead of these percentage values the keyfigure with the min and max function works. The others all provide wrong values.
    Is there a solution to get the right min and max value???
    It would be a great help when you have any hints.
    Thanks
    Claudia

    Hi Aduri,
    thanks for your answer but your solution doesn't work.
    The problem is that the periods are defined in a structure with offsets such as
    - period-11
    - period-10
    - period
    in this structure elements there is also the keyfigure "netvalue" defined.
    In the rows of the report there is another characteristic such as company code.
    Is there a solution to find the max and min values of the period values for each company code? Or must I change the data model e.g. copy the keyfigure and make a new keyfigure with another aggregation level?
    Thanks for any hints!
    Claudia

  • Most efficient way to track 3 states?

    In a program I am writing, I have an object with three states, which it progresses through during the corse of the program. Since the program uses a lot of these objects (potentially) I want to keep the size of them down. Here's the issue. How to store what state the object is in? a boolean won't work, of corse, since there are three states. So here's what I can up with:
    Either a Boolean (initial state is null, then false, then true)
    or a byte (any three values would work)
    I have a feeling that the byte is more efficient, but want to make sure. Also, if I'm missing an easy, efficient way to do this, tell me.

    Nearly there:
    <code>
    public abstract class State {
    abstract void handleState();
    abstract int getState();
    public class State1 extends State {
    void handleState() {
    //do state 1 specific stuff
    int getState() {
    return 1;
    public class State2 extends State {
    void handleState() {
    //do state 2 specific stuff
    int getState() {
    return 2;
    public class State3 extends State {
    void handleState() {
    //do state 3 specific stuff
    int getState() {
    return 3;
    public class StateController {
    private State currentState = new State1();
    public int getState() {
    return currentState.getState();
    public void handleState() {
    currentState.handleState();
    </code>
    might work ;)
    As to booleans... no they cannot be null actually... they are represented by a bit which is 0 or 1 (or if you prefer true of false).
    Boolean b = null;
    is not a null boolean, it is an uninitialised object.
    If you need an Object that you want to be a boolean then it is fine to use the Boolean class :)
    The reason boolean b: b == null doesn't compile is because you cannot compare different types.

  • Most efficient way to do some string manipulation

    Greetings,
    I need to cleanse some data in a string by replacing unsafe characters with encoded equivalents. (FYI, this is for the purpose of transforming "unsafe" characters into encoded values as data inside an XML document).
    The following code accomplishes the task:
    Note that a string "currentValue" contains the data to be cleansed.
    A string, "encodedValue" contains the result.
      for (counter = 0; counter < currentValue.length(); counter++)
        addChar = (currentValue.substring(counter,counter+1));
        if (addChar.equals("<"))
          addChar = "#60;";
        if (addChar.equals(">"))
          addChar = "#62;";
        if (addChar.equals("="))
          addChar = "#61;";
        if (addChar.equals("\""))
          addChar = "#34;";
        if (addChar.equals("'"))
          addChar = "#39;";
        if (addChar.equals("'"))
          addChar = "#39;";
        if (addChar.equals("/"))
          addChar = "#47;";
        if (addChar.equals("\\"))
          addChar = "#92;";
        encodedValue += addChar;
      } // forI'm sure there is a way to make this more efficient. I'm not exactly "new" to java, but I am learning on my own with no formal training and often take a "brute force" approach with my initial effort.
    What would be the most efficient way to re-do the above?
    TIA,
    --Paul Galvin
    Integrated Systems & Services Group

    im a c++ programmer so im not totally up on these java classes either but...from a c++ stand point you might want to consider using the if else statment.
    by using if else, you only test the character until you find the actual "violating" character and skip the rest of the tests.
    also, you might trying using something to check for alphaNumeric cases first and use the continue keyword when you find one. since more of your characters are probably safe than unsafe you can skip all the ifs/if else statement and only do one test on the good characters. (i just looked for a way to test that and i didnt find one. c++ has a function that does that by checking the ascii number range. dont think that works in java. but maybe you can find one, it would reduce the number of tests probably.)
    happy hunting,
    txjump :)

  • Most Efficient Way to Populate My Column?

    I have several very large tables, some of them are partitioned tables.
    I want to populate every row of one column in each of these tables with the same value.
    1.] What's the most efficient way to do this given that I cannot make the table unavailable to the users during this operation?
    I mean, if I were to simply do:
    update <table> set <column>=<value>;
    then I think I'll lock every row for writing by others until the commit. I figured there might be another way that makes better sense in my case.
    2.] Are there any optimizer hints I might be able to take advantage of here? I don't use hints much but with such a long running operation I'll take any help I can get.
    Thank you

    1. May be a better solution exists.
    Since you do not want to lock the table...
    Save the ROWID's of all the rows in that table in a temporary table.
    Write a routine which will loop through this temporary table and use the ROWID to update the main table and issue commit at regular intervals.
    However, this does not take into account the rows that would be added to main table after the temporary table has been created.
    2. Not that I am aware of.

  • Most efficient way to consume log files

    Hello everyone,
    I've been absent from the forums for awhile but I'm back at it now... 
    I have a question about the most efficient way to consume log files.  I read in Powershell in action, by Bruce Payette that using a switch statement with a regex worked pretty well, that being said I haven't tried it yet. Select-string is working pretty
    well for me but I have about 10 different entry types that I need to search logs for every 5 minutes and I'm scanning about 15 GB of logs at every interval.  Anyway, if anyone has information about how to do something like that as quickly as possible
    I'd appreciate it.
    1.  piping log files that meet my criteria to select-string
       - This seems to work well but I don't like searching the same files over and over again
    2. running logs through get-content and then building a filter statement
      - This is ok but it seems to use up a fair bit of memory
    3. Some other approach that I haven't thought of yet.
    Anyway, I know this is a relatively nebulous question, sorry about that.  I'm hoping that someone on here knows a really good way to find strings in logs files quickly.
    Hope that helps! Jason

    You can sometimes squeeze out more speed at the expense of memory usage, but filters are pretty fast. I don't see a benefit to holding the whole file in memory, in this case.
    As I mentioned earlier, though, C# code will usually blow PowerShell away in terms of execution time.  Here's a rewrite of what I just did (just for the INI Section pattern, to keep the post size down):
    $string = @'
    #Comment Line
    [Ini-Style Section Line]
    Key = Value Line
    192.168.0.1 localhost
    Some line that doesn't match anything.
    Set-Content -Path .\test.txt -Value $string
    Add-Type -TypeDefinition @'
    using System;
    using System.Text.RegularExpressions;
    using System.Collections;
    using System.IO;
    public interface ILineParser
    object ParseLine(string line);
    public class IniSection
    public string Section;
    public class IniSectionParser : ILineParser
    public object ParseLine(string line)
    object o = null;
    Match match = Regex.Match(line, @"^\s*\[([^\]]+)\]\s*$");
    if (match.Success)
    o = new IniSection() { Section = match.Groups[1].Value };
    return o;
    public class LogParser
    public static IEnumerable ParseFile(string fileName, ILineParser[] lineParsers)
    using (StreamReader sr = File.OpenText(fileName))
    string line;
    while ((line = sr.ReadLine()) != null)
    foreach (ILineParser parser in lineParsers)
    object result = parser.ParseLine(line);
    if (result != null)
    yield return result;
    $parsers = @(
    New-Object IniSectionParser
    $results = [LogParser]::ParseFile("$pwd\test.txt", $parsers)
    $results
    Instead of defining separate classes for each type of line and output object, you could probably do something more generic with delegates (similar to how I used ScriptBlock.Invoke() in the PowerShell example), but it might sacrifice some speed to do so.

  • Efficient Way of Inserting records into multiple tables

    Hello everyone,
    Im creating an employee application using struts framework. One of the functions of the application is to create new employees. This will involve using one web form. Upon submitting this form, a record will be inserted into two separate tables. Im using a JavaBean (Not given here) between the JSP page and the Java file (Which is partly given below). Now this Java file does work (i.e. it does insert a record into two seperate tables).
    My question is, is there a more efficient way of doing the insert into multiple tables (in terms of performance) rather than the way I've done it as shown below? Please note, I am using database pooling and MySQL db. I thought about Batch processing but was having problems writing the code for it below.
    Any help would be appreciated.
    Assad
    package com.erp.ems.db;
    import com.erp.ems.entity.Employee;
    import java.sql.Connection;
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.util.Collection;
    import java.util.ArrayList;
    public class EmployeeDAO {
         private Connection con;
         public EmployeeDAO(Connection con) {
              this.con = con;
         // METHOD FOR CREATING (INSERTING) A NEW EMPLOYEE
         public void create(Employee employee) throws CreateException {
              PreparedStatement psemployee = null;
              PreparedStatement psscheduleresource = null;
              String sqlemployee = "INSERT INTO employee (FIRSTNAME,SURNAME,GENDER) VALUES (?,?,?)";
              String sqlscheduleresource = "INSERT INTO scheduleresource (ITBCRATE,SKILLS) VALUES (?,?)";
              try {
                   if (con.isClosed()) {
                        throw new IllegalStateException("error.unexpected");
                            // Insert into employee table
                   psemployee = con.prepareStatement(sqlemployee);
                   psemployee.setString(1,employee.getFirstName());
                   psemployee.setString(2,employee.getSurname());
                   psemployee.setString(3,employee.getGender());
                            // Insert into scheduleresource table
                   psscheduleresource = con.prepareStatement(sqlscheduleresource);
                   psscheduleresource.setDouble(1,employee.getItbcRate());
                   psscheduleresource.setString(2,employee.getSkills());
                   if (psemployee.executeUpdate() != 1 && psscheduleresource.executeUpdate() != 1) {
                        throw new CreateException("error.create.employee");
              } catch (SQLException e) {
                   e.printStackTrace();
                   throw new RuntimeException("error.unexpected");
              } finally {
                   try {
                        if (psemployee != null && psscheduleresource != null)
                             psemployee.close();
                             psscheduleresource.close();
                   } catch (SQLException e) {
                        e.printStackTrace();
                        throw new RuntimeException("error.unexpected");
         }

    Hi ,
    U can use
    set Auto Commit function here ..
    let it be false first
    and when u do with u r all queries ..
    make it true
    this function take boolean values
    i e helful when u want record to be inserted in all or not at all..
    Hope it helps

  • Efficient way of updating data to database table

    what is the efficient way of updating data to database table  .
    i have huge amount of data in my internal table  , how to use update statement in this case .
    1. database table having 20 fields  ,
    2. one is key field and suppose 20 th field i want to change  .
    3. I have data for only 2 fields , i.e for ( 1 st and last 20 th field ) .
    i can't use update statement in loop , as it is not good practice(hits database several times ) .
    do it effects all the 20 fields for  particular record .

    Hi,
    Use UPDATE statement , check below description from SAP help.
    UPDATE dbtab FROM TABLE itab. or UPDATE (dbtabname) FROM TABLE itab.
    Effect
    Mass update of several lines in a database table.Here, the primary key for identifying the lines tobe updated and the values to be changed are taken from the lines of theinternal table itab. 
    The system field SY-DBCNT contains the number of updated lines,i.e. the number of lines in the internal table itab which havekey values corresponding to lines in the database table.
    Regards
    L Appana

  • [10g] Way to find least value greater than a value?

    I have a simple (I think) question ...
    Part 1:
    Is there a way to determine the least value, among a set of values, that is greater than 0?
    A couple of examples:
    Set of values:
    {0,1,2,3}
    Return value:
    1
    Set of values:
    {0,5,10,20,100}
    Return value:
    5
    Set of values:
    {1,4,9,11}
    Return value:
    1Part 2:
    Same thing, but greater than some given value, not necessary 0.
    Set of values:
    {0,1,2,3}
    Parameter value:
    2
    Return value:
    3
    Set of values:
    {0,5,10,20,100}
    Parameter value:
    2
    Return value:
    5
    Set of values:
    {1,4,9,11}
    Parameter value:
    2
    Return value:
    4In particular, I'm looking for an efficient way of doing this. I believe I can do it with a set of CASE statements, but it gets really complex the more values you are comparing.
    My first thought was to use the LEAST function, but that doesn't allow me a way to use a parameter.
    Any suggestions?

    -- this section has been edited
    And that's basically where I was heading. I was hoping there was a less complex way to do it... somehow replacing any zeros with an impossibly large number, without using case statements (something equivalent to the NVL function, but to replace any value with another), so that they'd never be less than anything, and then I could just use the LEAST function. The only way I can think of to do that though, would be to convert the numbers to strings, use REPLACE, and then convert them back to numbers, which doesn't seem less complex than the CASE statements, and most likely is worse performance-wise.
    For example:
    SELECT     ord_nbr
    ,     seq_nbr
    ,     time_spent /
         CASE     WHEN     comp_qty     <= plan_qty
              AND     comp_qty     <> 0
              THEN     comp_qty
              WHEN     comp_qty     > plan_qty
              THEN     LEAST     ( TO_NUMBER(REPLACE(TO_CHAR(ord_qty-scrap_qty),'0','999999999'))
                        , TO_NUMBER(REPLACE(TO_CHAR(plan_qty),'0','999999999'))
                        , TO_NUMBER(REPLACE(TO_CHAR(comp_qty),'0','999999999'))
              ELSE 1
         END     AS unit_time
    FROM     ord_detail
    ;-- end of section edited (I posted before I had fully gone through the solution provided)
    I checked the data, and though, theoretically all values could be zero, there are no instances where that happens. I think that, in the case all values were 0, I'd just want to use 1 instead.
    Side note on the "big" problem behind this question....
    My ultimate problem, (and if I end up needing help with that, I'll start a new post for it) is that the quantity data in our system has a fair amount of junk in it...values that can't be true. With this solution, I would assume that in any case where the quantity complete at a given step of a process is less than or equal to the quantity planned to be complete at that step, the value is good, which is not necessarily a correct assumption. Then, only in cases where something can't be true, like when quantity complete > the quantity planned, are when I would intervene with this solution to make a "best guess" at the correct value. There a few things related to this that I have to determine before I can figure out my next step.
    We have another database (so we can keep things straight, I'll call the database I've been querying up til now DB1, and this other one, DB2) that has much more reliable quantity data and step data (sometimes it has steps that aren't in DB1) but its structure is complex, I'm rather unfamiliar with it, and it does not have time spent data. Additionally, some products have all their information in DB1, and none in DB2.
    So my options are to:
    1) ...try to learn the structure of the other database, find the data I need, and query both databases together, using this thread's solution to resolve any questionable data that does not exist in both systems, and skipping any steps that occur in DB2, but not DB1 (since they won't have any time data, which is ultimately what I'm after)
    2) ...try to come up with a method to pre-"scrub" my data in DB1, based on some logical assumptions and looking at all steps in an order, so that I can then just query the scrubbed data...
    3) ...use the solution from this thread, and assume that the bad data isn't enough to significantly impact my calculations...
    What I wouldn't give for a single system with all good data!
    Edited by: user11033437 on Nov 19, 2010 4:21 PM

  • Calculate single value as ranked number function does not apply in CR

    Hi everybody,
    I built up a query with the SAP BEx Query designer. For one key figure I enabled the function "Calculate single values" as ranked list. So the query has the following result.
    Instead of...
    Score
    1220
    2032
    2390
    2389
    ...I got...
    Score
    1
    2
    4
    3
    Unfortunately when importing the query to Crystal Reports Crystal is just importing the key figure itself - the ranked list does not exist... so the output is the same as in the first example.
    I tried to rebuild the formula with crystal means using the Rank function but I failed...
    Can anybody provide a workaround for me?
    Is there another way as using the formula workbench?
    Best regards,
    Sebastian

    Hi Ingo and everybody,
    I used now the following function using the Nth largest function:
    If nthlargest(1, {TECHNAME_OF_QUERY.[Measures]-[9XU9YT56S6PRL7DR80I3DK9RA]})
       = {TECHNAME_OF_QUERY.[Measures]-[9XU9YT56S6PRL7DR80I3DK9RA]} then "1"
    else if nthlargest(2, {TECHNAME_OF_QUERY.[Measures]-[9XU9YT56S6PRL7DR80I3DK9RA]})
       = {TECHNAME_OF_QUERY.[Measures]-[9XU9YT56S6PRL7DR80I3DK9RA]} then "2"
    else if nthlargest(3, {TECHNAME_OF_QUERY.[Measures]-[9XU9YT56S6PRL7DR80I3DK9RA]})
       = {TECHNAME_OF_QUERY.[Measures]-[9XU9YT56S6PRL7DR80I3DK9RA]} then "3"
    else if nthlargest(4, {TECHNAME_OF_QUERY.[Measures]-[9XU9YT56S6PRL7DR80I3DK9RA]})
       = {TECHNAME_OF_QUERY.[Measures]-[9XU9YT56S6PRL7DR80I3DK9RA]} then "4"
    else if nthlargest(20, {TECHNAME_OF_QUERY.[Measures]-[9XU9YT56S6PRL7DR80I3DK9RA]})
       = {TECHNAME_OF_QUERY.[Measures]-[9XU9YT56S6PRL7DR80I3DK9RA]} then "20"
    The formula is not very handsome and will fail, if the number of records exceeds...
    Are there any alternatives?
    And: Is there a possibility to change the field name, because those clumsy field names cause that the whole formula is almost unreadable. Or is the only way to build subreports?
    Regards,
    Sebastian

  • Calculate maximum value of subarray while creating it using a case structure and shift registers

    I have two 1D arrays that contain cyclical information (kind of like a sine wave).  One that contains information on position in degrees and another that contains torque.  I would like to calculate the maximum torque value each time the position is within a certain range (e.g. from 30-80 degrees).  The ranges are repeated - that's why it is cyclical.   I use the "in range" function, a case structure and shift registers to build a new array with values that fall within the range I specify - this was the easy part (see VI attached).  I'm struggling with a way to calculate a maximum value for each subarray formed when values are "in range".   Your help is much appreciated.
    Solved!
    Go to Solution.
    Attachments:
    Simple Calculate between anatomical position range.vi ‏16 KB

    It's not really noise - it's more inconsistency.  So a position output can run: 20, 30, 40, 50, 60 etc.  OR, it could run: 21, 24, 32, 41, 44, 51, 59 etc. But, it is always cyclical. 
    Attached you will find a .csv file with the data arrays - I'm using POS (ANAT) degrees column (column D if you open in excel).  There you also see torque in ft-lbs along with some other information.
    Attachments:
    025C.csv ‏224 KB

  • Creating a time channel in the data portal and filling it with data - Is there a more efficient way than this?

    I currently have a requirement to create a time channel in the data portal and subsequently fill it with data. I've shown below how I am currently doing it:
    Time_Ch = ChnAlloc("Time channel", 271214           , 1      ,           , "Time"         ,1                  ,1)              'Allocate time channel
    For intLoop = 1 to 271214
      ChD(intLoop,Time_Ch(0)) = CurrDateTimeReal          'Create time value
    Next
    I understand that the function to create and allocate memory for the time channel is extremely quick. However the time to store data in the channel afterwards is going to be highly dependent on the length I have assigned to the Time_Ch. In my application the length of Time_Ch is variable but could easily be in the order of 271214 or higher. Under such circumstances the time taken to fill Time_Ch is quite considerable. I am wondering whether this is the most appropriate way of doing things or whether there is a more efficient way of creating a time channel and filling it.
    Thanks very much for any help.
    Regards
    Matthew

    Hi Matthew,
    You are correct that there is a more efficient way to do this.  I'm a little confused about your "CurrDateTimeReal" assignment-- is this a constant?  Most people want a Time channel that counts up linearly in seconds or fractions of a second over the duration of the measurement.  But that looks like you would assign the same time value to all the rows of the new Time channel.
    If you want to create a "normal" Time channel that increases at a constant rate, you can use the ChnGenTime() function:
    ReturnValue = ChnGenTime(TimeChannel, GenTimeUnit, GenTimeXBeg, GenTimeXEnd, GenTimeStep, GenTimeMode, GenTimeNo)
    If you really do want a Time channel filled with all the same values, you can use the ChnLinGen() function and simply set the GenXBegin and GenXEnd parameters to be the same value:
    ReturnValue = ChnLinGen(TimeChannel, GenXBegin, GenXEnd, XNo, [GenXUnitPreset])
     In both cases you can use the Time channel you've already created (which as you say executes quickly) and point the output of these functions to that Time channel by using the Group/Channel syntax of the Time channel you created for the first TimeChannel parameter in either of the above functions.
    Brad Turpin
    DIAdem Product Support Engineer
    National Instruments

Maybe you are looking for