# Natural program SORT area . . .

**URL:** <https://techcommunity.softwareag.com/t/natural-program-sort-area/80432>\
**Category:** Forum\
**Tags:** Adabas-Natural, Natural, Natural-Utilities\
**Created:** [March 6, 2009, 1:56am UTC](https://techcommunity.softwareag.com/t/natural-program-sort-area/80432 "2009-03-06T01:56:44Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![\_quot\_Pete\_quot\_M](https://avatars.discourse-cdn.com/v4/letter/_/919ad9/32.png) [@\_quot\_Pete\_quot\_M](https://techcommunity.softwareag.com/u/_quot_Pete_quot_M)\
**Post date:** [March 6, 2009, 1:56am UTC](https://techcommunity.softwareag.com/t/natural-program-sort-area/80432/1 "2009-03-06T01:56:44Z")

</div>

Is there a way to set/change the SORT AREA in a Natural program?

Example:

READ IN-FILE . . . [[ Do some input file stuff if needed] ]

END-ALL

SORT {IN-FILE field sort parameters} USING {other IN-FILE fields}

[[ Do some processing stuff] ]

END-SORT

END

---

<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:** [March 6, 2009, 2:30am UTC](https://techcommunity.softwareag.com/t/natural-program-sort-area/80432/2 "2009-03-06T02:30:23Z")

</div>

What do you mean by “sort area”? I presume you mean the data to be sorted.

The logical “records” to be sorted are a combination of the sort keys and the field list from the USING clause; what you defined as

> [@](#):
>
> {IN-FILE field sort parameters}

and

> [@](#):
>
> {other IN-FILE fields}

So you have complete control over the sort area.

---

<div class="post-metadata">

**Author:** ![Steve\_Robinson](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/steve_robinson/32/107_2.png) [@Steve\_Robinson](https://techcommunity.softwareag.com/u/Steve_Robinson)\
**Post date:** [March 6, 2009, 3:08am UTC](https://techcommunity.softwareag.com/t/natural-program-sort-area/80432/3 "2009-03-06T03:08:13Z")

</div>

Pete, you specified in your SORT statement:

SORT {IN-FILE field sort parameters} USING {other IN-FILE fields}

IN-FILE fields. In point of fact, you can have any fields as sort parameters or in the USING clause.

In addition, you do not have to have a READ (or FIND) statement to “anchor” the sort logic. You can have any loop; HISTOGRAM, FOR, REPEAT, READ WORK FILE. You do not have to sort “records”, you can sort arrays of data.

So, as Ralph indicated, you have complete control over what gets written to the “spin off” file to be sorted.

steve

---

<div class="post-metadata">

**Author:** ![Douglas\_Kelly](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/douglas_kelly/32/102_2.png) [@Douglas\_Kelly](https://techcommunity.softwareag.com/u/Douglas_Kelly)\
**Post date:** [March 7, 2009, 4:14am UTC](https://techcommunity.softwareag.com/t/natural-program-sort-area/80432/4 "2009-03-07T04:14:46Z")

</div>

if you are looking for control over the SORT program’s options, the DD $ORTPARM allows you to specify additional SORT parameters - I’ve used it to specify NORLSOUT and/or RELEASE=OFF when a Natural program (or step) will call the SORT many times and is likely to use temporary sort work files.

I believe this DD applies to SYNCSORT and ICEMAN (IBM’s SORT), but check your owner’s manual!

---

<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:51pm UTC](https://techcommunity.softwareag.com/t/natural-program-sort-area/80432/5 "2021-04-02T14:51:38Z")

</div>


