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

Clear the list buffer created by 'WRITE' statement

manoj_goyal2
Participant
0 Likes
2,460

Hi Guys,

I am creating a Z reporting program, where at point A in the program, I am creating a report with 'WRITE' statement. And later certain point B, I want to clear the list created at point A, and want to print new report created at point B with 'WRITE' statement.

Is this possible?

I will appreciate if somebody can help me.

Thanks a lot.

10 REPLIES 10
Read only

Sandra_Rossi
Active Contributor
0 Likes
1,639

Hi,

I think there is no direct function module or statement to clear the list buffer.

But you have several workarounds:

  • Either write your list inside a new screen sequence : create a dummy dynpro with SUPPRESS DIALOG in the PBO, and do your WRITEs in the PBO or PAI as you wish; then leave the screen sequence at the end of PAI (SET SCREEN 0 for instance), and call the dynpro; note: that should work in background as there is no real screen display
  • Or create 2 programs, with second program corresponding to the point A; call it through SUBMIT ... EXPORTING LIST TO MEMORY AND RETURN

Regards,

Sandra

Read only

Former Member
0 Likes
1,639

Hi Manoj,

Are you talking about Secondary lists?

When you use WRITE statement, it prints the contents to the screen.

The only way you can print some other content, say Point B, it will be executed when you do some other action, Button click, HOTSPOT etc. If this is the case, you don't have to do anything to handle the list output.

Can you explain what is the exact requirement?

Thanks,

Shambu

Read only

manoj_goyal2
Participant
0 Likes
1,639

Hi Guys,

Let me explain the requirement.

I am creating a Z reporting program with selection screen. At point A, I am using WRITE statement to create a report (report A) .  At point B, I am creating another report (report b) with WRITE. And due to logic, I don't want to print the report created by point A. I want to display only the report created at point B. Right now both Report A and Report B are displayed on screen.

Thanks a lot for your time.

Read only

0 Likes
1,639

Hi,

Again, the requirement is not clear.

How does the control go to point B?

END-OF-SELECTION.

WRITE: 'Report A'. " Basic list

AT LINE SELECTION.

WRITE : 'Report B'. " Secondary list

Is this what you are doing?

If you dont want to print the Report A, why are you writing this?

This doesn't make any sense. I am missing something.

Please explain.

Thanks,

Shambu

Read only

0 Likes
1,639

Hi Shambu,

Thanks for your time. 

Program : ZABC1

perform WRITE_REPORT_A  (Write report and create ITAB1)   (I have to run this. Mandetory)

export  ITAB1 to memoy id 'ZITAB1'

if new_logic = 'X'

submit  ZABC2 and return.

endif.

if new_logic = 'X'

import ITAB2 from memory id 'ZITAB2'

(clear previous report Report A)

Write report using ITAB2.

endif.

-------------------------------------

Program: ZABC2

Import ITAB1 from memory id 'ZABC1

Process ITAB1 and create ITAB2.

export ITAB2 to memory id 'ZITAB2'.

--------------------------------------------

I hope this helps you.

Thanks for your help again.

Read only

0 Likes
1,639

Hi Manoj,

There is  a way to clear the List content even after writing to the screen.

MODIFY LINE.

Check a sample program I have used.

   DATA :  lt_mara TYPE TABLE OF mara WITH HEADER LINE,
        ls_mara LIKE LINE OF lt_mara,
        test TYPE string,
        start TYPE i,
        lin TYPE i.

START-OF-SELECTION.
  SELECT * FROM mara INTO TABLE lt_mara UP TO 10 ROWS.

END-OF-SELECTION.

  LOOP AT lt_mara.
    WRITE:/ lt_mara-matnr, lt_mara-mtart, lt_mara-laeda, lt_mara-ernam.
  ENDLOOP.

  DESCRIBE LIST PAGE 1 INDEX 0 LINES lin.
  start = 1.
  DO lin TIMES.
    MODIFY LINE start OF CURRENT PAGE LINE VALUE FROM test.
    start = start + 1.
  ENDDO.

You can try commenting the MODIFY LINE statement and see what changes this brings.

Thanks,

Shambu

Read only

0 Likes
1,639

Hi,

To have the minimum amount of modifications, you could create ZABC0 program :

SUBMIT zabc1 ... EXPORTING LIST TO MEMORY... and return

CALL FUNCTION 'LIST_FROM_MEMORY'... -> itab1

if new_logic = 'X'

  FREE itab1

  submit  ZABC2 and return.

  import ITAB2 from memory id 'ZITAB2'

  Write report using ITAB2.

else

  CALL FUNCTION 'WRITE_LIST' of itab1

  FREE itab1

endif

Regards,

Sandra

Read only

0 Likes
1,639

Hi,

A possible workaround for this, if your tables ITAB1 and ITAB2 has the same structure (or at least the same output field length), is to overwrite your first list with the second one by using the statement BACK before outputting ITAB2... If ITAB2 contains less records than ITAB1, you will also have to overwrite the extra entries from ITAB1 with blank lines... Not really nice however

Question: Why not simply output the first list based on a condition as well??

E.g:

if new_logic = ' '

  perform WRITE_REPORT_A

else.

  submit  ZABC2 and return.

  import ITAB2 from memory id 'ZITAB2'

  Write report using ITAB2.

endif.

Kr,

Manu.

Read only

UweFetzer_se38
Active Contributor
0 Likes
1,639

Hi Manoj,

if I understand you requirement correct, just clear the magic sy-lsind variable...

AT LINE-SELECTION.

   CLEAR sy-lsind.

   WRITE:/ 'List 2'.

START-OF-SELECTION.

   WRITE:/ 'List 1'.

Best regards

Read only

0 Likes
1,639

Great! It worked for me.