ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Adding records to source file

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

  • Adding records to source file

    I have a routine that creates a source file member for MMAIL to work with. It builds the email body. My steps are:
    Code:
    fQTXTSRC   o  a e           k disk    usropn                    
    f                                     extfile( 'QGPL/QTXTSRC' ) 
    f                                     extmbr( mbr )             
    f                                     rename( QTXTSRC : ROW )   
    
    ADDPFM FILE(QGPL/QTXTSRC) MBR(MBRNAME)
    CLRPFM FILE(QGPL/QTXTSRC) MBR(MBRNAME)
    
    And then I WRITE records to the new member.

    Has worked perfectly forever ... until I try and write more than 44 records. Then I get:

    Code:
                            Additional Message Information                        
                                                                                  
    Message ID . . . . . . :   CPF5152       Severity . . . . . . . :   50        
    Message type . . . . . :   Escape                                             
    Date sent  . . . . . . :   11/03/10      Time sent  . . . . . . :   08:37:28  
                                                                                  
    Message . . . . :   Record format QTXTSRC not in member N608154.              
    Cause . . . . . :   The record format name, QTXTSRC, that was specified on the
      get interface is not in member N608154 file QTXTSRC in library QGPL.        
    Recovery  . . . :   Specify the name of a record format that is used by member
      N608154 and try your request again.                                         
        If the get interface is not available to you, there is no recovery.       
      Report the problem (ANZPRB command).

    Shouldn't I be able to write as many records as I need?
    Your friends list is empty!

  • #2
    Re: Adding records to source file

    I think you need to provide the source code of the program - I cannot see a linkage to the error from what you have provided.

    Comment


    • #3
      Re: Adding records to source file

      It blows up with that error on the "write Row" line when it attempts to write the 45th record. Every time I've got this error it was with record 45.


      Service Program:

      Code:
            **********************************************************************
            *¹compile options
            **********************************************************************
           h nomain
           h bnddir( 'QC2LE' )
      
            **********************************************************************
            *¹files
            **********************************************************************
           fQTXTSRC   o  a e           k disk    usropn
           f                                     extfile( 'QGPL/QTXTSRC' )
           f                                     extmbr( mbr )
           f                                     rename( QTXTSRC : ROW )
      
            **********************************************************************
            *¹prototypes
            **********************************************************************
            /copy hb2320mod/qrpglesrc,crtsrcapic
      
           d RunCmd          pr            10i 0 extproc( 'system' )
           d command                         *   value options( *string )
      
           d RtvJobInf       pr                  extpgm('QUSRJOBI')
           d   RcvVar                   32766a   options(*varsize)
           d   RcvVarLen                   10i 0 const
           d   Format                       8a   const
           d   JobName                     26a   const
           d   IntJobID                    16a   const
           d   ErrorCode                32766a   options(*varsize)
      
            **********************************************************************
            *¹QUSRJOBI API data structure
           d dsJobI0100      ds
           d  JobI_ByteRtn                 10i 0
           d  JobI_ByteAvl                 10i 0
           d  JobI_JobName                 10a
           d  JobI_UserID                  10a
           d  JobI_JobNbr                   6a
           d  JobI_IntJob                  16a
           d  JobI_Status                  10a
           d  JobI_Type                     1a
           d  JobI_SbType                   1a
           d  JobI_Reserv1                  2a
           d  JobI_RunPty                  10i 0
           d  JobI_TimeSlc                 10i 0
           d  JobI_DftWait                 10i 0
           d  JobI_Purge                   10a
      
            *¹QUSRJOBI API error data structure
           d dsEC            ds
           d  dsECBytesP             1      4i 0 inz(256)
           d  dsECBytesA             5      8i 0 inz(0)
           d  dsECMsgID              9     15
           d  dsECReserv            16     16
           d  dsECMsgDta            17    256
      
      
           d apos            c                   const( X'7D' )
           d cmd             s           5000a   varying
           d customer        s            100a   varying
           d mbr             s             10a   varying
           d subject         s            100a   varying
           d toEmail         s            100a   varying
           d toName          s            100a   varying
           d errorCode       s              7a   import('_EXCP_MSGID')
           d OK              c                   0
      
            ***********************************************************************
           p CreateSourceFile...
           p                 b                   export
           d CreateSourceFile...
           d                 pi              n
      
            /free
      
              mbr = GetSourceName();
              cmd = 'ADDPFM FILE(QGPL/QTXTSRC) MBR(' + mbr + ')' ;
              if RunCmd( cmd ) = OK;
                RunCmd( 'CLRPFM FILE(QGPL/QTXTSRC) MBR(' + mbr + ')' );
                Open QTXTSRC;
                return *on;
              else;
                return *off;
              endif;
      
            /end-free
      
           p CreateSourceFile...
           p                 e
            ***********************************************************************
           p WriteEmailLine  b                   export
           d WriteEmailLine  pi              n
           d  string                      100a   value varying
      
            /free
      
                srcdta = string;
                Write ROW;
      
                return *on;
      
            /end-free
      
           p WriteEmailLine  e
            ***********************************************************************
           p CloseSourceFile...
           p                 b                   export
           d CloseSourceFile...
           d                 pi              n
      
            /free
      
              if %open( QTXTSRC );
                Close QTXTSRC;
                return *on;
              else;
                return *off;
              endif;
      
            /end-free
      
           p CloseSourceFile...
           p                 e
            ***********************************************************************
           p DeleteSourceFile...
           p                 b                   export
           d DeleteSourceFile...
           d                 pi              n
      
            /free
      
              cmd = 'RMVM FILE(QGPL/QTXTSRC) MBR(' + mbr + ')' ;
              if RunCmd( cmd ) = OK;
                return *on;
              else;
                return *off;
              endif;
      
            /end-free
      
           p DeleteSourceFile...
           p                 e
            ***********************************************************************
           p GetSourceName   b                   export
           d GetSourceName   pi             7a
      
            /free
      
              //¹retrieve job attributes
              RtvJobInf( dsJOBI0100
                       : %size(dsJOBI0100)
                       : 'JOBI0100'
                       : '*'
                       : *blanks
                       : dsEC );
      
              return  'N' + JobI_JobNbr;
      
            /end-free
      
           p GetSourceName   e


      Test Code:
      Code:
           h bnddir( 'QC2LE' : 'EMAILPROCS' )
           h dftactgrp( *no )
      
            /copy hb2320mod/qrpglesrc,crtsrcapic
      
           d RunCmd          pr            10i 0 extproc( 'system' )
           d command                         *   value options( *string )
      
           d GetUserEmail    pr           100a
           d  userid                       10a   value options( *nopass )
      
           d apos            c                   const( X'7D' )
           d cmd             s           5000a   varying
           d source          s              7a
           d subject         s            100a   varying
           d toEmail         s            100a   varying
           d toName          s            100a   varying
           d i               s             10i 0
      
           é**********************************************************************
           c                   eval      source = GetSourceName()
           c                   callp     CreateSourceFile()
      
           c                   for       i = 1 to 100
           c                   callp     WriteEmailLine( %char( i ) + 'blah' )
           c                   endfor
           c
           c                   callp     CloseSourceFile()
           c                   callp     DeleteSourceFile()
      
           c                   eval      *inlr = *on
      Your friends list is empty!

      Comment


      • #4
        Re: Adding records to source file

        Hi Mjhaston:
        It sounds more like the qgpl/qtxtsrc was recently replaced and no-longer has format qtxtsrc.

        Record format QTXTSRC not in member N608154.

        Why record 45 blows up and nothing prior just does not make sense. It should blow up when you write the first record.
        do a "dspffd qgpl/qtxtsrc" from the command line and see what the record format name is. If it is other than qtxtsrc....re-compile the program (replacing this line....rename( QTXTSRC : ROW )) and see if you get better results

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

        Comment


        • #5
          Re: Adding records to source file

          I suspect that the error occurs when (or just after) the buffer is written out program. Simple test for this would be to change the size of the records from 100 to (say) 50 and see if the record count changes. If it does not at least one potential issue is ruled out.

          I don't see why it would impact it but I notice you are not initializing SRCSEQ and SRCDAT - they are zoned so I wouldn't expect that to have any impact but ...

          Comment


          • #6
            Re: Adding records to source file

            Code:
            Record Format Information                                      
              Record format . . . . . . . . . . . . . . . :  QASUTXTSRC

            When I change the rename to that it won't compile.

            You're right ... it makes no sense that it gets through the first 44 adds. This service program is uses all over the system all day long.
            Your friends list is empty!

            Comment


            • #7
              Re: Adding records to source file

              I pasted both MJ's source files on my V5R3 system I have at hand and met no problem to load 100+ records in the specified member. There's probably something wrong or missing on the MJ's system, PTFs not applied ?

              Code:
                      *************** Beginning of data ****************
              0001.00 1blah                                             
              0002.00 2blah                                             
              0003.00 3blah                                             
              0004.00 4blah                                             
              .
              .
              .
              0095.00 95blah 
              0096.00 96blah 
              0097.00 97blah 
              0098.00 98blah 
              0099.00 99blah 
              0100.00 100blah
              0101.00 101blah
              0102.00 102blah
              0103.00 103blah
              0104.00 104blah
              0105.00 105blah
              .
              .
              .
              0148.00 148blah                                             
              0149.00 149blah                                             
              0150.00 150blah                                             
                      ****************** End of data *************************
              Philippe

              Comment


              • #8
                Re: Adding records to source file

                Thanks Philippe. I'll check that out. The system was installed back in February and is at V5R4M5.
                Your friends list is empty!

                Comment


                • #9
                  Re: Adding records to source file

                  Hi Mjhaston:

                  When I change the rename to that it won't compile.
                  you may want to re-create qtxtsrc

                  By the way does this program work with less than 45 lines? .... It shouldn't

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

                  Comment


                  • #10
                    Re: Adding records to source file

                    Is it possible that the object is owned by a profile that has a very limited amount of storage that it is allowed to utilize. (ie: MaxStg on the profile is set to some low number. )
                    Michael Catalani
                    IS Director, eCommerce & Web Development
                    Acceptance Insurance Corporation
                    www.AcceptanceInsurance.com
                    www.ProvatoSys.com

                    Comment


                    • #11
                      Re: Adding records to source file

                      Is it possible that the object is owned by a profile that has a very limited amount of storage that it is allowed to utilize. (ie: MaxStg on the profile is set to some low number. )
                      in that case the program wouldn't fall over with the CPF5152 error message.
                      Philippe

                      Comment


                      • #12
                        Re: Adding records to source file

                        Originally posted by GLS400 View Post
                        Hi Mjhaston:


                        you may want to re-create qtxtsrc

                        By the way does this program work with less than 45 lines? .... It shouldn't

                        GLS
                        Yes, it works fine with 44 lines or less. I create FTP scripts with it and source files to use with MMAIL.
                        Your friends list is empty!

                        Comment


                        • #13
                          Re: Adding records to source file

                          Note that when you compile the program, it uses the FIRST QTXTSRC in the library list. The EXTFILE statement has no effect on the compile.

                          Look at the format name in the compile listing or do a DSPPGMREF on the program.

                          The program must execute using a file that has the same format name that it was compiled over. You cannot override the format name.
                          Denny

                          If authority was mass, stupidity would be gravity.

                          Comment


                          • #14
                            Re: Adding records to source file

                            Created a new QTXTSRC with record length of 100.

                            QSYS/CRTSRCPF FILE(MHASTON/QTXTSRC2) RCDLEN(100)

                            Created new *SRVPGM and test program and it writes out the 100 lines I expected.
                            Your friends list is empty!

                            Comment


                            • #15
                              Re: Adding records to source file

                              Originally posted by mjhaston View Post
                              Created a new QTXTSRC with record length of 100.

                              QSYS/CRTSRCPF FILE(MHASTON/QTXTSRC2) RCDLEN(100)

                              Created new *SRVPGM and test program and it writes out the 100 lines I expected.

                              I wonder if the error is occuring when the program is attempting to write the records to disk? In other words, the buffering of the writes work, because the program was compiled against a file that had the specified format, but when the system attempts to write the buffered records to disk, that's when it determines the record format for the file its writing to doesnt exist.
                              Michael Catalani
                              IS Director, eCommerce & Web Development
                              Acceptance Insurance Corporation
                              www.AcceptanceInsurance.com
                              www.ProvatoSys.com

                              Comment

                              Working...
                              X