Highlighted
Trusted Contributor.
Trusted Contributor.
2500 views

COBCH0837S Procedural code not allowed here

Jump to solution

I am writing an Eclipse  managed cobol program.

Whenever I try to put statements in the Class Working-Storage Section, my first statement gives me

error COBCH0837S Procedural code not allowed here.

Am stumped and i hope someone can assist me.

Thanks,

Warren Mundy

0 Likes
2 Solutions

Accepted Solutions
Highlighted
Absent Member.
Absent Member.

RE: COBCH0837S Procedural code not allowed here

Jump to solution

Yes, the class can have working-storage that is global to the class.  I wasn't sure if that's what you intended.  Procedural code (statements) must be in methods.  A class does not have its own procedural code outside of a method.

View solution in original post

0 Likes
Highlighted
Micro Focus Frequent Contributor
Micro Focus Frequent Contributor

RE: COBCH0837S Procedural code not allowed here

Jump to solution

This might help

 

Here is a simple class below, VCList with main static method for testing, yes the 0d0a could be improved but this show a class with a main method for testing and constructors.

 

This is from an article I wrote a long time ago.

It demonstrates how well Visual COBOL and JAVA can integrate. It covers the core subjects of CLASSPATH, PACKAGES, BUILDING JAR files and executing programs.

 

http://community.microfocus.com/microfocus/cobol/visual_cobol/w/knowledge_base/21473.visual-cobol-and-java-integration.aspx

 

Basically the class is self-contained, and has a static main method for testing.

 

>>>>>> VCList.cbl

     $set sourceformat(variable)    

     $set ooctrl(+p-f) intlevel"4"

     $set ilusing"java.util"

     $set ilusing"java.lang"

     $set ilusing"com.microfocus.vcexamples.list"

      

       class-id com.microfocus.vcexamples.list.VCList public.

      

       01 ls type List public.

      

       *> no argument constructor

       method-id new public.

       procedure division.

           set ls to new ArrayList[String]

           invoke ls::add("one")

           invoke ls::add("Three")

           invoke ls::add("two")

           invoke ls::add("four")

       end method.

 

     *> constructor passing a List

       method-id new public.

       procedure division using by reference ls as type List.

           set self::ls to new ArrayList(ls);

       end method.

              *> just exercise class for getting lists about

       method-id toString override.

       01 sb type StringBuffer.

       01 val string.

      

       procedure division returning lnkmessage as string.

           set sb to new StringBuffer

           perform varying val through ls

               invoke sb::append("<")

               invoke sb::append(val)

               invoke sb::append(">")

               invoke sb::append(x'0d0a') *> dont handle \n

           end-perform  

           set lnkmessage to sb::toString()

          

       end method.

                             

      

     *>

     *> main entry point

     *>

       method-id main public static.

       local-storage section.

       linkage section.

       01 args type String occurs any.

      

       procedure division using by value args.

           *> Create the VCList

           *> use the declare and create syntax

           declare tstVCList as type VCList

           create tstVCList

          

           display "Visual Cobol the VCList at start :"

           display "using List::tostring : ", tstVCList::ls

           display "using VCList::tostring : "

           display tstVCList

           *> Fire of a core java static method to sort

           invoke type Collections::sort(tstVCList::ls, String::CASE_INSENSITIVE_ORDER)

           display "Visual Cobol the VCList after sort :"

           display "using List::tostring : ", tstVCList::ls

           display "using VCList::tostring : "

           display tstVCList

          

 

       end method.

       end class.

>>>>>> 

 

View solution in original post

0 Likes
8 Replies
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: COBCH0837S Procedural code not allowed here

Jump to solution

Hi Warren,

Can you please be more specific? What type of statements are you trying to put in working-storage? The only statements that should go into working-storage are data definition clauses.

All procedural statements should go in the procedure division.

Can you copy/paste what it is that you are trying to do?

Thanks

0 Likes
Highlighted
Trusted Contributor.
Trusted Contributor.

RE: COBCH0837S Procedural code not allowed here

Jump to solution

I meant to say Procedure Division  Later today I will sent you the code.

Thanks,

Warren Mundy

0 Likes
Highlighted
Trusted Contributor.
Trusted Contributor.

RE: COBCH0837S Procedural code not allowed here

Jump to solution

Chris,

Here is the little class in question.

class-id consoleApplication24.Prog2b public.

      working-storage section.

      01  myobj1 type consoleApplication24.Prog2b

                 value new type consoleApplication24.Prog2b public.

      01  myarg type short.

      procedure division.

      invoke myobj1::getid returning myarg.       <<----gets message COBCH0837S

      display "myid is - " & myarg.

      goback.

      method-id getid public.

          local-storage section.

          linkage section.

          01  myid type short.

         procedure division returning myid.

         compute  myid = function random().

         goback.

         end method.

      end class.

0 Likes
Highlighted
Absent Member.
Absent Member.

RE: COBCH0837S Procedural code not allowed here

Jump to solution

You need a method to contain procedural code in managed code.  Add a method-id/end method around the first procedure division, or include the working-storage if that isn't class working-storage.

0 Likes
Highlighted
Trusted Contributor.
Trusted Contributor.

RE: COBCH0837S Procedural code not allowed here

Jump to solution

I thought that the class had it's own copy of working-storage section.  It is my intent that the first working-storage section and the procedure division be at class level and not a method level.  What have I missed?

Thanks,

warren mundy

0 Likes
Highlighted
Absent Member.
Absent Member.

RE: COBCH0837S Procedural code not allowed here

Jump to solution

Yes, the class can have working-storage that is global to the class.  I wasn't sure if that's what you intended.  Procedural code (statements) must be in methods.  A class does not have its own procedural code outside of a method.

View solution in original post

0 Likes
Highlighted
Micro Focus Frequent Contributor
Micro Focus Frequent Contributor

RE: COBCH0837S Procedural code not allowed here

Jump to solution

This might help

 

Here is a simple class below, VCList with main static method for testing, yes the 0d0a could be improved but this show a class with a main method for testing and constructors.

 

This is from an article I wrote a long time ago.

It demonstrates how well Visual COBOL and JAVA can integrate. It covers the core subjects of CLASSPATH, PACKAGES, BUILDING JAR files and executing programs.

 

http://community.microfocus.com/microfocus/cobol/visual_cobol/w/knowledge_base/21473.visual-cobol-and-java-integration.aspx

 

Basically the class is self-contained, and has a static main method for testing.

 

>>>>>> VCList.cbl

     $set sourceformat(variable)    

     $set ooctrl(+p-f) intlevel"4"

     $set ilusing"java.util"

     $set ilusing"java.lang"

     $set ilusing"com.microfocus.vcexamples.list"

      

       class-id com.microfocus.vcexamples.list.VCList public.

      

       01 ls type List public.

      

       *> no argument constructor

       method-id new public.

       procedure division.

           set ls to new ArrayList[String]

           invoke ls::add("one")

           invoke ls::add("Three")

           invoke ls::add("two")

           invoke ls::add("four")

       end method.

 

     *> constructor passing a List

       method-id new public.

       procedure division using by reference ls as type List.

           set self::ls to new ArrayList(ls);

       end method.

              *> just exercise class for getting lists about

       method-id toString override.

       01 sb type StringBuffer.

       01 val string.

      

       procedure division returning lnkmessage as string.

           set sb to new StringBuffer

           perform varying val through ls

               invoke sb::append("<")

               invoke sb::append(val)

               invoke sb::append(">")

               invoke sb::append(x'0d0a') *> dont handle \n

           end-perform  

           set lnkmessage to sb::toString()

          

       end method.

                             

      

     *>

     *> main entry point

     *>

       method-id main public static.

       local-storage section.

       linkage section.

       01 args type String occurs any.

      

       procedure division using by value args.

           *> Create the VCList

           *> use the declare and create syntax

           declare tstVCList as type VCList

           create tstVCList

          

           display "Visual Cobol the VCList at start :"

           display "using List::tostring : ", tstVCList::ls

           display "using VCList::tostring : "

           display tstVCList

           *> Fire of a core java static method to sort

           invoke type Collections::sort(tstVCList::ls, String::CASE_INSENSITIVE_ORDER)

           display "Visual Cobol the VCList after sort :"

           display "using List::tostring : ", tstVCList::ls

           display "using VCList::tostring : "

           display tstVCList

          

 

       end method.

       end class.

>>>>>> 

 

View solution in original post

0 Likes
Highlighted
Trusted Contributor.
Trusted Contributor.

RE: COBCH0837S Procedural code not allowed here

Jump to solution

Thanks to all of you that answered my question and cleared up my misunderstanding of class vs method procedure divisions.

Thanks again.

Warren Mundy

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.