sponsored links

Collapse

Announcement

Collapse
No announcement yet.

How to make a parameter optional in SQLRPGLE

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

  • How to make a parameter optional in SQLRPGLE

    Hi dudes

    Hope everyone is in the pink. I have a SQLRPGLE program which has 5 incoming parameters.The last parameter is numeric (defined as 15 P 5) in the program.I have used free-form RPG so I have declared the incoming parameters in PR and PI.I need to make this last parameter as optional parameter.So I have defined that parameter as Numrec S 15P 5 Options(*Nopass). But when I call the program from command line without this parameter, I get pointer or parameter error.

    Plz tell me how to make this parameter optional?

    Thanks in Advance

    Regards

    Nand...

  • #2
    Re: How to make a parameter optional in SQLRPGLE

    Dont use the passed in field name.

    use the bif %parms

    then like this move the in values to work values if the parm was passed in.


    http://www.code400.com/forum/showthread.php?t=535

    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


    • #3
      Re: How to make a parameter optional in SQLRPGLE

      Hi jimmy

      Thanks for thr eply.I have tried using %Parms.But still i get pointer or parameter error when I call the program without that parameter.


      Regards

      Nand

      Comment


      • #4
        Re: How to make a parameter optional in SQLRPGLE

        Nand,

        If u declare the last parm as Options(*nopass) it should work.
        For example the following code is working for me without any probs.
        ------------------------------------------------------------------------------------------------------
        D ZZS PR ExtPgm('ZZS')
        D apPPtype 2A
        D apStrRRN 15P 5 Options(*Nopass)


        D ZZS PI
        D apPPtype 2A
        D apStrRRN 15P 5 Options(*Nopass)

        /Free
        *Inlr= *on ;
        /End-Free
        ------------------------------------------------------------------------------------------------------


        But in the above program, if i tried to touch apStrRRN directly, i will get the pointer or parameter error.

        In the below prog, i got that error

        ------------------------------------------------------------------------------------------------------

        D ZZS PR ExtPgm('ZZS')
        D apPPtype 2A
        D apStrRRN 15P 5 Options(*Nopass)


        D ZZS PI
        D apPPtype 2A
        D apStrRRN 15P 5 Options(*Nopass)

        /Free
        If apStrRRN = 0 ;
        EndIf ;
        *Inlr= *on ;
        /End-Free
        ------------------------------------------------------------------------------------------------------

        But if i use that parm, using %parm built in func, i will not get any error.
        Below is the example
        ************************************************** ***********
        D ZZS PR ExtPgm('ZZS')
        D apPPtype 2A
        D apStrRRN 15P 5 Options(*Nopass)


        D ZZS PI
        D apPPtype 2A
        D apStrRRN 15P 5 Options(*Nopass)

        /Free
        If %Parms() > 1 and apStrRRN = 0 ;
        EndIf ;
        *Inlr= *on ;
        /End-Free

        ---------------------------------------------------------------------

        Let me know if u still have any doubt.
        Thanks,
        Giri

        Comment


        • #5
          Re: How to make a parameter optional in SQLRPGLE

          Hi Giri

          Thanks for the reply. But still I get 'pointer or parameter error'. To remind you, I call the program from Command line.



          Here is my code
          Code:
          0154.00 D PGM1         PR                
          0155.00 D   Field1                       1  
          0156.00 D   Field2                       8  
          0157.00 D   Field3                       8  
          0157.01 D   Field4                       6
          0158.00 D   Field5                       7    Options(*Nopass)
            
          0159.00  *  Procedure Interface for PGM1
          0160.00 D PGM1         PI                
          0161.00 D   Field1                       1  
          0162.00 D   Field2                       8  
          0163.00 D   Field3                       8 
          0163.01 D   Field4                       6 
          0164.00 D   Field5                       7    Options(*Nopass)
          
          
                   /Free
                              If  %Parms > 4 ;
                                    workfield5 = Field5 ;
                              Else ;
                                    workfield5 = ' ' ;
                              Endif ;
          I call the PGM1 as follows:

          CALL PGM1 PARM('C' '20020206' '20030206' 'ABCD') (Omitting the last parameter)


          But I get Parameter or pointer error. If I pass all the parameters, the programs works fine.

          Thanks

          Regards

          Nand

          Comment


          • #6
            Re: How to make a parameter optional in SQLRPGLE

            Nand -

            please just remove Options(*Nopass)
            from the D specs and give this a test.


            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 make a parameter optional in SQLRPGLE

              Hi Jimmy

              I removed Options(*Nopass) from the D spec, but to my dismay, I still get that error. Is it not possible to make a parameter optional when a program is called from command line?


              My H specs looks like below,

              0002.00 H DFTACTGRP(*NO) ACTGRP('QILE') BNDDIR('QC2LE') DEBUG
              0003.00 H OPTION(*NODEBUGIO)

              Does it have any impact on this problem?

              Thanks Jimmy.

              Regards

              Nand....

              Comment


              • #8
                Re: How to make a parameter optional in SQLRPGLE

                It does not matter where you call it from. As long as you dont reference the parameter name that was passed in you will be fine.


                You H-spec has nothing to do with it.

                It must be the fact that your using the PR / PI
                I have not tried optional parameters in FREE.

                I look later @ work...anyone 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


                • #9
                  Re: How to make a parameter optional in SQLRPGLE

                  I tried calling ur program from the command line with call command u have given

                  its working fine for me ....

                  ur code also looks good ....

                  Can u provide any extra info on this ....
                  Thanks,
                  Giri

                  Comment


                  • #10
                    Re: How to make a parameter optional in SQLRPGLE

                    Giri

                    Its quite strange that you are not getting any error.I still get that error.Dunno exactly where it goes wrong.

                    Its a SQLRPGLE program written in free-form.Im at V5R2.


                    Anything else you need to know??


                    Thanks

                    Nand

                    Comment


                    • #11
                      Re: How to make a parameter optional in SQLRPGLE

                      Hi Jamie and Giri

                      Thanks a lot for the help.Now its working fine.

                      I made a mistake in my code. i.e I have referenced the parameter name when it is not passed in the %Parms Condition.I have corrected it and now its working fine.


                      Thanks a lot for ur time and help.



                      Regards

                      Nand.

                      Comment

                      sponsored links

                      Collapse

                      Working...
                      X