Q: How to remove the previous window when displaying new window in AS400 I am trying to display windows from different display files. Even after providing the RMVWDW, The new window is getting overlapped on the previous window. Does the RMVWDW works when the windows are getting displayed from multiple display files?
What is the solution to remove the previous window when displaying new window when windows getting displayed from different display files?

A: So without any better description of the problem, let me try to describe what is going on. I wrote a few minimal programs to help.
First we have a display file with simply a full screen record, and a window. The window will overlay the full screen record.
DSPF1
 A          R RECORD1
 A                                  3 19'Base display record'
 A                                 20 18'Base Display Record'
 A          R W01                       WINDOW(7 15 10 50)
 A                                  5 14'Window in DSPF1'

The associated program PGM1
**free
dcl-f dspf1    workstn;

dcl-pr pgm2 ExtPgm('PGM2');
end-pr;

write record1;
exfmt w01;

pgm2();

*inlr = *On;
return;

displays both record1 and w01, and waits for a command key to be pressed. Note both records on the display.

The user presses enter and PGM2 is called. Following is the source for the display file and program. Notice the ASSUME keyword in the display file source. This prevents the previous display file from being erased from the display when this display file is opened.
DSPF2
 A          R W02                       WINDOW(9 20 10 50)
 A                                      RMVWDW
 A                                  5 14'Window 1 from DSPF2'
 A          R W03                       WINDOW(4 5 10 50)
 A                                      RMVWDW
 A                                  5 14'Window 2 from DSPF2'
 A          R DUMMY                     ASSUME
 A                                      OVERLAY
 A                                  1  2' '

Program for DSPF2 is PGM2.
**free
dcl-f dspf2   workstn ignore(dummy);

exfmt w02;

exfmt w03;

*inlr = *On;
return;

This will display the first window in DSPF2, wait for a command key press, then remove the first window from DSPF2 and display the second window fron DSPF2. 

When you press enter you get:

Enter again to end both programs.
Notice that the window from DSPF1 is not removed by PGM2. The ASSUME keyword keeps the display from PGM1 while DSPF2 is open. DSPF1 is suspended while DSPF2 is active, so you can't remove that window while DSPF2 is active unless you omit the ASSUME keyword from DSPF2. But if you omit the ASSUME keyword, the entire display is erased when DSPF2 is opened.
I suppose you might be able to remove the window from DSPF1 if you rewrote the screen without the window just before calling program 2, but you would have to set DFRWRT(*NO) on DSPF1, or the write will not be sufficient to update the screen.
