ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

XML parsing

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

  • XML parsing

    I have XMl like


    nila
    gosw


    I am initialising data str like

    DcustDs Qualified
    Dcust:first 10
    Cust:Last 10

    But it gives error. How to intialize this tag in DS.

  • #2
    Re: XML parsing

    colons are not valid in field names in RPG. try renaming the subfields in the DS. the field names in the DS do NOT have to match the XML tag names to work.
    I'm not anti-social, I just don't like people -Tommy Holden

    Comment


    • #3
      Re: XML parsing

      Hi

      Thanks for reply. but in that case, when I am diong the following:


      D InvAdjHandler PR 10I 0
      D Ok 1N
      D InvAdjInfo LikeDs(InvAdjTrn) Dim(1) Const

      /FREE

      Options = 'case=any doc=file path=POSLog/Transaction +
      allowmissing=no allowextra=yes';

      allOk = *On;

      XML-INTO %HANDLER(InvAdjHandler : allOk)
      %XML(%Trim(IFSFolder):Options);
      /END-FREE

      It gives run time error saying 'RPG variable does not match'.

      Comment


      • #4
        Re: XML parsing

        what does the XML look like for that? what is the definition of InvAdjTrn? also if there's only 1 element in the array, why make it an array to begin with???
        I'm not anti-social, I just don't like people -Tommy Holden

        Comment


        • #5
          Re: XML parsing

          XML look like:
          PHP Code:
          <POSLog>
           <
          Transaction>                                                                 
             <
          RetailStoreID>129</RetailStoreID>                                          
             <
          WorkstationID />                                                           
             <
          SequenceNumber>86102</SequenceNumber>                                      
             <
          OperatorID></OperatorID>                                                   
            <
          InventoryControlTransaction Version="2.2" DocumentType="StoreTransfer">     
               <
          ReceiveInventory DocumentType="AdvanceShipNotice" DocumentStatus="Posted"
                 
          <DocumentID>00001001291228075516</DocumentID>                           
                 <
          ToParty>129</ToParty>                                                  
                 <
          FromParty>1</FromParty>                                                
                 <
          ExpectedDeliveryDate>2007-10-11</ExpectedDeliveryDate>                 
                 <
          ActualDeliveryDate>2007-10-11</ActualDeliveryDate>                     
                  <
          LineItem>                                                          
                    <
          ItemID>00826220974125</ItemID>                                   
                    <
          QuantityReceived>100</QuantityReceived>>                         
                    <
          CartonNumber>00000912051673618883</CartonNumber>                 
                    <
          wms:PackingSlip>12345</wms:PackingSlip>                        
                  </
          LineItem>                                                         
                </
          ReceiveInventory>                                                   
              </
          InventoryControlTransaction>                                          
            </
          Transaction>                                                            
                                                                 
          </
          POSLog
          My code is:
          Code:
          DGssRcvTrn        Ds                  Qualified                    
          DRetailStoreID                   5  0                              
          DWorkStationID                  10a                                
          DSequenceNumber                  6  0                              
          DOperatorID                      1a                                
          DInventoryControlTransaction...                                    
          D                                     LikeDS(InvCtlTrans)          
           *                                                                 
          DInvCtlTrans      DS                  Qualified                    
          DVersion                         4A                                
          DDocumentType                   20A                                
          DReceiveInventory...                                               
          D                                     LikeDS(RcvInventory)         
                                                                             
          DRcvInventory     Ds                  Qualified                    
          DDocumentType                   30A                                
          DDocumentStatus                 10A                                
          DDocumentID                     20A                                
          DToParty                        10                                 
          DFromParty                      10                                 
          DExpectedDeliveryDate...                                           
          D                               10                                 
          DActualDeliveryDate...                                             
          D                               10                                 
          DLineItem                             LikeDS(LineItm)              
                                                                             
          DLineItm          Ds                  Qualified                    
          DItemID                         14A                                
          DQuantityReceived...                                               
          D                                7S 3                              
          DCartonNumber                   20A                                
          Dwms:PackingSlip...                                               
          D                                           10
          
          D InvAdjHandler   PR            10I 0                                  
          D Ok                             1N                                    
          D InvAdjInfo                          LikeDs(GssRcvTrn)  Dim(1) Const  
          D NumRecs                       10I 0 Value                            
          
          C     @InvAdjParse  BEGSR                                            
           /FREE                                                               
                                                                               
                 Options = 'case=any doc=file path=POSLog/Transaction +        
                           allowmissing=no allowextra=yes';                    
                                                                               
               allOk = *On;                                                    
                                                                               
               XML-INTO %HANDLER(InvAdjHandler:allOK)                          
                        %XML(%Trim(folder):Options);                          
           /END-FREE
          ...
          I cant give DS field name as wms: packingclip and if I rename
          during %XML and %Handler it says
          'The XML document does not match the RPG variable; reason code 4. '
          Last edited by rahulyell; February 27, 2008, 12:39 PM. Reason: formatting

          Comment


          • #6
            Re: XML parsing

            rename the field in the DS...not in the XML-INTO opcode. i *think* the problem is with your path= in your options. from the reference manual:
            Code:
            path
                |The path option specifies the path to the element as it appears |in the XML document, with elements separated by forward slashes. For |example, if this option is path=main/info/name, the parser will expect the |document element to be "main", a child of "main" to be "info", and a child of |"info" to be "name". If no element can be found, the operation will |fail with status 00353 (XML does not match RPG variable).
            
                |Note:
                    The value of the "allowmissing" option has no effect on this |situation. |
            
                |Note:
                    The path option is required when %HANDLER is used to specify an |array-handling procedure.
            I'm not anti-social, I just don't like people -Tommy Holden

            Comment


            • #7
              Re: XML parsing

              Thanks for your continuos help.

              But in the XML it start with POSLOg/Transaction which I menioned as path=POSLog/Transaction in options. I ran the code, except wms: PackingSlip it does work properly. Let me know how to rename this field inside data structure so that during parsing it reads properly. Thanks.
              Last edited by rahulyell; February 27, 2008, 12:40 PM.

              Comment


              • #8
                Re: XML parsing

                rahulyell,

                please post definition to FOLDER (nevermind made 256 varying)

                also could we see the rest of the code for InvAdjHandler.
                All my answers were extracted from the "Big Dummy's Guide to the As400"
                and I take no responsibility for any of them.

                www.code400.com

                Comment


                • #9
                  Re: XML parsing

                  when the XML-INTO fails what is the entire message for the RNX0353 message? it could be a data type assignment error:
                  Code:
                  f XML data is not valid for the type of the RPG variable it matches, 
                  the operation will fail with status 0353;
                   the specific status code for the assignment error will appear in the 
                  replacement text for message RNX0353.
                  I'm not anti-social, I just don't like people -Tommy Holden

                  Comment


                  • #10
                    Re: XML parsing

                    The FOLDER is a IFS folder say NKFLDR/WMS20080222.xml

                    The error I get if I use wms: packingSlip as wms_Packingslip is

                    XML document does not match RPG variable (C G D F). reason code 4.

                    Rest of teh code is:

                    mapping each field into database fields and writing into it.

                    Comment


                    • #11
                      Re: XML parsing

                      with the sample XML you posted i'm just curious if the XML-INTO is expecting the wms_Packingslip to be numeric and not character...
                      I'm not anti-social, I just don't like people -Tommy Holden

                      Comment


                      • #12
                        Re: XML parsing

                        Even if I change to neumeric it says 'XML document does not match RPG variable'. I think I have to give the exact tag as wmsackingslip in DS. If i change it to wms_packingslip, it gives te same error. Let me know any suggestrion if u have.

                        Comment


                        • #13
                          Re: XML parsing

                          Hi

                          can you please suggest me something. I am waiting for your reply.

                          Comment


                          • #14
                            Re: XML parsing

                            try using XML-SAX instead of XML-INTO??
                            http://publib.boulder.ibm.com/infoce...02.htm#ToC_943
                            I'm not anti-social, I just don't like people -Tommy Holden

                            Comment


                            • #15
                              Re: XML parsing

                              Thanks. I will try it out.

                              Comment

                              Working...
                              X