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

Clearing write statements

aakash_neelaperumal2
Active Participant
0 Likes
803

We are facing a problem with clearing the write statement buffer.

Our aim is to send mail by compressing the list memory, and the mail is sent in a loop. In each loop we have different set of data to be sent. But problem here is in the mails after the first mail, the data is getting appended in the subsequent mails.

For example,

do 10 times.

*****Have to clear buffer here*****

write 😕 hi.

perform sendmail.

enddo.

The above code should give ten emails...with only "hi". In other words, the list output should be only one "hi" and not 10 times hi. WE have tried all possibilites to clear the write buffer, Any help in this regard is highly appreciated.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
654

<b>Hi

U can use the following logic

do ctr times. "Define a counter varible and assign it to 10.

*****Have to clear buffer here*****

if sy-index = ctr.

write 😕 hi.

endif.

perform sendmail.

enddo.

It will only print Hi once when the last stmt will be executed.

Mark points if helpful.

Regs

Manas Ranjan Panda.</b>

4 REPLIES 4
Read only

anversha_s
Active Contributor
0 Likes
654

simple.

data : ch(10) default 'HI'. => out side the loop

do 10 times.

perform sendmail.

enddo.

rgds

Anver

Read only

Former Member
0 Likes
654

I think the internal table you are passing to send mail function should be refreshed once you send the mail.

Read only

Former Member
0 Likes
654

Hi aakash,

1. use MODIFY LINE concept,

to modify the line number 1

(so that line 1 is RE-WRITTEN there itself,

instead of line 2, 3, 4,..etc)

2. just copy paste

3. It will give only 1 HI, in 10 loops.

4.

report abc.

DATA : MSG(100) TYPE C.

MSG = 'HI'.

DO 10 TIMES.

IF SY-INDEX = 1.

WRITE 😕 MSG.

ELSE.

MODIFY LINE 1 LINE VALUE FROM MSG.

ENDIF.

ENDDO.

regards,

amit m.

Read only

Former Member
0 Likes
655

<b>Hi

U can use the following logic

do ctr times. "Define a counter varible and assign it to 10.

*****Have to clear buffer here*****

if sy-index = ctr.

write 😕 hi.

endif.

perform sendmail.

enddo.

It will only print Hi once when the last stmt will be executed.

Mark points if helpful.

Regs

Manas Ranjan Panda.</b>