IBMiAccess




Page 1 of 2 12 LastLast
Results 1 to 20 of 25

Thread: Entry parms in freeform *inzsr

  1. #1
    Code Monkey wgatchell's Avatar
    Join Date
    Oct 2004
    Location
    Delaware, OH
    Age
    42
    Posts
    60
    Rep Power
    804

    Entry parms in freeform *inzsr

    I'm new to the forums..so hello all!!!!

    Just quick question.

    How do i code for entry parms in a free form RPG pgm?

    Thanks in advance

  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,429
    Rep Power
    12629

    Smile Welcome

    Here is a sample RPG program

    Code:
         D index           s              5p 0
         D inparm1         s              1
         D inparm2         s              1
         D SOmeField       s              1
    
         D pgmsds         sds
         D  @@@pgm                 1     10
         D  @@@sts                11     15  0
          *
         C                   select
         C                   when      index = 1
         C                   eval      SomeField = 'A'
         C                   when      index = 2
         C                   eval      SomeField = 'B'
         C                   other
         C                   eval      SomeField = 'C'
         C                   endsl
          *
    
         C                   eval      *inlr = *on
          *===========================================
          *  *Inzsr - Initial one time subroutine
          *===========================================
         c     *inzsr        begsr
          *
         c     *entry        plist
         c                   parm                    InParm1
         c                   parm                    InParm2
          *
         c                   endsr

    Here is what it looks like with a PI (program interface)
    oh and in FREE

    Code:
         D index           s              5p 0
         D inparm1         s              1
         D inparm2         s              1
         D SOmeField       s              1
    
         D pgmsds         sds
         D @@@pgm                        10
         D @@@sts                         5  0
          *  Prototype for CALLFREE
         D CALLFREE        PR
         D InParm1_                       1
         D InParm2_                       1
          *  *ENTRY Interface for Main Procedure
         D CALLFREE        PI
         D InParm1                        1
         D InParm2                        1
          *
          /FREE
           select;
           when index = 1;
            SomeField = 'A';
           when index = 2;
            SomeField = 'B';
           other;
            SomeField = 'C';
           endsl;
           //
         
            *inlr = *on;
           //===========================================
           //  *Inzsr - Initial one time subroutine
           //===========================================
           begsr *inzsr;
           //
           //
           endsr;
           //
          /END-FREE
    You will have to compile with option 15 (CRTRPGMOD) then use the create program.

    Then do a callp and you should be set.


    hope this helps

    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
    Code Monkey wgatchell's Avatar
    Join Date
    Oct 2004
    Location
    Delaware, OH
    Age
    42
    Posts
    60
    Rep Power
    804
    thanks for the reply.

    The program i am writing is small and does not lend itself to procedures very well

    Basically the RPG is called from a batch CL which passes it a file member name and a date.

    The RPG then uses the parms to manipulate FTPSRC for an FTP command.

    Would it be better to just slip out of Freeform rather than fighting with a module?

    I was hoping to keep everything in Freeform.

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

    Red face If it were me

    I would slip out of free form......
    But that is your choice.


    Glad to have you on the forums hope you'll stay active.


    have a great weekend

    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

  6. #5
    Code Monkey wgatchell's Avatar
    Join Date
    Oct 2004
    Location
    Delaware, OH
    Age
    42
    Posts
    60
    Rep Power
    804
    That's what i figured

    thanks

  7. #6
    Experienced Forum Member
    Join Date
    Mar 2007
    Location
    USA
    Posts
    233
    Rep Power
    804

    Re: Welcome

    Quote Originally Posted by jamief View Post
    Here is a sample RPG program

    Code:
         D index           s              5p 0
         D inparm1         s              1
         D inparm2         s              1
         D SOmeField       s              1
    
         D pgmsds         sds
         D  @@@pgm                 1     10
         D  @@@sts                11     15  0
          *
         C                   select
         C                   when      index = 1
         C                   eval      SomeField = 'A'
         C                   when      index = 2
         C                   eval      SomeField = 'B'
         C                   other
         C                   eval      SomeField = 'C'
         C                   endsl
          *
    
         C                   eval      *inlr = *on
          *===========================================
          *  *Inzsr - Initial one time subroutine
          *===========================================
         c     *inzsr        begsr
          *
         c     *entry        plist
         c                   parm                    InParm1
         c                   parm                    InParm2
          *
         c                   endsr

    Here is what it looks like with a PI (program interface)
    oh and in FREE

    Code:
         D index           s              5p 0
         D inparm1         s              1
         D inparm2         s              1
         D SOmeField       s              1
    
         D pgmsds         sds
         D @@@pgm                        10
         D @@@sts                         5  0
          *  Prototype for CALLFREE
         D CALLFREE        PR
         D InParm1_                       1
         D InParm2_                       1
          *  *ENTRY Interface for Main Procedure
         D CALLFREE        PI
         D InParm1                        1
         D InParm2                        1
          *
          /FREE
           select;
           when index = 1;
            SomeField = 'A';
           when index = 2;
            SomeField = 'B';
           other;
            SomeField = 'C';
           endsl;
           //
         
            *inlr = *on;
           //===========================================
           //  *Inzsr - Initial one time subroutine
           //===========================================
           begsr *inzsr;
           //
           //
           endsr;
           //
          /END-FREE
    You will have to compile with option 15 (CRTRPGMOD) then use the create program.

    Then do a callp and you should be set.


    hope this helps

    jamie
    Help me, I am dense it seems.
    I've been trying to get more into free and I've bumped into *entry list.

    I've copied your code and I get this error:I understand the concept behind the prototype, but the PI is giving me fits.

    "External procedure on prototype for main procedure is not
    same as actual external name"

    What is CALLFREE? Is this a random name? InParm1 and InParm2 come into your program, but I don't see it used anywhere. Is this just an example where InParm1 and InParm2 can be used somewhere else?

    Here is how I have interpreted your code in my program.

    * prototype for CALLFREE
    d CALLFREE PR
    d custcode_ like(AMCUST)
    * ENTRY interface for Main Procedure
    d CALLFREE PI
    d custcode like(AMCUST)

    Unless I am mistaken when my program works I should still be able to do this, right?

    call myprogram 'whatever'

    Where 'whatever' is a variable that matches the definition of AMCUST.

  8. #7
    Analyst dhuesman's Avatar
    Join Date
    Aug 2005
    Location
    KY
    Posts
    279
    Rep Power
    1099

    Re: Entry parms in freeform *inzsr

    I believe CALLFREE is his EXTPGM name.

  9. #8
    Sr. Product Specialist FaStOnE's Avatar
    Join Date
    Nov 2005
    Location
    Phoenix, AZ
    Age
    51
    Posts
    2,611
    Rep Power
    4003

    Re: Entry parms in freeform *inzsr

    CALLFREE is the name of the procedure being called.

    I usually do something like:

    PHP Code:
         D Entry           PR                  ExtPgm'PGMNAME' )        
         
    D   Prm_Request               3000A                              
         D   Prm_Response              3000A                              
         D   Prm_IPAddr                  15A                              
                                                                          
         D Entry           PI                                             
         D   Prm_Request               3000A                              
         D   Prm_Response              3000A                              
         D   Prm_IPAddr                  15A 
    That way I know the "ENTRY" is where stuff comes in/out

    His InParm1 and InParm2 reference the Index field in the example Jamie gave. He just didn't show the assignment of the field value I would assume.

    hth

    -Rick
    -Rick

    _____________________________

    Need a Managed File Transfer Solution -OR- iSeries Encryption?
    GoAnywhere and Crypto Complete by Linoma Software


  10. #9
    Harbinger of Doom tomholden's Avatar
    Join Date
    Dec 2007
    Location
    Lebanon, Tennessee, United States
    Posts
    4,341
    Rep Power
    8669

    Re: Entry parms in freeform *inzsr

    Quote Originally Posted by wgatchell View Post
    thanks for the reply.

    The program i am writing is small and does not lend itself to procedures very well

    Basically the RPG is called from a batch CL which passes it a file member name and a date.

    The RPG then uses the parms to manipulate FTPSRC for an FTP command.

    Would it be better to just slip out of Freeform rather than fighting with a module?

    I was hoping to keep everything in Freeform.
    why? instead of a module just compile as normal and call via CALLP? just compile using option 14 in PDM and in your CL you can just call the program same as always...
    I'm not anti-social, I just don't like people -Tommy Holden

  11. #10
    Experienced Forum Member
    Join Date
    Mar 2007
    Location
    USA
    Posts
    233
    Rep Power
    804

    Re: Entry parms in freeform *inzsr

    Quote Originally Posted by FaStOnE View Post
    CALLFREE is the name of the procedure being called.

    I usually do something like:

    PHP Code:
         D Entry           PR                  ExtPgm'PGMNAME' )        
         
    D   Prm_Request               3000A                              
         D   Prm_Response              3000A                              
         D   Prm_IPAddr                  15A                              
                                                                          
         D Entry           PI                                             
         D   Prm_Request               3000A                              
         D   Prm_Response              3000A                              
         D   Prm_IPAddr                  15A 
    That way I know the "ENTRY" is where stuff comes in/out

    His InParm1 and InParm2 reference the Index field in the example Jamie gave. He just didn't show the assignment of the field value I would assume.

    hth

    -Rick
    This is where I get lost. Most every example I find on this has an EXTPGM and I don't know what this would be. In my code, there is NO external program. I am just calling this program and getting things back.

    I am trying to replace 3 lines:

    d custcode S like(AMCUST)
    * ------------------------------------------------------
    * parms
    * ------------------------------------------------------
    c *entry plist
    c parm custcode

    It can't be this difficult. I must be overthinking this. This is the code I am trying to bring into FREE RPG. Basically, I am trying to remove the C specs. Otherwise, I could leave it like this and it works. Basically, this is learning thing for me.

  12. #11
    Harbinger of Doom tomholden's Avatar
    Join Date
    Dec 2007
    Location
    Lebanon, Tennessee, United States
    Posts
    4,341
    Rep Power
    8669

    Re: Entry parms in freeform *inzsr

    if the name of your program is the same as the prototype name then you don't need the EXTPGM() for example i have a program named JUNK i can simply do this:
    Code:
    dJunk             pr                                
    d CustCode                            Like(AMCUST)  
    dJunk             pi                                
    d CustCode                            Like(AMCUST)
    if my prototype name is ENTRY for the same program i'd have to use the EXTPGM():
    Code:
    dEntry            pr                  ExtPgm('JUNK')   
    d CustCode                            Like(AMCUST)     
    dEntry            pi                                   
    d CustCode                            Like(AMCUST)
    also using prototypes the field name on the PI is actually a field (not a comment like the PR) and you do not have to define it in the program...
    I'm not anti-social, I just don't like people -Tommy Holden

  13. #12
    Experienced Forum Member
    Join Date
    Mar 2007
    Location
    USA
    Posts
    233
    Rep Power
    804

    Re: Entry parms in freeform *inzsr

    Quote Originally Posted by tomholden View Post
    if the name of your program is the same as the prototype name then you don't need the EXTPGM() for example i have a program named JUNK i can simply do this:
    Code:
    dJunk             pr                                
    d CustCode                            Like(AMCUST)  
    dJunk             pi                                
    d CustCode                            Like(AMCUST)
    if my prototype name is ENTRY for the same program i'd have to use the EXTPGM():
    Code:
    dEntry            pr                  ExtPgm('JUNK')   
    d CustCode                            Like(AMCUST)     
    dEntry            pi                                   
    d CustCode                            Like(AMCUST)
    also using prototypes the field name on the PI is actually a field (not a comment like the PR) and you do not have to define it in the program...
    Ok, I changed it to this:
    * prototype for CALLFREE
    d CALLFREE PR extpgm('UPDARCMT')
    d custcode_ like(AMCUST)
    * ENTRY interface for Main Procedure
    d CALLFREE PI
    d custcode like(AMCUST)

    I added the extpgm('UPDARCMT') which is also the name of the program and it compiled...FINALLY. I don't know why it did and I don't know why it would. Then I compiled it with op 15 and then option 14 and I have a module and a program and I am more confused than I was when I started in this new venture. Now, I am starting to think this is why the RPGIII guy in my shop refuses to go forward.

  14. #13
    Analyst MdnghtPgmr's Avatar
    Join Date
    Oct 2005
    Location
    Topeka, KS
    Age
    56
    Posts
    517
    Rep Power
    2232

    Re: Entry parms in freeform *inzsr

    rpgKnight,

    Try viewing this:

    http://systeminetwork.com/tuesdaytips

    Then go to the Sept. 16, 2008 (there is a little scrolling list just under the "screen"). It will show you exactly how to do what you are trying to do.

    HTH,
    MdnghtPgmr

  15. #14
    Experienced Forum Member
    Join Date
    Mar 2007
    Location
    USA
    Posts
    233
    Rep Power
    804

    Re: Entry parms in freeform *inzsr

    Quote Originally Posted by tomholden View Post
    if the name of your program is the same as the prototype name then you don't need the EXTPGM() for example i have a program named JUNK i can simply do this:
    Code:
    dJunk             pr                                
    d CustCode                            Like(AMCUST)  
    dJunk             pi                                
    d CustCode                            Like(AMCUST)
    if my prototype name is ENTRY for the same program i'd have to use the EXTPGM():
    Code:
    dEntry            pr                  ExtPgm('JUNK')   
    d CustCode                            Like(AMCUST)     
    dEntry            pi                                   
    d CustCode                            Like(AMCUST)
    also using prototypes the field name on the PI is actually a field (not a comment like the PR) and you do not have to define it in the program...
    The second version of this example works. The first version does not.

    This, to me, tells me that there is a second program that is to be called within my first program and I am identifying it and the number of parms I will pass to it. In my case, there is NO external program. This is a stand alone program.

  16. #15
    Analyst dhuesman's Avatar
    Join Date
    Aug 2005
    Location
    KY
    Posts
    279
    Rep Power
    1099

    Re: Entry parms in freeform *inzsr

    EXTPGM is required for "Program" interfaces.

    This is why your second option is working.

    Although I usually name the interface the same "Entry" vs. "Junk" is kind of confusing to some.

  17. #16
    Experienced Forum Member
    Join Date
    Mar 2007
    Location
    USA
    Posts
    233
    Rep Power
    804

    Re: Entry parms in freeform *inzsr

    Quote Originally Posted by MdnghtPgmr View Post
    rpgKnight,

    Try viewing this:

    http://systeminetwork.com/tuesdaytips

    Then go to the Sept. 16, 2008 (there is a little scrolling list just under the "screen"). It will show you exactly how to do what you are trying to do.

    HTH,
    MdnghtPgmr
    Thank you, thank you, thank you!! Bob Cozzi rocks. All of you do, too, of course. The Tuesday Tips is a nice site.

    Got the answers.

    I knew I was overthinking this.

  18. #17
    Harbinger of Doom tomholden's Avatar
    Join Date
    Dec 2007
    Location
    Lebanon, Tennessee, United States
    Posts
    4,341
    Rep Power
    8669

    Re: Entry parms in freeform *inzsr

    if you read the post you would see that the prototype name must match the program name to avoid using the EXTPGM (i did however forget to mention that DFTACTGRP(*NO) should be used for that method )

    @dhuesman: "junk" was just a example name...i'd never use it for real. and i generally use the first method having the prototype name = program name just makes more sense to me...but that's just my preference.
    I'm not anti-social, I just don't like people -Tommy Holden

  19. #18
    Analyst dhuesman's Avatar
    Join Date
    Aug 2005
    Location
    KY
    Posts
    279
    Rep Power
    1099

    Re: Entry parms in freeform *inzsr

    yes sir ~ I understood. I just added the comment for the original poster.

  20. #19
    Blreen-O-holic vikramx's Avatar
    Join Date
    May 2006
    Location
    Chennai, India
    Posts
    247
    Rep Power
    1408

    Re: Entry parms in freeform *inzsr

    @rpgknight and others
    Also while ensuring the program name = procedure name the case of the name also matters

    Junk <> JUNK

    So basically, when you have a program name in all CAPS, which would usually be how the AS400 identifies RPGLE and COBOL programs, then the procedure name within the code should also be all CAPS.

    So lets say your program name is UPDARCMT then the following would be your procedure definition

    d UPDARCMT PR
    d custcode like(AMCUST)
    d UPDARCMT PI
    d custcode like(AMCUST)

    The following would give a compilation error
    d Updarcmt PR
    d custcode like(AMCUST)
    d Updarcmt PI
    d custcode like(AMCUST)

  21. #20
    Harbinger of Doom tomholden's Avatar
    Join Date
    Dec 2007
    Location
    Lebanon, Tennessee, United States
    Posts
    4,341
    Rep Power
    8669

    Re: Entry parms in freeform *inzsr

    Quote Originally Posted by vikramx View Post
    @rpgknight and others
    Also while ensuring the program name = procedure name the case of the name also matters

    Junk <> JUNK

    So basically, when you have a program name in all CAPS, which would usually be how the AS400 identifies RPGLE and COBOL programs, then the procedure name within the code should also be all CAPS.

    So lets say your program name is UPDARCMT then the following would be your procedure definition

    d UPDARCMT PR
    d custcode like(AMCUST)
    d UPDARCMT PI
    d custcode like(AMCUST)

    The following would give a compilation error
    d Updarcmt PR
    d custcode like(AMCUST)
    d Updarcmt PI
    d custcode like(AMCUST)
    wrong...the case only matters when the junk is specified as EXTPGM('junk') in this case. as far as the procedure name the case does not matter the compiler will translate that to uppercase at compile time. however you can create problems in service programs if you are using mixed case names...
    I'm not anti-social, I just don't like people -Tommy Holden

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

Facebook Comments


Similar Threads

  1. Sep
    By giduturi in forum ANY THING GOES
    Replies: 3
    Last Post: January 31st, 2007, 10:10 PM
  2. QAUDJRN and reattaching journal receivers?
    By PMSLIC in forum Iseries System administration
    Replies: 1
    Last Post: April 5th, 2006, 02:48 PM
  3. Call stack entry problem
    By vinod in forum RPG/RPGLE
    Replies: 3
    Last Post: March 28th, 2006, 08:11 AM
  4. Freeform date question
    By Iwana in forum RPG/RPGLE
    Replies: 2
    Last Post: October 11th, 2005, 12:39 PM
  5. First CLP/CLLE entry
    By jamief in forum CLP/CLLE
    Replies: 0
    Last Post: January 29th, 2004, 04:02 PM

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
  •