sponsored links

Collapse

Announcement

Collapse
No announcement yet.

Entry parms in freeform *inzsr

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

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

    Comment


    • #3
      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.

      Comment


      • #4
        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

        Comment


        • #5
          That's what i figured

          thanks

          Comment


          • #6
            Re: Welcome

            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.

            Comment


            • #7
              Re: Entry parms in freeform *inzsr

              I believe CALLFREE is his EXTPGM name.

              Comment


              • #8
                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

                Comment


                • #9
                  Re: Entry parms in freeform *inzsr

                  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

                  Comment


                  • #10
                    Re: Entry parms in freeform *inzsr

                    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.

                    Comment


                    • #11
                      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

                      Comment


                      • #12
                        Re: Entry parms in freeform *inzsr

                        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.

                        Comment


                        • #13
                          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
                          "Tis better to be thought a fool then to open one's mouth and remove all doubt." - Benjamin Franklin

                          Comment


                          • #14
                            Re: Entry parms in freeform *inzsr

                            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.

                            Comment


                            • #15
                              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.

                              Comment

                              sponsored links

                              Collapse

                              Working...
                              X