ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

XML file into an iseries physical file

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • XML file into an iseries physical file

    Does anyone have an easy way to take an xml file and convert it into a physical file? Can goanywhere do it ? or any other options?

  • #2
    There isn't a direct 1-to-1 relationship between XML (at least, in the general sense) and a physical file. You will need someone with knowledge of how data is organized in the XML file to create instructions that tell software how to map data from the XML format to the PF format.

    SQL on Db2 for i has built-in support for XML. So you can handle the mapping/conversion by simply writing an SQL statement if you like. You can also do it with RPG's XML-INTO opcode or with countless other tools (all of the open source environments have XML tools available.)

    I'm not familiar with GoAnywhere, you'd need to ask the people who make it what it can do.

    Comment


    • #3
      i have the following code it keeps telling me data structure LINEITEM cannot be changed by the xml-into operation ?
      I thought i could take my xml file on ifs and bring into rpgle ?

      D FileName S 100A INZ

      D OPTIONS S 100A INZ

      D lineItem DS QUALIFIED
      D lenderLoanNbr S 10S 0
      D amtDue S 8S 2


      options = 'case=any doc=file' ;

      FileName = '/testpath/QTEMP/billng.xml' ;

      xml-into lineItem %xml(%Trim(FileName)ptions);

      Comment


      • #4
        The error message RNF5355 says
        Field or data structure cannot be changed by the XML-INTO operation.
        Cause . . . . . : The XML-INTO operation must have at least one valid field or subfield to change. It cannot change fields or subfields of type pointer, procedure pointer or Object. It cannot change unnamed subfields or subfields that overlay other fields.​
        You would also have message RNF3530 for your data structure: "Data structure LINEITEM has no valid subfields."

        It's because your subfields are not actually subfields because you coded 'S' in the definition-type column. (The same column where you have the "DS" for the data structure)
        Code:
        [FONT=Courier New]D lineItem        DS                  QUALIFIED
        D lenderLoanNbr   S             10S 0
        D amtDue          S              8S 2[/FONT]
        ​
        Remove the 'S' from those subfields and those messages will go away.

        Whenever you don't understand a compiler error message, try compiling with OPTION(*SECLVL), so you can see the full message in the message summary at the end.

        Comment


        • #5
          Thanks that worked, when I run the program i get the following message. The job log says reason code 1, no such path or directory, which seems like it is fine ? Any ideas?

          Message . . . . : XML document does not match RPG variable (C G D F).
          Cause . . . . . : While parsing an XML document for RPG procedure RHSXML in
          program BARBOUR/RHSXML at statement 001800, the parser did not find the
          expected XML elements to correspond to the RPG variable.
          Recovery . . . : Check the job log for previous messages, and contact the
          person responsible for program maintenance.
          Possible choices for replying to message . . . . . . . . . . . . . . . :​

          Comment


          • #6
            Could we be missing something on our iseries that is not allowing this to work?

            Comment


            • #7
              We are on V7R4

              Comment


              • #8
                The message that says "XML document does not match RPG variable" is RNQ0353. The previous message RNX0353 would have more information.

                Could you show the text of the RNX0353 message from your joblog?

                And what is the message ID for the message that says "reason code 1, no such path or directory".

                Comment


                • #9
                  > call rhsxml
                  The XML document does not match the RPG variable; reason code 1.
                  Function check. RNX0353 unmonitored by RHSXML at statement 0000001700,
                  instruction X'0000'.
                  XML document does not match RPG variable (C G D F).
                  XML document does not match RPG variable (C G D F).
                  2>> *SYSTEM/DSPJOB​
                  Message . . . . : The XML document does not match the RPG variable; reason
                  code 1.
                  Cause . . . . . : While parsing an XML document, the parser found that the
                  XML document does not correspond to RPG variable "lineitem" and the options
                  do not allow for this. The reason code is 1. The exact subfield for which
                  the error was detected is "lineitem". The options are "doc=file case=any
                  allowextra=yes allowmissing=yes". The XML document name is
                  /linoma/QTEMP/RHSbilling.xml; *N indicates that the XML document was not an
                  external file.
                  Recovery . . . : Contact the person responsible for program maintenance to
                  determine the cause of the problem.
                  Technical description . . . . . . . . : Reason codes and their meanings are
                  More...​
                  as follows:
                  1. The specified path to the XML element was not found in the XML document.
                  2. The XML document contains too few array elements for array subfields of a
                  data structure.
                  3. The XML document contains too many array elements for array subfields of
                  a data structure.
                  4. The XML document is missing XML attributes or elements to match
                  subfields.
                  5. The XML document contains extra XML attributes or elements that do not
                  match subfields.
                  6. The XML document contains text content within the content for the
                  subfields of a data structure.
                  7. The XML document contains unexpected attributes or child elements for XML​

                  Comment


                  • #10
                    You need to specify "path=XXX" in the %XML built-in function, where "XXX" is the start of the path to the element. That tells XML-INTO where to start looking for the element.

                    Comment


                    • #11
                      You may also need to specify "ns=remove", "case=any", "allowmissing=yes", and "allowextra=yes". The last two if you're extracting only a portion of the values.

                      Code:
                      XML-Into(E) xmlDs %XML(apiResponse: 'path=carrier/' +
                      'shipments/' +
                      'shipment ' +
                      'ns=remove ' +
                      'case=any ' +
                      'allowmissing=yes ' +
                      'allowextra=yes');

                      Comment

                      Working...
                      X