How to delete data from IFS directory?

185 pts.
Tags:
as/400 data
CL Program
IFS
IFS Commands
IFS Directory
How to write the program for deletion of data from IFS directory?

Any cl program?

 

ASKED: September 3, 2010  7:49 AM
UPDATED: September 3, 2010  7:24 PM

Answer Wiki

Thanks. We'll let you know when a new response is added.

Here is some code for you

<pre>
PGM PARM(&PDIR)

DCL VAR(&PDIR) TYPE(*CHAR) LEN(512)
DCL VAR(&DIR) TYPE(*CHAR) LEN(514)
DCL VAR(&MSGID) TYPE(*CHAR) LEN(7)
DCL VAR(&MSGDATA) TYPE(*CHAR) LEN(256)
DCL VAR(&NULL) TYPE(*CHAR) LEN(50) VALUE(X’00′)
DCL VAR(&STRLENGTH) TYPE(*CHAR) LEN(5) +
VALUE(’00256′)
DCL VAR(&EMPTYSTR) TYPE(*CHAR) LEN(50) VALUE(‘ ‘)
DCL VAR(&DIRNEW) TYPE(*CHAR) LEN(256)
DCL VAR(&MAX_TRIES) TYPE(*DEC) LEN(2 0) VALUE(10)
DCL VAR(&TRIES) TYPE(*DEC) LEN(2 0)

/* Add ‘/*’ to dir name to remove objects in the dir. */
CHGVAR VAR(&DIR) VALUE(&PDIR *TCAT ‘/*’)

/* First remove the objects. */
top:
DEL OBJLNK(&DIR)
MONMSG MSGID(CPFA0BD CPFA093)

/* Then remove subdirs. */
RMDIR DIR(&DIR) RMVLNK(*YES)
MONMSG MSGID(CPFA093)

/* For the subdirs that are not empty, call this same command */
MONMSG MSGID(CPFA0B7) EXEC(DO)
RCVERR:
RCVMSG MSGTYPE(*DIAG) MSGDTA(&MSGDATA) MSGID(&MSGID)
IF COND(&MSGID *EQ ‘ ‘) THEN(GOTO +
CMDLBL(CONTINUE))
IF COND(&MSGID *EQ CPFA0AC) THEN(DO)
CHGVAR VAR(&DIRNEW) VALUE(%SST(&MSGDATA 5 251))
DELDIR PDIR(&DIRNEW)
ENDDO
GOTO CMDLBL(RCVERR)
ENDDO

CONTINUE:
RMDIR DIR(&PDIR)
MONMSG MSGID(CPFA093 CPFA0AC) EXEC(DO)
IF COND(&TRIES *LT &MAX_TRIES) THEN(DO)
CHGVAR VAR(&TRIES) VALUE(&TRIES + 1)
GOTO CMDLBL(TOP)
ENDDO
ENDDO

END: ENDPGM</pre>

Discuss This Question: 1  Reply

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • DanTheDane
    By entering "ifs delete file" in the searchbox of this very site (ITKnowledge Exchange) I found this for you: delete old IFS files : http://itknowledgeexchange.techtarget.com/itanswers/delete-old-ifs-files/ Delete files from IFS based on last used age : http://itknowledgeexchange.techtarget.com/itanswers/delete-files-from-ifs-based-on-last-used-age/ delete records from a directory with IFS root using CL : http://itknowledgeexchange.techtarget.com/itanswers/delete-records-from-a-directory-with-ifs-root-using-cl/ Pls be more specific if you need more help :-) DanF
    2,555 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following