Count the number of segments used in payload.

Hi experts,
We have a received payload like :
Seg1 - header
seg2 - item
seg2 - item
seg2 - item
seg3 - footer
In the seg3 footer filed1 should have the value of number of segments used in payload,
for example in above payload the value of field1 should be 5.
How we can count these segments and place the value in field1 of seg3, in our receiver payload ?
Please help.
Regards,
Study SAP

Hi,
if you want you could try this xslt mapping:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  <xsl:template match="/">
    <xsl:apply-templates/>
  </xsl:template>
  <xsl:template match="seg3">
    <xsl:copy>
      <xsl:element name="field1">
        <xsl:value-of select="count(//seg2)"/>
      </xsl:element>
    </xsl:copy>
  </xsl:template>
  <xsl:template match="@*|node()">
    <xsl:copy>
      <xsl:apply-templates select="@*|node()"/>
    </xsl:copy>
  </xsl:template>
</xsl:stylesheet>
I have try with this similar xml as source:
<?xml version="1.0" encoding="UTF-8"?>
<segments>
  <seg1>header</seg1>
  <seg2>item1</seg2>
  <seg2>item2</seg2>
  <seg2>item3</seg2>
  <seg3>footer</seg3>
</segments>
And the result was:
<?xml version="1.0" encoding="UTF-8"?>
<segments>
  <seg1>header</seg1>
  <seg2>item1</seg2>
  <seg2>item2</seg2>
  <seg2>item3</seg2>
  <seg3>
    <field1>3</field1>
  </seg3>
</segments>
Maybe it could be useful for you.
Regards,
Emiliano

Similar Messages

  • Count the number of cells used in a formula

    Is it possible to count the number of cells used in a formula?
    For example the following formula: "=Tabel 1 :: D45+D8+F7"
    The answer needed is 3

    From your description, it appears you could use SUMIF to get the totals.
    It's not necessary to know the number of times a name appears in the list to determine the sum of the numbers in the cell to the right, but if you have a separate need for that count, then COUNTIF will do the job.
    As the names may appear in more than one column, you'll need to use one iteration of the formula for each pair of columns containing name and associated number. In your description, there are names in columns C and E, with associated values in D and F respectively, and all of these cells are in the same table (which I'll name Table 1). I would calculate the totals on a second table (Table 2) containing a list of all of the names in column A, starting at A2, the COUNT of times each name is listed in column B, and the sum of the values in cells immeditely to the right of each name in column C.
    Table 2::B2: =SUM(COUNTIF(Table 1::C,A),COUNTIF(Table 1::E,A))
    Table 2::C2: =SUM(SUMIF(Table 1 :: C,A,Table 1 :: D),SUMIF(Table 1 :: E,A,Table 1 :: F))
    Select cells B2 and C2, then fill the formulas down each column.
    Regards,
    Barry

  • Count the number of seeds using labview - new to labview

    hello,
    I am new to labview and need to create a VI to count the number of seeds being dropped.
    I understand you can do this using labview.
    please can someone direct me to a tutorial or an example to do this?
    I use a camera - how do you connect up the camera to work with labview?
    thanks

    You'll have to use IMAQ vision, an addon package that brings LabVIEW a series of tools for image analysis.
    There are a number of examples/solutions. Some deal already with particle counting.
    Although your question is rather vague, I suppose you want to get more info tahn the mere particle number (shape, color). That's definitely possible with LabVIEW, but will require a significant investment.
    There is a forum dedicated to Machine Vision where you'll get all the required help.
    Chilly Charly    (aka CC)
             E-List Master - Kudos glutton - Press the yellow button on the left...        

  • To Count the Number of segments in the EDI structure

    Hi everyone,
    I am dealing with an Idoc to Edi scenario.
    In the target EDI structure, in the feild number 74 in UNT segment (Message Trailer), I want the count of the number of active segments in the message i.e., the count of the fileds which are having values. How to go about this? Kindly through some light on this.
    Thank you.
    Edited by: Nisha Chopra on Dec 22, 2007 11:37 AM

    HI Nisha,
    If you are using the satandard Seeburger mapping program then u do not need to write anything for counting the no of UNT segment (Message Trailer). It will be calculated by seeburger only.
    Do let me know if u need more help.
    Thanks and Regards,
    Chirag

  • How to count the number of test ABAP Unit test methods

    I need to count the number of test methods of a class.   Has anybody done this before?   For example, if I have a class that has 3 methods and I wrote 6 abap unit test methods for it.   I can count the number of methods using cl_abap_classdescr=>describe_by_name (which gave me 3 from my example) but I could not find the function module to count the number of test methods (which should give me 6 in my example).
    I appreciate your reply.

    This call does thew trick.  I just had to make sure the prog name that I pass has "CP" from the 30th pos for it return the result.   Here is thew subroutine that I use:
    form get_test_method_count using     query_class
                               changing  test_method_count.
      data: l_progname type progname.
      l_progname = query_class.
      l_progname+30 = 'CP'.  "needed so the following method will recognize this as a class
      data: l_result type if_aunit_prog_info_types=>ty_t_testclasses.
      try.
          call method cl_aunit_prog_info=>get_tests_of_program
            exporting
              progname = l_progname
            receiving
              result   = l_result.
          if l_result is not initial.
            data: result_rec like line of l_result.
            loop at l_result into result_rec.
              test_method_count = lines( result_rec-methods ).
            endloop.
          endif.
        catch cx_root.
      endtry.
    endform.

  • Count the number of days in the selected range using Customer exit

    Hi Experts,
    we have requirment where user is asking to add a column to report, which will have 'count of days for which key figure is having values' for each of the months and the Header would be 'Day Count'
    Please let me know if its possible using Customer exit?

    Hi,
    In our report we have two characteristics site no. and product and we have 6 key figures of type quantity and Input for the report is Fiscal year/period
    So in the report Key figures are populated with values for respective site no. and product combination
    Now the user wants new column in report which will have header u2018Day countu2019 and it should Simply count the number of days in the selected range that have a volume different than 0 for key figure
    Please let me know if more details are required

  • Count the number of times a character is in a string using pl/sql

    I need to count the number of times ":" appers in the string ":XXX:CCC:BBB:".
    I have sound some solution using SQL but I do not want the context switch.
    Also I am on 10g so I can not use REGEXP_COUNT.
    Any help would be great.

    Hi,
    length(REGEXP_REPLACE(':XXX:CCC:BBB:','[[:alnum:]]'))counts all kinds of punctuation, spaces, etc., not just colons. Change any (or all) of the colons to periods and it will still return 4. Use '[^:]' instead of '[[:alnum:]]' if you really want to count just colons.
    Also, "SELECT ... FROM dual" is usually needed only in SQL*Plus or similar front end tools. In PL/SQL, you can call functions without a query, like this:
    x := NVL (LENGTH (REGEXP_REPLACE (txt, '[^:]')), 0);

  • How to use counters of PCI 6251 to count the number of pulses

    Hello,
    I have inputs from an optical encoder {pulse train} and i need to count the number of pulses for a short period of time to estimate the speed of the DC motor. Could you please tell me how to use the counters in PCI 6251 DAQ. I found something on DAQ STC, whichs says the input pulse should be connected to PF0 {ctr source}, but i have query where do i get the output {number of pulses counted in a particular period of time}.
    Looking for your reply.
    Thanks & Regards,
    bsnr

    Hi bsnr,
    Thanks for the post!
    In MAX (Measurement and Automation Explorer), if you find the device (DAQmx devices) and right-click, you can select pinouts - which should contain a table telling you which pins are what PFI lines.
    Then, in labVIEW, you need to generate some code to use the choosen coutner in a task to count digital edges. If your not sure on this, go to Help>>Find Examples>>Hardware I/O>>DAQmx>>Counters.. and take a look at some of the code provide.
    ps. It seems (maybe just your wording), but your expecting the counter output pin to provide the number of counted edges - this isn't the case.  
    Please let me know what you think?
    Kind Regards, 
    Kind Regards
    James Hillman
    Applications Engineer 2008 to 2009 National Instruments UK & Ireland
    Loughborough University UK - 2006 to 2011
    Remember Kudos those who help!

  • Using count to count the number of occurrences of a primary key

    Hi,
    I'm relatively new to T-SQL and more of a SAS guy.
    I just need to some help.
    I have a table
    CF_ID    Name
    4444     Mark
    4444    Mark
    3321   Sarah 
    All i want to do add in a new column to count the number of occurrence of the CF_ID. So my new table would be:
    CF_ID    Name     New_column
    4444     Mark       1
    4444     Mark       2
    3321     Sarah     1 
    Any help would be gratefully appreciated.
    Thank you
    Umar Javed

    Hello Umar,
    You can use the
    ROW_NUMBER (Transact-SQL) for this:
    SELECT *, ROW_NUMBER() OVER (PARTITION BY CF_ID ORDER BY Name) AS New_Column
    FROM yourTable
    Olaf Helper
    [ Blog] [ Xing] [ MVP]

  • Counting the number of IDocs in a package of IDocs in BPM

    Hello All,
        I need a solution where I need to count the number of EDI_DC40  segments (The IDoc Count) in a package of IDoc's. The following is the scenario
    1) We are receiving a package of IDoc's in receive step using the XI File Adapter. I was wondering if there is a way that I can count the number of IDoc's in the BPM using a container operation or some other Method. I appreciate any help.
    Thanks.

    HI,
    We have two ooptions,
    one as explained above , yu can use standard count function and that can be used.
    Second one is we have count option in file adapter to count the msgs.
    see the below link
    http://help.sap.com/saphelp_erp2005vp/helpdata/en/0b/9a50465ccf84479e39a6d50c90fb3f/content.htm
    Regards
    Chilla

  • Is there a way to count the number of times an array moves from positive to negative?

    I have an array of values, and I need to find the number of times that the array changes signs (from positive to negative, or vice versa). In other words from a graphical standpoint, how many times a certain line crosses the x-axis. Counting the number of times the array equals zero does not help however, because the array does not always equal exactly zero when it crosses the axis (ie, the points could move from .1 to -.1).
    Thanks for you help. Feel free to email me at [email protected] I only have lv 5.1.1 so if you attach any files, they cannot be version 6.0.

    Attached is a VI showing the # of Pos and Neg numbers in an array, with 0 considered as non-Pos. It is easily modifiable to other parameters - including using the X-axis value as your compare point versus only Zero.
    This is a modified VI from LV (Separate Array.vi)
    Compare this with your other responses to find the best fit.
    Doug
    Attachments:
    arraysizesposneg.vi ‏40 KB

  • How do I count the number of records returned in the CMIS query

    How do I count the number of records returned in the query CMIS?
    SELECT COUNT(*) FROM ora:t:IDC:GlobalProfile WHERE ora:p:xRegionDefinition = \'RD_PROJETOS_EXCLUSIVOS\''}
    Euler Homero

    Hi Euler,
    interestingly enough, the reference guide for CMIS ( http://wiki.alfresco.com/wiki/CMIS_Query_Language ) that I found does not mention the COUNT function at all. On the other hand it states that: "The SELECT clause identifies which virtual columns to return in the result set. It can be either a comma-separated list of one or more queryNames of properties that are defined by queryable object types or * for all virtual columns."
    There are, however, some other posts like e.g. http://alfrescoshare.wordpress.com/2010/01/20/count-the-total-number-of-documents-in-alfresco-using-sql/ which state that they could make it working.
    Having asked in the WebCenter Portal forum, I assume that your content repository is WebCenter Content. The CMIS doc for the Content is available here: http://docs.oracle.com/cd/E23943_01/doc.1111/e15813.pdf (no COUNT there either). It does, however, mention explicitly that "CMIS queries return a Result Set where each Entry object will contain only the properties that were specified in the query.". This means your could rather investigate the Result Set. Note that there are also other means than CMIS how to get the requested result set (e.g. calling a search service directly via so-called RIDC).
    In the given context I am also interested what your use case is. OOTB CMIS in WebCenter Portal is used, for instance, in Content Presenter, where it is content rather than "parameters" what's displayed.

  • How to count the number of rows in a cube!!??

    Experts,
    I can somebody tell me how do I count the number of rows in my cube when i am using listcube???..
    Thanks
    Ashwin

    Hi,
    have a look ath this theard too
    Number of Records in Cube
    regards

  • How to count the number of rows in a resultser object?

    hi there
    how to count the number of rows in a resultser object which may contains millions of rows? besides using a while loop? thanks

    You don't, you execute a query whose result is the record count of those records that match the search and then you execute the actual query to create your record set. Typically you do
    select count(id) from YourTable where [filter]
    from the resulting ResultSet do
    int res.getInt(1);
    which gives you the count and then
    select id from YourTable where [filter]
    to produce the actual result set.
    in the second query the id part can be substituted with the actual fields you want.

  • Programatically count the number of files in a folder

    Hi Folks
    I need to programatically count the number of files in a given folder and return the value to a Program Unit to be included in further processing.
    Can anyone point me in the right direction. I have looked at UTL_FILE but this does not offer what I want.
    Does anyone know of an obscure package in Oracle that I could use?
    I'm using 9i in a W2K environment.
    Many thanks
    Simon Gadd

    Hi,
    following a java based solution i found somewhere on Tom Kyte's AskTom forum.
    GRANT JAVAUSERPRIV to TESTUSER;
    dbms_java.grant_permission( 'TESTUSER', 'SYS:java.io.FilePermission', 'c:\', 'read' );
    create global temporary table DIR_LIST
    ( filename varchar2(255) )
    on commit delete rows
    create or replace and compile java source named "DirList"
    as
      import java.io.*;
      import java.sql.*;
      public class DirList
        public static void getList(String directory)
                           throws SQLException
          File path = new File( directory );
          String[] list = path.list();
          String element;
          for(int i = 0; i < list.length; i++)
              element = list;
    #sql { INSERT INTO DIR_LIST (FILENAME)
    VALUES (:element) };
    create or replace procedure get_dir_list( p_directory in varchar2 )
    as language java
    name 'DirList.getList( java.lang.String )';
    exec get_dir_list( 'c:\temp' );
    select count(*) from dir_list;

Maybe you are looking for