Search code examples
ibm-midrangerpgle

Compilation error when using EXTFLD to define an array as subfield of a data structure


I am trying to define an array as a subfield of a DS by referring to an external table using EXTNAME and EXTFLD. But it results in a compilation error.

dcl-ds P_IAC3002L                          extname('IAC3002_L') qualified template;
  LISTROWNumber                            extfld('LISTROWNBR');                   
  WorkTitle                                extfld('WORKTITLE');                    
  OriginalWorkTitle                        extfld('WRKTITLEOR');                   
  TypeOfWorkTitle                          extfld('WRKTITLETY');                   
  TitleTypeDescription                     extfld('TITLEDESC');                    
  OriginalVersionInd                       extfld('WRKORGIND');                    
  OriginalVersionIndDescription            extfld('WRKORGDESC');                   
  Role                                     extfld('ROLE' );                        
  RoleDescription                          extfld('ROLEDESC');                     
  StatusOfWork                             extfld('WRKSTS' );                      
  WorkStatusDescription                    extfld('WRKSTSDESC');                   
  WorkKey                                  extfld('WORKKEY');                      
  WorkTitleNumber                          extfld('WRKTITLENO');                   
  WorkMatchIndicator                       extfld('WRKMATCHIN');                   
  WorkCCIndicator                          extfld('WRKCCIND');                     
  OtherTitlesExist                         extfld('OTHTITLIND');                   
  WorkIsReferenced                         extfld('WRKISREF');                     
  WorkIsActive                             extfld('WRKISACT');                     
  AgreementExceptionExists                 extfld('PAGEXCEP');         
  PublisherReferences                      extfld('PUBREFS') dim(500); 
end-ds; 

Above is the DS.

Below is the Error:

 PublisherReferences                      extfld('PUBREFS') dim(500);   
======>    aaaaaaaaaaaaaaaaaaa                                                        
*RNF0518 20 a      012900  Length of item PUBLISH... is less than 1; length defaults  
                           to 1.                                                      
                           

The table definition is rather straight forward:

      Field                         Field                             
   Text                          Name     Type Length  Dec  Loc    
 List Row Number                 LISTROWNBR S      3    0     1    
 Work Title                      WORKTITLE  A     90          4    
 Work Original Title             WRKTITLEOR A     90         94    
 Type of Work Title              WRKTITLETY A      2        184    
 Title Type Description          TITLEDESC  A     60        186    
 Original/version Indicato       WRKORGIND  A      3        246    
 Work Original Indicator D       WRKORGDESC A     60        249    
 Role                            ROLE       A     10        309    
 Role Description                ROLEDESC   A     60        319    
 Status Of Work                  WRKSTS     S      1    0   379    
 Work Status Description         WRKSTSDESC A     60        380    
 Work Key Number                 WORKKEY    S     11    0   440 
 Work Title Sequence Numbe       WRKTITLENO S      7    0   451 
 Work Match Indicator            WRKMATCHIN A      1        458 
 Work Counterclaim Indicat       WRKCCIND   A      1        459 
 Other Titles Exist              OTHTITLIND A      1        460 
 No of none Wsm                  NONONEWSM  S      3    0   461 
 Work has Trigger                HASTRIGGER A      1        464 
 Work Is Referenced              WRKISREF   A      1        465 
 Work Is Active                  WRKISACT   A      1        466 
 Agreement Exception Exist       PAGEXCEP   A      1        467 
 Work Number Cross Referen       PUBREFS    A     20        468 
                

Can somebody help on why this wont compile ?


Solution

  • Ah, your last comment provides the answer...

    You can't take a char(20) from a file and redefine it bigger than 20 bytes.

    RPG is willing to treat char(20) as char(1) dim(20).

    What are you trying to accomplish with dim(500)?

    EDIT

    try doing what you're trying to do like so:

    dcl-ds P_IAC3002L extname('IAC3002_L') qualified template;
    end-ds;
    
    dcl-ds myWorkDs qualified template;
       LISTROWNumber like(p_iac3002l.LISTROWNBR);
       ....
       PublisherReferences like(p_iac3002l.PUBREFS) dim(500);
    end-ds;