ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Decimal data error on passed parms only when submitted to batch

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

  • Decimal data error on passed parms only when submitted to batch

    'morning all.....
    I got an odd problem here that only rears it's ugly head when the job is submitted to batch. If I run it interactive (debug) no problems.

    I have an application that tracks a users tasks, time spent on each and important Notes regarding what they have done and why.

    Within this app is a function for the user to see an on-screen version of their weekly report which needs to be handed in for billing purposes. If they are satisfied with it (there are some things they can do to clean it up, make it easier to read, etc.) they have a function key to generate a data file which they can then download into an Excel spreadsheet template. The function key calls a program with specific parms which then submits a job to batch.

    Well, whenever they take this option to generate the file, they get a decimal data error.

    As I have said, when I debug it without submitting the job to batch, it runs fine. I'm using all the same programs and parms but I get no errors.

    I have traced the flow from the very first program, and all the parms, are correct. I have triple-checked the parm types, decimal vs character and all are correct.

    I even went so far as to create a command for them to use in the interim until I can figure out what is going wrong AND it too uses the same programs and parms without error!

    there are a lot of programs, too many to include here.
    Any ideas?
    Everyday's a school day, what grade are you in?

  • #2
    Re: Decimal data error on passed parms only when submitted to batch

    Could you post your code...it's easier to see the issue if you have something to look at.

    Comment


    • #3
      Re: Decimal data error on passed parms only when submitted to batch

      Originally posted by NYCountryGal View Post
      Could you post your code...it's easier to see the issue if you have something to look at.
      =there are a lot of programs, too many to include here. Any ideas?
      It's a long process, select dates, verify dates, check for files, create files, opnqryf X2, copy to files,.....
      It has to be something with the submit to batch portion.
      Everyday's a school day, what grade are you in?

      Comment


      • #4
        Re: Decimal data error on passed parms only when submitted to batch

        show us the parms coming from the calling program (along with the field definitions) the SBMJOB command and the parms being received in the called program and their definitions. just a WAG but you are passing numeric values to the calling program as text when using sbmjob vs. them actually being numeric on a call.
        Code:
        mycmd = 'SBMJOB CMD(''CALL MYPGM PARM(12345)'')';
        
        is [I]not[/I] the same as:
        MYPGM(12345)
        anything enclosed in quotes is character...
        I'm not anti-social, I just don't like people -Tommy Holden

        Comment


        • #5
          Re: Decimal data error on passed parms only when submitted to batch

          If you can't post anything, look at your variables that you're passing. Debug again but don't look at it from the perspective of running interactively, look at it as if it were running in batch. You know what field is in error so how is that field moving from program to program. Somewhere along the line, you have it defined as alphanumeric but try to use it as numeric or vice versa. I always look at the decimal data error as... I'm passing junk. If you don't have anyone else there to review your code, then step away from the code for 10-15 minutes. Refresh your mind and take a look at it again, clear minds prevail...

          Comment


          • #6
            Re: Decimal data error on passed parms only when submitted to batch

            Simple rule. Any parameter on the submitted batch CALL that is an unquoted numeric must be defined in the called program as numeric 15.5.
            Denny

            If authority was mass, stupidity would be gravity.

            Comment


            • #7
              Re: Decimal data error on passed parms only when submitted to batch

              Sorry for the delay, up to my eyeballs and leaving for vacation today.
              I will try to get you what Tomholden asked for asap, hopefully today because this is on my hot list just a lot to dig out.
              Everyday's a school day, what grade are you in?

              Comment


              • #8
                Re: Decimal data error on passed parms only when submitted to batch

                i have a similar problem but the very first line in *inzsr have a z-add operation (9P0 entry parm --> 9S0 display file field). i tried Denny's rule and it worked fine. my only question is, why and how does it work that way?? or other problems regarding Packed to Zoned z-add operations to avoid future re-occurance of this problem

                thanks for the reply and this is my very first post.. been working as an as400 programmer in the philippines for the last 3 years

                Originally posted by Denny View Post
                Simple rule. Any parameter on the submitted batch CALL that is an unquoted numeric must be defined in the called program as numeric 15.5.
                Last edited by urriah; September 3, 2012, 12:45 AM. Reason: additional details

                Comment


                • #9
                  Re: Decimal data error on passed parms only when submitted to batch

                  No one can answer better than IBM --Itself:
                  http://publib.boulder.ibm.com/infoce...evfclmst80.htm
                  CL Programming


                  Using the CALL Command

                  When the CALL command is issued by a CL procedure, each parameter value passed to the called program can be a character string constant, a numeric constant, a logical constant, or a CL variable. A maximum of 40 parameters can be passed to the called program. The values of the parameters are passed in the order in which they appear on the CALL command, and this must match the order in which they appear in the parameter list of the called program. The names of the variables passed do not have to be the same as the names on the receiving parameter list. The names of the variables receiving the values in the called program must be declared to the called program, but the order of the declare commands is not important.

                  No association exists between the storage in the called program and the variables it receives. Instead, when the calling program passes a variable, the storage for the variable is in the program in which it was originally declared. The system passes variables by address. When passing a constant, the calling program makes a copy of the constant, and passes the address of that copy to the called program.

                  The result is that when a variable is passed, the called program can change the value of the variable, and the change is reflected in the calling program. The new value does not have to be returned to the calling program for later use; it is already there. Thus no special coding is needed for a variable that is to be returned to the calling program. When a constant is passed, and its value is changed by the called program, the changed value is not known to the calling program. Therefore, if the calling program calls the same program again, it reinitializes the values of constants, but not of variables.

                  An exception to the previous description is when the CALL command calls an ILE C program. When using the CALL command to call an ILE C program and pass character or logical constants, the system adds a null character (x'00') after the last non-blank character. If the constant is a character string that is enclosed in apostrophes or a hexadecimal constant, the null character is added after the last character that was specified. This preserves the trailing blanks (x '40' characters). Numeric values are not null-terminated.

                  If a CL program might be called using a CALL command that has not been compiled (an interactive CALL command or through the SBMJOB command), the decimal parameters (*DEC) should be declared with LEN(15 5), and the character parameters (*CHAR) should be declaredLEN(32) or less in the receiving program.

                  A CALL command that is not in a CL procedure or program cannot pass variables as arguments. Be careful when specifying the CALL command as a command parameter that is defined as TYPE(*CMDSTR). This converts the contents of any variables that are specified on the PARM parameter to constants. The command (CMD) parameters on the Submit Job (SBMJOB) command, Add Job Schedule Entry (ADDJOBSCDE) command, or Change Job Schedule Entry (CHGJOBSCDE) command are examples. IBM has provided online information on how to pass parameters when using an interactive CALL command. Refer to the description of the CALL command in the CL section of the Programming category in the iSeries Information Center.


                  Parameters can be passed and received as follows:
                  • Character string constants of 32 bytes or less are always passed with a length of 32 bytes (padded on the right with blanks). If a character constant is longer than 32 bytes, the entire length of the constant is passed. If the parameter is defined to contain more than 32 bytes, the CALL command must pass a constant containing exactly that number of bytes. Constants longer than 32 characters are not padded to the length expected by the receiving program.The receiving program can receive less than the number of bytes passed. For example, if a program specifies that 4 characters are to be received and ABCDEF is passed (padded with blanks in 26 positions), only ABCD are accepted and used by the program.
                    If the receiving program receives more than the number of bytes passed, the results may be unexpected. Numeric values passed as characters must be enclosed in apostrophes.
                  • Decimal constants are passed in packed form and with a length of LEN(15 5), where the value is 15 digits long, of which 5 digits are decimal positions. Thus, if a parameter of 12345 is passed, the receiving program must declare the decimal field with a length of LEN(15 5); the parameter is received as 12345.00000.If you need to pass a numeric constant to a program and the program is expecting a value with a length and precision other than 15 5, the constant can be coded in hexadecimal format. The following CALL command shows how to pass the value 25.5 to a program variable that is declared as LEN(5 2):

                    CALL PGMA PARM(X'02550F')
                  • Logical constants are passed with a length of 32 bytes. The logical value 0 or 1 is in the first byte, and the remaining bytes are blank. If a value other than 0 or 1 is passed to a program that expects a logical value, the results may be unexpected.
                  • A floating point literal or floating point special value (*NAN, *INF, or *NEGINF) is passed as a double precision value, which occupies 8 bytes. Although a CL program cannot process floating point numbers, it can receive a floating point value into a character variable and pass that variable to an HLL program that can process floating point values.
                  • The system can pass a variable if the call is made from a CL procedure or program. In this case the receiving program should declare the field to match the variable that is defined in the calling CL procedure or program. For example, assume that a CL procedure or program defines a decimal variable that is named &CHKNUM as LEN(5 0). Then the receiving program should declare the field as packed with 5 digits total, with no decimal positions. When running a CALL command in batch mode by using the SBMJOB command in a CL procedure or program, the system treats any variables that are passed as arguments like constants.
                  • If either a decimal constant or a program variable can be passed to the called program, the parameter should be defined as LEN(15 5), and any calling program must adhere to that definition. If the type, number, order, and length of the parameters do not match between the calling and receiving programs (other than the length exception noted previously for character constants), results cannot be predicted.
                  • The value *N cannot be used to specify a null value because a null value cannot be passed to another program.

                  In the following example, program A passes six parameters: one logical constant, three variables, one character constant, and one numeric constant.
                  PHP Code:
                  PGM /* PROGRAM A */
                  DCL VAR(&BTYPE(*CHAR)
                  DCL VAR(&CTYPE(*DECLEN(15 5VALUE(13.529)
                  DCL VAR(&DTYPE(*CHARVALUE('1234.56')
                  CHGVAR VAR(&BVALUE(ABCDEF)
                  CALL PGM(BPARM('1' &&&D XYZ 2)  /* Note blanks between parms */
                  .
                  .
                  .
                  ENDPGM 
                  PHP Code:
                  PGM PARM(&&&&&&U/* PROGRAM B */
                  DCL VAR(&ATYPE(*LGL)
                  DCL VAR(&BTYPE(*CHARLEN(4)
                  DCL VAR(&CTYPE(*DEC)
                              
                  /* Default length (15 5) matches DCL LEN in program A */
                  DCL VAR(&WTYPE(*CHAR)
                  DCL VAR(&VTYPE(*CHAR)
                  DCL VAR(&UTYPE(*DEC)
                  .
                  .
                  ENDPGM 



                  Note:
                  If the fifth parameter passed to PGMB was 456 instead of XYZ and was intended as alphanumeric data, the value would have been specified as'456' in the parameter.
                  The logical constant '1' does not have to be declared in the calling program. It is declared as type logical and named &A in program B.
                  Because no length is specified on the DCL command for &B, the default length, which is 32 characters, is passed. Only 6 characters of &B are specified (ABCDEF). Because &B is declared with only 4 characters in program B, only those 4 characters are received. If they are changed in program B, those 4 positions for &B will also be changed in program A for the remainder of this call.
                  The length (LEN) parameter must be specified for &C in program A. If it were not specified, the length would default to the specified value's length, which would be incompatible with the default length expected in program B. &C has a value of 13.52900.
                  &W in program B (&D in program A) is received as a character because it is declared as a character. Apostrophes are not necessary to indicate a string if TYPE is *CHAR. In program A, the length defaults to the value's length of 7 (the decimal point is considered a position in a character string). Program B expects a length of 32. The first 7 characters are passed, but the contents past the position 7 cannot be predicted.
                  The variable &V is a character string XYZ, padded with blanks on the right. The variable &U is numeric data, 2.00000.
                  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: Decimal data error on passed parms only when submitted to batch

                    thanks jamie, i experienced the error again after changing the size to 15,5. i don't know how to post codes yet. this is what the data looks like in the compiler (field names were changed since i don't think that they are relevant)

                    Code:
                    C           *ENTRY    PLIST                    
                    C                     PARM           PARM1  155
                    C                     PARM           PARM2  155
                    
                    OUTPUT FIELDS FOR RECORD XXX6 FILE XXXS FORMAT XXX6
                    DFFLD1   233  ZONE  9,0
                    DFFLD2    48  ZONE  9,0    
                    
                    DFFLD1      P(9,0)    20600M Z000028D
                    DFFLD2      P(9,0)    20700M Z000008D[/FONT]
                    
                    and the "bad line" looks like this..
                    [FONT=Courier New]C           INZSR     BEGSR                
                    C                     Z-ADDPARM1     DFFLD1
                    C                     Z-ADDPARM2     DFFLD2[/FONT]


                    the error occurs on the z-add line..

                    if it is important.. the parameters i passed were

                    PARM1 --> 000077942
                    PARM2 --> 001210681
                    Last edited by tomholden; September 4, 2012, 06:09 AM.

                    Comment


                    • #11
                      Re: Decimal data error on passed parms only when submitted to batch

                      This Code works fine ?

                      PHP Code:
                                                                                                                   
                       
                      *OUTPUT FIELDS FOR RECORD XXX6 FILE XXXS FORMAT XXX6                                    
                      C     
                      *ENTRY        PLIST                                                                
                      C                   PARM                    PARM1            15 5                        
                      C                   PARM                    PARM2            15 5                        
                                                                                                               
                      C                   CLEAR                   DFFLD1            9 0                        
                      C                   CLEAR                   DFFLD2            9 0                        
                                                                                                               
                      C                   
                      EVAL      *INLR = *ON                                                
                       
                      *and the "bad line" looks like this..                                                   
                      C     INZSR         BEGSR                                                                
                      C                   Z
                      -ADD     PARM1         DFFLD1                                       
                      C                   Z
                      -ADD     PARM2         DFFLD2                                       
                      C                   ENDSR                                                                                                                                                                                                                                        
                      *OUTPUT 
                      Call:
                      Code:
                      CALL @ERROR PARM(20120904 20120904)
                      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


                      • #12
                        Re: Decimal data error on passed parms only when submitted to batch

                        long story short.. i get the Decimal Data Error when calling the program from the command line (debugging or not) while passing parameters.. Calling the program from another program "works" sometimes.. provided it is not in a locked file... that being said.. the calling program has a file locked that will be used in the called program and so it hung-up on me.. problem solved and thanks for the help jamie

                        Comment

                        Working...
                        X