
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Convert a command from C# to Cobol
Hi,
I am trying to convert a C # program to Cobol but there is an instruction that, despite not giving a compilation error, is not being executed.
The original statement is:
Manager.Http.SendRequestAsync(HttpMethodType.POST, this.ActionUri, body);
and the conversion will be:
invoke type Manager::Http::SendRequestAsync(type HttpMethodType::POST, self::ActionUri, body)
What is happening is that SendRequestAsync is not being executed.
Is there a different way to convert the statement to C #?
Thanks
Alberto Ferraz

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
The code appears to be converted to COBOL properly but I am not sure what you mean by it is never executed. Does it cause an exception to occur, does it never return from the call or does it just fall thru to the next statement?
You might try wrapping a TRY/CATCH block around it to see if an exception can be trapped?
Do you have a small cutdown example that we could test with?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
This statement should execute exactly the same way C# would execute it. Keep in mind though, that this is an asynchronous method. It probably returns a Task<T> object which is used to track when the operation completes as it will be executed in the background.
You can find more information about asynchronous programming on Microsoft's documentation:
Asynchronous programming in C# | Microsoft Docs
It is likely though that you probably want to use the `await` syntax to block the current method until the operation completes successfully. Note that the await keyword is only supported in Visual COBOL 6.0 and above.
Example:
declare response = await type Manager::Http::SendRequestAsync(type HttpMethodType::POST, self::ActionUri, body)
declare content = await response::Content::ReadAsStringAsync()
Relevant MF documentation is here:
Async - in COBOL and C# (microfocus.com)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Good afternoon:
When I say that the instruction is not executed, it is because it skips to the next instruction.
My question is that I cannot understand if the parameters are all correct and if that is why it is failing.
I already tried to put the instruction in a TRY-CATCH but it also doesn't "go out" through the cath, it moves on to the next instruction.
I will try to isolate a part of the application to be able to send.
Thanks
Alberto Ferraz

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Please refer to the previous post by Ted John above for more details that you should look into...
Thanks.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Hi,
Thank you for your answers. I was able to execute the command and send the data to the machine.
Now I see how I get the answer, to know when the process is finished. If necessary,
I will send a new request for help.
Regarding the solution that Ted John presented, I was unable to incorporate it because it gives the error COBCH1927 in the "await" instruction and I still haven't figured out how to remove the error.
Thanks again.
Best regards
Alberto Ferraz