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 modifications

Former Member
0 Likes
1,104

hello gurus,

I got output of a report as bellow.

.
sl no       date                name           state         contry
 1            10.10.2009                         mtm
 1             10.10.2009     A1                    
 1            10.10.2009                                               abc  
 1            10.10.2009    b1 
 1            10.10.2009    c1


but my required output is.
sl no       date                name           state         contry
 1            10.10.2009      A1                   mtm     ABC
 1             10.10.2009    B1                    
 1            10.10.2009     C1                                            

.

can any body tell me how to change the format.

my internal table data contains as displayed output only.

so i need to do operations at internal table level to get the required output.

thanks,

padmaja.

Edited by: padmaja vaddi on Mar 9, 2009 5:09 AM

10 REPLIES 10
Read only

Former Member
0 Likes
1,023

Hi Padmaja,

while filling your final internal table you need to separate the State and Country fields only based on your date..

Thanks!

Edited by: Prasanth on Mar 9, 2009 9:44 AM

Read only

Former Member
0 Likes
1,023

Hi Padmaja,

Make use of text elements if your problem is to align them.

Create a text element and write the required field under it like this.

write w_country under text-004.

where text-004 is 'Country'.

Much Regards,

Amuktha.

Read only

I355602
Product and Topic Expert
Product and Topic Expert
0 Likes
1,023

Hi,

One alternative is to create another internal table (say it_temp) with fields name, state and country.

Select the details in this internal table and take another internal table same as you have declared already with five fields (say it_final) and select only fields sl no, date and name.

Now use code:-


sort it_final by sl_no date name.
sort it_temp by name.

loop at it_final.
  read table it_temp with key name = it_final-name.
  if sy-subrc eq 0.
    it_final-state = it_temp-state.
    it_final-country = it_temp-country.
    modify it_final index sy-tabix.
  endif.
  clear it_temp.
  clear it_final.
endloop.

Hope this helps you.

Regards,

Tarun

Read only

Former Member
0 Likes
1,023

hello padma ,

while writing the output allocate necessary space for each table of internal table ,

based on number of characters in internal table for each column reserve the space using write statement

hope it solves problem

Read only

Former Member
0 Likes
1,023

Hi Padmaja,

the following procedure woulld help in getting the reqd output.

data: w_idx type i.

loop at itab where state = 'mtm'.

w_idx = sy-tabix.

itab-name = 'A1'.

itab-contry = 'ABC'.

modify table itab index w_idx.

endloop.

Regards,

Mdi.Deeba

Read only

keerthy_k
Product and Topic Expert
Product and Topic Expert
0 Likes
1,023

Hi Padmaja,

Please see the code below:

itab1[ ] = itab[ ].

sort itab1 comparing date name.

delete adjacent duplicates from itab1.-->itab1 will contain 3 records and itab will contain 5 records

loop at itab1 into wa_itab1.

clear: wa_itab2, wa_itab.

loop at itab into wa_itab where date = wa_itab1-date

name = ' '.

if wa_itab-state is not initial.

wa_itab2-state = wa_itab-state.

endif.

if wa_itab-country is not initial.

wa_itab2-country = wa_itab-country.

endif.

endloop.

wa_itab2-name = wa_itab1-name.

wa_itab2-date = wa_itab1-date.

wa_itab2-sl_no = wa_itab1-sl_no.

append wa_itab2 to itab2.

endloop.

And in the internal table itab2 , u will have the required output.

Keerthi.

Read only

Former Member
0 Likes
1,023

Hi,

Check your logic while you are populating your internal table. There is some mistake there.

Otherwise if you want to operations at the internal table only you can do something like this:

while displaying the ouput you will be looping at the internal table. instead of directly displaying it you use variables corresponding to the specific fields, and then:

LOOP AT ITAB.

V_DATE = WA_ITAB-date.

V_NAME = WA_ITAB-name.

V_STATE = WA_ITAB-state.

V_COUNTRY = WA_ITAB-country.

IF V_DATE IS NOT INITIAL AND V_NAME IS NOT INITIAL AND V_STATE IS NOT INITIAL AND V_COUNTRY IS NOT INITIAL.

WRITE: /

V_DATE UNDER 'date',

V_NAME UNDER 'name'

V_STATE UNDER 'state',

V_COUNTRY UNDER 'country'.

ENDIF.

ENDLOOP.

Regards.

Edited by: rajan roy on Mar 9, 2009 5:54 AM

Read only

Former Member
0 Likes
1,023

Hi,

How are you getting data into the internal table, we cannot give any code before knowing how the data is populated as it may lead to problems in future by just writing code with respect to the output you have provided us....

hence if you can let us know how you are populating data into the internal table then probably can help you with getting the required output...

Regards,

Siddarth

Read only

Former Member
0 Likes
1,023

answered

Read only

Former Member
0 Likes
1,023

answered