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

ABAP query

Former Member
0 Likes
844

hello experts...

my question is...

for example my WA_TAB contains this data:

Pernr lgart begda

0001 0101 2009.06.01

0001 0101 2009.06.02

0001 0101 2009.06.03

0001 0101 2009.06.04

0001 0101 2009.06.05

0002 0101 2009.06.01

0002 0101 2009.06.02

0002 0101 2009.06.03

0002 0101 2009.06.04

0002 0101 2009.06.05

But i want to add another field for the sequence number in field CNT.

Pernr lgart begda cnt

0001 0101 2009.06.01 1

0001 0101 2009.06.02 2

0001 0101 2009.06.03 3

0001 0101 2009.06.04 4

0001 0101 2009.06.05 5

0002 0101 2009.06.01 1

0002 0101 2009.06.02 2

0002 0101 2009.06.03 3

0002 0101 2009.06.04 4

0002 0101 2009.06.05 5

how to achieve this?

please help...

thank you

Edited by: Bernadette6184 on Oct 5, 2009 5:11 AM

1 ACCEPTED SOLUTION
Read only

venkat_o
Active Contributor
0 Likes
805

Hi, Try this way.


LOOP AT it_tab INTO wa_tab.
  wa_tab-cnt = sy-tabix.
  MODIFY it_tab FROM wa_tab INDEX sy-tabix TRANSPORTING cnt
ENDLOOP.
Thanks Venkat.O

8 REPLIES 8
Read only

venkat_o
Active Contributor
0 Likes
806

Hi, Try this way.


LOOP AT it_tab INTO wa_tab.
  wa_tab-cnt = sy-tabix.
  MODIFY it_tab FROM wa_tab INDEX sy-tabix TRANSPORTING cnt
ENDLOOP.
Thanks Venkat.O

Read only

Former Member
0 Likes
805

hello...

this code will help me count the total number of itab entry but my problem is

example employee 0001 and 0002 both have 5 entries in wa_tab table total of 10 entries

so if i add field CNT in wa_tab it will create 1~5 sequence number for employee 0001 and 0002

not 1~10 sequence number.

wa_tab should look like this:

PERNR LGART BEGDA CNT

0001 0101 2009.06.01 1

0001 0101 2009.06.02 2

0001 0101 2009.06.03 3

0001 0101 2009.06.04 4

0001 0101 2009.06.05 5

0002 0101 2009.06.01 1

0002 0101 2009.06.02 2

0002 0101 2009.06.03 3

0002 0101 2009.06.04 4

0002 0101 2009.06.05 5

Read only

venkat_o
Active Contributor
0 Likes
805

Hi, I could not observe last time. Check this


DATA:count TYPE i. "Define one variable for count
SORT it_tab BY pernr. "sort table by pernr
LOOP AT it_tab INTO wa_tab.
  count = 1.
  wa_tab-cnt = count.
  MODIFY it_tab FROM wa_tab INDEX sy-tabix TRANSPORTING cnt.
  AT END OF pernr. 
    CLEAR count. "Clear when it reaches last record for pernr
  ENDAT.
ENDLOOP.
Thanks Venkat.O

Read only

Sm1tje
Active Contributor
0 Likes
805

Well I guess, what Venkat actually means that you should add 1 to count in every loop pass

So NOT count = 1, but count = COUNT + 1.

Right Venkat? Probably a typo.

Allthough I don't know why you would want to have another variable COUNT when wa_tab-CNT is already available.

Read only

venkat_o
Active Contributor
0 Likes
805

Yes Micky. You are right. I think that Bernadette6184 might have corrected. That is why he is keep quite. Thanks Venkat.O

Read only

Former Member
0 Likes
805

hello...

Thank you experts for helping me

Read only

venkat_o
Active Contributor
0 Likes
805

Now you can close thread. Thanks Venkat.O

Read only

Sm1tje
Active Contributor
0 Likes
805

and give Venkat O. the credit he deserves (meaning a w a r d... some p o i n t s).