× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



You _can_ process the source file just as you would any other physical file, 
i.e. externally describe it in RPG and perform READs, WRITEs and UPDATEs to it.

However, as you say, the file has only 3 fields known to the systems, the 
source sequence number, the source date and the source "data". The latter is an 
unformatted data block and, as you say, can be of varying lengths depending on 
what RCDLEN was defined on the CRTSRCPF command when the file was created. 

Personally, I find it easier to process source files by program-describing them 
and using data structures to do I-O. For example, if you were processing a 
source member containing RPG code, you could define different data structures 
for each spec type (H-specs, F-specs, D-specs, C-specs etc.).  I know you're 
not processing RPG source, but it's a good example.

In the example below I've allowed for up to 1,000 bytes of source data. If the 
data in the actual file is less than this, you'll get a warning message in your 
job log but it will work fine.

Since you won't know what kind of record you've read until you read it, input 
should be done to a generic data structure, and the specific data structure for 
each spec-type mapped over that generic structure (i.e the structure share the 
same meomory), e.g.

FSrcFile   IF   F 1012        DISK                               
                                                                 
D Generic         DS          1012                               
D   SeqNbr                       6S 0                            
D   SrcDate                      6S 0                            
D                                5A                              
D   SpecType                     1A                              
D   Comment                      1A                              
                                                                 
 * Pointer to generic structure                                  
                                                                 
D pGeneric        S               *   INZ(%addr(Generic))        
                                                                 
 * C-spec structure mapped over generic structure                
                                                                 
D CSpec           DS          1012    BASED(pGeneric)            
D                               23A                              
D   CFactor1                    14A                              
D   COpCode                     10A                              
D   CFactor2                    14A                                    
D   CResult                     14A                                    
                                                                       
 * D-spec structure mapped over generic structure                      
                                                                       
D DSpec           DS          1012    BASED(pGeneric)                  
D                               18A                                    
D   DName                       15A                                    
D   DExternal                    1A                                    
D   DPSDS                        1A                                    
D   DDeclType                    2A                                    
D   DFrom                        7A                                    
D   DTo                          7A                                    
D   DType                        1A                                    
D   DDecimals                    2A                                    
D                                1A                                    
D   DKeywords                   37A                                    

   * Read source file into generic structure
                                                                       
C                   READ      SrcFile              Generic
                                                                 
C                   SELECT                                       
        
  * End of file                                 
C                   WHEN      not %eof(SrcFile)                  
  
  * Ignore comment lines                     
C                   WHEN      Comment = '*'                      
 
  * Handle C-specs
C                   WHEN      SpecType = 'C'                     
C                   CALLP     DoSomethingCSpec                   

  * Update using the C-spec structure
C                   UPDATE    SrcFile       CSpec                

  * Handle D-specs                               
C                   WHEN      SpecType = 'D'                     
C                   CALLP     DoSomethingDSpec                   

  * Update using the D-spec structure
C                   UPDATE    SrcFile       DSpec                
                                                                 
C                   ENDSL                                        

etc.

Be warned: I knocked this up pretty quickly and haven't compiled or tested it 
so the data structures etc. are incomplete the the positions might be a bit 
out, but hopefully you get the idea.

Pete                    
----- Original Message ----- 
From: "Deese, Cynthia" <Cynthia.Deese@xxxxxxx>
To: <vinayak_toal@xxxxxxxxxxxxx>
Cc: <rpg400-l@xxxxxxxxxxxx>
Sent: Friday, June 20, 2003 12:45 PM
Subject: RE: Modify source physical file member in RPG


> Hi,
> 
> I appreciate your assistance.  What I am trying to do, specifically, is that
> I have a source file member called EDIEMAIL of type TXT in a source file
> called QTXTSRC that will, ultimately, be used as the body of an email.  I am
> receiving an inbound EDI transaction from our translator from which I am
> trying to insert certain fields from the EDI document into the source file
> member.  I am just confused as to how you work with a source file member
> over just a physical file.  I can see the similarities as the physical
> source file member has three fields, but since it is not a compiled object I
> am a little confused how I would read, write, update fields as well as
> determine the size of the file, ie 80, 112, etc.  I think I would use a
> QCMDCMD or QCMDEXC to determine that, but I have only worked with physical
> and logical files in rpg and cl.
> 
> Again, thank you for any assistance you may provide.
> 
> Cyndy Deese
> 
> 
> 
> -----Original Message-----
> From: Vinayak Toal [mailto:vinayak_toal@xxxxxxxxxxxxx]
> Sent: Friday, June 20, 2003 1:02 AM
> To: Cynthia Deese (E-mail)
> Subject: Modify source physical file member in RPG
> 
> 
> Hi Deese,
> Can you elaborate in detail exactly what you want to do?
> 
> Thanks and Regards,
> 
> Vinayak Toal
> Project Leader - JDE World Soft
> SYSTIME Computers Ltd.
> Tel:+91-22-28290051
> Fax:+91-22-28290126
> web www.systime.net
> 
> _______________________________________________
> This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list
> To post a message email: RPG400-L@xxxxxxxxxxxx
> To subscribe, unsubscribe, or change list options,
> visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
> or email: RPG400-L-request@xxxxxxxxxxxx
> Before posting, please take a moment to review the archives
> at http://archive.midrange.com/rpg400-l.
> 
> 
> 

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.