Hello willy jensen,
I tried the free command alone but it did not work. But with REUSE in allocate then freeing the file worked perfectly.
The final command looks like below.
'ALLOC DD(DDNAME) PATH(/u/USERS/userid/file1.text) PATHOPTS(ORDWR,OCREAT) PATHDISP(KEEP,KEEP) PATHMODE(SIRWXU) FILEDATA(RECORD) REUSE'
'FREE DD(DDNAME)'
@willy jensen, sergeyken, Thank you for your help .