Delete all members in a Library programmatically

Is there any way in natural, we can delete all the modules present in a library programmatically? Can anyone please let me know.

You can do this with the API MAINUSER which is in libray SYSMAIN. With this API you can perform all SYSMAIN operations.
For further information see the Natural Documentation for the SYSMAIN utility. Especially the chapter “Invoking and Terminating SYSMAIN”.

Thanks Helmut for the reply.

I tried creating a module similar to MAINCALL from SYSMAIN libary in my library. But if I pass DELETE * to the SYS-PARM, its treating * as a module name and searching for it and throwing an error

PARM-MSG:
4867:Nothing found for this request.

So I caputured all the object names in the library and passed it to the SYSPARM and tried executing the job,
A is an object name in KAPTEST libary I tried giving the library name also, Its then saying SYNTAX error.

04:52:23 ***** NATURAL SYSMAIN UTILITY ***** 2009-10-23
- Direct Commands -
Command line being processed:
DELETE A
The following Error has occurred:
4871:Invalid object name specified
.
***** End of Report *****
Page 3 09-10-23 04:52:23
PARM-MSG:
4871:Invalid:object name specified.
NAT9995 Natural session terminated normally.

I am giving my code for your reference

READ WORK FILE 1 #IN-REC /* WORK FILE 1 CONTAINS PROGRAM NAMES
WRITE ‘=’ #PGM-NAME
*
IF SUBSTR(#PGM-NAME,1,6) EQ ‘Number’
ESCAPE BOTTOM
END-IF
*
IF #PGM-NAME EQ ‘MAINCALL’
ESCAPE TOP
END-IF
*
COMPRESS #PGM-NAMES ’ ’ #PGM-NAME INTO #PGM-NAMES
END-WORK
*
WRITE ‘=’ #PGM-NAMES
*
COMPRESS /* SET UP PARM AREA
‘DELETE A TYPE PM’
INTO PARM-AREA

  CALLNAT 'MAINUSER' PARM-AREA PARM-ERR PARM-MSG PARM-LIB  

Please have a look at it and let me know if you find Something.

Thanks
Kal

Do you really need to delete objects programmatically, or is your objective to avoid all the manual entries required when deleting many objects on-line?

Your sample program reads a file of object names. It would be simple to modify the list (during or after its creation) to have the format

SCR obj-name

Then submit the work file to Natural’s input stream, so

//CMSYNIN DD *
LOGON library
/*
//        DD DSN=your.work.file,DISP=SHR
//        DD *
FIN
/*

Careful - output will be voluminous (in number of pages, not in characters printed). To reduce the number of pages, change the file format to scratch up to 7 objects at a time.

SCR object1 object2 object3 object4 object5 object6 object7

I suggest you use SYSOBJH. It has an API OBJHAPI. The command to delete all Natural objects from a library is: DELETE * LIB xxx OBJT N NATT * SCKIND A.