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

Internal Table related query

Former Member
0 Likes
1,265

Hi Guys,

I have a 1st Internal Table with all shipments details.

I have 2nd internal table shipments details along with pallets details.

My 2nd Internal table looks like below.

PN TKNUM

1 1144

2 1144 and many more than this

3 1145

4 1145

I need to calculate that TKNUM 1144 has total 2 PN's and TKNUM 1145 has total 2 PN's

Thanks,

Prasad.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,246

HI,

Check this Code..

SORT itab by  TKNUM.
LOOP AT itab.

  COUNT = COUNT + 1.

AT END OF TKNUM.
"  Move total PN count to another internal table
  ITAB2-PN = COUNT.
  ITAB2-TKNUM = ITAB1-TKNUM.
  APPEND ITAB2.
  CLEAR COUNT.
ENDAT.

ENDLOOP.

Hi Guys,

I have a 1st Internal Table with all shipments details.

I have 2nd internal table shipments details along with pallets details.

My 2nd Internal table looks like below.

PN TKNUM

1 1144

2 1144 and many more than this

3 1145

4 1145

I need to calculate that TKNUM 1144 has total 2 PN's and TKNUM 1145 has total 2 PN's

Thanks,

Prasad.

8 REPLIES 8
Read only

former_member156446
Active Contributor
0 Likes
1,246

see the help on at statement....

loop at itab into wa_itab.

at new tknum / at last tknum....etc...

count.....and move...

enddat.

Read only

0 Likes
1,246

Hi Jay,

Thanks for your reply.

Can you give me any example.

Thanks,

Prasad.

Read only

0 Likes
1,246

>[Click Here|https://forums.sdn.sap.com/search.jspa?q=at%20endat&dateRange=last90days&searchID=22926323&rankBy=10001&start=0]<

alternative:


loop at itab into wa_itab.
itab1[] = itab[].

delete itab1 where tknum NE wa_itab-tknum.
describe table itab1 lines lv_lines.
write: 'No. of records:', wa_itab-tknum , lv_lines.

endloop.

Read only

Former Member
0 Likes
1,247

HI,

Check this Code..

SORT itab by  TKNUM.
LOOP AT itab.

  COUNT = COUNT + 1.

AT END OF TKNUM.
"  Move total PN count to another internal table
  ITAB2-PN = COUNT.
  ITAB2-TKNUM = ITAB1-TKNUM.
  APPEND ITAB2.
  CLEAR COUNT.
ENDAT.

ENDLOOP.

Read only

0 Likes
1,246

Hi Avinash,

Its not working.

Let me give my internal table details once again.

PN TKNUM

8 |0000001144

8 |0000001144

8 |0000001144

8 |0000001144

7 |0000001144

7 |0000001144

7 |0000001144

7 |0000001144

I need to get count as 2 for TKNUM .

Plz can you let me know.

Thanks,

Prasad.

Read only

Former Member
0 Likes
1,246

Hello,

You can do this way.

Loop at 2nd internal table.

At new TKNUM.

if flag is initial. " at 1st loop also AT new control break event occurs.

" 1st loop pass count should not be displayed

write:/ count, tknum.

endif.

flag = 'X'.

endat.

count = count + 1.

endllop.

Regards,

Sameer

Read only

0 Likes
1,246

Thanks for ur answer sameer.

Prasad.

Read only

Former Member
0 Likes
1,246

Thanks to all....