myITforum and Windows IT Pro Forums
Forum Themes:
Welcome !

 Command on QP2TERM and CL

Author Message
mg1956

  • Total Posts : 5
  • Scores: 0
  • Reward points : 870
  • Joined: 9/5/2017
  • Status: offline
Command on QP2TERM and CL Tuesday, September 05, 2017 12:31 PM (permalink)
0
Hi.
 
system chgdtaara qgpl/SHA2INP "'$(pr -t msgsigned.b64)'"
 
The command above works so good in QP2TERM but in CL doesn't work. Why ? Why ? 
 
My CL:
DCL VAR(&QP2LIB)    TYPE(*CHAR) LEN(18) VALUE('/QOpenSys/usr/bin/')
CHKOBJ OBJ(QGPL/SHA2INP) OBJTYPE(*DTAARA)
MONMSG CPF9801 EXEC(DO)                                            
CRTDTAARA DTAARA(QGPL/SHA2INP) TYPE(*CHAR) LEN(172)
ENDDO                                                              
CHGVAR &QP2CMD   (&QP2LIB *CAT 'system' *CAT &NULL)                
CHGVAR &QP2PARM1 ('chgdtaara '  *CAT 'qgpl/sha2inp '  *cat  '"''$(pr ' *caT +
                                  '-t ' *caT 'msgsigned.b64)''"'  *CAT &NULL)             
SNDPGMMSG ('PARM1: ' *CAT &QP2PARM1) 
CALL QP2SHELL (&QP2CMD &QP2PARM1)
The result:
PARM1: chgdtaara qgpl/sha2inp "'$(pr -t msgsigned.b64)'"
CPD0020: Carácter ''' não é válido a seguir à cadeia '"         '. 
CPF0006: Ocorreram erros no comando.    
Thanks                         
 
#1
    jsev

    • Total Posts : 24
    • Scores: 2
    • Reward points : 44190
    • Joined: 11/19/2015
    • Status: offline
    Re:Command on QP2TERM and CL Tuesday, September 05, 2017 5:19 PM (permalink)
    0
    Why the heck would you try and use QSHELL to do this from a CL program?  That makes no sense and is just overcomplicating something that is extremely trivial.
    You should just use the CHGDTAARA command in your CL program:
    CHGDTAARA QGPL/SHA2INP '''$(pr -t msgsigned.b64'''
    You can even prompt it like you do on a command line and type the parameters in there.
     
    #2
      mg1956

      • Total Posts : 5
      • Scores: 0
      • Reward points : 870
      • Joined: 9/5/2017
      • Status: offline
      Re:Command on QP2TERM and CL Wednesday, September 06, 2017 4:50 AM (permalink)
      0
      First, thanks. But ...
      1. msgsigned.b64 is a IFS file. I am no tsure if it is a problem in your sugestion
      2. I tried your sugestion and received a error from the editor: Character ''' is not valid after string '"               '.
      3. I tried others variations, without ", change "' by '" but ... when is OK the data area has $(pr -t msgsigned.b64)
      Another sugestion ? Or ... What am I doing wrong ?
       
       
      #3
        jsev

        • Total Posts : 24
        • Scores: 2
        • Reward points : 44190
        • Joined: 11/19/2015
        • Status: offline
        Re:Command on QP2TERM and CL Wednesday, September 06, 2017 5:09 PM (permalink)
        0

        1. msgsigned.b64 is a IFS file. I am no tsure if it is a problem in your sugestion

        What your code is doing, is putting text into a DTAARA.  A DTAARA is an object that holds whatever values you wish to place in it - it has been created to hold character data with a maximum length of 172 characters.  I guess you can think of it as a text file on a PC but with a pre-defined length.  As such, the system makes no assumptions about what is in there, it's just a string of characters.  DSPDTAARA QGPL/SHA2INP will display its contents.  The CHGDTAARA command is changing its contents to whatever you specify.  You can type the command on a command line and prompt it (using F4) to display the parameters.  This is not a PASE command so there is absolutely no need to overly complicate this by doing it via QSHELL.


        2. I tried your sugestion and received a error from the editor: Character ''' is not valid after string '"               '.

        I was guessing what text you were trying to add to the DTAARA without trying the command in QSHELL myself.  If all you want to add is:
        $(pr -t msgsigned.b64)
        Then the command would be:  CHGDTAARA QGPL/SHA2INP '$(pr -t msgsigned.b64)'
        However, if you were wanting:
        '$(pr -t msgsigned.b64)'
        i.e. quotes around it, then the command would be:CHGDTAARA QGPL/SHA2INP '''$(pr -t msgsigned.b64)'''
        Note, that ''' is actually 3 single quotes.  The reason for this is the string you are adding needs quotes around it (which is the first and last quote).  The two single quotes ('') denote to the system that you are wanting to add a quote around your text.  So, ''abc'' is interpreted as 'abc' rather than open quote, close quote, abc, open quote, close quote...  I hope that makes sense.
         
        Your CL would therefore look something like this:
         
         DCL VAR(&QP2LIB)    TYPE(*CHAR) LEN(18) VALUE('/QOpenSys/usr/bin/') 
         CHKOBJ OBJ(QGPL/SHA2INP) OBJTYPE(*DTAARA) 
         MONMSG CPF9801 EXEC(DO) 
         CRTDTAARA DTAARA(QGPL/SHA2INP) TYPE(*CHAR) LEN(172) 
         ENDDO 
         CHGDTAARA QGPL/SHA2INP '$(pr -t msgsigned.b64)' 
          

         
        <message edited by jsev on Wednesday, September 06, 2017 5:11 PM>
         
        #4
          mg1956

          • Total Posts : 5
          • Scores: 0
          • Reward points : 870
          • Joined: 9/5/2017
          • Status: offline
          Re:Command on QP2TERM and CL Thursday, September 07, 2017 3:58 AM (permalink)
          0
          I'm not trying to complicate anything.
          Apparently I could not explain what I mean.
          There is an IFS file, msgsigned.b64, and I want to put the contents of this file in the variable (data area) QGPL / SHA2INP.
          The command pr -t msgsigned.b64 will "print" the IFS file without a header.
          What I want at the end? What I want ? Let the contents of the file be placed in SHA2INP.
          Calling SHELL from the command line, CALL QP2TERM, and then executing the command system chgdtaara QGPL/SHA2INP "'$ (pr -t msgsigned.b64)'" it turns out that SHA2INP gets the contents of the IFS file perfectly including the ASCII conversion (UNIX) to EBCDIC (AS400).
          But if I try to execute the same command via CL, and I need to go to SHELL because of the IFS file, it always gives parameters error. (See the first post).
          I need help to know how to mount the command in CL so when it goes to SHELL it will be executed as if I had typed the command directly in the SHELL.
          I currently use the CPYFRMSTMF command to transfer the IFS file to AS400, and then, in the COBOL program that called the CL, read the AS400 file. I'm trying to optimize this process by looking for the content of the IFS file that returns in one of the CL parameters.
           
           
          #5
            jsev

            • Total Posts : 24
            • Scores: 2
            • Reward points : 44190
            • Joined: 11/19/2015
            • Status: offline
            Re:Command on QP2TERM and CL Thursday, September 07, 2017 5:54 PM (permalink)
            0
            Ah, that makes more sense now...
            I'm not sure how copying a STMF into a DTAARA is more streamlined than copying it into a file but I guess you're wanting to do all that stuff in the CL.
            You could continue to use the CPYFRMSTMF command and read the file in the CL program.  Just declare it and read the contents and pass the value back to the calling program.  e.g.
             
            DLCF x/y
             CPYFRMSTMF FROMSTMF(msgsigned.b64) TOMBR('/QSYS.LIB/x.lib/y.file')
             RCVF

            The field name defined in the file can be passed back to the cobol program.
             
            If you prefer to use the DTAARA method, it looks like you are missing the "system" command.  Try something like:
            CHGVAR &QP2PARM1 ('system chgdtaara qgpl/sha2inp "''$(pr -t msgsigned.b64)''"'  *CAT &NULL)
            I'm also not sure if the NULL is required.
             
            #6
              mg1956

              • Total Posts : 5
              • Scores: 0
              • Reward points : 870
              • Joined: 9/5/2017
              • Status: offline
              Re:Command on QP2TERM and CL Friday, September 08, 2017 11:36 AM (permalink)
              0
              Hi jsev.
              Thanks for your effort but read more carefully the previous posts. What you tell me to do I've already done it or it's how I'm doing.
               
              #7
                jsev

                • Total Posts : 24
                • Scores: 2
                • Reward points : 44190
                • Joined: 11/19/2015
                • Status: offline
                Re:Command on QP2TERM and CL Sunday, September 10, 2017 4:54 PM (permalink)
                0
                Did you think about using a file instead?
                You could:
                1.  Create a PF with a single field (e.g. FIELD1) that is 172 characters long instead of the DTAARA.
                2.  Declare this file in your CL program and use the CPYFRMSTMF command to put the contents of msgsinged.b64 into the file.
                3.  RCVF will retrieve the contents of the PF and place it into a variable with the same name as the field name in the PF (e.g. &FIELD1).
                4.  That variable can be passed back to the cobol program.
                 
                All in all, it's about 3 lines of code to do in your CL program and sounds like what you are trying to achieve:
                 

                DLCF x/y
                 CPYFRMSTMF FROMSTMF(msgsigned.b64) TOMBR('/QSYS.LIB/x.lib/y.file')
                 RCVF

                 
                I you want to go down the far more convoluted path, looking a the QP2TERM API, it is expecting pointers to be passed, not text variables.  These are far more complicated in CL so I would suggest using a file as above.  The code will be understandable and infinitely more readable for people who may look at the code later down the track.
                 
                #8
                  mg1956

                  • Total Posts : 5
                  • Scores: 0
                  • Reward points : 870
                  • Joined: 9/5/2017
                  • Status: offline
                  Re:Command on QP2TERM and CL Tuesday, September 19, 2017 10:10 AM (permalink)
                  0
                  Yes, I did this. I am using this solution.
                  I am trying using something with more performance, less steps to use.
                  My most important question is: why the command works well in the shell and not by a command in CL ? What am I doing wrong ? Just this
                   
                  #9
                    Online Bookmarks Sharing: Share/Bookmark

                    Jump to:

                    Current active users

                    There are 0 members and 1 guests.

                    Icon Legend and Permission

                    • New Messages
                    • No New Messages
                    • Hot Topic w/ New Messages
                    • Hot Topic w/o New Messages
                    • Locked w/ New Messages
                    • Locked w/o New Messages
                    • Read Message
                    • Post New Thread
                    • Reply to message
                    • Post New Poll
                    • Submit Vote
                    • Post reward post
                    • Delete my own posts
                    • Delete my own threads
                    • Rate post

                    2000-2017 ASPPlayground.NET Forum Version 3.9