ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

how to receive data in dynamic file field?

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

  • how to receive data in dynamic file field?

    Hi All,

    My question is , In my program i have received the data is long string (say 512 Characters) and want to distributes in the a file fields, which would be dynamic.

    Suppose
    Variable A = '00472 Sanjib '

    We want to receive the above data in file XYZ in field1(5S 0) and field2(10A). (Note: The file and field's attribute would not be same everytime, We can get the file name in program at run time.

    Please let me know if you need any more clarification....

    Thanks in advance.......
    SKMA

  • #2
    Re: how to receive data in dynamic file field?

    select dec(substr('00472 Sanjib ',1,5),5,0), substr('00472 Sanjib ' , 7,507) into :Field1, :Field2
    from .....
    where....

    if not from a file then
    field1 = %dec(%Substr('00472 Sanjib ' ,1,5),5,0)....

    you get the drift brah?
    Hunting down the future ms. Ex DeadManWalks. *certain restrictions apply

    Comment


    • #3
      Re: how to receive data in dynamic file field?

      hi

      Got you point ... BUT here the thing is (Note: The file and field's attribute would not be same everytime, We can get the file name in program at run time.)

      Comment


      • #4
        Re: how to receive data in dynamic file field?

        What is the problem? SQL seems to be a reasonable way to do this. You can construct an INSERT statement and run it dynamically. You won't need field definitions compiled into the program. You'll only retrieve field definitions in order to know whether your output fields are numeric or character and need quotes or not, possibly for lengths depending on what you know about the input data.

        Field definitions can be retrieved for a file at run-time with the List Fields (QUSLFLD) API.

        Tom
        Tom

        There are only two hard things in Computer Science: cache invalidation, naming things and off-by-one errors.

        Why is it that all of the instruments seeking intelligent life in the universe are pointed away from Earth?

        Comment


        • #5
          Re: how to receive data in dynamic file field?

          I think accessing the SYSCOLUMNS catalog view for finding out the data types and lengths would be an easier approach.

          Birgitta
          Last edited by B.Hauser; June 17, 2013, 06:58 AM.

          Comment


          • #6
            Re: how to receive data in dynamic file field?

            From a SQL viewpoint, SYSCOLUMNS should be more appropriate.

            Tom
            Tom

            There are only two hard things in Computer Science: cache invalidation, naming things and off-by-one errors.

            Why is it that all of the instruments seeking intelligent life in the universe are pointed away from Earth?

            Comment


            • #7
              Re: how to receive data in dynamic file field?

              SYSCOLUMNS won't work on a file in QTEMP, though, not sure if that matters in this case?

              If this is a tool you plan to sell commercially for users to use on any file in any library, it's definitely worth the extra work to use QUSLFLD or DSPFFD to *OUTFILE rather than SYSCOLUMNS.

              Comment


              • #8
                Re: how to receive data in dynamic file field?

                Here is an OLD example of what you are looking at... I have the code for the display logicals if you want it.
                zip file attached

                PHP Code:
                     H dftactgrp(*nobnddir('QC2LE'OPTION(*NODEBUGIOACTGRP('HAMMERTIME')                       
                ?     *************************************************************************                    ?
                ?     *  
                TO COMPILE:                                                                               ?
                ?     *     
                CRTRPGPGM PGM(LIBRARY/FFDILE)                                                          ?
                ?     *************************************************************************                    ?
                     
                fFFDDSP    CF   E             WORKSTN                                                          
                     f                                     SFILE
                (SFLRCD:RelRecNbr)                                  
                     
                fQSYSPRT   O    F  132        PRINTER OFLIND(*INOF)                                            
                ?     *                                                                                            ?
                ?     *  
                Stand Alone variables                                                                     ?
                ?     *                                                                                            ?
                     
                d AR              S              1    DIM(9999)                                                
                     
                d AKEY            S             10    DIM(9999)                                                
                     
                d AK#             S              2  0 DIM(9999)                                                
                     
                d J               S              2  0                                                          
                     d JJ              S              2  0                                                          
                     d I               S             15  0                                                          
                     d S               S             15  0                                                          
                     d RelRecNbr       S              4  0                                                          
                     d RelRecHi
                #       S              4  0                                                          
                     
                d XX              S              7  0                                                          
                     d I1              S              1                                                             
                     d I2              S              2                                                             
                     d 
                @Scrn1          S              1     Inz('Y')                                                
                ?     *                                                                                            ?
                ?     *  
                Data structures                                                                           ?
                     
                d GENDS           DS                                                                           
                     d  OffsetHdr            117    120B 0                                                          
                     d  SizeHeader           121    124B 0                                                          
                     d  OffsetList           125    128B 0                                                          
                     d  NbrInList            133    136B 0                                                          
                     d  SizeEntry            137    140B 0                                                          
                                                                                                                    
                     d HeaderDs        DS                                                                           
                     d  OutFileNam             1     10                                                             
                     d  OutLibName            11     20                                                             
                     d  OutType               21     25                                                             
                     d  OutFormat             31     40                                                             
                     d  RecordLen             41     44B 0                                                          
                                                                                                                    
                     d InputDs         DS                                                                           
                     d  UserSpace              1     20                                                             
                     d  SpaceName              1     10                                                             
                     d  SpaceLib              11     20                                                             
                     d  InpFileLib            29     48                                                             
                     d  InpFFilNam            29     38                                                             
                     d  InpFFilLib            39     48                                                             
                     d  InpRcdFmt             49     58                                                             
                                                                                                                    
                     d ListDs          DS                                                                           
                     d  SfFld                  1     10                                                             
                     d  SfType                11     11                                                             
                     d  BufferOut             13     16B 0                                                          
                     d  FieldLen              21     24B 0                                                          
                     d  Digits                25     28B 0                                                          
                     d  Decimals              29     32B 0                                                          
                     d  FieldDesc             33     82                                                             
                     d  Filler                83    151                                                             
                     d  ColHeader1           152    171                                                             
                     d  ColHeader2           172    191                                                             
                     d  ColHeader3           192    211                                                             
                                                                                                                    
                     d ErrorDs         DS                  INZ                                                      
                     d  BytesPrv               1      4B 0                                                          
                     d  BytesAvl               5      8B 0                                                          
                     d  MessageId              9     15                                                             
                     d  ERR
                ###                16     16                                                             
                     
                d  MessageDta            17    116                                                             
                                                                                                                    
                     d ReceiveVr2      S            100                                                             
                                                                                                                    
                     d ReceiveVar      DS          4096                                                             
                     d  NbrOfFmts             62     63B 0                                                          
                     d  DBFileOff            317    320B 0                                                          
                                                                                                                    
                     d FindSelDs       DS           150                                                             
                     d  NbrOfKeys            117    118B 0                                                          
                     d  KeyOffset            136    139B 0                                                          
                                                                                                                    
                     d KeyDataDs       DS                                                                           
                     d  DependKey              1     10                                                             
                                                                                                                    
                     d                 DS                                                                           
                     d  StartPosit             1      4B 0                                                          
                     d  StartLen               5      8B 0                                                          
                     d  SpaceLen               9     12B 0                                                          
                     d  ReceiveLen            13     16B 0                                                          
                     d  MessageKey            17     20B 0                                                          
                     d  MsgDtaLen             21     24B 0                                                          
                     d  MsgQueNbr             25     28B 0                                                          
                     dGenSpcPtr                        
                *                                                            
                     
                dLstSpcPtr                        *                                                            
                     
                dHdrPtr                           *                                                            
                                                                                                                    
                ?     *---------------------------------------------------------------                             ?
                ?     *  
                M A I N   L I N E                                                                         ?
                ?     *---------------------------------------------------------------                             ?
                ?     *                                                                                            ?
                ?     *  
                Entry parm(s) {File Library} and File Format {default is *FIRST}                          ?
                ?     *                                                                                            ?
                     
                c     *Entry        Plist                                                                      
                     c                   Parm                    FileLib          20                                
                     c                   Parm                    EntryFmt         10                                
                ?     *                                                                                            ?
                ?     * 
                set up variables                                                                           ?
                ?     * 
                Create a user space named FFDSPC in library QTEMP.                                         ?
                ?     *                                                                                            ?
                     
                c                   Movel(p)  'FFDSPC'      SpaceName                                          
                     c                   Movel
                (p)  'QTEMP'       SpaceLib                                           
                     c                   Movel     FileLib       InpFFilNam                                         
                     c                   Move      FileLib       InpFFilLib                                         
                     c                   
                Eval      BytesPrv 116                                                   
                     c     
                'QCPFMSG'     Cat       'QSYS':3      MSGF                                               
                     c                   Seton                                        53                            
                ?     *                                                                                            ?
                ?     * 
                Create the user space                                                                      ?
                ?     *                                                                                            ?
                     
                c                   Call      'QUSCRTUS'                                                       
                     
                c                   Parm                    UserSpace                                          
                     c                   Parm      
                *BLANKS       SpaceAttr        10                                
                     c                   Parm      4096          SpaceLen                                           
                     c                   Parm      
                *BLANKS       SpaceVal          1                                
                     c                   Parm      
                '*CHANGE'     SpaceAuth        10                                
                     c                   Parm      
                *BLANKS       SpaceText        50                                
                     c                   Parm      
                '*YES'        SpaceRepl        10                                
                     c                   Parm                    ErrorDs                                            
                ?     *                                                                                            ?
                ?     * 
                Attemp to retrieve object description                                                      ?
                ?     *                                                                                            ?
                     
                c                   Call      'QUSROBJD'                                                       
                     
                c                   Parm                    ReceiveVr2                                         
                     c                   Parm      100           ReceiveLen                                         
                     c                   Parm      
                'OBJD0100'    FileFormat        8                                
                     c                   Parm                    FileLib                                            
                     c                   Parm      
                '*FILE'       ObjectType       10                                
                     c                   Parm                    ErrorDs                                            
                ?     *                                                                                            ?
                ?     *  If 
                file doesn't exist, send message and get out                                           ?
                ?     *                                                                                            ?
                     c                   If        MessageId <> *BLANKS                                             
                     c                   Exsr      SNDMSG                                                           
                     c                   Exsr      $ShutDown                                                        
                     c                   ENDIF                                                                      
                ?     *                                                                                            ?
                     c                   if        OUTTYPE = '
                PF'                                                   
                     c                   EXSR      GETKEY                                                           
                     c                   endif                                                                      
                ?     *  List fields to user space                                                                 ?
                     c                   CALL      '
                QUSLFLD'                                                        
                     c                   PARM                    UserSpace                                          
                     c                   PARM      '
                FLDL0100'    ListFormat        8                                
                     c                   PARM                    InpFileLIb                                         
                     c                   PARM      EntryFmt      InpRcdFmt                                          
                     c                   PARM      '
                1'           OverRide          1                                
                     c                   Eval      StartPosit = 1                                                   
                     c                   Eval      StartLen = 140                                                   
                     c                   CALL      '
                QUSRTVUS'                                                       
                     c                   PARM                    UserSpace                                          
                     c                   PARM                    StartPosit                                         
                     c                   PARM                    StartLen                                           
                     c                   PARM                    GENDS                                              
                     c                   EVAL      StartPosit = OffsetHdr + 1                                       
                     c                   EVAL      StartLen = SizeHeader                                            
                     c                   CALL      '
                QUSRTVUS'                                                       
                     c                   PARM                    UserSpace                                          
                     c                   PARM                    StartPosit                                         
                     c                   PARM                    StartLen                                           
                     c                   PARM                    HeaderDs                                           
                     c                   EVAL      SpaceName = '
                FFDSPC'                                             
                     c                   EVAL      SpaceLib = '
                QTEMP'                                               
                     c                   EVAL      StartPosit = OffsetList + 1                                      
                     c                   EVAL      StartLen = SizeEntry                                             
                ?     *  Do for number of fields                                                                   ?
                B1   c                   DO        NbrInList                                                        
                     c                   CALL      '
                QUSRTVUS'                                                       
                     c                   PARM                    UserSpace                                          
                     c                   PARM                    StartPosit                                         
                     c                   PARM                    StartLen                                           
                     c                   PARM                    ListDs                                             
                ?     *  Write the record to the subfile                                                           ?
                     c                   EXSR      WRITER                                                           
                     c                   EVAL      StartPosit = StartPosit + SizeEntry                              
                E1   c                   ENDDO                                                                      
                     c                   IF        RelRecNbr > 0                                                    
                     c                   EVAL      *IN21 = *ON                                                      
                E1   c                   ENDIF                                                                      
                     c                   EVAL      OutRecLen = RecordLen                                            
                     c     ' '           CHECKR    OutType       Z                 1 0                              
                     c                   MOVEL(P)  OutType       F5                5                                
                     c     5             SUB       Z             Z                                                  
                     c                   IF        Z < 5                                                            
                     c                   EVAL      OutType = *BLANKS                                                
                     c                   CAT       F5:Z          OutType                                            
                     c                   ENDIF                                                                      
                     c                   EVAL      RelRecPos = 1                                                    
                ?     *                                                                                            ?
                     c                   Reset                   @Scrn1                                             
                     c                   Dow       @Scrn1 = '
                Y'                                                     
                ?     *                                                                                            ?
                     c                   Write     FORMAT1                              99                          
                     c                   Exfmt     SFLCTL                                                           
                ?     *                                                                                            ?
                     c                   Select                                                                     
                     c                   When      *In03  Or *In12                                                  
                     c                   Clear                   @Scrn1                                             
                     c                   Exsr      $ShutDown                                                        
                ?     *                                                                                            ?
                ?     * Display the Logicals if this is physical file(only)                                        ?
                ?     * a good change would be to get the physical if it is logical then                           ?
                ?     * substitute in the physical name.                                                           ?
                ?     *                                                                                            ?
                     c                   When      *In07                                                            
                     c                   Call      '
                PTHRPG'                                                         
                     c                   Parm                    FileLib                                            
                ?     *                                                                                            ?
                ?     * Print the field listing                                                                    ?
                ?     *                                                                                            ?
                     c                   When      *In08                                                            
                     c                   Exsr      $PrintMe                                                         
                     c                   Endsl                                                                      
                ?     *                                                                                            ?
                     c                   IF        PositionFl <> *BLANKS                                            
                     c                   EXSR      REPOS                                                            
                     c                   ENDIF                                                                      
                     c                   Enddo                                                                      
                ?     *------------------------------------------------------------------                          ?
                ?     *  $PrimtMe - Print out the field listing                                                    ?
                ?     *------------------------------------------------------------------                          ?
                     c     $PrintMe      Begsr                                                                      
                ?     *                                                                                            ?
                ?     *  Print loop                                                                                ?
                ?     *                                                                                            ?
                     c                   EXCEPT    HEDING                                                           
                B2   c     1             DO        9998          X                 4 0                              
                     c     X             CHAIN     SFLRCD                             68                            
                B3   c                   IF        *IN68 = *OFF                                                     
                     c                   EXCEPT    DETAIL                                                           
                E3   c                   ENDIF                                                                      
                E2   c  N68              ENDDO                                                                      
                ?     *                                                                                            ?
                     c                   Endsr                                                                      
                ?     *                                                                                            ?
                ?     *------------------------------------------------------------------                          ?
                ?     *  $ShutDown - Kill the program                                                              ?
                ?     *------------------------------------------------------------------                          ?
                     c     $ShutDown     Begsr                                                                      
                     c                   Eval      *INLR = *On                                                      
                     c                   Endsr                                                                      
                ?     *------------------------------------------------------------------                          ?
                ?     *  Write the field data to the subfile.                                                      ?
                ?     *------------------------------------------------------------------                          ?
                     c     WRITER        BEGSR                                                                      
                     c                   EVAL      SFLEN = Digits                                                   
                     c                   MOVE      Decimals      SFDEC                                              
                     c                   IF        SFLEN = *ZEROS                                                   
                     c                   EVAL      SFLEN = FieldLen                                                 
                     c                   EVAL      SFDEC = *BLANKS                                                  
                E1   c                   ENDIF                                                                      
                     c                   EVAL      SFFROM = BufferOut                                               
                     c                   EVAL      SFTO = ((SFFROM + Fieldlen) - 1)                                 
                     c                   MOVEL     FieldDesc     SFTEXT                                             
                     c                   EVAL      SFKEY = *BLANKS                                                  
                B1   c                   DO        20            I                                                  
                     c                   IF        AKEY(I) = SFFLD                                                  
                     c                   IF        AK#(I) < 10                                                      
                     c                   MOVE      AK#(I)        I1                1                                
                     c     '
                K'           CAT(P)    I1:0          SFKEY                                              
                X3   c                   ELSE                                                                       
                     c                   MOVE      AK#(I)        I2                2                                
                     c     '
                K'           CAT(P)    I2:0          SFKEY                                              
                E3   c                   ENDIF                                                                      
                     c                   LEAVE                                                                      
                E2   c                   ENDIF                                                                      
                E1   c                   ENDDO                                                                      
                     c                   EVAL      RelRecNbr = (RelRecNbr + 1)                                      
                     c                   EVAL      CURCSRPOS = (CURCSRPOS + 1)                                      
                     c                   WRITE     SFLRCD                                                           
                     c                   EVAL      RelRecHi# = RelRecNbr                                            
                     c                   ENDSR                                                                      
                ?     *                                                                                            ?
                     c     REPOS         BEGSR                                                                      
                     c                   SELECT                                                                     
                     c                   WHEN      PositionFl = '
                *TOP'                                              
                     c                   EVAL      RelRecPos = 1                                                    
                     c                   WHEN      PositionFl = '
                *BOTTOM'                                           
                     c                   EVAL      RelRecPos = (RelRecHi# - 10)                                     
                     c                   IF        RelRecPos <= 0                                                   
                     c                   EVAL      RelRecPos = 1                                                    
                     c                   ENDIF                                                                      
                     c                   OTHER                                                                      
                     c                   DO        RelRecHi#     XX                                                 
                     c     XX            CHAIN     SFLRCD                             68                            
                     c                   IF        *IN68 = *OFF                                                     
                     c     ' '           CHECKR    PositionFl    P                 2 0    68                        
                     c     PositionFl:P  SCAN      SFTEXT                                 60                        
                     c                   IF        (SFFLD = PositionFl) or (*IN60 = *ON)                            
                     c                   EVAL      RelRecPos = XX                                                   
                     c                   LEAVE                                                                      
                     c                   ENDIF                                                                      
                     c                   ENDIF                                                                      
                     c                   ENDDO                                                                      
                     c                   ENDSL                                                                      
                     c                   EVAL      PositionFl = *BLANKS                                             
                     c                   ENDSR                                                                      
                ?     *                                                                                            ?
                     c     GETKEY        BEGSR                                                                      
                ?     *  Get key field information into ReceiveVar                                                 ?
                     c                   CALL      '
                QDBRTVFD'                                                       
                     c                   PARM                    ReceiveVar                                         
                     c                   PARM      4096          ReceiveLen                                         
                     c                   PARM                    InpFileLib                                         
                     c                   PARM      '
                FILD0100'    FileFormat        8                                
                     c                   PARM                    FileLib          20                                
                     c                   PARM      EntryFmt      RecordFmt        10                                
                     c                   PARM      '
                0'           OverRide                                           
                     c                   PARM      '
                *LCL'        System           10                                
                     c                   PARM      '
                *EXT'        FormatType       10                                
                     c                   PARM                    ErrorDs                                            
                     c     MessageId     CABEQ     '
                CPF5715'     ENDGET                                             
                     c                   MOVEA     ReceiveVar    AR(1)                                              
                     c                   EVAL      I = DBFileOff                                                    
                B1   c                   DO        NbrofFmts                                                        
                     c                   MOVEA     AR(I)         FindSelDs                                          
                     c                   EVAL      S = (KeyOffset + 1)                                              
                ?     *  Don'
                t exceed array size                                                                   ?
                     
                c                   IF        NbrOfKeys 20                                                   
                     c                   
                EVAL      NbrOfKeys 20                                                   
                E2   c                   
                ENDIF                                                                      
                     
                c                   EVAL      JJ 0                                                           
                ?     *  Do for number of key fields                                                               ?
                B2   c                   DO        NbrOfKeys                                                        
                     c                   MOVEA     AR
                (S)         KeyDataDs                                          
                     c                   
                EVAL      = (1)                                                      
                     
                c                   EVAL      JJ = (JJ 1)                                                    
                     
                c                   MOVEA     DependKey     AKEY(J)                                            
                     
                c                   MOVEA     JJ            AK#(JJ)                                            
                     
                c                   EVAL      = (32)                                                     
                E2   c                   ENDDO                                                                      
                     c                   
                EVAL      = (160)                                                    
                E1   c                   ENDDO                                                                      
                     c     ENDGET        TAG                                                                        
                     c                   ENDSR                                                                      
                ?     *                                                                                            ?
                     
                c     SNDMSG        BEGSR                                                                      
                ?     *  Send error message                                                                        ?
                     
                c                   CALL      'QMHSNDPM'                                                       
                     
                c                   PARM                    MessageId                                          
                     c                   PARM                    MSGF             20                                
                     c                   PARM                    FileLib                                            
                     c                   PARM      20            MsgDtaLen                                          
                     c                   PARM      
                '*DIAG'       MessageTyp       10                                
                     c                   PARM      
                '*'           MessageQue       10                                
                     c                   PARM      1             MsgQueNbr                                          
                     c                   PARM                    MessageKey                                         
                     c                   PARM                    ErrorDs                                            
                     c                   ENDSR                                                                      
                                                                                                                    
                     oQSYSPRT   E            HEDING         3 02                                                    
                     o         
                OR    OF                                                                             
                     o                                            5 
                'DATE:'                                         
                     
                o                       UDATE         Y     14                                                 
                     o                                           75 
                'PAGE:'                                         
                     
                o                       PAGE          Z     80                                                 
                     o                                           48 
                'DISPLAY FIELD FOR FILE'                        
                     
                o                       OutFileNam          59                                                 
                ?     *                                                                                            ?
                     
                o          E            HEDING         1                                                       
                     o         
                OR    OF                                                                             
                     o                                           24 
                'PHYSICAL FILE...........'                      
                     
                o                       OutFileNam          35                                                 
                     o                                           64 
                'FILE TYPE...............'                      
                     
                o                       OutType             75                                                 
                ?     *                                                                                            ?
                     
                o          E            HEDING         1                                                       
                     o         
                OR    OF                                                                             
                     o                                           24 
                'LIBRARY.................'                      
                     
                o                       OutLibName          35                                                 
                     o                                           64 
                'RECORD LENGTH...........'                      
                     
                o                       OutRecLen     Z     75                                                 
                ?     *                                                                                            ?
                     
                o          E            HEDING         3                                                       
                     o         
                OR    OF                                                                             
                     o                                           24 
                'RECORD FORMAT...........'                      
                     
                o                       OutFormat           35                                                 
                     o                                           64 
                'NUMBER OF FIELDS........'                      
                     
                o                       RelRecNbr     Z     78                                                 
                ?     *                                                                                            ?
                     
                o          E            HEDING         1                                                       
                     o         
                OR    OF                                                                             
                     o                                           22 
                'KEY    FIELD   LENGTH'                         
                     
                o                                           45 'DEC  TYPE  FROM   TO'                          
                     
                o                                           75 'TEXT....................'                      
                ?     *                                                                                            ?
                     
                o          EF           DETAIL         1                                                       
                     o                       SFKEY                4                                                 
                     o                       SFFLD               16                                                 
                     o                       SFLEN         Z     20                                                 
                     o                       SFDEC               27                                                 
                     o                       SFTYPE              32                                                 
                     o                       SFFROM        Z     39                                                 
                     o                       SFTO          Z     45                                                 
                     o                       SFTEXT              88                                                 
                ?     *                                                                                            ? 
                Attached Files
                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: how to receive data in dynamic file field?

                  Thanks to everybody for helpful suggestions?.

                  Comment


                  • #10
                    Re: how to receive data in dynamic file field?

                    Hi,

                    Why can't we use dspffd to get the field information for the dynamic file selection?
                    if we use dspffd we can get file information with field information. so, what ever field value you want to move to the dynamic file field and update the same to the file

                    Thanks
                    Dileep

                    Comment


                    • #11
                      Re: how to receive data in dynamic file field?

                      Why can't we use dspffd to get the field information for the dynamic file selection?
                      As was mentioned earlier in the thread, you can use DSPFFD to an outfile if you want to. It's the way it's done by many beginners when trying to do this kind of thing.

                      Personally, I would probably have used the QUSLFLD API. Birgitta's suggestion about using SYSCOLUMNS made sense because a likely way to get the data from the original question into a file would be with SQL. And if SQL was already going to be a main technology used in the program, then there is some rationale to using SQL to retrieve column definitions from the system catalog.

                      By using DSPFFD to an outfile, the program becomes a mix of SQL and native I/O. That won't break the program, but it does change the character of it. It's going to be tricky enough trying to get the unformatted data into a valid record format. By sticking with SQL, future maintenance might be more straightforward. It wouldn't be necessary to know how RPG does its native I/O functions.

                      Similar thoughts might be applied to using the API.

                      Also, for both the API and for DSPFFD, it's necessary to create and to populate an external object, a user space for the API and a database file for DSPFFD. Object creation has side effects that sometimes interfere with programming, as does putting data into the objects. But SYSCOLUMNS already exists. You might as well retrieve the values from it if you can.

                      Why build a file, add records to it and then read those records into your program when all you really have to do is just read the records into your program from a file that already exists and already has the records you need?

                      Well, at least one reason was mentioned by Scott when he mentioned that SYSCOLUMNS won't have information about files in QTEMP in it. I'm not sure how often that would be a concern since many jobs already know about files in their own QTEMP, but it can make a difference.

                      In short, you can use DSPFFD to an outfile if you want to. Eventually, though, you might find that other ways can be better (and possibly easier once you learn how they work.)

                      Tom
                      Last edited by tomliotta; June 27, 2013, 02:21 AM. Reason: Typo fix
                      Tom

                      There are only two hard things in Computer Science: cache invalidation, naming things and off-by-one errors.

                      Why is it that all of the instruments seeking intelligent life in the universe are pointed away from Earth?

                      Comment


                      • #12
                        Re: how to receive data in dynamic file field?

                        Hi,

                        Thanks for u valuable information tomliotta.I will try to use QUSLFLD API and work on it.

                        Thanks
                        Dileep

                        Comment

                        Working...
                        X