Application Development 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: 

Collect the records based on the field

Former Member
0 Kudos

Hi ,

I have a scenario like below.

name id emailid

X 1 XXX

y 2 XXX

z 3 YYY

w 4 XXX

So I want to send mail to XXX with X y and W information at a time i.e means in the single mail and mail should go to YYY with the Z information.

please guide me on this.

Thanks & Regards,

Suresh.

6 REPLIES 6

Former Member
0 Kudos

Hi,

You can sort the table using the Email IDs and based on the group you can send the mail to that particular User with all the required information.

Regards,

Pramod

Former Member
0 Kudos

Hi Pramod,

I am sorting the table , can you guide me how to collect thses X Y W three record into one internal table based on the emailid refernce.

Thanks in advance,

Regards,

Suresh

Former Member
0 Kudos

report z_demo_jg1 line-count 10(2) no standard page heading.

data: begin of itab occurs 0,

mailid(3) type c,

info1(1) type c,

info2(1) type c,

end of itab.

data: begin of info occurs 0,

info1(1) type c,

end of info.

start-of-selection.

itab = 'XXXXX1'.

append itab.

itab = 'XXXY2'.

append itab.

itab = 'YYYX3'.

append itab.

itab = 'XXXW4'.

append itab.

sort itab by mailid.

loop at itab.

info-info1 = itab-info1 .

append info.

at end of mailid.

  • Send mail with content from int. table info

refresh info.

endat.

endloop.

Former Member
0 Kudos

Hi ,

Sort on itab mailid.

lv_mail = space.

loop at itab into wa.

if lv_mail ne wa-mail.

lv_mail = wa-mail.

endif.

if lv_mail = wa-mail.

read itab2 with mail = wa-mail.

if sy-subrc eq zero.

concatenate itab2-msg wa-masg into itab2-msg.

modify itab2 at sy-tabix transporting msg.

else.

itab2-mail = wa-mail.

itab2-msg= wa-msg.

append itab2.

endif.

endif.

endloop.

loop on itab2.

send mail.

endloop.

in some scenario we faced problem with using "at end".

i am not sure exactly, think basis on type and key part of internal table.so the above is an suggestion from my side.

Regards,

Salini.

Edited by: satya Visalini on Sep 19, 2008 10:05 AM

Edited by: satya salini on Sep 19, 2008 10:08 AM

Former Member
0 Kudos

hi

i think you can use collect statement..

Former Member
0 Kudos

Hi ,

Thanks for all your help.

I got the logic and it's meeting my requirement.

loop at emailidtable

.......

.......

.......

loop at int tab(for main data) where email = emailid.

l_tabix = sy-tabix.

getting all information in one internal table with referenece to emailid.

endloop.

send mail.

endloop.

Thanks,

Suresh.