IBM for i / RPG: How to compile a module and create a service program with one call in IBM Rational Developer for i (RDi)

533 Views Asked by At

How to avoid having to use the Compile menu of RDi 2 times in a row - to create first a SQL RPGLE module and then to create the service program associated?

1

There are 1 best solutions below

7
On

For that, you create first a CL Program (let's name it CRTSRVPRG) like this:

         PGM        PARM(&LIBRARY &SOURCE &NAME &HASITFCHG)

         DCL        VAR(&LIBRARY) TYPE(*CHAR) LEN(10)
         DCL        VAR(&SOURCE)  TYPE(*CHAR) LEN(10)
         DCL        VAR(&NAME)    TYPE(*CHAR) LEN(10)
         DCL        VAR(&HASITFCHG)    TYPE(*CHAR) LEN(1)


         CRTSQLRPGI OBJ(&LIBRARY/&NAME) SRCFILE(&LIBRARY/&SOURCE) SRCMBR(&NAME) REPLACE(*YES) OBJTYPE(*MODULE) RPGPPOPT(*LVL2) DBGVIEW(*SOURCE) OPTION(*EVENTF)

         IF         COND(&HASITFCHG = 'Y') THEN(DO)
            CRTSRVPGM  SRVPGM(&LIBRARY/&NAME) MODULE(&LIBRARY/&NAME) EXPORT(*ALL) SRCFILE(&LIBRARY/&SOURCE)
            RTVBNDSRC  SRVPGM(&LIBRARY/&NAME) SRCFILE(&LIBRARY/QSRVSRC)
            CHGPFM     FILE(&LIBRARY/QSRVSRC) MBR(&NAME) SRCTYPE(BND)
         ENDDO

         ELSE       CRTSRVPGM  SRVPGM(&LIBRARY/&NAME) MODULE(&LIBRARY/&NAME) EXPORT(*SRCFILE) SRCFILE(&LIBRARY/QSRVSRC) SRCMBR(&NAME)

         ENDPGM      

Then in the menu Compile / Compile / Work With Compile Command…, you add the following 2 new commands:

  1. "New service program or change in the interface"

    CALL PGM([your library]/CRTSRVPRG) PARM(&L &F &N 'Y') /* OPTION(*EVENTF) SRCMBR(&N) */

  2. "Recompile service program"

    CALL PGM([your library]/CRTSRVPRG) PARM(&L &F &N 'N') /* OPTION(*EVENTF) SRCMBR(&N) */

Tipp: you can use the button "Run compile command without prompting" from the toolbar to execute the last command, without having to use the menu.

The addition in the command of

/* OPTION(*EVENTF) SRCMBR(&N) */

gives you the feedback for the module compilation in the Tab "Error List". Unfortunately, there is no feedback for the creation of the Service Program. For that, you'll have to look into the Tab "Commands Log"...