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: 

Group By in ABAP ..

Former Member
0 Kudos

Hi,

My Itab contains n number of records and i am triggering mails wrto the mail id in itab.

and it's working fine .I want to group my Itab wrto Mailid, and want to trigger mail Only

once with the set of records.

Say,if my itab contains 15 records ..with 2 category of mailid's,

Then i want to send 2 mails one with 10 records and other with 5 records .

Tnks in Advance.

Regards,

SAPUser100

1 ACCEPTED SOLUTION

christian_wohlfahrt
Active Contributor
0 Kudos

Hi!

Place your mailid in the first column of your itab.

Then make something like this:

loop at itab.
  prepare mail-lines.
  at end of mailid.
    send mail.
    refresh mail-lines.
  endat.
endloop.

Regards,

Christian

4 REPLIES 4

christian_wohlfahrt
Active Contributor
0 Kudos

Hi!

Place your mailid in the first column of your itab.

Then make something like this:

loop at itab.
  prepare mail-lines.
  at end of mailid.
    send mail.
    refresh mail-lines.
  endat.
endloop.

Regards,

Christian

Former Member
0 Kudos

Hi

You should sort your itab by mail id and fill a new internal table with the record belonging the same group.

SORT ITAB BY MAIL_ID.

LOOP AT ITAB.

IF ITAB-MAIL_ID <> OLD_MAILD_ID AND

NOT OLD_MAIL_ID IS INITIAL.

-


> Here send the mail

REFRESH ITAB2.

ENDIF.

APPEND ITAB TO ITAB2.

OLD_MAIL_ID = ITAB-MAIL_ID.

AT LAST.

-


> here send email for the last group

ENDAT.

ENDLOOP.

You can also use the command AT THE END, but in this case the field MAIL_ID should be the first field of the table:

LOOP AT ITAB.

APPEND ITAB TO ITAB2.

AT END OF MAIL_ID.

-


> Here send the mail

REFRESH ITAB2.

ENDIF.

ENDLOOP.

Max

Message was edited by: max bianchi

0 Kudos

Hi guys,

Thxs. i am trying to send mails to the Superiors .

If an employee has only one Manager , i can send mail to him only ..but in our case, few of the emp's are controlled by more than one manager.I hav used HRP1001 relation to fetch Employees superior.

In My Itab,mailid field i hav grouped all the superior mailid by comma a,bc,ff,dd ...

Now i want to send mail to all the mail id's ...Itab grouping aswell as field split ..

Rgds,

SAPUSER100

0 Kudos

From the internal tables, populate the RECEIVERS table of the mail function module...and the grouping condition remains the same.

Refresh the receivers table once the call is made to the FM.

loop at itab.

prepare mail-lines.

if only they belong to the same group.

prepare receivers_list.

endif.

at end of mailid.

send mail.

refresh mail-lines.

refresh recievers-list.

endat.

endloop.

REgards,

Ravi