Hello,
I'm converting an application from an equipment supplier, and he provided me with a C# source.
I tried to convert from C# to Cobol, using the "OpenText C# to Micro Focus Visual Cobol Translator" tool, but it is giving me an erro in one of the parts.
The original source:
public async Task<InitialResponse> InitiateOperationAsync(string baseUrl, PaymentRequest paymentRequest)
{
string payJson = JsonSerializer.Serialize(new
{
PAY = new
{
posto = paymentRequest.Posto,
operador = paymentRequest.Operador,
valor = paymentRequest.Valor
}
});
string requestUrl = $"{baseUrl}?PAY={payJson}";
try
{
HttpResponseMessage response = await _httpClient.GetAsync(requestUrl);
response.EnsureSuccessStatusCode();
string content = await response.Content.ReadAsStringAsync();
return JsonSerializer.Deserialize<InitialResponse>(content);
}
catch (Exception ex)
{
throw new InvalidOperationException("Failed to initiate payment operation.", ex);
}
}
The result in cobol:
method-id InitiateOperationAsync (baseUrl as string, paymentRequest as type PaymentRequest) yielding return-value as type InitialResponse async final.
declare payJson as string = type JsonSerializer::Serialize(
PAY
posto paymentRequest::Posto
operador paymentRequest::Operador
valor paymentRequest::Valor
)
declare requestUrl as string = string::Format("{0}?PAY={1}", baseUrl, payJson)
try
declare response as type HttpResponseMessage = await _httpClient::GetAsync(requestUrl)
invoke response::EnsureSuccessStatusCode()
declare #content as string = await response::Content::ReadAsStringAsync()
set return-value to type JsonSerializer::Deserialize[type InitialResponse](#content)
goback
catch ex as type Exception
raise new InvalidOperationException("Failed to initiate payment operation.", ex)
end-try
end method.
Can you help me mor one time?
Best regards
Alberto Ferraz
------------------------------
Alberto Ferraz
E.S.I.C. - Serviços De Informática, Lda
Massamá PT
------------------------------
Hi Chris,
Thank you for your programming lines.
I have already created a WPF project and combined Class.cbl with the content you sent me.
I have already made the necessary adaptations and carried out some tests.
Apparently everything will be working.
Now I have to improve some features to be 100% effective.
There is a situation that I will have to implement but I haven't been able to see how yet.
I have to find a way to cancel the process (CANCEL) while I'm in the machine query cycle to see if it's already finished.
I have a window with an AMOUNT field, a PAY button and a CANCEL button.
I enter the amount and click PAY. While the machine is waiting for the customer to enter the money, I may have to cancel the process.
Considering that the CANCEL button is in the main program, if I click on CANCEL, will the program detect this CANCEL?
Thank again.
------------------------------
Alberto Ferraz
Sr
E.S.I.C. - Serviços De Informática, Lda
Massamá PT
------------------------------
The general technique you're looking for in WPF is to use a background thread for the processing instead of doing the work on the UI thread (where the button is). If it is done on the UI thread, the button will be frozen until the process returns back. This is something you will need to read up on for .NET/WPF. This concept has been around for quite some time in .NET/WPF
------------------------------
Michael Bleistein
Other
Rocket Internal - All Brands
Denver CO US
------------------------------
The general technique you're looking for in WPF is to use a background thread for the processing instead of doing the work on the UI thread (where the button is). If it is done on the UI thread, the button will be frozen until the process returns back. This is something you will need to read up on for .NET/WPF. This concept has been around for quite some time in .NET/WPF
------------------------------
Michael Bleistein
Other
Rocket Internal - All Brands
Denver CO US
------------------------------
Hi Chris,
Now that I have all the tests done, I'm trying to integrate the development I did (WPF project) into my application.
I copied the "cashClass" to the general project and I'm trying to copy the part that makes the "call" to the cashClass in the application.
I created a "method-id" in the invoice issuing source containing the part of the call to "cashClass".
As this call has an "await", the method-id has to be async so I created it like this "method-id bus_alice public async".
After issuing the invoice, I invoke this method with "invoke self::bus_alice()".
In terms of compilation, there is no error. When I run the application, this invoke gives the following error:

If you create the method as "method-id bus_alice public async-void.", it also doesn't give compilation errors but it still gives an error:

I don't know what to do. I've tried everything.
I am attaching the test project so you can check what I am trying to do. I integrated the "cashClass" into my project without any problems (for now).
The real issue is the part of calling the class.
Best regards
------------------------------
Alberto Ferraz
Sr
E.S.I.C. - Serviços De Informática, Lda
Massamá PT
------------------------------
Hi Chris,
Now that I have all the tests done, I'm trying to integrate the development I did (WPF project) into my application.
I copied the "cashClass" to the general project and I'm trying to copy the part that makes the "call" to the cashClass in the application.
I created a "method-id" in the invoice issuing source containing the part of the call to "cashClass".
As this call has an "await", the method-id has to be async so I created it like this "method-id bus_alice public async".
After issuing the invoice, I invoke this method with "invoke self::bus_alice()".
In terms of compilation, there is no error. When I run the application, this invoke gives the following error:

If you create the method as "method-id bus_alice public async-void.", it also doesn't give compilation errors but it still gives an error:

I don't know what to do. I've tried everything.
I am attaching the test project so you can check what I am trying to do. I integrated the "cashClass" into my project without any problems (for now).
The real issue is the part of calling the class.
Best regards
------------------------------
Alberto Ferraz
Sr
E.S.I.C. - Serviços De Informática, Lda
Massamá PT
------------------------------
Hi Alberto,
I ran your test project using V10.0 and it all worked perfectly.
I will test it with the version you are using which is V8.0 to see if the problem is there.
------------------------------
Chris Glazier
Principal Technical Support Specialist
Rocket Forum Shared Account
------------------------------
Hi Alberto,
I ran your test project using V10.0 and it all worked perfectly.
I will test it with the version you are using which is V8.0 to see if the problem is there.
------------------------------
Chris Glazier
Principal Technical Support Specialist
Rocket Forum Shared Account
------------------------------
Actually, it runs fine under V8.0 as well but I dont see the method on which you are getting the error.
Is there something I am supposed to do to the code in order to make it fail>
------------------------------
Chris Glazier
Principal Technical Support Specialist
Rocket Forum Shared Account
------------------------------
Actually, it runs fine under V8.0 as well but I dont see the method on which you are getting the error.
Is there something I am supposed to do to the code in order to make it fail>
------------------------------
Chris Glazier
Principal Technical Support Specialist
Rocket Forum Shared Account
------------------------------
Hi Chris,
But the problem is not the test project.
The problem is moving from the test project to the real project.
I have to pass the part of calling the "cashClass" to the content of my application.
I don't send the actual project as it is very large and requires some configuration.
If the solution has to go through the actual project, it's almost worth accessing it remotely.
Thanks
------------------------------
Alberto Ferraz
Sr
E.S.I.C. - Serviços De Informática, Lda
Massamá PT
------------------------------
Actually, it runs fine under V8.0 as well but I dont see the method on which you are getting the error.
Is there something I am supposed to do to the code in order to make it fail>
------------------------------
Chris Glazier
Principal Technical Support Specialist
Rocket Forum Shared Account
------------------------------
I'll try to make a better explanation of the problem I'm having.
I will send it in a next post.
------------------------------
Alberto Ferraz
Sr
E.S.I.C. - Serviços De Informática, Lda
Massamá PT
------------------------------
I'll try to make a better explanation of the problem I'm having.
I will send it in a next post.
------------------------------
Alberto Ferraz
Sr
E.S.I.C. - Serviços De Informática, Lda
Massamá PT
------------------------------
Hi Chris,
In the meantime, I opted for another strategy but it is also causing problems.
Instead of integrating the lines into the invoicing program, I chose to make a call to a .xaml (WPF window).
In that .xaml, then place the instructions to access the equipment's API.
The result of calling .xaml is the following:
When I click on the euro icon, it should jump to this part:
------------------------------
Alberto Ferraz
Sr
E.S.I.C. - Serviços De Informática, Lda
Massamá PT
------------------------------
Hi Chris,
In the meantime, I opted for another strategy but it is also causing problems.
Instead of integrating the lines into the invoicing program, I chose to make a call to a .xaml (WPF window).
In that .xaml, then place the instructions to access the equipment's API.
The result of calling .xaml is the following:
When I click on the euro icon, it should jump to this part:
------------------------------
Alberto Ferraz
Sr
E.S.I.C. - Serviços De Informática, Lda
Massamá PT
------------------------------
Can you please provide the required copybooks for the new program?
------------------------------
Chris Glazier
Principal Technical Support Specialist
Rocket Forum Shared Account
------------------------------
Can you please provide the required copybooks for the new program?
------------------------------
Chris Glazier
Principal Technical Support Specialist
Rocket Forum Shared Account
------------------------------
They are attached.
------------------------------
Alberto Ferraz
Sr
E.S.I.C. - Serviços De Informática, Lda
Massamá PT
------------------------------
They are attached.
------------------------------
Alberto Ferraz
Sr
E.S.I.C. - Serviços De Informática, Lda
Massamá PT
------------------------------
Still missing LNKREC.CPY.
------------------------------
Chris Glazier
Principal Technical Support Specialist
Rocket Forum Shared Account
------------------------------
Still missing LNKREC.CPY.
------------------------------
Chris Glazier
Principal Technical Support Specialist
Rocket Forum Shared Account
------------------------------
Sorry...
------------------------------
Alberto Ferraz
Sr
E.S.I.C. - Serviços De Informática, Lda
Massamá PT
------------------------------
Sorry...
------------------------------
Alberto Ferraz
Sr
E.S.I.C. - Serviços De Informática, Lda
Massamá PT
------------------------------
The problem appears to be caused by the SQL(DBMAN=ODBC) directive on in the Call_Icash.xaml.cbl program. If I comment out the directive and the statements referencing SQL syntax then it seems to work fine.
I will look into the cause more, but it is recommended that instead of embedding SQL statements directly in a WPF class that you instead put it into a separate class or COBOL program and call it from the WPF app.
------------------------------
Chris Glazier
Principal Technical Support Specialist
Rocket Forum Shared Account
------------------------------
The problem appears to be caused by the SQL(DBMAN=ODBC) directive on in the Call_Icash.xaml.cbl program. If I comment out the directive and the statements referencing SQL syntax then it seems to work fine.
I will look into the cause more, but it is recommended that instead of embedding SQL statements directly in a WPF class that you instead put it into a separate class or COBOL program and call it from the WPF app.
------------------------------
Chris Glazier
Principal Technical Support Specialist
Rocket Forum Shared Account
------------------------------
Hi Chris,
That was really the problem.
I removed everything that referred to SQL and it now works.
By the way, I didn't need any of this, but as I made a copy of an existing . xaml, this part came later.
He continued with the process.
Thanks again for the help.
------------------------------
Alberto Ferraz
Sr
E.S.I.C. - Serviços De Informática, Lda
Massamá PT
------------------------------