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

Modifying final internal table content.. (to sum up)

Former Member
0 Likes
602

Hi Experts,

I have started working on ABAP reports very recently....

My output internal table have 4 fields

Date type dats

Ward type c(4)

count1 type i

count2 type i

and the content is like :

Date ward count1 count2

10.01.2008 ward1 1 0

10.01.2008 ward1 1 1

10.01.2008 ward2 0 1

11.01.2008 ward1 1 1

11.01.2008 ward1 1 0

11.01.2008 ward3 0 1

11.01.2008 ward3 1 1

and i need the output in the format

Date ward count1 count2

10.01.2008 ward1 2 1

ward2 0 1

11.01.2008 ward1 2 1

ward3 1 2

and my internal table is

data : begin of it_final occurs 0,

date1 like sy-datum,

ward(4) type c,

count1 type i,

count2 type i,

end of it_final.

Exepcting the reply..

Guru.

Edited by: Guru Ram on Aug 8, 2008 3:09 PM

5 REPLIES 5
Read only

Former Member
0 Likes
574

Hi,

insted of append stmt try using collect stmt at the final internal table.

collect itab.

Read only

Former Member
0 Likes
574

hi

u can use at new in side the loop or collect statement

Cheers

Snehi

Read only

Former Member
0 Likes
574

Hii!

Check this code


REPORT z_sdn.
DATA:
  w_num TYPE i.
DATA :
  BEGIN OF fs_final,
    date1 LIKE sy-datum,
    ward(5) TYPE c,
    count1 TYPE i,
    count2 TYPE i,
  END OF fs_final.


DATA:
  t_final LIKE
    TABLE OF
          fs_final.

START-OF-SELECTION.

  fs_final-date1  = '20081001'.
  fs_final-ward   = 'ward1'.
  fs_final-count1 = '1'.
  fs_final-count2 = '0'.
  COLLECT fs_final INTO t_final.

  CLEAR fs_final.
  fs_final-date1  = '20081001'.
  fs_final-ward   = 'ward1'.
  fs_final-count1 = '1'.
  fs_final-count2 = '1'.

  COLLECT fs_final INTO t_final.

  CLEAR fs_final.
  fs_final-date1  = '20081001'.
  fs_final-ward   = 'ward2'.
  fs_final-count1 = '0'.
  fs_final-count2 = '1'.
  COLLECT fs_final INTO t_final.

  CLEAR fs_final.
  fs_final-date1  = '20081101'.
  fs_final-ward   = 'ward1'.
  fs_final-count1 = '1'.
  fs_final-count2 = '1'.
  COLLECT fs_final INTO t_final.

  CLEAR fs_final.
  fs_final-date1  = '20081101'.
  fs_final-ward   = 'ward1'.
  fs_final-count1 = '1'.
  fs_final-count2 = '0'.
  COLLECT fs_final INTO t_final.

  CLEAR fs_final.
  fs_final-date1  = '20081101'.
  fs_final-ward   = 'ward3'.
  fs_final-count1 = '0'.
  fs_final-count2 = '1'.
  COLLECT fs_final INTO t_final.

  CLEAR fs_final.
  fs_final-date1  = '20081101'.
  fs_final-ward   = 'ward3'.
  fs_final-count1 = '1'.
  fs_final-count2 = '1'.
  COLLECT fs_final INTO t_final.

  LOOP AT t_final INTO fs_final.
    AT NEW date1.
      WRITE: / fs_final-date1.
    ENDAT.
    WRITE: / fs_final-ward,
             fs_final-count1,
             fs_final-count2.
  ENDLOOP.

Regards

Abhijeet

Read only

0 Likes
574

Thank u Mr. Abhijeet Kulshr.

but i need to wirte this data inta Unix SAP Directory...

will here

loop at it_final.

on change of it_final-date1.

on change of it_final-ward1. will it work here..

collect it_final.

Read only

0 Likes
574

Hi,

To write to Unix server

Use

OPEN DATASET p_file FOR OUTPUT IN BINARY MODE ENCODING DEFAULT.

If Sy-subrc <> 0.

exit.

endif.

Loop at IT_FINAL into WA_FINAL.

TRANSFER WA_FINAL TO p_file.

CLOSE DATASET p_final.

where IT_FINAL is ur final data internal table,

p_file is the file name on UNIX server.