Highlighted
Super Contributor.
Super Contributor.
157 views

Acu GT cobol do not give build the logic now

Jump to solution

Hi,

I have working storage variable WS-WEB-LINK pic X(150). 

And after i read my SYSFILE , I am moving the values from SYS-WEB-LINK variable  to  WS-WEB-LINK  variable.  Just note SYS-WEB-LINK also declared pic X(150) in copy book,.

Now, i wanted to ignore all spaces in WS-WEB-LINK  and move the ONLY values to WS-FINAL-LINK.(without spaces) using STRING statement. I did that. that is okay.

  WS-FINAL-LINK we will not know how variable size either 60 or 70 or 90 size.,.. But, maximum i declared as 150 bytes . that is okay,

My question is here,  I just wanted to know how do i declare the size to WS-FINAL-LINK based on Inspect counter value at the run time using Acu GT cobol software.

That is reason i am saying Acu GT cobol do not give build the logic now..

Any clue please? This is urgent request from my side....thank you in advance.,

 

 

 

 

0 Likes
1 Solution

Accepted Solutions
Highlighted
Micro Focus Expert
Micro Focus Expert

Re: Acu GT cobol do not give build the logic now

Jump to solution

you can use STRING with a POINTER to automatically count the characters moved:

WORKING-STORAGE SECTION.

 01 SOURCE-STRING PIC X(50) VALUE NULL.
 01 STR-PTR PIC 9(3).

PROCEDURE DIVISION.

    MOVE 1 TO STR-PTR
    STRING "  The length of string    "
    INTO SOURCE-STRING
    POINTER STR-PTR
    SUBTRACT 1 FROM STR-PTR

STR-PTR will contain the length of the actual string. Note that STR-PTR must be explicitly set to 1 before using the STRING command.

View solution in original post

0 Likes
10 Replies
Highlighted
Contributor.
Contributor.

Re: Acu GT cobol do not give build the logic now

Jump to solution

Hi Joseph.

May I ask why do you need to declare the WS-FINAL-LINK variable with the right size?

Can't you just:

- Define WS-FINAL-LINK variable as PIC X(150)

- Count how many chars are stored in that variable and save it in another variable, for example WS-SIZE

- When you need to use the "sized variable", use the syntax WS-FINAL-LINK(1:WS-SIZE)

 

If you can't use this syntax, can you tell us where do you have to use the WS-FINAL-LINK variable and why it can't work?

0 Likes
Highlighted
Super Contributor.
Super Contributor.

Re: Acu GT cobol do not give build the logic now

Jump to solution

Hello , Thanks for your quick response.

Hi Joseph.

May I ask why do you need to declare the WS-FINAL-LINK variable with the right size?

My answer - Yes, I should keep size as X(150)

Can't you just:

- Define WS-FINAL-LINK variable as PIC X(150)

- Count how many chars are stored in that variable and save it in another variable, for example WS-SIZE

- When you need to use the "sized variable", use the syntax WS-FINAL-LINK(1:WS-SIZE)

My answer- WS-SIZE i can do reference modification. Yes, But, if i get to know runtime variable declaration, more helpful to fulfill my customer requirement. I will need it for many purpose.

 

If you can't use this syntax, can you tell us where do you have to use the WS-FINAL-LINK variable and why it can't work?

My answer- I declared like 01 WS-FINAL-LINK  X(150)

0 Likes
Highlighted
Contributor.
Contributor.

Re: Acu GT cobol do not give build the logic now

Jump to solution

Well, if you can't use the (1:size) syntax I can suggest you to take a look at the M$ALLOC.

It is not so comfortable to use, but you can directly manage the memory... 

0 Likes
Highlighted
Super Contributor.
Super Contributor.

Re: Acu GT cobol do not give build the logic now

Jump to solution

Ok Thanks. Can you please brief about M$ALLOC 

Any link please to study?

0 Likes
Highlighted
Super Contributor.
Super Contributor.

Re: Acu GT cobol do not give build the logic now

Jump to solution

Any simple sample program to understand about M$ALLOC please?

What  disadvantage on this?

0 Likes
Highlighted
Super Contributor.
Super Contributor.

Re: Acu GT cobol do not give build the logic now

Jump to solution
CALL "M$ALLOC" 
    USING ITEM-SIZE, MEM-ADDRESS

do i need to declare MEM-ADDRESS in working storage section.? what size ?

0 Likes
Highlighted
Super Contributor.
Super Contributor.

Re: Acu GT cobol do not give build the logic now

Jump to solution

when i use "M$ALLOC" in my program, it gives below error. Pleas note I am using Acubench to compile/run program.

Invalid or missing parameter to "M$ALLOC"

0 Likes
Highlighted
Contributor.
Contributor.

Re: Acu GT cobol do not give build the logic now

Jump to solution

Hi

M$ALLOC allows you to directly work with the memory. In this way, you can decide how many data store in this memory at runtime.

Main disadvantages are:

- It is a low-level rout, so you have to manually release the memory with M$FREE routine

- It is not so easy to use as common variables, since you have to get/put/copy memory with specific routines (M$GET, M$PUT, M$COPY)

 

But in this way, you can use any desired size.

 

Honestly, I still don't understand what your customer ask and why can't you use the "(1:SIZE)" syntax, but if it doesn't work, the only way I know is to manage the memory directly from M$ALLOC

 

 

About your question, I don't have any example since I used it only once in my life. In any way, this is the link where you can find the documentation of the M$ALLOC routine and all other related stuff: https://www.microfocus.com/documentation/extend-acucobol/103/extend-Interoperability-Suite/BKPPPPLIBRS136.html

With M$ALLOC you have to pass two parameters: size (working storage variable or a number) and the pointer to the memory, defined in working storage as "USAGE HANDLE".

All other call to the memory (M$GET, M$PUT, ...) are done with this HANDLE that is the pointer to the allocated memory.

 

Pay attention to always call the right M$FREE for each call to the M$ALLOC, or nobody will release the allocated memory 

0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

Re: Acu GT cobol do not give build the logic now

Jump to solution

you can use STRING with a POINTER to automatically count the characters moved:

WORKING-STORAGE SECTION.

 01 SOURCE-STRING PIC X(50) VALUE NULL.
 01 STR-PTR PIC 9(3).

PROCEDURE DIVISION.

    MOVE 1 TO STR-PTR
    STRING "  The length of string    "
    INTO SOURCE-STRING
    POINTER STR-PTR
    SUBTRACT 1 FROM STR-PTR

STR-PTR will contain the length of the actual string. Note that STR-PTR must be explicitly set to 1 before using the STRING command.

View solution in original post

0 Likes
Highlighted
Super Contributor.
Super Contributor.

Re: Acu GT cobol do not give build the logic now

Jump to solution

Great! Thanks for your solution, it worked.

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.