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

ALV

Former Member
0 Likes
1,601

Hi Experts,

My requirements is like . In a SAP trasaction i have made some changes with some fields for ex. I made changes for a fields XXX for 3 times and made another for field ZZZ changes for 2 times .And i want my output like

fieldname No. of. changes.

XXX 3

ZZZ 2.

I ve done some coding for that . But i getting the output like below

Fieldname No. of Changes

XXX 1

XXX 2

XXX 3

ZZZ 4

ZZZ 5.

I ve one internal table T_OUTPUT_DATA where all the 5 records is stored .

Just help me out .Its Very urgent.

Message was edited by:

Satyanarayan Pujahari

1 ACCEPTED SOLUTION
Read only

former_member194669
Active Contributor
0 Likes
1,583

Hi,

Sorry I am sleepy mood


data : v_flg type c.
data : v_no type 1.

refresh : t_output_data1. "<< Modified

sort  t_output_data by fieldname. "<< check your fieldname for sort 
loop at  t_output_data.
  at end of fieldname.
     move 'Y' to v_flg.
  endat.
  v_no = v_no + 1.  "<<<<< changed 
  if v_flg = 'Y'.
     move t_output_data-fieldname to  t_output_data1-fieldname.
     move v_no           to  t_output_data1-noofchanges. " Check this variable
     append  t_output_data1.
     clear: v_no, v_flg.
  endif.

endloop.

I have changed v_no = v_no + 1. line before if condition

aRs

Hi Experts,

My requirements is like . In a SAP trasaction i have made some changes with some fields for ex. I made changes for a fields XXX for 3 times and made another for field ZZZ changes for 2 times .And i want my output like

fieldname No. of. changes.

XXX 3

ZZZ 2.

I ve done some coding for that . But i getting the output like below

Fieldname No. of Changes

XXX 1

XXX 2

XXX 3

ZZZ 4

ZZZ 5.

I ve one internal table T_OUTPUT_DATA where all the 5 records is stored .

Just help me out .Its Very urgent.

Message was edited by:

Satyanarayan Pujahari

12 REPLIES 12
Read only

former_member194669
Active Contributor
0 Likes
1,583

Hi,



create another internal table as same structure of t_output_data as t_output_data1
data : v_flg type c.
data : v_no type 1.
sort  t_output_data by fieldname.
loop at  t_output_data.
  at end of fieldname.
     move 'Y' to v_flg.
  endat.
  if v_flg = 'Y'.
     move t_output_data-fieldname to  t_output_data1-fieldname.
     move v_no           to  t_output_data1-noofchanges.
     append  t_output_data1.
     clear: v_no, v_flg.
  endif.
  v_no = v_no + 1.
endloop.

After this loop your t_output_data1 table contains records

XXX 3
ZZZ 2

Read only

0 Likes
1,583

Thanks for the quick response,

But in my t_output_data table i ve 7 fields. I tried with ur code but it'll add that field along with the five records and its showing only one records.

Please help .

Regards,

Satya

Read only

0 Likes
1,583

Your query not clear

Read only

0 Likes
1,583

Hi,

As i told u i ve 5 records in my T_OUTPUT_DATA table . And i added ur code then it shows 6 records like ...

FNAME No of changes

XXX 3

XXX 1

XXX 2

XXX 3

ZZZ 4

ZZZ 5.

Regards,

Satya

Read only

0 Likes
1,583

Hi,

Got it , i just refresh the table and it'll show one records but i want both records.

my output is like this

XXX 3

Read only

0 Likes
1,583

Hi,


data : v_flg type c.
data : v_no type 1.

refresh : t_output_data1. "<< Modified

sort  t_output_data by fieldname. "<< check your fieldname for sort 
loop at  t_output_data.
  at end of fieldname.
     move 'Y' to v_flg.
  endat.
  if v_flg = 'Y'.
     move t_output_data-fieldname to  t_output_data1-fieldname.
     move v_no           to  t_output_data1-noofchanges. " Check this variable
     append  t_output_data1.
     clear: v_no, v_flg.
  endif.
  v_no = v_no + 1.
endloop.

Please look into table T_OUTPUT_DATA1 table after the loop. results will be

XXX 3

ZZZ 2.

aRs

Read only

0 Likes
1,583

Please close this thread

aRs

Read only

0 Likes
1,583

Hi,

I checked the table T_OUTPUT_DATA1 after loop but its having the 2 records but

like

ZZZ 1 (This should be two)

XXX 3

And in my output its showing only one records

i.e.XXX 3

I am giving my code...

DATA: t_output_data1 LIKE T_OUTPUT_DATA OCCURS 0 WITH HEADER LINE.

data : v_flg type c.

data : v_no type i.

refresh : t_output_data1.

sort t_output_data by fname.

loop at t_output_data.

at end of fname.

move 'Y' to v_flg.

endat.

if v_flg = 'Y'.

move t_output_data-FIELD_DESC to t_output_data1-FIELD_DESC.

move v_no to t_output_data1-noc.

append t_output_data1.

clear: v_no, v_flg.

endif.

v_no = v_no + 1.

endloop.

refresh : t_output_data.

append t_output_data1 to t_output_data[].

Help me,

Regards,

Satya

Message was edited by:

Satyanarayan Pujahari

Read only

0 Likes
1,583

Hi Satya

Have u tried my code

Read only

Former Member
0 Likes
1,583

Hi

first move the first field into one internal table say itab1.

loop at itab.

itab1 -fld1 = itab-fld1.

append itab1.

clear itab,itab1.

endloop.

now sort itab1.

delete adjacent duplicates from itab1.

sort itab by fld1.

itab2[] = itab[].

loop at itab1.

loop at itab2.

if itab1 - fld1 = itab2 - fld1.

count = count + 1.

endif.

endloop.

itab3- fld1 = itab1 -fld1.

itab3-count = count.

append itab3.

clear itab1,itab2,count.

endloop.

reward points to all helpful answers

kiran.M

Read only

former_member194669
Active Contributor
0 Likes
1,584

Hi,

Sorry I am sleepy mood


data : v_flg type c.
data : v_no type 1.

refresh : t_output_data1. "<< Modified

sort  t_output_data by fieldname. "<< check your fieldname for sort 
loop at  t_output_data.
  at end of fieldname.
     move 'Y' to v_flg.
  endat.
  v_no = v_no + 1.  "<<<<< changed 
  if v_flg = 'Y'.
     move t_output_data-fieldname to  t_output_data1-fieldname.
     move v_no           to  t_output_data1-noofchanges. " Check this variable
     append  t_output_data1.
     clear: v_no, v_flg.
  endif.

endloop.

I have changed v_no = v_no + 1. line before if condition

aRs

Read only

0 Likes
1,583

Hi,

Yes its working and now the correct records are coming in that table but why its not showing in the output.

Definitely i'll give the reward point.

Regards,

Satya