ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

How to transfer desktop .xls file from desktop of local user to AS/400 system in RPG

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

  • How to transfer desktop .xls file from desktop of local user to AS/400 system in RPG

    Hi,

    How can i send a user desktop .xls file to an AS/400 Subfile screen through an RPGLE program.

    Can anyone tell me is that feasible???

  • #2
    Re: How to transfer desktop .xls file from desktop of local user to AS/400 system in

    Please don't post this question more than once....here is an example of reading a .csv from IFS. You will have to do a save as from the .xls to .csv.I create a share on local workstation (PC) to IFS directory.then user just saves as ...to this share.

    Code:
     
    
         H Option( *SrcStmt: *NoDebugIo )  BndDir( 'QC2LE' ) DFTACTGRP(*No)                             
         ‚**********************************************************************                        
         ‚* Project ID     Date  Pgmr ID  Rev  Description                                              
         ‚*                                                                                             
         ‚*            11/16/11  JJF       00  program written                                          
         ‚*              ** pulls .csv tables from directory:                                           
         ‚*                 /home/jamie/                                                  
         ‚*                                                                                             
         ‚**********************************************************************                        
          *                                                                                             
          * Directory Entry Structure (dirent)                                                          
          *                                                                                             
         d p_dirent        s               *                                                            
         d dirent          ds                  based(p_dirent)                                          
         d   d_reserv1                   16A                                                            
         d   d_reserv2                   10U 0                                                          
         d   d_fileno                    10U 0                                                          
         d   d_reclen                    10U 0                                                          
         d   d_reserv3                   10I 0                                                          
         d   d_reserv4                    8A                                                            
         d   d_nlsinfo                   12A                                                            
         d     nls_ccsid                 10I 0 OVERLAY(d_nlsinfo:1)                                     
         d     nls_cntry                  2A   OVERLAY(d_nlsinfo:5)                                     
         d     nls_lang                   3A   OVERLAY(d_nlsinfo:7)                                     
         d     nls_reserv                 3A   OVERLAY(d_nlsinfo:10)                                    
         d   d_namelen                   10U 0                                                          
         d   d_name                     640A                                                            
                                                                                                        
          *------------------------------------------------------------                                 
          * Open a Directory                                                                            
          *------------------------------------------------------------                                 
         d opendir         pr              *   EXTPROC('opendir')                                       
         d  dirname                        *   VALUE                                                    
          *------------------------------------------------------------                                 
          * Read Directory Entry                                                                        
          *------------------------------------------------------------                                 
         d readdir         pr              *   EXTPROC('readdir')                                       
         d  dirname                        *   VALUE                                                    
          *------------------------------------------------------------                                 
          * Close Directory                                                                             
          *------------------------------------------------------------                                 
         d closedir        pr              *   EXTPROC('closedir')                                      
         d  dirname                        *   VALUE                                                    
          *------------------------------------------------------------                                 
          * Open IFs table                                                                              
          *------------------------------------------------------------                                 
         d open            pr            10i 0   ExtProc('open')                                        
         d   filename                      *     value                                                  
         d   openflags                   10i 0   value                                                  
         d   mode                        10u 0   value options(*nopass)                                 
         d   codepage                    10u 0   value options(*nopass)                                 
          *------------------------------------------------------------                                 
          * Read IFS table                                                                              
          *------------------------------------------------------------                                 
         d read            pr            10i 0   ExtProc('read')                                        
         d   filehandle                  10i 0   value                                                  
         d   datareceived                  *     value                                                  
         d   nbytes                      10u 0   value                                                  
          *------------------------------------------------------------                                 
          * Close IFs table                                                                             
          *------------------------------------------------------------                                 
         d close           pr            10i 0   ExtProc('close')                                       
         d   filehandle                  10i 0   value                                                  
          *------------------------------------------------------------                                 
          * read ifs table  - internal procedure                                                        
          *------------------------------------------------------------                                 
         d RdIfsFil        pr           256a                                                            
         d  FileName                    256a   const                                                    
          *------------------------------------------------------------                                 
          * Delay - sleep function                                                                      
          *------------------------------------------------------------                                 
         d sleep           pr            10i 0 ExtProc( 'sleep' )                                       
         d  seconds                      10u 0 Value                                                    
          *------------------------------------------------------------                                 
          * Command - run a command                                                                     
          *------------------------------------------------------------                                 
         d $command        pr                  extpgm('QCMDEXC')                                        
         d   command                    256                                                             
         d   length                      15  5                                                          
          *------------------------------------------------------------                                 
          * Grab the date in LongFormat                                                                 
          *------------------------------------------------------------                                 
         d CEEDATE         pr                  opdesc                                                   
         d   Lilian                      10i 0                                                          
         d   picture                  65535A   const options(*varsize)                                  
         d   OutputDate               65535A   const options(*varsize)                                  
         d   Feedback                    12a   options(*omit)                                           
          *------------------------------------------------------------                                 
          * a few local variables...                                                                    
                                                                                                        
         d BaseDate        s               d   inz(D'1582-10-14')                                       
         d cmdlength       s             15  5                                                          
         d cmdstring       s            256                                                             
         d count           s              3  0                                                          
         d cr              c                   Const(x'0D')                                             
         d data            s          65535A                                                            
         d Data_Rec        s          65535A                                                            
         d datasize        s              5  0                                                          
         d dh              s               *                                                            
         d Eol             c                   Const(x'0D25')                                           
         d Error_Flag      s              1A   INZ('0')                                                 
         d File            s            256                                                             
         d FileName        s            256    varying                                                  
         d FolderNames     s            256    dim(50)                                                  
         d Fp              s             10i 0                                                          
         d KeepLooping     s               n   inz('1')                                                 
         d lf              C                   Const(x'25')                                             
         d MyNewName       s            265    varying                                                  
         d N               s              5  0                                                          
         d nDays           s             10i 0                                                          
          * values for oflag parameter, used by open()                                                  
         d O_RDONLY        s             10i 0   inz(1)                                                 
         d O_TEXTDATA      s             10i 0   inz(16777216)                                          
                                                                                                        
         d Oflag           s             10i 0                                                          
         d Omode           s             10u 0                                                          
         d PathName        s             26                                                             
         d Q               s              1    inz('''')                                                
         d R               S              5  0                                                          
         d Rc              S             10i 0                                                          
         d ReturnData      s             12                                                             
         d SleepSeconds    s             10i 0 inz(1)                                                   
         d ta              s              3  0                                                          
         d Today           s               d   inz(*SYS)                                                
                                                                                                        
             // entire document stored in here                                                          
         d MyData          ds                  qualified  inz                                           
         d  bighunkdata               65535                                                             
         d   OneSlice                    60    dim(1000) overlay(bighunkdata:*next)                     
          *------------------------------------------------------                                       
          * MAIN LINE                                                                                   
          *------------------------------------------------------                                       
                                                                                                        
          /free                                                                                         
                                                                                                        
                    // program will loop until outside force                                            
                    // stops it.                                                                        
                  dow KeepLooping;                                                                      
                                                                                                        
                   exsr $GetFileName;                                                                   
                   if ta > *zeros;                                                                      
                    // read the tables one at a time                                                    
                    for count = 1 to ta;                                                                
                     filename = foldernames(count);                                                     
                     Error_flag = rdifsfil(Filename);                                                   
                     //exsr $MoveToHistory;                                                             
                    endfor;                                                                             
                   endif;                                                                               
                                                                                                        
                   // Delay job for a number of seconds then start                                      
                   // the process all over again.                                                       
                   sleep(SleepSeconds);                                                                 
                                                                                                        
                  enddo;                                                                                
                                                                                                        
               *inlr = *on;                                                                             
                                                                                                        
               //-------------------------------------------                                            
               // $GetFileName - get the next csv table                                                 
               //-------------------------------------------                                            
                 begsr $GetFileName;                                                                    
                                                                                                        
                   clear filename;                                                                      
                    // tables will hold all the names of the tables                                     
                   clear TA;                                                                            
                   clear folderNames;                                                                   
                                                                                                        
                    // loop on the directory                                                            
                    // Step1: Open up the directory.                                                    
                   PathName = '/home/jamie/';                                             
                   dh = opendir(%addr(PathName));                                                       
                   if dh <> *NULL;                                                                      
                                                                                                        
                    // Step2: Read each entry from the directory (in a loop)                            
                    p_dirent = readdir(dh);                                                             
                                                                                                        
                    dow p_dirent <> *NULL;                                                              
                     if d_namelen < 256;                                                                
                      FileName = %subst(d_name:1:d_namelen);                                            
                      // process only csv files                                                         
                      // even MT directory contains folders:                                            
                      // o .                                                                            
                      // o ..                                                                           
                      if %scan('.csv':Filename) > *zeros;                                               
                       ta+=1;                                                                           
                       foldernames(ta) = %trim(pathname) + %trim(filename);                             
                      endif;                                                                            
                     endif;                                                                             
                      p_dirent = readdir(dh);                                                           
                    enddo;                                                                              
                   endif;                                                                               
                                                                                                        
                   // Step3: Close the directory to reprocess                                           
                   closedir(dh);                                                                        
                                                                                                        
                 endsr;                                                                                 
                                                                                                        
               //-------------------------------------------                                            
               // $MoveToHistory - move processed table to                                              
               //                  history                                                              
               //-------------------------------------------                                            
                                                                                                        
                 begsr $MoveToHistory;                                                                  
                                                                                                        
                  //  *****  Rename the file  *****                                                     
                  // RNM OBJ('/home/jamie/some.csv')                            
                  // NEWOBJ('SomeNewName.csv')                                                          
                  // *like: November16_2011_114547.csv                                                  
                                                                                                        
                                                                                                        
                     nDays = %diff(today : baseDate : *days);                                           
                     ceedate(nDays:'Mmmmmmmmmm':ReturnData:*OMIT);                                      
                                                                                                        
                     MyNewName = %trim(ReturnData)  +                                                   
                     %char(%subdt(Today:*days)) + '_' +                                                 
                     %char(%subdt(Today:*years)) + '_' +                                                
                     %ScanRpl('.' : '' :                                                                
                     %char(%time())) + '.csv';                                                          
                                                                                                        
                     cmdstring = 'RNM OBJ(' + Q + %trim(PathName) +                                     
                                 %trim(filename) + Q + ')' +                                            
                                 ' NEWOBJ(' + Q + %trim(MyNewName) +                                    
                                 Q + ')';                                                               
                                                                                                        
                     cmdlength = %len(%trim(cmdstring));                                                
                     monitor;                                                                           
                      $command(cmdstring:cmdlength);                                                    
                     on-error;                                                                          
                      // process for errors                                                             
                     endmon;                                                                            
                                                                                                        
                                                                                                        
                  //  *****  Move file to history  *****                                                
                  // MOV OBJ('/home/jamie/some.csv')                            
                  //  TODIR('/home/jamie/history/')                                       
                                                                                                        
                     cmdstring = 'MOV OBJ(' + Q + %trim(PathName) +                                     
                                 %trim(MyNewName) + Q + ')' +                                           
                                 ' TODIR(' + Q + %trim(PathName) + 'History/' +                         
                                 Q + ')';                                                               
                     cmdlength = %len(%trim(cmdstring));                                                
                     monitor;                                                                           
                      $command(cmdstring:cmdlength);                                                    
                     on-error;                                                                          
                      // process for errors                                                             
                     endmon;                                                                            
                                                                                                        
                 endsr;                                                                                 
                                                                                                        
               //-------------------------------------------                                            
                                                                                                        
          /end-free                                                                                     
                                                                                                        
          *-------------------------------------------------------------                                
          *    RdIfsFil - Subprocedure To Read The IFS File                                             
          *-------------------------------------------------------------                                
         p RdIfsFil        B                   Export                                                   
         d RdIfsFil        PI           256A                                                            
         d  FileName                    256A   Const                                                    
         d CharsRead       S             10i 0                                                          
         d CurChar         S              1                                                             
         d Eof             C                   const(x'00')                                             
                                                                                                        
          /free                                                                                         
                 Oflag = O_Rdonly + O_Textdata;                                                         
                 // need whole path here                                                                
                 File = %trim(FileName) + x'00';                                                        
                 Fp = open(%addr(File): Oflag);                                                         
                                                                                                        
                 if  Fp < 0;                                                                            
                  Error_Flag = *On;                                                                     
                  Return  Error_Flag;                                                                   
                 Endif;                                                                                 
                                                                                                        
                 R = 0;                                                                                 
                 N = 0;                                                                                 
                 dou  CurChar = Eof;                                                                    
                  exsr getChar;                                                                         
                  R+=1;                                                                                 
                  %Subst(Data: R: 1) = CurChar;                                                         
                                                                                                        
                  if CurChar = X'25';                                                                   
                   %Subst(Data: R: 1)  = *blanks;                                                       
                  endif;                                                                                
                                                                                                        
                  select;                                                                               
                   when  R = 256 or CurChar = X'25';                                                    
                                                                                                        
               // if you find the  code then we still have more data in                                 
               // memory  and we need to process that remaining data.                                   
                                                                                                        
                    if  CurChar = X'25';                                                                
                     %Subst(Data: R: 1)  = *blanks;                                                     
                    endif;                                                                              
                                                                                                        
                // one record is here                                                                   
                    clear  R;                                                                           
                    clear  Data;                                                                        
                                                                                                        
                  endsl;                                                                                
                 enddo;                                                                                 
                                                                                                        
                 Return    Error_Flag;                                                                  
                                                                                                        
              //---------------------------------------------------------                               
              //  GetChar - Process IFS Record, One Character At A Time                                 
              //---------------------------------------------------------                               
                 begsr GetChar;                                                                         
                                                                                                        
                   //  If input buffer is empty, or all characters have been                            
                   //    processed, refill the input buffer.                                            
                  if N = CharsRead;                                                                     
                   CharsRead = Read(Fp:%Addr(Data_Rec): 2560);                                          
                   N = *Zero;                                                                           
                  endif;                                                                                
                                                                                                        
                   // Get the next character in the input buffer.                                       
                  if CharsRead <= 0;                                                                    
                   CurChar = Eof;                                                                       
                  else;                                                                                 
                   N+=1;                                                                                
                   CurChar = %Subst(Data_Rec: N: 1);                                                    
                   select;                                                                              
                    when  CurChar = *blanks or CurChar = cr  or  CurChar = lf;                          
                     mydata.bighunkdata = %trim(mydata.bighunkdata) + '|';                              
                    other;                                                                              
                     mydata.Bighunkdata = %trim(mydata.bighunkdata) +                                   
                     %trim(Curchar);                                                                    
                    endsl;                                                                              
                  endif;                                                                                
                                                                                                        
                 endsr;                                                                                 
                                                                                                        
             //---------------------------------------------------------                                
          /end-free                                                                                     
                                                                                                        
         p RdIfsFil        E                                                                            
         H Option( *SrcStmt: *NoDebugIo )  BndDir( 'QC2LE' ) DFTACTGRP(*No)                             
         ‚**********************************************************************                        
         ‚* Project ID     Date  Pgmr ID  Rev  Description                                              
         ‚*                                                                                             
         ‚*            11/16/11  JJF       00  program written                                          
         ‚*              ** pulls .csv tables from directory:                                           
         ‚*                 /home/jamie/                                                  
         ‚*                                                                                             
         ‚**********************************************************************                        
          *                                                                                             
          * Directory Entry Structure (dirent)                                                          
          *                                                                                             
         d p_dirent        s               *                                                            
         d dirent          ds                  based(p_dirent)                                          
         d   d_reserv1                   16A                                                            
         d   d_reserv2                   10U 0                                                          
         d   d_fileno                    10U 0                                                          
         d   d_reclen                    10U 0                                                          
         d   d_reserv3                   10I 0                                                          
         d   d_reserv4                    8A                                                            
         d   d_nlsinfo                   12A                                                            
         d     nls_ccsid                 10I 0 OVERLAY(d_nlsinfo:1)                                     
         d     nls_cntry                  2A   OVERLAY(d_nlsinfo:5)                                     
         d     nls_lang                   3A   OVERLAY(d_nlsinfo:7)                                     
         d     nls_reserv                 3A   OVERLAY(d_nlsinfo:10)                                    
         d   d_namelen                   10U 0                                                          
         d   d_name                     640A                                                            
                                                                                                        
          *------------------------------------------------------------                                 
          * Open a Directory                                                                            
          *------------------------------------------------------------                                 
         d opendir         pr              *   EXTPROC('opendir')                                       
         d  dirname                        *   VALUE                                                    
          *------------------------------------------------------------                                 
          * Read Directory Entry                                                                        
          *------------------------------------------------------------                                 
         d readdir         pr              *   EXTPROC('readdir')                                       
         d  dirname                        *   VALUE                                                    
          *------------------------------------------------------------                                 
          * Close Directory                                                                             
          *------------------------------------------------------------                                 
         d closedir        pr              *   EXTPROC('closedir')                                      
         d  dirname                        *   VALUE                                                    
          *------------------------------------------------------------                                 
          * Open IFs table                                                                              
          *------------------------------------------------------------                                 
         d open            pr            10i 0   ExtProc('open')                                        
         d   filename                      *     value                                                  
         d   openflags                   10i 0   value                                                  
         d   mode                        10u 0   value options(*nopass)                                 
         d   codepage                    10u 0   value options(*nopass)                                 
          *------------------------------------------------------------                                 
          * Read IFS table                                                                              
          *------------------------------------------------------------                                 
         d read            pr            10i 0   ExtProc('read')                                        
         d   filehandle                  10i 0   value                                                  
         d   datareceived                  *     value                                                  
         d   nbytes                      10u 0   value                                                  
          *------------------------------------------------------------                                 
          * Close IFs table                                                                             
          *------------------------------------------------------------                                 
         d close           pr            10i 0   ExtProc('close')                                       
         d   filehandle                  10i 0   value                                                  
          *------------------------------------------------------------                                 
          * read ifs table  - internal procedure                                                        
          *------------------------------------------------------------                                 
         d RdIfsFil        pr           256a                                                            
         d  FileName                    256a   const                                                    
          *------------------------------------------------------------                                 
          * Delay - sleep function                                                                      
          *------------------------------------------------------------                                 
         d sleep           pr            10i 0 ExtProc( 'sleep' )                                       
         d  seconds                      10u 0 Value                                                    
          *------------------------------------------------------------                                 
          * Command - run a command                                                                     
          *------------------------------------------------------------                                 
         d $command        pr                  extpgm('QCMDEXC')                                        
         d   command                    256                                                             
         d   length                      15  5                                                          
          *------------------------------------------------------------                                 
          * Grab the date in LongFormat                                                                 
          *------------------------------------------------------------                                 
         d CEEDATE         pr                  opdesc                                                   
         d   Lilian                      10i 0                                                          
         d   picture                  65535A   const options(*varsize)                                  
         d   OutputDate               65535A   const options(*varsize)                                  
         d   Feedback                    12a   options(*omit)                                           
          *------------------------------------------------------------                                 
          * a few local variables...                                                                    
                                                                                                        
         d BaseDate        s               d   inz(D'1582-10-14')                                       
         d cmdlength       s             15  5                                                          
         d cmdstring       s            256                                                             
         d count           s              3  0                                                          
         d cr              c                   Const(x'0D')                                             
         d data            s          65535A                                                            
         d Data_Rec        s          65535A                                                            
         d datasize        s              5  0                                                          
         d dh              s               *                                                            
         d Eol             c                   Const(x'0D25')                                           
         d Error_Flag      s              1A   INZ('0')                                                 
         d File            s            256                                                             
         d FileName        s            256    varying                                                  
         d FolderNames     s            256    dim(50)                                                  
         d Fp              s             10i 0                                                          
         d KeepLooping     s               n   inz('1')                                                 
         d lf              C                   Const(x'25')                                             
         d MyNewName       s            265    varying                                                  
         d N               s              5  0                                                          
         d nDays           s             10i 0                                                          
          * values for oflag parameter, used by open()                                                  
         d O_RDONLY        s             10i 0   inz(1)                                                 
         d O_TEXTDATA      s             10i 0   inz(16777216)                                          
                                                                                                        
         d Oflag           s             10i 0                                                          
         d Omode           s             10u 0                                                          
         d PathName        s             26                                                             
         d Q               s              1    inz('''')                                                
         d R               S              5  0                                                          
         d Rc              S             10i 0                                                          
         d ReturnData      s             12                                                             
         d SleepSeconds    s             10i 0 inz(1)                                                   
         d ta              s              3  0                                                          
         d Today           s               d   inz(*SYS)                                                
                                                                                                        
             // entire document stored in here                                                          
         d MyData          ds                  qualified  inz                                           
         d  bighunkdata               65535                                                             
         d   OneSlice                    60    dim(1000) overlay(bighunkdata:*next)                     
          *------------------------------------------------------                                       
          * MAIN LINE                                                                                   
          *------------------------------------------------------                                       
                                                                                                        
          /free                                                                                         
                                                                                                        
                    // program will loop until outside force                                            
                    // stops it.                                                                        
                  dow KeepLooping;                                                                      
                                                                                                        
                   exsr $GetFileName;                                                                   
                   if ta > *zeros;                                                                      
                    // read the tables one at a time                                                    
                    for count = 1 to ta;                                                                
                     filename = foldernames(count);                                                     
                     Error_flag = rdifsfil(Filename);                                                   
                     //exsr $MoveToHistory;                                                             
                    endfor;                                                                             
                   endif;                                                                               
                                                                                                        
                   // Delay job for a number of seconds then start                                      
                   // the process all over again.                                                       
                   sleep(SleepSeconds);                                                                 
                                                                                                        
                  enddo;                                                                                
                                                                                                        
               *inlr = *on;                                                                             
                                                                                                        
               //-------------------------------------------                                            
               // $GetFileName - get the next csv table                                                 
               //-------------------------------------------                                            
                 begsr $GetFileName;                                                                    
                                                                                                        
                   clear filename;                                                                      
                    // tables will hold all the names of the tables                                     
                   clear TA;                                                                            
                   clear folderNames;                                                                   
                                                                                                        
                    // loop on the directory                                                            
                    // Step1: Open up the directory.                                                    
                   PathName = '/home/jamie/';                                             
                   dh = opendir(%addr(PathName));                                                       
                   if dh <> *NULL;                                                                      
                                                                                                        
                    // Step2: Read each entry from the directory (in a loop)                            
                    p_dirent = readdir(dh);                                                             
                                                                                                        
                    dow p_dirent <> *NULL;                                                              
                     if d_namelen < 256;                                                                
                      FileName = %subst(d_name:1:d_namelen);                                            
                      // process only csv files                                                         
                      // even MT directory contains folders:                                            
                      // o .                                                                            
                      // o ..                                                                           
                      if %scan('.csv':Filename) > *zeros;                                               
                       ta+=1;                                                                           
                       foldernames(ta) = %trim(pathname) + %trim(filename);                             
                      endif;                                                                            
                     endif;                                                                             
                      p_dirent = readdir(dh);                                                           
                    enddo;                                                                              
                   endif;                                                                               
                                                                                                        
                   // Step3: Close the directory to reprocess                                           
                   closedir(dh);                                                                        
                                                                                                        
                 endsr;                                                                                 
                                                                                                        
               //-------------------------------------------                                            
               // $MoveToHistory - move processed table to                                              
               //                  history                                                              
               //-------------------------------------------                                            
                                                                                                        
                 begsr $MoveToHistory;                                                                  
                                                                                                        
                  //  *****  Rename the file  *****                                                     
                  // RNM OBJ('/home/jamie/some.csv')                            
                  // NEWOBJ('SomeNewName.csv')                                                          
                  // *like: November16_2011_114547.csv                                                  
                                                                                                        
                                                                                                        
                     nDays = %diff(today : baseDate : *days);                                           
                     ceedate(nDays:'Mmmmmmmmmm':ReturnData:*OMIT);                                      
                                                                                                        
                     MyNewName = %trim(ReturnData)  +                                                   
                     %char(%subdt(Today:*days)) + '_' +                                                 
                     %char(%subdt(Today:*years)) + '_' +                                                
                     %ScanRpl('.' : '' :                                                                
                     %char(%time())) + '.csv';                                                          
                                                                                                        
                     cmdstring = 'RNM OBJ(' + Q + %trim(PathName) +                                     
                                 %trim(filename) + Q + ')' +                                            
                                 ' NEWOBJ(' + Q + %trim(MyNewName) +                                    
                                 Q + ')';                                                               
                                                                                                        
                     cmdlength = %len(%trim(cmdstring));                                                
                     monitor;                                                                           
                      $command(cmdstring:cmdlength);                                                    
                     on-error;                                                                          
                      // process for errors                                                             
                     endmon;                                                                            
                                                                                                        
                                                                                                        
                  //  *****  Move file to history  *****                                                
                  // MOV OBJ('/home/jamie/some.csv')                            
                  //  TODIR('/home/jamie/history/')                                       
                                                                                                        
                     cmdstring = 'MOV OBJ(' + Q + %trim(PathName) +                                     
                                 %trim(MyNewName) + Q + ')' +                                           
                                 ' TODIR(' + Q + %trim(PathName) + 'History/' +                         
                                 Q + ')';                                                               
                     cmdlength = %len(%trim(cmdstring));                                                
                     monitor;                                                                           
                      $command(cmdstring:cmdlength);                                                    
                     on-error;                                                                          
                      // process for errors                                                             
                     endmon;                                                                            
                                                                                                        
                 endsr;                                                                                 
                                                                                                        
               //-------------------------------------------                                            
                                                                                                        
          /end-free                                                                                     
                                                                                                        
          *-------------------------------------------------------------                                
          *    RdIfsFil - Subprocedure To Read The IFS File                                             
          *-------------------------------------------------------------                                
         p RdIfsFil        B                   Export                                                   
         d RdIfsFil        PI           256A                                                            
         d  FileName                    256A   Const                                                    
         d CharsRead       S             10i 0                                                          
         d CurChar         S              1                                                             
         d Eof             C                   const(x'00')                                             
                                                                                                        
          /free                                                                                         
                 Oflag = O_Rdonly + O_Textdata;                                                         
                 // need whole path here                                                                
                 File = %trim(FileName) + x'00';                                                        
                 Fp = open(%addr(File): Oflag);                                                         
                                                                                                        
                 if  Fp < 0;                                                                            
                  Error_Flag = *On;                                                                     
                  Return  Error_Flag;                                                                   
                 Endif;                                                                                 
                                                                                                        
                 R = 0;                                                                                 
                 N = 0;                                                                                 
                 dou  CurChar = Eof;                                                                    
                  exsr getChar;                                                                         
                  R+=1;                                                                                 
                  %Subst(Data: R: 1) = CurChar;                                                         
                                                                                                        
                  if CurChar = X'25';                                                                   
                   %Subst(Data: R: 1)  = *blanks;                                                       
                  endif;                                                                                
                                                                                                        
                  select;                                                                               
                   when  R = 256 or CurChar = X'25';                                                    
                                                                                                        
               // if you find the  code then we still have more data in                                 
               // memory  and we need to process that remaining data.                                   
                                                                                                        
                    if  CurChar = X'25';                                                                
                     %Subst(Data: R: 1)  = *blanks;                                                     
                    endif;                                                                              
                                                                                                        
                // one record is here                                                                   
                    clear  R;                                                                           
                    clear  Data;                                                                        
                                                                                                        
                  endsl;                                                                                
                 enddo;                                                                                 
                                                                                                        
                 Return    Error_Flag;                                                                  
                                                                                                        
              //---------------------------------------------------------                               
              //  GetChar - Process IFS Record, One Character At A Time                                 
              //---------------------------------------------------------                               
                 begsr GetChar;                                                                         
                                                                                                        
                   //  If input buffer is empty, or all characters have been                            
                   //    processed, refill the input buffer.                                            
                  if N = CharsRead;                                                                     
                   CharsRead = Read(Fp:%Addr(Data_Rec): 2560);                                          
                   N = *Zero;                                                                           
                  endif;                                                                                
                                                                                                        
                   // Get the next character in the input buffer.                                       
                  if CharsRead <= 0;                                                                    
                   CurChar = Eof;                                                                       
                  else;                                                                                 
                   N+=1;                                                                                
                   CurChar = %Subst(Data_Rec: N: 1);                                                    
                   select;                                                                              
                    when  CurChar = *blanks or CurChar = cr  or  CurChar = lf;                          
                     mydata.bighunkdata = %trim(mydata.bighunkdata) + '|';                              
                    other;                                                                              
                     mydata.Bighunkdata = %trim(mydata.bighunkdata) +                                   
                     %trim(Curchar);                                                                    
                    endsl;                                                                              
                  endif;                                                                                
                                                                                                        
                 endsr;                                                                                 
                                                                                                        
             //---------------------------------------------------------                                
          /end-free                                                                                     
                                                                                                        
         p RdIfsFil        E
    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


    • #3
      Re: How to transfer desktop .xls file from desktop of local user to AS/400 system in

      Thanks Jamie,
      Let me explain actual requirement –
      1) User (any person from there AS/ 400) call a program AND it pop up user desktop screen.
      2) Now user can select .xls or .csv file from any folder at their desktop.
      3) When user click that file once, this will need to send to AS/400 system any specific directory, from there a program can display this file in Sub file on screen to user.

      Challenges – Note –All pogromming need to be done in RPGLE (No Java or .net tech) no other language
      Point 1 – A user window IP is able to identify using QDCIPADF.
      How to track user name or say it’s Desktop?
      - start \\User System IPADDRESS\Users\xxxxxxx\Desktop
      Point 2 – Once user reaches to desktop it can select file like below.

      Point 3 – When user clicks that file once, how that file location (which folder and all) can be traced.
      How that file will be send to AS/400 systems specific directory, from where a program can display this file in Sub file on screen to user.

      Comment


      • #4
        Re: How to transfer desktop .xls file from desktop of local user to AS/400 system in

        well I have to read this more in detail, but first off..
        you cannot read .xls table without conversion..


        jamie
        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


        • #5
          Re: How to transfer desktop .xls file from desktop of local user to AS/400 system in

          Thanks Jamie
          Ok,let me know if you found somthing...

          Comment


          • #6
            Re: How to transfer desktop .xls file from desktop of local user to AS/400 system in

            I can do this with a .txt or .csv table file all day long.
            The only way to do it with an .xls table would be to use qshell or runpccmd (java - something or another) to convert it to text.

            Are you dead set on using .xls?

            I have programs on the site that creates pc shares over an ifs folder.
            there is another one that shows in a subfile a text file read.

            The example I posted reads a text file.

            can you explain the exact requirements once more?

            thanks
            Jamie
            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


            • #7
              Re: How to transfer desktop .xls file from desktop of local user to AS/400 system in

              thats kinda funny a post with something you can use ---


              jamie
              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


              • #8
                Re: How to transfer desktop .xls file from desktop of local user to AS/400 system in

                Hi Jamie,

                Here are exact requirement –
                Need to create a program which when user called from as/400 command prompt it will popup user desktop screen from where user can select any folder and any .xls or .csv file and just single click it will return (FTP) that file to as/400 system, from there it will be displayed on sub file screen. Once user got this on screen they can manipulate data or whatever they want to do.

                Thanks

                Comment


                • #9
                  Re: How to transfer desktop .xls file from desktop of local user to AS/400 system in

                  are you interviewing

                  Anyone else got anything else??

                  jamie
                  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


                  • #10
                    Re: How to transfer desktop .xls file from desktop of local user to AS/400 system in

                    No not at all,
                    With help of STRPCCMD probably the user desktop location will be open,but click and return to as/400 nothing come to my mind...

                    Comment


                    • #11
                      Re: How to transfer desktop .xls file from desktop of local user to AS/400 system in

                      DOS commands ...can that can be useful to send file to as/400 system,wage idea...but question is how to do that...

                      Comment


                      • #12
                        Re: How to transfer desktop .xls file from desktop of local user to AS/400 system in

                        Hi,

                        Does anyone got anything on this???

                        Comment


                        • #13
                          Re: How to transfer desktop .xls file from desktop of local user to AS/400 system in

                          Unless you have some sort of pc program that you call that wraps some directory listing stuff that you can use to catch the mouse click that will automatically covert and upload the xls file to the IFS. Then your RPGLE program could be polling the expected IFS directory for a file name in a particular way that would tell the program specifically which of the xls files it should pull into the subfile. But you would have to write a special windows program and you said no .Net magic.
                          Your future President
                          Bryce

                          ---------------------------------------------
                          http://www.bravobryce.com

                          Comment


                          • #14
                            Re: How to transfer desktop .xls file from desktop of local user to AS/400 system in

                            Hi RPV2803:

                            If you can figure out how to convert the xls into a csv (probably using dos and excel macros) you can use this program to convert the csv into an AS/400 file.




                            Best of Luck
                            GLS
                            The problem with quotes on the internet is that it is hard to verify their authenticity.....Abraham Lincoln

                            Comment


                            • #15
                              Re: How to transfer desktop .xls file from desktop of local user to AS/400 system in

                              Originally posted by bryce4president View Post
                              Unless you have some sort of pc program that you call that wraps some directory listing stuff that you can use to catch the mouse click that will automatically covert and upload the xls file to the IFS. Then your RPGLE program could be polling the expected IFS directory for a file name in a particular way that would tell the program specifically which of the xls files it should pull into the subfile. But you would have to write a special windows program and you said no .Net magic.
                              mmmm... wouldn't the copy dll's work? One would need to run the copy dll with the selected file to copy plus any other parameters, and then the target directory. At this stage it's then it's out of the IBM i's scope, so (for example) if the user wished to cancel it would also be ok.
                              Regards

                              Kit
                              http://www.ecofitonline.com
                              DeskfIT - ChangefIT - XrefIT
                              ___________________________________
                              There are only 3 kinds of people -
                              Those that can count and those that can't.

                              Comment

                              Working...
                              X