ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Retrieve Packed Data from specific position in Dtaara

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

  • Retrieve Packed Data from specific position in Dtaara

    Hi all,

    I would like to retrieve data from a dtaara in Java.

    The dtaara contains the value of 212 different fields which are described in a file description. Some fields contain packed decimal data. And I need in my java the value of such a packed decimal data field.

    When I look at the file description (DSPFFD) I see for my field :
    Output Buffer Position = 178
    Input Buffer In Bytes = 6
    Field Length Digits = 11
    Number of Decimal Positions = 0


    How can I retrieve this value so I can perform the test that my field contains 11 nines?
    for example : if fieldFromDtaara = 99999999999

  • #2
    Re: Retrieve Packed Data from specific position in Dtaara

    Not sure bout JAVA but is there a way to say field is at *HIVAL.

    rpg for *HIVAL

    Code:
    d  all9           s             11  0 inz(99999999995)    
    d  count          s              2  0                     
                                                              
     /free                                                    
             for count = 1 to 10;                             
              if all9 = *hival;                               
               all9 = 1;                                      
              else;                                           
               all9 += 1;                                     
              endif;                                          
             endfor;                                          
                                                              
                                                              
             *inlr = *on;                                     
     /end-free
    --0r-- a way to say if field = *all'9'

    rpg for *all9

    Code:
    d  all9           s             11  0 inz(99999999995)     
    d  count          s              2  0                      
                                                               
     /free                                                     
             for count = 1 to 10;                              
              if all9 = *all'9';                               
               all9 = 1;                                       
              else;                                            
               all9 += 1;                                      
              endif;                                           
             endfor;                                           
                                                               
                                                               
             *inlr = *on;                                      
     /end-free
    then you wouldnt need the length of the field


    also here is an example of a program to retrieve data from a dataarea (using API)
    you could create as a procedure then call it from JAVA (I would guess)

    Code:
          //
          //  entry plist
          //
    
         d EntryPlist      pr                  extpgm('DATAAREA')
         d  inDtaAra                     10
         d  inLibrary                    10
    
         d EntryPlist      pi
         d  inDtaAra                     10
         d  inLibrary                    10
    
          //
          // Variable Definition
          //
    
         d indataarea      s             20
    
         d DtaAraRcv       ds
         d  AraBytes                     10i 0
         d  AraBytesOut                  10i 0
         d  AraDtaType                   10a
         d  AraLibrary                   10a
         d  AraLength                    10i 0
         d  AraDecimals                  10i 0
         d  AraValue                   2000a
    
         d APIError        ds                  Qualified
         d  BytesP                       10i 0 inz(%size(apiError))
         d  BytesA                       10i 0 inz(0)
         d  Messageid                     7
         d  Reserved                      1
         d  messagedta                  240
    
          //
          //  external calls
          //
    
         d $GetData        pr                  extpgm('QWCRDTAA')
         d   thedata                           like(DtaAraRcv)
         d   thedatasize                 10i 0 const
         d   libDtaara                   20    const
         d   start                       10i 0 const
         d   length                      10i 0 const
         d   Error                             Like(ApiError)
    
          // call the API
    
          /free
    
                if indtaara = '*GDA' or
                   indtaara = '*LDA' or
                   indtaara = '*PDA';
                 %subst(indataarea:1:10)  = InDtaARa;
                 %subst(indataarea:11:10) = *blanks;
                else;
                 indataarea =  inDtaAra + inlibrary;
                endif;
    
                $getData(DtaAraRcv       :
                         %Size(DtaAraRcv):
                         InDataArea      :
                         -1              :
                         512             :
                         ApiError        );
    
    
                             *inlr = *on;
          /end-free
    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


    • #3
      Re: Retrieve Packed Data from specific position in Dtaara

      We need this info in Java at the client sight. We are using JT400 to connect from the client to the System I

      Comment


      • #4
        Re: Retrieve Packed Data from specific position in Dtaara

        You can use the DataArea classes that are provided with the AS400 Toolbox. InfoCenter has examples that show you how to access Decimal, Character, and Logical Datareas.

        Last edited by kpmac; November 26, 2007, 12:50 PM.
        Predictions are usually difficult, especially about the future. ~Yogi Berra

        Vertical Software Systems
        VSS.biz

        Comment

        Working...
        X