Results 1 to 11 of 11

Thread: How to make a parameter optional in SQLRPGLE

  1. #1
    Analyst nandas400's Avatar
    Join Date
    Mar 2005
    Location
    US
    Age
    34
    Posts
    131
    Rep Power
    859

    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. # 666
    Circuit advertisement
    Join Date
    Aug 1965
    Location
    Yakutsk, Russia
    Age
    21
    Posts
    1,000,000
     

  3. #2
    Driver of cars, eater of food jamief's Avatar
    Join Date
    Jan 2004
    Location
    Belvidere, IL - United States of America
    Age
    49
    Posts
    9,416
    Rep Power
    12606

    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

  4. #3
    Analyst nandas400's Avatar
    Join Date
    Mar 2005
    Location
    US
    Age
    34
    Posts
    131
    Rep Power
    859

    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

  5. #4
    Analyst giri's Avatar
    Join Date
    May 2005
    Location
    Salt lake City, US
    Age
    33
    Posts
    247
    Rep Power
    1664

    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

  6. #5
    Analyst nandas400's Avatar
    Join Date
    Mar 2005
    Location
    US
    Age
    34
    Posts
    131
    Rep Power
    859

    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

  7. #6
    Driver of cars, eater of food jamief's Avatar
    Join Date
    Jan 2004
    Location
    Belvidere, IL - United States of America
    Age
    49
    Posts
    9,416
    Rep Power
    12606

    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

  8. #7
    Analyst nandas400's Avatar
    Join Date
    Mar 2005
    Location
    US
    Age
    34
    Posts
    131
    Rep Power
    859

    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....

  9. #8
    Driver of cars, eater of food jamief's Avatar
    Join Date
    Jan 2004
    Location
    Belvidere, IL - United States of America
    Age
    49
    Posts
    9,416
    Rep Power
    12606

    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

  10. #9
    Analyst giri's Avatar
    Join Date
    May 2005
    Location
    Salt lake City, US
    Age
    33
    Posts
    247
    Rep Power
    1664

    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

  11. #10
    Analyst nandas400's Avatar
    Join Date
    Mar 2005
    Location
    US
    Age
    34
    Posts
    131
    Rep Power
    859

    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

  12. #11
    Analyst nandas400's Avatar
    Join Date
    Mar 2005
    Location
    US
    Age
    34
    Posts
    131
    Rep Power
    859

    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.

  13. # 666
    Circuit advertisement
    Join Date
    Aug 1965
    Location
    Yakutsk, Russia
    Age
    21
    Posts
    1,000,000
     

Facebook Comments


Similar Threads

  1. Difference between *OMIT and *NOPASS
    By emo in forum RPG/RPGLE
    Replies: 4
    Last Post: May 10th, 2008, 12:00 PM
  2. Jobd
    By ris_skma in forum RPG/RPGLE
    Replies: 1
    Last Post: July 27th, 2005, 06:34 AM
  3. Replies: 8
    Last Post: June 17th, 2005, 02:44 PM
  4. Message subfile related problem
    By Dimitry in forum RPG/RPGLE
    Replies: 7
    Last Post: June 9th, 2005, 06:29 PM
  5. How to code SQL embebed in RPGIII?
    By uidamt98 in forum SQL
    Replies: 25
    Last Post: March 4th, 2005, 12:54 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •