Difference between Module and a Program in AS/400

635 pts.
Tags:
AS/400
AS/400 programming
OS/400
Can someone please tell me how to differentiate between Module and Program in As400 just by looking at it?

Software/Hardware used:
OS400

Answer Wiki

Thanks. We'll let you know when a new response is added.

By just looking at it: a Object Description you would see if it is type *PGM a module is of type *MODULE.

Discuss This Question: 9  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.
  • HMSSL2K
    3,175 pointsBadges:
    report
  • TomLiotta
    As CharlieBrowne said, they have different object types. Obviously, though, "telling the difference" requires knowing how you are "looking". What do you mean by "looking at it"? You can't look at a program nor a module except perhaps by going in through Service Tools and examining bytes on disk. So, you must be using some command to output some results. Perhaps you are "looking at" a list of objects in a library. What command or menu option created the list? Tom
    125,585 pointsBadges:
    report
  • Sangay
    I think there was a confusion. I wanted to ask how to differentiate between Module and program by looking at its source code. You open a source code and now there must be differences between the these two which actually makes them different. if this question makes Modules and procedures same then for a procedure i believe we have specifications P, D and C. Not sure. Any suggestions?
    635 pointsBadges:
    report
  • TomLiotta
    ...how to differentiate between Module and program by looking at its source code. Ah. Yes, that gets a little tricky. First, a *MODULE must be compiled as ILE. If it's not ILE-compatible source, it will always compile as a *PGM. Second, ILE always compiles *MODULEs. ILE programs are never compiled; they are bound from modules. However, the ILE languages all supply commands that do the module compilation and the program binding in a single command. For example, the CRTBNDRPG command will first compile the source as a *MODULE in QTEMP and then generate the bound *PGM from that *MODULE along with any system *MODULEs (service programs) that are indicated. So, the distinction can be tricky since all ILE source that can be compiled is always *MODULE source. But some modules are not sufficient to create bound programs; they require other modules. Generally, in order to result in a program, a "main" procedure must be supplied in the module source. So, the first clue with ILE RPG is likely to be the presence of the NOMAIN H-spec keyword. If the source compiles with NOMAIN, you know it can't stand alone as a *PGM; some other module must supply the "main" procedure. (Note that the procedure doesn't need to be named "main". Being the main procedure isn't the same as having a procedure named 'main'.) Also, RPG requires a way to end a *PGM. Usually, that means you'll find a reference to indicator LR or *INLR in the source. Since that might be supplied in a /COPY member or similar means, it's not guaranteed. Now, with ILE CL, any source that compiles can be either a "main" procedure or a secondary procedure. There are no clues -- the source can be handled either way. ILE C will actually have a procedure named 'main' that you can search for in the source. ILE COBOL... I'm not sure yet. Everything I tested resulted in a *PGM or *MODULE depending on the creation command that I used, even for source that I explicitly wrote for use as a *MODULE. I'll see if I can track down details. Well, in short, if the source doesn't explicitly carry an indication such as the ILE RPG NOMAIN keyword, you may need to submit compiles into QTEMP and have the system tell you if it succeeds or fails when creating a *PGM. (A *MODULE can almost always succeed.) I've always found that the system is much faster at making the determinations than I am. After all, we're programmers. We're supposed to know how to get the system to do work for us. It's not necessarily the source that makes a difference. It's what you do with the source that is most important. If I find more, I'll try to remember to add it. Tom
    125,585 pointsBadges:
    report
  • Sangay
    thanks a ton for the explaination. Could you please also add the basic difference between module and a procedure but again just by looking at it.
    635 pointsBadges:
    report
  • TomLiotta
    Could you please also add the basic difference between module and a procedure... For what language? ILE RPG and ILE C both have language constructs for including multiple procedures in modules. COBOL and CL both have a single procedure per module. When multiple procedures are allowed, there will be prototypes for each one. (Though, in ILE RPG a prototype for the "main" procedure isn't required.) In RPG, you'd recognize procedures by their P-specs. Tom
    125,585 pointsBadges:
    report
  • The Most-Watched IT Questions: February 1, 2011 - ITKE Community Blog
    [...] All the usual suspects showed up to help Sangay tell the difference between module and a program in AS/400. 6. Rakei and Rechil do their best to describe how to properly mass delete user profiles in [...]
    0 pointsBadges:
    report
  • hikerz2010
    Thank you.
    15 pointsBadges:
    report
  • bernard85
    here one example of module:
         h option(*NOSHOWCPY) BndDir('U6IFS':'U6INT') nomain
          //‚copy                                                               -
          /copy cpy,u6ibm_h
          /copy cpy,u6ifs_h
          /copy cpy,u6int_h
          /copy cpy,u6fmt_h

          /copy cpy,u6xml_h
          //‚--------------------------------------------------------------------
          //‚xml_read
          //‚--------------------------------------------------------------------
         pxml_read         b                   export
         d xml_read        pi
         d  path                        255a   varying const
         d  pprocessNode                   *   procptr const
         d  pBox                           *           const
          *
         d  NodeDefine     ds                  likeDs(xml_NodeDefine)
          *
         d  processNode    pr              n   extproc(pProcessNode)
         d    NodeDefine                       likeDs(xml_NodeDefine)
         d    pBox                         *   const

         d p1              s              5U 0
         d p2              s              5U 0
         d p9              s              5U 0 INZ(1)
         d buffer          s          65535a
         d hstmf           s             10i 0
         d nRead           s             10i 0
          /free
           //‚ouverture du fichier
           hSTMF=open(path:O_rdonly+o_TextData);
           nRead=Read(hSTMF:%addr(buffer):%size(buffer));
           //‚read nodes
           p1=%scan('<':buffer);
           dow p1>0;
             clear NodeDefine;
             p9=%scan('>':buffer:p1);
             //‚XML declaration
             if     %subst(buffer:p1:2)='<?';                                       // declaration
             //‚XML close node
             elseIf %subst(buffer:p1:2)='</';
                 NodeDefine.isOpen=*off;
                 NodeDefine.isclose=*on;
                 NodeDefine.ID=%subst(buffer:p1+2:p9-p1-2);
                 if processNode(nodeDefine:pBox);
                   leave;
                 endif;
             else;
             //‚XML regular node
                 NodeDefine.isOpen=*on;
                 NodeDefine.isClose=%subst(buffer:p9-1:2)='/>';
                 p2      =getminnot0(%scan(' ' :buffer:p1):
                                     %scan('/>':buffer:p1):
                                     %scan('>' :buffer:p1));
                 nodeDefine.id  =%subst(buffer:p1+1:p2-p1-1);
                 //‚Case of a node with attributes
                 if p9>p2;
                   nodeDefine.atts=%subst(buffer:p2+1:p9-p2-1);
                   nodeDefine.atts=xml_SeekSpecialCharacters(
                                           nodeDefine.atts);
                 endif;
                 p1      =p9;
                 p9      =%scan('<':buffer:p1);
                 nodeDefine.text=%subst(buffer:p1+1:p9-p1-1);
                 nodeDefine.text=int_scanRpl(x'0d':'':nodeDefine.Text);
                 nodeDefine.text=int_scanRpl(x'25':'':nodeDefine.Text);
                 nodeDefine.Text=%trimR(nodeDefine.Text);
                 nodeDefine.text=xml_SeekSpecialCharacters(
                                           nodeDefine.text);
                 if processNode(nodeDefine:pBox);
                   leave;
                 endif;
             endIf;

             p1=%scan('<':buffer:p9);
           endDo;
           //‚Close the file
           hSTMF=Close(hSTMF);
          /end-free
         p                 e
          //‚--------------------------------------------------------------------
          //‚get attribut as string
          //‚--------------------------------------------------------------------
         pXML_getAttAsString...
         p                 b                   export
         dXML_getAttAsString...
         d                 pi           128    varying
         d  pty                         128    varying const
         d  ptys                       2048    varying const
          *
         d  p1             s              5u 0
         d  p2             s              5u 0
         d  val            s            128a   varying
          /free
           p1=%scan(pty+'="':ptys);
           if p1=0;
             return '';
           endif;
           p1+=%len(pty)+2;
           p2=%scan('"':ptys:p1);
           val=%subst(ptys:p1:p2-p1);
           return val;
          /end-free
         p                 e
          //‚--------------------------------------------------------------------
          //‚get attribut as integer
          //‚--------------------------------------------------------------------
         pXML_getAttAsInteger...
         p                 b                   export
         dXML_getAttAsInteger...
         d                 pi            10i 0
         d  pty                         128    varying const
         d  ptys                       2048    varying const
          *
         d  val            s            128a   varying
          /free
            val=XML_getAttAsString(pty:ptys);

            if val='';
              return 0;
            else;
              return %int(val);
            endif;
          /end-free
         p                 e
          //‚--------------------------------------------------------------------
          //‚get attribut as boolean
          //‚--------------------------------------------------------------------
         pXML_getAttAsBoolean...
         p                 b                   export
         dXML_getAttAsBoolean...
         d                 pi              n
         d  pty                         128    varying const
         d  ptys                       2048    varying const
          *
         d  val            s            128a   varying
          /free
            val=XML_getAttAsString(pty:ptys);

            return val='Y';
          /end-free
         p                 e
          //‚--------------------------------------------------------------------
          //‚get min not null
          //‚--------------------------------------------------------------------
         pgetMinNot0       b
         d                 pi             5u 0
         d    u1                          5u 0 const
         d    u2                          5u 0 const
         d    u3                          5u 0 const

         d    min          s              5u 0 inz(*hival)
          /free
            if u1<min and u1>0;
              min=u1;
            endif;
            if u2<min and u2>0;
              min=u2;
            endif;
            if u3<min and u3>0;
              min=u3;
            endif;
            if min=*hival;
              return 0;
            endif;
            return min;
          /end-free
         p                 e
          //‚--------------------------------------------------------------------
          //‚hide special characters
          //‚--------------------------------------------------------------------
         pxml_HideSpecialCharacters...
         p                 b                   export
         dxml_HideSpecialCharacters...
         d                 pi          2048a   varying
         d S_                          2048a   varying const
         d S               s           2048a   varying
          /free
           S=int_scanRpl(';':'&amp;' :S_);
           S=int_scanRpl('<':'&lt;'  :S );
           S=int_scanRpl('>':'&gt;'  :S );
           S=int_scanRpl('"':'&quot;':S );
           return s     ;
          /end-free
         p                 e
          //‚--------------------------------------------------------------------
          //‚seek special characters
          //‚--------------------------------------------------------------------
         pxml_SeekSpecialCharacters...
         p                 b                   export
         dxml_SeekSpecialCharacters...
         d                 pi          2048a   varying
         d String_                     2048a   varying const
         d String          s           2048a   varying
          /free
           String=int_scanRpl('&lt;'  :'<':String_);
           String=int_scanRpl('&gt;'  :'>':String );
           String=int_scanRpl('&quot;':'"':String );
           String=int_scanRpl('&amp;' :';':String );
           return string;
          /end-free
         p                 e
          //‚-----------------------------------------------------------------------
          //‚set attribut from integer value
          //‚-----------------------------------------------------------------------
         pxml_setAttfromInteger...
         p                 b                   export
         dxml_setAttfromInteger...
         d                 pi
         d  atts                       2048    varying
         d  pty                         128    varying const
         d  val                          20i 0 const
           atts+=' '+pty+'="'+%char(val)+'"';
          /end-free
         p                 e
          //‚-----------------------------------------------------------------------
          //‚set attribut from string value
          //‚-----------------------------------------------------------------------
         pxml_setAttfromString...
         p                 b                   export
         dxml_setAttfromString...
         d                 pi
         d  atts                       2048    varying
         d  pty                         128    varying const
         d  val                         128    varying const
          /free
           atts+=' '+pty+'="'+%trimR(val)+'"';
          /end-free
         p                 e
          //‚-----------------------------------------------------------------------
          //‚xml write node
          //‚-----------------------------------------------------------------------
         pxml_writeNode    b                   export
         d xml_writeNode   pi
         d  hJRN                         10i 0 const
         d  nodeDefine                         likeDs(xml_nodeDefine) const
          *
         d  space          s            255    inz('')
         d  dta            s          65535a   varying inz('')
          /free
           if nodedefine.level>0;
             dta=%subst(space:1:nodedefine.level*2);
           endIf;
           if nodeDefine.isOpen;
             dta+='<'+nodeDefine.ID+NodeDefine.atts;
             if nodeDefine.isClose;
               dta+='/';
             endIf;
             dta+='>';
           elseif nodeDefine.isClose;
             dta='</'+nodeDefine.ID+'>';
           endIf;
           ifs_println(hJRN:dta);
          /end-free
         p                 e

    380 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.

Following

Share this item with your network: