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 in count

Former Member
0 Likes
668

Hi All,

I have problem in count .

Example:

I have values in internal table like this:

-


No of Traller , | No of Pallets , | Deliveries,

-


|--


|--


ABC | 00987 | 0000302

ABC | 00989 | 0000302

,

In report out put I have to display like this, I have to count.

___________________________________________________________

No of Traller , No of Pallets , Deliveries, ________________________________________________________

1 , 2 , 1

How can I count like this, Can any one suggest me.

Thanks,

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
633

this shouldn't be a big problem using control breaks.

you'll have to get a little creative, though - create a few variables to hold counts, but you should easily get those numbers using AT NEW, AT END etc...

5 REPLIES 5
Read only

Former Member
0 Likes
634

this shouldn't be a big problem using control breaks.

you'll have to get a little creative, though - create a few variables to hold counts, but you should easily get those numbers using AT NEW, AT END etc...

Read only

Former Member
0 Likes
633

HI Claim,

check this logic..

Loop at itab.

AT NEW FLD1.

count1 = count1 + 1.

ENDAT.

Endloop.

Loop at itab.

AT NEW FLD2.

count2 = count2 + 1.

ENDAT.

Endloop.

Loop at itab.

AT NEW FLD3.

count3 = count3 + 1.

ENDAT.

Endloop.

Regards

SAB

Read only

Former Member
0 Likes
633

each field move to one internal table ,

use delete adjacent table and use describe command.

You need to have three internal tables :

one for Trialers,one for Pallets and one for delivery.

move ur trailer value to int table 1.

now use delete adjacent table

describe command

write : / V_triler.

same thing you need to write.

Reward Points if it is helpful

Thanks

Seshu

Read only

Former Member
0 Likes
633

Hi Claim,

I donno if your scenario varies but I assumed that you will have same Traller and Deliveries but different Pallets..So, this chunk of code displays the count corresponding to Pallets. Just copy and paste following code as temporary program and execute it.

==============================================================

REPORT ZTEST_COUNT.

TYPES: BEGIN OF COMPANIES_TYPE,

TRALLER(30),

PALLETS TYPE I,

DELIVERIES TYPE I,

END OF COMPANIES_TYPE.

DATA: COMPANIES TYPE STANDARD TABLE OF COMPANIES_TYPE WITH

NON-UNIQUE DEFAULT KEY INITIAL SIZE 20,

WA_COMPANIES TYPE COMPANIES_TYPE,

COUNT TYPE I.

WA_COMPANIES-TRALLER = 'ABC'.

WA_COMPANIES-PALLETS = 00987.

WA_COMPANIES-DELIVERIES = 0000302.

APPEND WA_COMPANIES TO COMPANIES.

CLEAR WA_COMPANIES.

WA_COMPANIES-TRALLER = 'ABC'.

WA_COMPANIES-PALLETS = 00989.

WA_COMPANIES-DELIVERIES = 0000302.

APPEND WA_COMPANIES TO COMPANIES.

CLEAR WA_COMPANIES.

WA_COMPANIES-TRALLER = 'BCD'.

DO 3 TIMES.

WA_COMPANIES-PALLETS = 00980.

WA_COMPANIES-DELIVERIES = 0000305.

APPEND WA_COMPANIES TO COMPANIES.

ENDDO.

LOOP AT COMPANIES INTO WA_COMPANIES.

COUNT = COUNT + 1.

AT END OF TRALLER.

WRITE: / 'TRALLER_COUNT:', COUNT.

CLEAR COUNT.

ENDAT.

CLEAR WA_COMPANIES.

ENDLOOP.

==============================================================

You can use Work areas also to count..

Hope this will help you.

Regards,

Vivek

Read only

Former Member
0 Likes
633

See the example code :

REPORT ZTEST3 line-size 400.

  • Internal table for all data

data : begin of itab occurs 0,

nt(3) type c,

np type i,

nd(10) type c,

end of itab.

  • Internal table for number trailers

data : begin of i_nt occurs 0,

nt(3) type c,

end of i_nt.

  • Internal table for number pallet

data : begin of i_np occurs 0,

np type i,

end of i_np.

  • Internal table for number Delivery

data : begin of i_nd occurs 0,

nd(10) type c,

end of i_nd.

  • Variable

data : v_lines1 type i,

v_lines2 type i,

v_lines3 type i.

start-of-selection.

clear : v_lines1,

v_lines2,

v_lines3,

itab,

i_np,

i_nt,

i_nd.

refresh : itab,

i_nd,

i_np,

i_nt.

  • Pass the value to main internal table manually

itab-nt = 'ABC'.

itab-np = 00987.

itab-nd = '0000302'.

append itab.

itab-nt = 'ABC'.

itab-np = 00989.

itab-nd = '0000302'.

append itab.

loop at itab.

i_nt-nt = itab-nt.

append i_nt.

i_np-np = itab-np.

append i_np.

i_nd-nd = itab-nd.

append i_nd.

endloop.

  • Count ur Number Trailers

DELETE ADJACENT DUPLICATES FROM i_nt.

describe table i_nt lines v_lines1.

  • Count ur Number pallets

DELETE ADJACENT DUPLICATES FROM i_np.

describe table i_np lines v_lines2.

  • Count ur Number Delivery

DELETE ADJACENT DUPLICATES FROM i_nd.

describe table i_nd lines v_lines3.

write:/5 'Number of Trailers',30 'Number of pallet',

55 'Number of delivery'.

write:/5 v_lines1,30 v_lines2,55 v_lines3.

Reward Points if it is helpful

Thanks

Seshu