ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Hi

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

  • Hi

    Hi
    I am using extname in my program.i described one physical file .during read operations its only pick the key fields.non-key fields are blanks

  • #2
    Re: Hi

    it would be easier if you posted the relevant code. "what's wrong" type questions such as this leaves too much to consider. there could be hundreds of different things affecting this...too vague. provide more detail.
    I'm not anti-social, I just don't like people -Tommy Holden

    Comment


    • #3
      Re: Hi

      DDRR E DS EXTNAME(DWXPMEDSD:*all)


      this my external defined data structure.

      POLICY OF DRR = 'T205WC1010'
      EFFDTE OF DRR = 20060715.
      STRDAT OF DRR = 20091212.
      ENDDAT OF DRR = 20101212.
      SLD001 OF DRR = ' '
      SLD002 OF DRR = ' '
      SLD003 OF DRR = ' '
      SLD004 OF DRR = ' '
      SLD005 OF DRR = ' '
      SLD006 OF DRR = ' '
      SLD007 OF DRR = ' '
      SLD008 OF DRR = ' '
      SLD009 OF DRR = ' '


      so while reading the file first four fields have some value but remaining fields are blanks...
      how its possible.
      first four fields are key fields....but i had given extname(*all)

      please help

      Comment


      • #4
        Re: Hi

        Additionally pls paste the RPG statement that reads the file, ie READ, CHAIN, ... and the relevant F-spec.
        Philippe

        Comment


        • #5
          Re: Hi

          PHP Code:
          *************** Beginning of data ***************************************
          0000.01 HOPTION(*NODEBUGIO)                                                      
          0001.00 FDWXPMEDSD IF   E           k DISK                                       
          0002.00 FDWVPMEDSD O    E             DISK                                       
          0002.02 DARR              S              5    DIM
          (240)                           
          0002.03 DDRR            E DS                  EXTNAME(DWXPMEDSD:*all)            
          0004.47 C                   MOVEL     '001'         Y                 3          
          0004.48 C                   Z
          -ADD     001           N                 3 0        
          0004.49 C     
          *LOVAL        SETLL     RWXPMED1                                   
          0004.50 C                   READ      RWXPMED1                                   
          0004.51 C                   DOW       NOT 
          %EOF(DWXPMEDSD)                        
          0004.52 C                   DOW       A <= 240                                   
          0004.53 C                   MOVE      
          'SLD'         X                 3          
          0004.54 C     X             CAT       Y             Z                 6          
          0004.55 C                   MOVE      Z             ARR
          (N)                       
          0004.56 C                   MOVEA     ARR(N)        MEDS                         
          0004.57 C                   WRITE     RWVPMED1                                   
          0004.58 C                   MOVEL     Y             A                 3 0        
          0004.59 C                   
          EVAL      A=A+1                                      
          0004.60 C                   
          EVAL      N=N+1                                      
          0004.61 C                   MOVE      A             Y                               
          0004.62 C                   ENDDO                                                   
          0005.00 C                   READ      RWXPMED1                                      
          0006.00 C                   ENDDO                                                   
          0007.00 C                   SETON                                        LR 
          dont expect standards...this my rough code

          Comment


          • #6
            Re: Hi

            Not sure I understand the point of the DRR array. I don't see it ever being used. I would remove that first of all. (but I don't see how that would cause your blank fields.) I would double check the data in the file too... to make sure the input data isn't bad.

            Comment


            • #7
              Re: Hi

              Can you give me a brief idea of what the program is trying to accomplish? It looks like you are trying to update a field in the file with a sequential value of 'SLD001, SLD002, SLD003, etc etc)

              Comment


              • #8
                Re: Hi

                ok FWIW if you're going to use *ALL for EXTNAME...you don't have to put the *ALL..it's implied. Also I HATE mixed RPG III + RPG IV operations...i hate defining variables in the C specs even more. Using the "magic number" 240 in your code is also a bad habit. Use %ELEM() that way if you have to change the array size later on then all you have to do is change the DIM() on the array. From the looks of your code this should suffice:
                Code:
                HOPTION(*NODEBUGIO)                                              
                FDWXPMEDSD IF   E           k DISK                               
                FDWVPMEDSD O    E             DISK                               
                DArr              S              5a   Dim(240)                   
                DDrr            E DS                  ExtName(DWXPMEDSD)         
                d A               s              3p 0                            
                C                   Read      RWXPMED1                           
                C                   DoW       Not %EOF(DWXPMEDSD)                
                C                   For       A = 1 To %Elem( Arr )              
                C                   Eval      Arr(A) = 'SLD' + %EditC( A : 'X' ) 
                C                   MoveA     Arr(A)        Meds                 
                C                   Write     RWVPMED1                           
                C                   EndFor                                       
                C                   Read      RWXPMED1                           
                C                   EndDo                                        
                C                   Eval      *InLR = *On
                and as soup_dog said...what exactly is the point of the DRR DS? it's not being used anywhere. also if you are only using the ARR array to load into a single field called "MEDS" what do you need that array for? This would suffice:
                Code:
                HOPTION(*NODEBUGIO)                                            
                FDWXPMEDSD IF   E           k DISK                             
                FDWVPMEDSD O    E             DISK   
                d Max             c                      Const(240)                          
                d A               s              3p 0                          
                C                   Read      RWXPMED1                         
                C                   DoW       Not %EOF(DWXPMEDSD)              
                C                   For       A = 1 To Max            
                C                   Eval      Meds = 'SLD' + %EditC( A : 'X' ) 
                C                   Write     RWVPMED1                         
                C                   EndFor                                     
                C                   Read      RWXPMED1                         
                C                   EndDo                                      
                C                   Eval      *InLR = *On
                If you're using RPG IV then use RPG IV syntax instead of the cobbled together RPG "blend"
                Last edited by tomholden; June 25, 2010, 09:28 AM.
                I'm not anti-social, I just don't like people -Tommy Holden

                Comment


                • #9
                  Re: Hi

                  This is my requirement

                  POlicy(parameter from previous pgm) Effective(parameter from previous pgm)


                  start date_____________ Enddate_________________



                  Medallions

                  _____ _____ ______ _____ ______ ______ _______ _______ _______


                  _____ _____ ______ _____ ______ ______ _______ _______ _______


                  _____ _____ ______ _____ ______ ______ _______ _______ _______


                  _____ _____ ______ _____ ______ ______ _______ _______ _______


                  _____ _____ ______ _____ ______ ______ _______ _______ _______


                  _____ _____ ______ _____ ______ ______ _______ _______ _______


                  _____ _____ ______ _____ ______ ______ _______ _______ _______


                  _____ _____ ______ _____ ______ ______ _______ _______ _______



                  F2=Unprotect F9=Adding medallions F6= edit F7= more f12= cancel


                  Here
                  we are entering starting date ,ending date and medallions for the policy

                  in a single click we have to write the medallions into the database

                  so our file is like


                  POlicy effdat strdat enddat med1 med2 med3 med4 .....med220

                  as2323 20091212 20090616 20100616 asas asas asas asas asasas





                  we have to move the file structure into

                  policy effdte strdat enddat meds
                  as2323 20091212 20090616 20100616 asas
                  as2323 20091212 20090616 20100616 asas
                  as2323 20091212 20090616 20100616 asas
                  as2323 20091212 20090616 20100616 asas
                  as2323 20091212 20090616 20100616 asas


                  moving the rows into columns

                  and load the file into subfile to edit

                  opt policy effdte strdat enddat meds
                  _ as2323 20091212 20090616 20100616 asas
                  _ as2323 20091212 20090616 20100616 asas
                  _ as2323 20091212 20090616 20100616 asas
                  _ as2323 20091212 20090616 20100616 asas
                  _ as2323 20091212 20090616 20100616 asas





                  POlicy(parameter from previous pgm) Effective(parameter from previous pgm)


                  start date_____________ Enddate_________________



                  Medallions

                  _____ _____ ______ _____ ______ ______ _______ _______ _______


                  _____ _____ ______ _____ ______ ______ _______ _______ _______


                  _____ _____ ______ _____ ______ ______ _______ _______ _______


                  _____ _____ ______ _____ ______ ______ _______ _______ _______


                  _____ _____ ______ _____ ______ ______ _______ _______ _______


                  _____ _____ ______ _____ ______ ______ _______ _______ _______


                  _____ _____ ______ _____ ______ ______ _______ _______ _______


                  _____ _____ ______ _____ ______ ______ _______ _______ _______



                  F2=Unprotect F9=Adding medallions F6= edit F7= more f12= cancel




                  after editing we need to move the medallions to old screen

                  Comment


                  • #10
                    Re: Hi

                    make it a subfile....

                    Code:
                         A*%%TS  SD  20100625  124732  FLANARY     REL-V5R4M0  5722-WDS
                         A*%%EC
                         A                                      DSPSIZ(27 132 *DS4)
                         A                                      REF(*LIBL/LBAFREF)
                         A                                      CHGINPDFT(UL)
                         A                                      INDARA
                         A                                      CF01
                         A                                      CF02
                         A                                      CF03
                         A                                      CF04
                         A                                      CF05
                         A                                      CF06
                         A                                      CF07
                         A                                      CF08
                         A                                      CF09
                         A                                      CF10
                         A                                      CF11
                         A                                      CF12
                         A                                      CF13
                         A                                      CF14
                         A                                      CF15
                         A                                      CF16
                         A                                      CF17
                         A                                      CF18
                         A                                      CF19
                         A                                      CF20
                         A                                      CF21
                         A                                      CF22
                         A                                      CF23
                         A                                      CF24
                         A N41                                  PAGEDOWN
                         A                                      PAGEUP
                         A                                      PRINT
                         A*=============================================================
                         A*  Subfile number one:Master List
                         A*=============================================================
                         A          R SUB01                     SFL
                         A*%%TS  SD  20100625  124732  FLANARY     REL-V5R4M0  5722-WDS
                         A            S1MED          4   B 11  6
                         A*=============================================================
                         A*  Control for subfile number one:Master List
                         A*=============================================================
                         A          R SUB01CTL                  SFLCTL(SUB01)
                         A*%%TS  SD  20100625  124732  FLANARY     REL-V5R4M0  5722-WDS
                         A                                      RTNCSRLOC(&#REC &#FLD)
                         A                                      BLINK
                         A                                      OVERLAY
                         A                                      SFLCSRRRN(&WHERE)
                         A  31                                  SFLDSP
                         A  32                                  SFLDSPCTL
                         A  30                                  SFLCLR
                         A  33                                  SFLEND(*MORE)
                         A                                      SFLSIZ(0056)
                         A                                      SFLPAG(0055)
                         A                                      SFLLIN(0010)
                         A            SCRRN          4S 0H      SFLRCDNBR
                         A            #REC          10A  H
                         A            #FLD          10A  H
                         A            WHERE          5S 0H
                         A                                  1  3DATE
                         A                                      EDTCDE(Y)
                         A            C1DAY         12A  O  1 13
                         A            ATR_DACONM     1A  P
                         A            DACONM        30A  O  1 52DSPATR(&ATR_DACONM)
                         A            HDPROGRAM     10A  O  1121
                         A            C1TITLE       40A  O  2 47DSPATR(&ATR_DACONM)
                         A            C1SNAME       40A  O  3  3DSPATR(HI)
                         A N70                              5  3'Type options, press Enter.'
                         A                                      COLOR(BLU)
                         A            H1FDATE        6S 0H
                         A            H1TDATE        6S 0H
                         A            C1COST        14A  O  3106
                         A                                  5 62'Start'
                         A                                  5 68'Date:'
                         A            C1STARTDT      6Y 0B  5 74EDTWRD('  /  /  ')
                         A                                  5 85'End Date:'
                         A            C1ENDDT        6Y 0B  5 95EDTWRD('  /  /  ')
                         A                                 10  6'Medallions'
                         A                                      DSPATR(HI)
                         A*=========================================================================
                         A*  Function Keys(01)
                         A*=========================================================================
                         A          R FKEY01
                         A                                 25  5'F3=Exit'
                         A                                      COLOR(BLU)
                         A            T1DWEIGHT      8Y 0O 23 36EDTCDE(2)
                         A                                      COLOR(PNK)
                         A            T1PWEIGHT      8Y 0O 23 47EDTCDE(2)
                         A                                      COLOR(PNK)
                         A            T1GP$          9Y 2O 23117EDTCDE(K)
                         A                                      COLOR(PNK)
                         A                                 22 36'=========='
                         A                                 22 47'==========='
                         A                                 22 80'============'
                         A                                 25 66'F7=Prev Day'
                         A                                      COLOR(BLU)
                         A                                 25 81'F8=Next Day'
                         A                                      COLOR(BLU)
                         A                                 25 16'F4=Prompt'
                         A                                      COLOR(BLU)
                         A                                 26  5'F9=Display By Customer'
                         A                                      COLOR(BLU)
                         A                                 26 31'F10=Display By Inside'
                         A                                      COLOR(BLU)
                         A                                 25 47'F6=Extract Data'
                         A                                      COLOR(BLU)
                         A                                 26 56'F11=Switch Company'
                         A                                      COLOR(BLU)
                         A                                 22 59'====='
                         A            T1STOPS        4Y 0O 23 59EDTCDE(2)
                         A                                      COLOR(PNK)
                         A                                 25 29'F5=Toggle Cost'
                         A                                      COLOR(BLU)
                         A                                 22117'============'
                         A            T1MATCOST      9Y 2O 23 80EDTCDE(K)
                         A                                      COLOR(PNK)
                         A                                 22 66'============'
                         A            T1INVTOT       9Y 2O 23 66EDTCDE(K)
                         A                                      COLOR(PNK)
                         A                                 22  2'Actual Route Weight:'
                         A            T1ROUTEWGT     8Y 0O 22 24EDTCDE(2)
                         A                                      COLOR(PNK)
                         A            T1INVPFT       8Y 2O 23 94EDTCDE(K)
                         A                                      COLOR(PNK)
                         A                                 22 94'==========='
                         A                                 26 78'F13=View Route'
                         A                                      COLOR(BLU)
                    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


                    • #11
                      Re: Hi

                      Originally posted by tomholden View Post
                      ok FWIW if you're going to use *ALL for EXTNAME...you don't have to put the *ALL..it's implied.
                      Not wanting to nit pick Tommy but the default is actually *INPUT. You won't see any difference with a database but it makes a big difference with a display file!
                      Originally posted by tomholden View Post
                      and as soup_dog said...what exactly is the point of the DRR DS? it's not being used anywhere.
                      By defining an externally described DS for the file the compiler will use those fields for I/O - so when you read the file all of the fields are automagically populated.
                      Originally posted by tomholden View Post
                      If you're using RPG IV then use RPG IV syntax instead of the cobbled together RPG "blend"
                      Amen to that - all due respect to the OP but the mixed style was truly horrible.

                      Now to answer the original question. Why are only the key fields populated? Simply becuase they are the only fields used in the program. Unlike COBOL or C which will simply map their record layout to the I/O buffer, RPG physically copies the data from the buffer to the fields. BUT - in order to save time it will only copy those fields that are actually being used. Look at the example below:
                      Code:
                           FCUSTOMERS IF   E           K DISK
                           D CustData      E DS                  Extname(CUSTOMERS : *INPUT )
                            /free
                             DoU %Eof(Customers);
                               Read Customers;
                               Dsply ('Customer: ' + CustNo + ' Name: ' + Name); // Remove this line and NO fields are moved
                             EndDo;
                             *INLR = *On;
                      The only two fields populated are CustNo and Name. All the other fields in the DS will be left blank.

                      However - if I change the Read to use a target DS as below then all fields should show up.
                      Code:
                      ...
                           D CustData      E DS                  Extname(CUSTOMERS : *INPUT )
                            /free
                      ...
                               Read Customers CustData;
                      ...
                      Hope this helps explain it all.

                      Comment


                      • #12
                        Re: Hi

                        nit pick away...no harm no foul! i don't mind being wrong as long as it don't cost me my job
                        I'm not anti-social, I just don't like people -Tommy Holden

                        Comment

                        Working...
                        X