Skip to Content
avatar image
Former Member

Counting records in a flat file and Record number

Hi All,

I have been struggling to get a solution for this problem. Please help.

--> I have an IDOC to Flat file scenario. The flat file structure is mentioned below. The header and trailer come only once per file. The item segment repeats based on a few conditions. The catch is I am unable to generate a record number at every line. The record number has to be continous from the header to the last item. The first field of every line in the flat file is he record number.

--> Also the firlst field of the Trailer record is the Record Count, i.e. The total number of records in that flat file. Please help.

header - record number ,  ************* ,     ************

item1 -  record number ,  ************* ,     ************

item2 -   record number , ************* ,      ************

item n -   record number , ************* ,      ************

Trailer-    record Count   , ************* ,      ************

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • avatar image
    Former Member
    Mar 28, 2012 at 06:34 AM

    try this - the source msg should have line items to correspond to your target item structure. take the name of the line item segment and do a collapseContext followed by index function ,  then add 1 to it for header.

    in case of header, map it to constant 1.

    in case of trailer, above logic of item and instead of adding 1 add 2 to get the total record count.

    Add comment
    10|10000 characters needed characters exceeded

  • Mar 28, 2012 at 07:10 AM

    Hi

    In mapping you change context to whole idoc, and use function

    • count to count all records.
    • Index to get current line

    BR

    Maciej

    Add comment
    10|10000 characters needed characters exceeded

  • Mar 28, 2012 at 09:16 AM

    I had written a wiki on this some time back - http://wiki.sdn.sap.com/wiki/display/XI/Count+of+Records+-+%27Count+on+the+easiest+way+through%27

    let me know if that helps 😊

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Mar 28, 2012 at 10:43 AM

    Did you try using Global variable and increment it each time you create target node in a UDF.

    -Amol

    Add comment
    10|10000 characters needed characters exceeded