Welcome Serena Central users! CLICK HERE
The migration of the Serena Central community is currently underway. Be sure to read THIS MESSAGE to get your new login set up to access your account.
Angel3 Absent Member.
Absent Member.
1627 views

Long Strings

Hi, guys

I'm using a dll to get a xml string from a Web Service. I don't know what size has this string, but I need to store it in a cobol variable or in a file, to parse it later.

I don't want to use something like:this:

77  XML-STRING pic x(5000000)

My code:

CREATE "@Manager"
                  NAMESPACE   IS "Manager"
                  CLASS-NAME  IS "ManagerHelper"
                  CONSTRUCTOR IS CONSTRUCTOR1 (

                                                                                    M-URL,
                                                                                    M-PROPERTY,
                                                                                    M-USER-ID,
                                                                                    M-USER-PW
                                                                                   )
                  HANDLE      IS API-M.
                  MODIFY API-M "GetPendingData" (M-PROPERTY)
                                GIVING XML-STRING.

The method 'GetPendingData' returns the xml string that I need to store.

Can you help me!!!!

Thanks

0 Likes
4 Replies
Knowledge Partner
Knowledge Partner

RE: Long Strings

I want to address your statement "to parse it later."  

Rather than parse the XML data, I would encourage using XML Extensions to import the data into a COBOL data  structure.  See A Guide to Interoperating with ACUCOBOL-GT, Sections 11.2.7 through 11.2.9.

If you were to use RMNet to invoke your web service, you could use the tutorial found here to guide your development.  But perhaps you don' have that choice...


Tom Morrison
Consultant

0 Likes
dalekreitzer
Visitor.

RE: Long Strings

Use C$XML to parse the string, then write it to a file name

               MOVE "somefile.xml" to xml-file-name.

*        Create a new parser and load it up with the request XML.

              CALL "C$XML" USING CXML-PARSE-STRING, XML-STRING

              MOVE RETURN-CODE              TO XML-FILE-HANDLE

*        Write the XML to the file.

              CALL "C$XML"

                  USING CXML-WRITE-FILE, XML-FILE-HANDLE, XML-FILE-NAME

     *        Release the parser.

              CALL "C$XML"

                  USING CXML-RELEASE-PARSER, XML-FILE-HANDLE

Dale

0 Likes
Angel3 Absent Member.
Absent Member.

RE: Long Strings

Hi both,

I receive a long string when I call the .NET Assembly:

MODIFY API-M "GetPendingData" (M-PROPERTY)

                               GIVING XML-STRING

But I don't know how to define this variable in COBOL.(xml-string).

I checked the documentation that you refer, but I have found nothing about sending or receiving strings using .Net Assemblies

Kind regards

0 Likes
dalekreitzer
Visitor.

RE: Long Strings

I don't think there is a way in COBOL to define an unbound string.  If you have control over the .dll, you may want to write it out from there.

Dale

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.