# Create SUBROUTINE with parameter

**URL:** <https://techcommunity.softwareag.com/t/create-subroutine-with-parameter/183751>\
**Category:** Forum\
**Tags:** Adabas-Natural, Natural, Natural-on-Linux\
**Created:** [September 8, 2015, 3:21pm UTC](https://techcommunity.softwareag.com/t/create-subroutine-with-parameter/183751 "2015-09-08T15:21:46Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alexander\_Andreev1](https://avatars.discourse-cdn.com/v4/letter/a/858c86/32.png) [@Alexander\_Andreev1](https://techcommunity.softwareag.com/u/Alexander_Andreev1)\
**Post date:** [September 8, 2015, 3:21pm UTC](https://techcommunity.softwareag.com/t/create-subroutine-with-parameter/183751/1 "2015-09-08T15:21:46Z")

</div>

Hi there!

How I can create a subroutine with parameter in a report mode?

Could you give me some code snippets please?

Best Regards,  
Alexander

---

<div class="post-metadata">

**Author:** ![Giles](https://avatars.discourse-cdn.com/v4/letter/g/c68b51/32.png) [@Giles](https://techcommunity.softwareag.com/u/Giles)\
**Post date:** [September 8, 2015, 5:00pm UTC](https://techcommunity.softwareag.com/t/create-subroutine-with-parameter/183751/2 "2015-09-08T17:00:35Z")

</div>

0010 PERFORM SUB ‘FRED’  
0020 END

```
                                  > + Subroutine

```

l …+…1…+…2…+…3…+…4…+…  
0010 DEFINE DATA PARAMETER  
0020 1 #A (A4)  
0030 END-DEFINE  
0040 DEFINE SUBROUTINE SUB  
0050 DISPLAY #A  
0060 RETURN  
0070 END

why don’t you want to use structured mode ?

---

<div class="post-metadata">

**Author:** ![Alexander\_Andreev1](https://avatars.discourse-cdn.com/v4/letter/a/858c86/32.png) [@Alexander\_Andreev1](https://techcommunity.softwareag.com/u/Alexander_Andreev1)\
**Post date:** [September 9, 2015, 7:01am UTC](https://techcommunity.softwareag.com/t/create-subroutine-with-parameter/183751/3 "2015-09-09T07:01:44Z")

</div>

Thank you for reply Giles!

This code for the structured mode , right?

P. S. Sorry, I’m new to Natural.

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![Giles](https://avatars.discourse-cdn.com/v4/letter/g/c68b51/32.png) [@Giles](https://techcommunity.softwareag.com/u/Giles)\
**Post date:** [September 9, 2015, 11:36am UTC](https://techcommunity.softwareag.com/t/create-subroutine-with-parameter/183751/4 "2015-09-09T11:36:48Z")

</div>

that code will catalog in reporting mode (it does on the mainframe natural 8 anyway).  
You didn’t explain why you want to use reporting mode though.

---

<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:** [September 9, 2015, 12:46pm UTC](https://techcommunity.softwareag.com/t/create-subroutine-with-parameter/183751/5 "2015-09-09T12:46:22Z")

</div>

Strictly speaking there are just two modes, Reporting mode and Structured mode.

There are two main areas where they differ. The first is syntax. In Reporting mode all loops end with the word LOOP (or CLOSE LOOP). Also IF clauses with more than one statement require DO…DOEND to “define the bounds” of the IF.

In structured mode all loops end with special terms like END-READ, END-FIND, etc. IF clauses require an END-IF, etc.

The second area of difference is data definition. In the original Reporting Mode, variables were always defined at the first physical occurrence. Thus MOVE ‘QWERT’ TO #A (A10). When Structured Mode was introduced, it contained all the DEFINE DATA clauses like LOCAL, PARAMETER, GLOBAL, etc.

There is also a third mode. I have always called this “Mixed Mode”, although the documentation calls it Structured Data Mode. This is Reporting Mode with the DEFINE DATA clauses.

Mixed (structured data) MODE is a subset of Reporting Mode, not Structured Mode.

Thus, the following is valid Reporting Mode code:

DEFINE DATA LOCAL  
1 MYVIEW VIEW OF EMPLOYEES  
2 NAME  
2 FIRST-NAME  
1 #NAME (A20)  
END-DEFINE  
READ (10) MYVIEW  
IF NAME = ‘SMITH’  
DO  
MOVE NAME TO #NAME  
::::  
DOEND  
LOOP

Note, the Report Mode Syntax. For example DO:::DOEND not END-IF. LOOP not END-READ.  
Note also the use of a View, which is allowed in Mixed Mode, and, of course, in Structured Mode. Note also the definition of #NAME in the DEFINE DATA clause, not in the first use of #NAME.

There are, of course, other differences between Report and Structured Mode. For example, MOVE INDEXED is allowed in Report (and hence Mixed) Mode, but not in Structured Mode.

Hence Giles’ code is perfectly valid Mixed Mode (and hence Report Mode) code.

Although Structured Mode is the newer Mode, it is a subset of Report Mode, since the “new stuff” (e.g. DEFINE DATA) was incorporated within the Mixed Mode version of Report Mode.

I tend to call Structured Mode the “idiot proof” version of Natural since statements that could get you in trouble in Report Mode (MOVE INDEXED being a prime example) do not exist in Structured Mode.

There is really no reason to write new Report (or Mixed Mode ) code unless you have an ancient version of Natural which does not have Structured or Mixed Modes.

---

<div class="post-metadata">

**Author:** ![Alexander\_Andreev1](https://avatars.discourse-cdn.com/v4/letter/a/858c86/32.png) [@Alexander\_Andreev1](https://techcommunity.softwareag.com/u/Alexander_Andreev1)\
**Post date:** [September 9, 2015, 3:14pm UTC](https://techcommunity.softwareag.com/t/create-subroutine-with-parameter/183751/6 "2015-09-09T15:14:32Z")

</div>

> [@Giles](#):
>
> that code will catalog in reporting mode (it does on the mainframe natural 8 anyway).  
> You didn’t explain why you want to use reporting mode though.

I have the Natural 6.3 on the board.  
All programs which was created by the previous programmer written in the report mode.  
I decided to go on the same way.

Thank you so much for help and explanation!

Kind Regards,

---

<div class="post-metadata">

**Author:** ![Giles](https://avatars.discourse-cdn.com/v4/letter/g/c68b51/32.png) [@Giles](https://techcommunity.softwareag.com/u/Giles)\
**Post date:** [September 9, 2015, 3:39pm UTC](https://techcommunity.softwareag.com/t/create-subroutine-with-parameter/183751/7 "2015-09-09T15:39:03Z")

</div>

Don’t propagate his decision. Start using structured mode.  
I only use report mode for a quick and dirty to query a file e.g.  
READ FILE  
DISPLAY FIELD .

---

<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, 3:34pm UTC](https://techcommunity.softwareag.com/t/create-subroutine-with-parameter/183751/8 "2021-04-02T15:34:09Z")

</div>


