ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Long Field Names in RPGLE from Tables Created With SQL

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

  • Long Field Names in RPGLE from Tables Created With SQL

    For the first time in almost a year, I am writing some code, and a few cobwebs are in there.

    I have a table I have described in DQL and created using long field names (Insurance_Carrier instead of INSCAR, as an example) and would prefer to use the long names in my code. I remember being able to do that rather easily but I cannot recall how to do so.

    I am writing in fully freeform RPGLE, and this table will be updated as an accumulating table for future review.

  • #2
    You need the ALIAS keyword within the F-Specs
    It is also possible to use the long table names (Definition only in Free Format F-Specs). Define the short name with Keyword ExtDesc() and add ExtFile(*ExtDesc).

    Code:
     //--------------------------------------------------------------------
     DCL-F ExTable01 [COLOR=#B22222][B] Alias;   [/B][/COLOR]          
     DCL-F OrderHdrX_Hist_I02 [B][COLOR=#0000CD]ExtDesc('ORDHHI02') ExtFile(*ExtDesc)[/COLOR][/B] [B][COLOR=#B22222]Alias;  [/COLOR]  [/B]                
     //--------------------------------------------------------------------
     DCL-DS DSExTable01  LikeRec(ExTable01F);                              
    
     DCL-DS DSDsp        Qualified   Inz;                                  
       Id                Int(10);                                          
       VarChar           Like([COLOR=#B22222][B]DSExTable01.ExampleVarChar[/B][/COLOR]);                
       Varying           Like([COLOR=#B22222][B]DSEXTable01.ExampleVarying[/B][/COLOR]);                
     End-Ds;                                                              
     //--------------------------------------------------------------------
     Monitor;                                                              
    
       Read ExTable01F DSExTable01;                                        
       Clear DSDsp;                                                        
       DSDsp.Id      = [COLOR=#B22222][B]DSExTable01.ExampleId[/B];      [/COLOR]                        
       DsDsp.VarChar = [COLOR=#B22222][B]DSExTable01.ExampleVarChar[/B];  [/COLOR]                      
       //More code
       Chain (Key1: Key2) [B][COLOR=#0000CD]OrderHdrX_Hist_I02;[/COLOR][/B]
       If %Found(OrderHdrX_Hist_I02);
    [COLOR=#B22222][B]      Delivery_Date[/B][/COLOR] = %Date();
       //More code
    Birgitta
    Last edited by B.Hauser; March 27, 2019, 12:22 AM.

    Comment


    • #3
      The Alias keyword can also be applied to externally defined DS's

      Comment


      • #4
        Also, I did not know you could apply text formatting within code tags.
        I'll have to remember that one, thanks Birgitta

        Comment


        • #5
          Ignore this reply- I misunderstood something, and I can't delete it.

          Comment

          Working...
          X