Skip to Content

Output data in different lines for header and line item

Hello experts,

My source data is H-1 H-1 H-1 H-1 L-1 L-1 L-1 L-1 L-1 L-1

                           H-1 H-1 H-1 H-1 L-2 L-2 L-2 L-2 L-2 L-2

                           H-2 H-2 H-2 H-2 L-2 L-2 L-2 L-2 L-2 L-2

where H is the header fields and L is the line item fields, so header and line item in one line

Now my requirement is such that

                           H-1 H-1 H-1 H-1

                                                    L-1 L-1 L-1 L-1 L-1 L-1

                                                    L-2 L-2 L-2 L-2 L-2 L-2

                           H-2 H-2 H-2 H-2

                                                    L-2 L-2 L-2 L-2 L-2 L-2

Header data in one line, and corresponding Line items in the next line,

How do i achieve this.

Thanks and regards,

Abhishek Biwal

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Nov 02, 2015 at 10:06 PM

    Assuming your talking about input and output fiels, not database tables, correct?

    A possible solution will depend on the format of your files. Simplest case will be with fixed file format.

    1/. Define input file format with 2 fields: H and L.

    2/. In a 1st data flow, read the file into a dataflow and load into a 3-column database table. 2 columns for H and L (make sure they are varchar of the same length!), the 3rd column will contain a sequence number restarting from 1 for every new value of H. Use gen_row_num_by_group(H) to that extent.

    3/. In a 2nd data flow, read all distinct H values from the table. Write the results back into the same table, with a null value for L, and a zero value for the sequence.

    4/. Define output file format with 1 field.

    5/. In a 3rd data flow, read the table again, sort by H and sequence. Map H to output when seq = 0, L to output when seq <> 0, and write to file.

    Add comment
    10|10000 characters needed characters exceeded