Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Problem with routine

Former Member
0 Likes
771

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

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
735

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.

6 REPLIES 6
Read only

Former Member
0 Likes
735

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.

Read only

prasanth_kasturi
Active Contributor
0 Likes
735

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

Read only

Former Member
0 Likes
735

Hi,

i think u can try this,

use AT NEW statement.

AT NEW of column1.

column2 = 1.

ENDAT.

Regards,

kk.

Read only

Former Member
0 Likes
735

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.

Read only

0 Likes
735

hi,

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.

waiting for your reward

prasanth

Read only

Former Member
0 Likes
736

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.