ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Can CL Commands be executed in RPGLE??

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

  • Can CL Commands be executed in RPGLE??

    I have following requirement:

    An application has set of Libraries, once the application is run the PFs and PRTFs in the libraries gets changed. I have to compare all the PFs and PRTFs and display a report of changes.

    I am using some RPFLE code and some CLLE code. At one place ineed the CL commands to get executed in RPGLE loop. I have written following code but it did not work. Can we use CL commands in the following way in RPGLE code. I think that variables defined in the cl command cause problem.

    Can any one suggest any thing in this regard or can suggest alternate way of achieving this task.

    Thanks


    D****************************************
    d zcmd s 200a

    d qcmdexc pr extpgm('QCMDEXC')
    d 200a const
    d 15p 5 const


    C*********************************************
    c eval zcmd = 'CLRPFM FILE(&LIBP/&PF1)'
    c callp(e) qcmdexc(%trim(zcmd):%len(%trim(zcmd)))

    c eval zcmd = 'CMPPFM NEWFILE(&LIBN/&NEW) NEWMBR
    c (*FIRST) OLDFILE(&LIBO/&OLD) OLDMBR (*FIR
    c CMPTYPE(*LINE) RPTTYPE(*DIFF) OUTPUT +
    c (*OUTFILE) OUTFILE(&LIBP/&PF1)'
    c callp(e) qcmdexc(%trim(zcmd):%len(%trim(zcmd)))

  • #2
    Well i also use qcmdexc to call CL in a rpg loop.

    The only thing that can cause trouble is the "". Have to put it right on the strig.

    lets see
    C*********************************************
    c eval zcmd = 'CLRPFM FILE(&LIBP/&PF1)'
    c callp(e) qcmdexc(%trim(zcmd):%len(%trim(zcmd)))
    becomes
    C*********************************************
    c eval zcmd = 'CLRPFM FILE('+var1+'/'+var2+')'
    c callp qcmdexczcmd:%size(zcmd))
    think that with this example u understood what u got to do
    "It's like a koala pooped a rainbow on my head and I can taste the colors."

    Comment


    • #3
      idscypher is exactly right

      ASRPG400 - You have your variables entered as a text constant because they are include between the quotes.

      Look closely at idscypher example and you will see his are not.

      I have include a big ugly hunk of code that may also help.
      Inlibrary and InsourceFile are passed in as *entry parameters to the program:

      Code:
      c                   Eval      CmdString = 'DSPFD FILE('              
      c                             + %Trim(InLibrary) + %Trim('/')        
      c                             + %trim(InsourceFile) + %Trim(')')     
      c                             + %trim('@@')                          
      c                             + %trim('TYPE(*MBRLIST) OUTPUT(')      
      c                             + %trim('*OUTFILE)  OUTFILE(QTEMP/')   
      c                             + %trim('QAFDMBRL)')                   
                                                                           
      c                   eval      CmdString = %Xlate('@':' ': Cmdstring) 
      c                   eval      CmdLength = %len(%trim(CmdString))     
                                                                           
      c                   call(e)   'QCMDEXC'                              
      c                   parm                    CmdString                
      c                   parm                    CmdLength

      Comment


      • #4
        I also want to execute CL command in RPGLE loop but it gives error. I have placed a tag "ERR" where the error occured. Can any one tell me what is the error. The code is as under :


        c Eval ZCMD = 'CMPPFM NEWFILE('
        c + %Trim(&LIBN) + %Trim('/') "ERR"
        c + %trim(&NEW) + %Trim(')') "ERR"
        c + %trim('NEWMBR(*FIRST)')
        c + %trim ('OLDFILE('
        c + %trim(&LIBO) + %Trim('/') "ERR"
        c + %trim(&OLD) + %Trim(')') "ERR"
        c + %trim('OLDMBR(*FIRST)')
        c + %trim('CMPTYPE(*LINE)RPTTYPE(*DIFF)')
        c + %trim('OUTPUT(*OUTFILE)')
        c + %trim('OUTFILE(&LIBP) + %Trim('/')')
        c + %trim(&PF1) + %Trim(')') "ERR"

        Thanks
        SAM

        Comment


        • #5
          sam400 i think its the bad position of the " ' ".

          And & can't be used in rpg so if you remove it you will be ok .

          And dont know why you want to remove blanks %Trim for something like '/'
          "It's like a koala pooped a rainbow on my head and I can taste the colors."

          Comment


          • #6
            as always idscypher is exactly correct

            You have to remove the "&" it is not valid in RPG.


            good luck

            jimmy

            Comment

            Working...
            X