Skip to Content
author's profile photo Former Member
Former Member

Problem with routine

Hi Expert,

I have the following problem. I have in flat file the Column1, and I need write the column2. I need the number 1 with 10 only once, the number 1 with 11 only once, the number 1 with 12 only once, the number 1 with 13 only once, the number 1 with 14 only once......

Column1---- -


Column2

10----


1

10----


0

10----


0

11----


1

12----


1

12----


0

13----


1

13----


0

13----


0

13----


0

13----


0

14----


1

14----


0

14----


0

Is there any routine?

Can you help me please?

Thanks

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

5 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on May 21, 2008 at 04:40 AM

    Hi,

    REPORT z_example NO STANDARD PAGE HEADING .

    data : begin of itab occurs 0,

    col1(2) ,

    col2(2) ,

    end of itab.

    itab-col1 = 10.

    append itab.

    itab-col1 = 10.

    append itab.

    itab-col1 = 11.

    append itab.

    itab-col1 = 11.

    append itab.

    itab-col1 = 12.

    append itab.

    itab-col1 = 12.

    append itab.

    itab-col1 = 13.

    append itab.

    itab-col1 = 13.

    append itab.

    sort itab by col1.

    loop at itab.

    on change of itab-col1.

    itab-col2 = 1.

    modify itab.

    else.

    itab-col2 = 0.

    modify itab.

    endon.

    endloop.

    loop at itab.

    write:/ itab-col1,

    itab-col2.

    endloop.

    Plz rewards points if helpful,

    Ganesh.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 20, 2008 at 11:48 AM

    Hi,

    DO this,

    sort itab by column1.

    loop at itab.

    s_itab = itab.

    at new of column1.

    write s_itab-column2.

    endat.

    endloop

    Cheers.

    ...Reward if useful.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on May 20, 2008 at 11:51 AM

    hi

    try like this

    after uploading data into your internal table

    sort itab by col1.

    METHOD 1

    loop at itab.

    on change of itab-col1.

    itab-col2 = 1.

    modify itab.

    endon.

    endloop.

    METHOD 2 " take care col 1 must be the first field

    loop at itab.

    at new col1.

    itab-col2 = 1.

    modify itab.

    endat.

    endloop.

    reward if helpful

    prasanth

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 20, 2008 at 11:53 AM

    Hi,

    i think u can try this,

    use AT NEW statement.

    AT NEW of column1.

    column2 = 1.

    ENDAT.

    Regards,

    kk.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 20, 2008 at 12:06 PM

    Hi,

    As the number 10 is repeated, I need put 1 only once. If number 10 appear again put 0.

    Can you help me please??

    Thanks for your answer.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.