Bernd do you have a small example of how you did this : Call from C# into COBOL via normal linkage.
Regards
Neil
Bernd do you have a small example of how you did this : Call from C# into COBOL via normal linkage.
Regards
Neil
We have Net Express version 3.1 and i have been trying to call a C# program from a COBOL program unsuccessfully. Any help would be appreciated.
My problems are not the same, but similar.
I solved the case by opening the XML file first as simple line sequential file. Then analyze the contents one byte after another. If I find a possible UTF character: > X"7F" I look for the next character, which must be larger than > X"7F". If not, I reject the whole XML file and do not even try to open/read it. This is a “selfmade” solution to a problem, that NETEXPRESS should detect, but does not.
My report (nov.2014) was:
We receive a lot of invoices in XML format from our suppliers. All have the header
<?xml version="1.0" encoding="UTF-8"?>
and should be in that format. Unfortunately some do not fulfill this format and have some fields filled with ASCII characters (not UTF-8 as it should be), including accented vowels á é í ó ú. X”F3” X”E9” X”E1” X”FA” etc.
The Internet Explorer does not open/show the file due to this wrong codification.
My program has the
ENVIRONMENT DIVISION.
FILE-CONTROL.
select factura-XML assign to ID-ARCHIVO-FAC
file status is file-status-spec.
The program generally works very fine if the XML is encoded right and reads all fields. But if the READ statement tries to read such a malformed file, the status does not report any error code, but aborts the program with a 114 error code.
What must I do to receive an error code instead of aborting the program?
I have no chance to examine the file-status-spec and inform the operator, because the program aborts immediately with the message
Execution error: file LEC-XML5
error CODE 114, PC=0, CALL=1, SEG=0
114 Attempt to access item beyond bounds of memory (Signal 11)
In adition to my previous report, here a more detailed description of the problem.
The wrong coded XML that I received starts with the following:
<?xml version="1.0" encoding="UTF-8"?>
<cfdi:Comprobante xmlns:xsi="www.w3.org/.../XMLSchema-instance" xsi:schemaLocation="http://www.sat.gob.mx/cfd/3www.sat.gob.mx/.../cfdv32.xsd" version="3.2" folio="857" fecha="2014-11-04T11:31:18" formaDePago="Pago en una sola exhibición"
The Word “exhibición” is wrong coded.
“exhibición” x”65 78 68 69 62 69 63 69 F3 6E the accented o is not coded in UTF-8
e x h i b i c i o
It should be
“exhibición” x”65 78 68 69 62 69 63 69 C3 B3 6E the accented o = X”C3B3”
e x h i b i c i o
Our problem is, that the NETEXPRESS does not return any error code, but just aborts the program with
Execution error: file LEC-XML5
ERROR CODE: 114, PC=0, CALL=1, SEG=0
114 Attempt to access item beyond bounds of memory (Signal 11)
As I wrote in my previous report, I solved the case by analyzing the XML as plain text file.
If any byte > than X”7F” (in this case X”F3” ) is not followed by a byte also > than X”7F” (in the wrong case X”6E”) I reject the whole file, and don’t even open or read the XML.
If the file is coded right as UTF-8 X"C3" is followed by X"B3"
Perhaps an unusual way to solve the problem, but it works. Of course it would be better if Micro Focus corrects the compiler. I would not need the analyzing, but just open the XML, read it and look at the status-code.
Rolf,
We should be able to handle this error condition in a better manner than a RTS 114 error that would alert you to the condition but allow the program to continue.
Have you reported this to Customer Care in a support incident? What was the number?
Yes, I reported it 11/03/2015 with Report 2802674 . As I found a way around the Problem they asigned a medium priority.
I just tested the problem here and it does still exist in the latest wrappack of NX 5.1 but it appears to already be fixed in later products like Studio 6.0 and Visual COBOL 2.3. In these products an xml status code of -9 is returned on the read instead of an RTS 114.
If you would like this to be fixed in 5.1 then please update the incident with that request and the engineer will assign a higher priority to it.
Hi Shatty,
First off I notice you are executing "vuescan.exe" asynchronously so the program can never pass anything back to the program that initiates it. You notice that I say initiates rather than call as "CBL_EXEC_RUN_UNIT" executes "vuescan.exe" in another operating system process not in the same process as the program that invokes it. If you look up the documentation for "CBL_EXEC_RUN_UNIT" you will notice RU-Flags should contain 1, not zero to execute synchronously.
Given the fact that you are invoking a program in another run unit you have only two choices to get those sort of details:
Good luck,
Michael
We have upgraded (Windows) NE 5.1.6 to NE 5.1.12.
After this update there is an automatic conversion from 2 bytes diacritic to one character diacritic
Now some my programs are not working any more .
Example.
My program converted Indonesië to Indonesie .
translation table:
# Kolommen : Cod = Unicode
# S = Soort (X = exact of V = vervangend of E = Escapeteken)
# F = Formaat (H = Hexadecimaal of A = Alfanumeriek)
# Teken = Teken volgens tekenset
#ade
#Cod S F Teken Omschrijving
#--- - - ---------- ----------------------------
00E9 X H C3A9 LATIN SMALL LETTER E WITH ACUTE
The 5.1.6 program showes the 'ë' as two bytes and translated it to 'e'
Now 5.1.12 program, noting changed in program code, see it as 'ë' (while debugging) one character
How can we change it to the 2 bytes like the 5.1.6 version ?
Code-set or settings or cfg or something else ?
The incidentnumber is 2870879.
It is an urgent problem......
I have upload a program and a file, where you can test the diacritic problem. It is a zip file.
I hope it can be solved quickly (incidentnumber 2870879)
Actually, there is one more way that you can communicate data between different rununits and that is by using shared memory and the NX library routines, CBL_PUT_SHMEM_PTR and CBL_GET_SHMEM_PTR.
You can find an example in the knowledgebase article here:
Thanks Michael,, you're right, I will to make a test
Hi Chris,
Probably not a goer in this case though Chris as Shatty is communicating with a non-COBOL program ...
I'll admit to a bias against using shared memory for interprocess communication - there's just too many things that can go wrong, especially with locking. That's probably unfair of me but explains why I blocked it out!
Michael
Hi Michael,
Sorry, I completely missed the part about it being a non-COBOL process even though it is right there in the post title.
Thanks
Hi Michael,
Thanks for your feedback, I understand the problem I’m facing as you did explain it, but I really get lost how to solve it out as you mentioned in that two choices,
I will appreciate it if you could give an example in how to do it.
Within the application I’m designing “using MF Netexpress 5.1”,, I need to scan documents and pictures as a part of an employee record,, then when that employee data to be retrieved these documents and pictures will be shown if required.
I don’t know how to use scanner in COBOL, that’s why I tried to "vuescan.exe"
Best regards
Shatty
Hi Shatty,
we have a quite similar need, and solved it very easy. Our Netexpress does not scan directly (that is done Independent with a Kodak ScanMate i1120 scanner and the included Software) We scan the documents that shall be linked into a certain specific folder. (images to be linked) that should be possible with any scanner.
The NETEXPRESS program now makes the important job in the following steps:
1. with call 'CBL_DIR_SCAN_READ' it builds a table of all images to be processed (all *.jpg in order to have small files).
2. A call to PDFCREATOR or PDFC1 converts all images to PDF (to Show them with AcroRd)
3. A call to 'AcroRd32 /a "zoom=60" ' visualizes one image after an other on the screen.
4. The operator identifies the image, types the new name for the document.
5. Netexpress renames the file (=moves it to another folder), writes the name in a file which makes the link between the image and the invoice.
Perhaps you need some different steps for your purpose, but with this operation I avoide to scan the documents from within the Netexpress program, shared Memory, etc..
If you need more explanation, please tell me.
Rolf
Hi Rolf
Thanks for your interest and feedback,, I really don't have good experience in Library routines, thus I can’t follow up how to use “CBL_DIR_SCAN_READ” .
Kindly if you send me a sample program of how using it I will appreciate your help
My email :shatty1954@gmail.com
best regards
Shatty
Here the just compiled program, a DEMO from MICRO FOCUS.
000001$SET FOLDCOPYNAME"LOWER"
000002*
000004*
000009 identification division.
000010 program-id. dirdemo.
000011 data division.
000012 working-storage section.
000013
000014* Variables for CBL_DIR_SCAN_BEGIN
000015* Some used by other CBL_DIR_SCAN_ routines.
000016
000017* The handle.
000018 01 dir-handle pointer.
000019
000020* The pattern. I chose a null terminator instead of
000021* specified length.
000022 01 dir-name-pattern.
000023* 10 dir-name-pattern-length cblt-x2-comp5 value zero.
000024 10 dir-name-pattern-length pic xx comp-5 value zero.
000025 10 dir-name-pattern-text pic x(2048).
000026
000027* The terminator.
000028 01 pattern-terminator pic x value low-values.
000029
000030* Search attributes.
000031 01 search-attributes pic x(4) comp-5 value zero.
000032 78 find-file value 1.
000033 78 find-directory value 2.
000034 78 find-neither value 4.
000035
000036* Flags
000037 01 dirflags PIC X(4) COMP-5.
000038 78 escape-seq value 1.
000039 78 wildcards value 2.
000040
000041 01 search-status pic xx comp-5.
000042
000043* Variables for CBL_DIR_SCAN_READ
000044
000045* The entry.
000046 01 entry-data.
000047 10 entry-data-attribute PIC X(4) COMP-5.
000048 10 entry-data-date-stamp.
000049 20 stamp-year PIC X(4) COMP-5.
000050 20 stamp-month PIC X(2) COMP-5.
000051 20 stamp-day PIC X(2) COMP-5.
000052 20 stamp-hour PIC X(2) COMP-5.
000053 20 stamp-minute PIC X(2) COMP-5.
000054 20 stamp-sec PIC X(2) COMP-5.
000055 20 stamp-msec PIC X(2) COMP-5.
000056 20 stamp-dst PIC X COMP-5.
000057 20 stamp-size PIC X(8) COMP-5.
000058 10 entry-data-name.
000059 20 name-length PIC X(2) COMP-5 value 50.
000060 20 name-text pic x(50).
000061
000062* Variables for CBL_DIR_SCAN_END
000063* No additional data items required.
000064
000065* Command line argument data area
000066*01 arg-pos pic 9 value 1.
000067*01 arg-text pic x(2048) value spaces.
000068
000069* OTHER VARIABLES
000070 01 attrib-work pic x comp-5.
000071 01 attrib-text pic x(10).
000072 01 nonblank-len pic 9(9).
000073 01 terminator-position pic 9(9).
000074 01 Indix pic 99 usage comp.
000075 procedure division.
000076
000077* Check for directory specification on command line.
000078* display arg-pos upon argument-number.
000079* accept arg-text from argument-value.
000080* if arg-text = spaces
000081 move '\cobol\source\cli*.cbl' to dir-name-pattern-text
000082* move '\cobol' to dir-name-pattern-text
000083* else
000084* move arg-text to dir-name-pattern-text.
000085
000086* Find the nonblank length and append string terminator.
000087 perform varying nonblank-len
000088 from function length(dir-name-pattern-text)
000089 by -1 until
000090 dir-name-pattern-text(nonblank-len:1) <> space
000091 or
000092 nonblank-len = 1.
000093* add 1 to nonblank-len giving terminator-position.
000094 add 1 to nonblank-len giving indix.
000095* move nonblank-len to indix.
000096 MOVE X"00" TO dir-name-pattern-text(indix:1)
000097* move function NULL-TERMINATE dir-name-pattern-text
000098* to arg-text
000099
000100* move pattern-terminator
000101* to dir-name-pattern-text(terminator-position:1).
000102
000103* Set desired search attributes by name.
000104 compute search-attributes =
000105 find-file +
000106 find-directory +
000107 find-neither.
000108* move zero to dirflags.
000109 move 2 to dirflags.
000110
000111* Start the scan -- similar to opening a file.
000112 call 'CBL_DIR_SCAN_START' using
000113 dir-handle
000114 dir-name-pattern
000115 search-attributes
000116 dirflags
000117 returning
000118 search-status.
000119
000120* Read to end, similar to reading a file.
000121 perform walk-dir thru walk-dir-exit until
000122 search-status <> zero.
000123
000124
000125* At end or upon error, end the scan, similar to closing a file.
000126 call 'CBL_DIR_SCAN_END' using
000127 dir-handle
000128 returning
000129 search-status.
000130
000131* End the program.
000132 display 'That''s all!'.
000133 goback.
000134
000135 walk-dir.
000136* Initialize name-text; function does not right-pad to length.
000137 move spaces to name-text.
000138
000139* Do the read.
000140 call 'CBL_DIR_SCAN_READ' using
000141 dir-handle
000142 entry-data
000143 returning
000144 search-status.
000145
000146 if search-status <> zero exit paragraph.
000147
000148* Remove all but the two rightmost bits of result.
000149 move function MOD(entry-data-attribute, 3) to attrib-work.
000150
000151* Format result display.
000152 evaluate attrib-work
000153 when 1 move 'File' to attrib-text
000154 when 2 move 'Directory' to attrib-text
000155 when other move '???' to attrib-text.
000156 display 'Next entry is: '
000157 attrib-text ' ' name-text(1:name-length).
000158
000159 walk-dir-exit.
* Micro Focus Net Express V5.0 revision 000 Compiler
* Total Messages: 0
* Data: 2764 Code: 408
hello,,
I'm using the bellow routine it's working fine,
move spaces to RU-Command-Line.
string "vuescan.exe" delimited by size
into RU-Command-Line
end-string.
move length of RU-Command-Line to RU-Command-Line-Len.
move 0 to RU-Stack-Size.
move 0 to RU-Flags.
call "CBL_EXEC_RUN_UNIT"
using by reference RU-Command-Line
by value RU-Command-Line-Len
by reference RU-ID
by value RU-Stack-Size
by value RU-Flags
returning RU-Status-Code
end-call.
*
My qustion and needs :how can I get data from the called program "vuescan.exe", like the file-name and the path were that file have been saved,, and pass it to the calling program.
Regards
For COBOL to NON COBOL you could create a GUID in the COBOL program and pass that to the NON COBOL program, the NON COBOL program could use it to write out a file. On return read then delete the file.
This way it could also be thread safe.
Neil