ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

SNDPGMMSG in CL

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

  • SNDPGMMSG in CL

    Hello Everyone,

    I have this CL program that makes use of SNDPGMMSG in order to have messages displayed at the bottom of the screen.

    The concern now is that, earlier the manner in which the send to program message was implemented was as below:

    Code:
    SNDPGMMSG   MSGID(CPF9898)  MSGF(QCPFMSG)  MSGDTA('Message has been submitted to batch')
                TOPGMQ(*PRV)MSGTYPE(*COMP)
    But now the command makes use of a variable instead of hardcoded text within MSGDTA like below:

    Code:
    SNDPGMMSG   MSGID(CPF9898)  MSGF(QCPFMSG)  MSGDTA(&FIELD1)
                TOPGMQ(*PRV)MSGTYPE(*COMP)
    Everything is successfully working excepting for the fact that the text now appears truncated with just 'Message has been submitted.' appearing. Is the defined length the issue. If so where exactly can i go and increase the length. Also the program worked well during the hard coded text, the new variable too has the same text so where could be the exact issue?

    Please guide.

  • #2
    Re: SNDPGMMSG in CL

    hi techas400

    At the top of your code you will probably have a line as follows..

    DCL &FIELD1 *CHAR 30

    Change the length and you should be good to go

    Comment


    • #3
      Re: SNDPGMMSG in CL

      Hi Chris,

      Thanks for responding. Yes,this field has been defined to a length of 132 yet to no avail

      Also i see the message which appears as truncated tends to be ending with a dot in the end of the half thrown text. Any clue on that?

      Comment


      • #4
        Re: SNDPGMMSG in CL

        Can you post the full code?

        Is the &Field1 passed into the program? It may be the calling program that is calling this program with a shortened version?

        Comment


        • #5
          Re: SNDPGMMSG in CL

          The message text for message ID CPF9898 has just one message data variable with a period. If you DSPMSGD CPF9898, you'll see that the message text is "&1." If you want to send the message without the period at the end, then use message ID CPF9897 or just use the MSG parameter instead of the MSGID/MSGF/MSGDTA parameters of the SNDPGMMSG command.

          Comment


          • #6
            Re: SNDPGMMSG in CL

            Thanks Brian and Chris,

            The period thing is understandable now. But what about the text going short. Chris, theres no other parent pgm involved, all thats happening is going on in this pgm itself.

            DCL VAR(&FIELD1) TYPE(*CHAR) LEN(132)

            This is how it has been defined and used with a SNDPGMMSG as was illustrated above

            Comment


            • #7
              Re: SNDPGMMSG in CL

              TechAs400...

              I strongly suspect that you are leaving something important out of your description. There are important, relevant, details that we need to know that you are not telling us. Unfortunately, I don't have any way of knowing what those details are, so I can't tell you what to include, or what's wrong with your program.

              Here's everything I learned from you so far:

              1) You changed a SNDPGMMSG from a literal to a variable.
              2) Your variable is named &FIELD1 (which probably isn't true, but that's what you told us)
              3) Your variable is 132 chars long.

              However, if I code the following program, it works as expected:

              Code:
              PGM                                                         
                  DCL VAR(&FIELD1) TYPE(*CHAR) LEN(132)                   
                                                                          
                  CHGVAR VAR(&FIELD1) +                                   
                         VALUE('Message has been submitted to batch')     
                                                                          
                  SNDPGMMSG MSGID(CPF9898) MSGF(QCPFMSG) MSGDTA(&FIELD1) +
                            TOPGMQ(*PRV) MSGTYPE(*COMP)                   
              ENDPGM
              When I run this, I get:
              Code:
               MAIN                           IBM i Main Menu                                 
                                                                           System:   PLBOX    
               Select one of the following:                                                   
                                                                                              
                    1. User tasks                                                             
                    2. Office tasks                                                           
                    3. General system tasks                                                   
                    4. Files, libraries, and folders                                          
                    5. Programming                                                            
                    6. Communications                                                         
                    7. Define or change the system                                            
                    8. Problem handling                                                       
                    9. Display a menu                                                         
                   10. Information Assistant options                                          
                   11. IBM i Access tasks                                                     
                                                                                              
                   90. Sign off                                                               
                                                                                              
               Selection or command                                                           
               ===>                                                                           
                                                                                              
               F3=Exit   F4=Prompt   F9=Retrieve   F12=Cancel   F13=Information Assistant     
               F23=Set initial menu                                                           
              [B] Message has been submitted to batch. [/B]
              So, the message is not "cut off in the middle" at all.

              Can you provide a simple program (very simple.. similar to the one I provided above) that shows how to reproduce the problem you're seeing?

              Comment

              Working...
              X