# Delete all members in a Library programmatically

**URL:** <https://techcommunity.softwareag.com/t/delete-all-members-in-a-library-programmatically/91564>\
**Category:** Forum\
**Tags:** Adabas-Natural, Natural, Natural-Utilities\
**Created:** [October 21, 2009, 4:29pm UTC](https://techcommunity.softwareag.com/t/delete-all-members-in-a-library-programmatically/91564 "2009-10-21T16:29:14Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kal2](https://avatars.discourse-cdn.com/v4/letter/k/97f17d/32.png) [@Kal2](https://techcommunity.softwareag.com/u/Kal2)\
**Post date:** [October 21, 2009, 4:29pm UTC](https://techcommunity.softwareag.com/t/delete-all-members-in-a-library-programmatically/91564/1 "2009-10-21T16:29:14Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Helmut\_Spichtinger](https://avatars.discourse-cdn.com/v4/letter/h/e0b2c6/32.png) [@Helmut\_Spichtinger](https://techcommunity.softwareag.com/u/Helmut_Spichtinger)\
**Post date:** [October 22, 2009, 1:25pm UTC](https://techcommunity.softwareag.com/t/delete-all-members-in-a-library-programmatically/91564/2 "2009-10-22T13:25:10Z")

</div>

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”.

---

<div class="post-metadata">

**Author:** ![Kal2](https://avatars.discourse-cdn.com/v4/letter/k/97f17d/32.png) [@Kal2](https://techcommunity.softwareag.com/u/Kal2)\
**Post date:** [October 23, 2009, 4:35pm UTC](https://techcommunity.softwareag.com/t/delete-all-members-in-a-library-programmatically/91564/3 "2009-10-23T16:35:02Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Ralph\_Zbrog](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/ralph_zbrog/32/78_2.png) [@Ralph\_Zbrog](https://techcommunity.softwareag.com/u/Ralph_Zbrog)\
**Post date:** [October 24, 2009, 1:13am UTC](https://techcommunity.softwareag.com/t/delete-all-members-in-a-library-programmatically/91564/4 "2009-10-24T01:13:05Z")

</div>

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

```auto
SCR obj-name
```

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

```auto
//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.

```auto
SCR object1 object2 object3 object4 object5 object6 object7
```

---

<div class="post-metadata">

**Author:** ![Priscilla\_Fuller](https://avatars.discourse-cdn.com/v4/letter/p/b5ac83/32.png) [@Priscilla\_Fuller](https://techcommunity.softwareag.com/u/Priscilla_Fuller)\
**Post date:** [October 26, 2009, 11:38am UTC](https://techcommunity.softwareag.com/t/delete-all-members-in-a-library-programmatically/91564/5 "2009-10-26T11:38:24Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/techcommunity/original/3X/c/d/cd19967bb605d28a72d77eb83a1cae22f3df2eb8.svg) [@system](https://techcommunity.softwareag.com/u/system)\
**Post date:** [April 2, 2021, 2:57pm UTC](https://techcommunity.softwareag.com/t/delete-all-members-in-a-library-programmatically/91564/6 "2021-04-02T14:57:39Z")

</div>


