ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Problems with SNDDST

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

  • Problems with SNDDST

    I found something that sends a spool file to an e-mail addr using SNDDST. When it does the SNDDST, I get a CPC9033 that says "Send distribution completed successfully." However, I don't receive the e-mail.

    The basic things it does are:
    1) cpysplf to a file in qtemp
    2) cpytopcd
    3) snddst

    I hesitate to post the source because it's so huge. Hopefully this isn't information overkill. TIA for any help anyone can give me.

    This is a program called "X" on my system so I don't have to keep typing in this info over and over. (I just type in "call x")
    Code:
    SPLF2EML JOB(226212/QSECOFR/FVLDSP03) +
                                    SPLFNAM(PRINTERA) SPLFNBR(1) +
                                    ??TOINTNET(USER@SOMETHING.COM) +
                                    MSG('See attached.')



    Command SPLF2EML:
    Code:
    /*           CRTCMD     CMD(mylib/SPLF2EML) +                      */
    /*                      PGM(*LIBL/SPLF2EMLC) +                     */
    /*                      SRCFILE(mylib/mysrcf) +                    */
    /*                      SRCMBR(SPLF2EML) +                         */
    /*                      TEXT('Spoolfile to e-mail')                */
    
                 CMD        PROMPT('Create splf/email attachment')
                 PARM       KWD(JOB) TYPE(Q00BF) SNGVAL( (* )) MIN(1) PROMPT('Qualified job name')
    
     Q00BF:      QUAL       TYPE(*NAME) LEN(10) MIN(1)
                 QUAL       TYPE(*NAME) LEN(10) PROMPT('Job user')
                 QUAL       TYPE(*CHAR) LEN(6) RANGE( '000000' '999999') PROMPT('Job number')
    
                 PARM       KWD(SPLFNAM) TYPE(*NAME) LEN(10) MIN(1) PROMPT('*SPLF name')
                 PARM       KWD(SPLFNBR) TYPE(*INT4) DFT(*LAST) RANGE( -1 9999) SPCVAL( (*ONLY 0) +
                              (*LAST -1)) PROMPT('*SPLF number')
                 PARM       KWD(TOINTNET) TYPE(*CHAR) LEN(253) EXPR(*YES) CHOICE(*NONE) +
                              PROMPT('Internet Recipient')
                 PARM       KWD(MSG) TYPE(*CHAR) LEN(256) DFT('See attached.') EXPR(*YES) +
                              PROMPT('Message')
    
                 DEP        CTL(*ALWAYS) PARM( (TOINTNET))
    SPLF2EMLC -- CPP for SPLF2EML:
    Code:
    /*                                                                           */
    /* SPLF2EML: A basic means of e-mailing AS/400 spoolfiles...                 */
    /*                                                                           */
    
     SPLF2EML:   PGM        PARM(&PQJOB &PSPLFNAM &PSPLFNBR &PINTNETADR &PMSG)
    
                 DCL        VAR(&PQJOB) TYPE(*CHAR) LEN(26) /* Qualified job name... */
                 DCL        VAR(&PSPLFNAM) TYPE(*CHAR) LEN(10) /* Spoolfile name... */
                 DCL        VAR(&PSPLFNBR) TYPE(*CHAR) LEN(4) /* Spoolfile number... */
                 DCL        VAR(&PINTNETADR) TYPE(*CHAR) LEN(253) /* Recipient internet address... +
                              */
                 DCL        VAR(&PMSG) TYPE(*CHAR) LEN(256) /* An additional message to go with +
                              the spoolfile... */
    
    
    /*                                                                           */
    /* Spoolfile name and number...                                              */
    /*                                                                           */
                 DCL        VAR(&SPLFNAM) TYPE(*CHAR) LEN(10)
                 DCL        VAR(&SPLFNBR) TYPE(*DEC) LEN(5)
    
    /* Spoolfile number: *CHAR...                                                */
                 DCL        VAR(&SPLFNBR_C) TYPE(*CHAR) LEN(5)
    
    /* Recipient internet address...                                             */
                 DCL        VAR(&INTNETADR) TYPE(*CHAR) LEN(253)
    
    /* A message to go with the spoolfile...                                     */
                 DCL        VAR(&MSG) TYPE(*CHAR) LEN(256)
    
    /*                                                                           */
    /* Break out the qualified job name...                                       */
    /*                                                                           */
                 DCL        VAR(&JOB) TYPE(*CHAR) LEN(10)
                 DCL        VAR(&JOBUSER) TYPE(*CHAR) LEN(10)
                 DCL        VAR(&JOBNBR) TYPE(*CHAR) LEN(6)
    
    /*                                                                           */
    /* Spoolfile attributes, used to find spoolfile record length...             */
    /*                                                                           */
                 DCL        VAR(&SPLFA) TYPE(*CHAR) LEN(1142)
    
    /* Used for spoolfile record length...                                       */
                 DCL        VAR(&RLEN) TYPE(*DEC) LEN(9)
    
    /*                                                                           */
    /* Temporary workfile and folder names...                                    */
    /*                                                                           */
                 DCL        VAR(&SPLFPF) TYPE(*CHAR) LEN(10) VALUE(#$SPLFPF)
                 DCL        VAR(&SPLFFLR) TYPE(*CHAR) LEN(12) VALUE(#$SPLF.FLR)
    
    /* Working document name...                                                  */
                 DCL        VAR(&DOCNAM) TYPE(*CHAR) LEN(12)
    
    
    /*---------------------------------------------------------------------------*/
    
    /*                                                                           */
    /* Global monitor message...                                                 */
    /*                                                                           */
                 MONMSG     MSGID(CPF0000 CPF9999 MCH0000) EXEC(GOTO CMDLBL(STDERR))
    
    /*---------------------------------------------------------------------------*/
    
    /*                                                                           */
    /* Get parameter values into working fields...                               */
    /*                                                                           */
                 CHGVAR     VAR(&JOB) VALUE(%SST(&PQJOB 1 10))
                 CHGVAR     VAR(&JOBUSER) VALUE(%SST(&PQJOB 11 10))
                 CHGVAR     VAR(&JOBNBR) VALUE(%SST(&PQJOB 21 6))
    
                 CHGVAR     VAR(&INTNETADR) VALUE(&PINTNETADR)
    
                 CHGVAR     VAR(&MSG) VALUE(&PMSG)
    
                 CHGVAR     VAR(&SPLFNAM) VALUE(&PSPLFNAM)
    
                 CHGVAR     VAR(&SPLFNBR) VALUE(%BIN(&PSPLFNBR))
    
    /*                                                                           */
    /* Convert special-values for *ONLY and *LAST...                             */
    /*                                                                           */
                 IF         COND(&SPLFNBR *EQ 0) THEN(DO)
                    CHGVAR     VAR(&SPLFNBR_C) VALUE('*ONLY')
                 ENDDO
                 ELSE       CMD(IF COND(&SPLFNBR *EQ -1) THEN(DO))
                    CHGVAR     VAR(&SPLFNBR_C) VALUE('*LAST')
                 ENDDO
                 ELSE       CMD(DO)
                    CHGVAR     VAR(&SPLFNBR_C) VALUE(&SPLFNBR)
                 ENDDO
    
    /*                                                                           */
    /* Get Spoolfile Attributes structure for the specified spoolfile name and   */
    /*   number and job name. Note that job name '*' can't be broken out into    */
    /*   its qualified parts (unless we retrieve the current job's name first)...*/
    /*                                                                           */
                 IF         COND(&PQJOB *EQ '*') THEN(DO)
                    RTVSPLFAST SPLFA(&SPLFA) JOB(*) SPLFNAM(&SPLFNAM) SPLFNBR(&SPLFNBR)
                 ENDDO
    
                 ELSE       CMD(DO)
                    RTVSPLFAST SPLFA(&SPLFA) JOB(&JOBNBR/&JOBUSER/&JOB) SPLFNAM(&SPLFNAM) +
                                 SPLFNBR(&SPLFNBR)
                 ENDDO
    
    /* Extract the spoolfile record length...                                    */
                 CHGVAR     VAR(&RLEN) VALUE(%BIN(&SPLFA 429 4) + 1)
    
    /*                                                                           */
    /* Delete any temporary workfile we might've created earlier...              */
    /*                                                                           */
                 DLTF       FILE(QTEMP/&SPLFPF)
                 MONMSG     MSGID(CPF2105)
    
    /* Create a workfile appropriate to our current spoolfile...                 */
                 CRTPF      FILE(QTEMP/&SPLFPF) RCDLEN(&RLEN)
    
    /*                                                                           */
    /* Copy our current spoolfile into our temporary workfile. Note that we use  */
    /*   *FCFC for forms control. Note that job name '*' can't be broken out into*/
    /*   its qualified parts (unless we retrieve the current job's name first)...*/
    /*                                                                           */
                 IF         COND(&PQJOB *EQ '*') THEN(DO)
                    CPYSPLF    FILE(&SPLFNAM) TOFILE(QTEMP/&SPLFPF) SPLNBR(&SPLFNBR_C) +
                                 CTLCHAR(*FCFC)
                 ENDDO
    
                 ELSE       CMD(DO)
                    CPYSPLF    FILE(&SPLFNAM) TOFILE(QTEMP/&SPLFPF) JOB(&JOBNBR/&JOBUSER/&JOB) +
                                 SPLNBR(&SPLFNBR_C) CTLCHAR(*FCFC)
                 ENDDO
    
    /*                                                                           */
    /* Delete any temporary work folder we might've created earlier...           */
    /*                                                                           */
                 DLTDLO     DLO(&SPLFFLR)
                 MONMSG     MSGID(CPF8A16)
    
    /* Create a work folder for our spoolfile document...                        */
                 CRTFLR     FLR(&SPLFFLR)
                 MONMSG     MSGID(CPF8A18)
    
    /* Create a document name based on spoolfile name...                         */
                 CHGVAR     VAR(&DOCNAM) VALUE(%SST(&SPLFNAM 1 8) *TCAT '.TXT')
    
    /*                                                                           */
    /* Get our spoolfile from our workfile into our work document...             */
    /*                                                                           */
                 CPYTOPCD   FROMFILE(QTEMP/&SPLFPF) TOFLR(&SPLFFLR) TODOC(&DOCNAM) REPLACE(*YES)
    
                 SNDDST     TYPE(*DOC) TOINTNET((&INTNETADR)) DSTD('AS/400 report') MSG(&MSG) +
                              DOC(&DOCNAM) FLR(&SPLFFLR)
    
    /*                                                                           */
    /* General cleanup before exit...                                            */
    /*                                                                           */
                 DLTF       FILE(QTEMP/&SPLFPF)
    
                 DLTDLO     DLO(&DOCNAM) FLR(&SPLFFLR)
                 DLTDLO     DLO(&SPLFFLR)
    
                 RETURN
    
    
    /*                                                                           */
    /* Standard error processing...                                              */
    /*                                                                           */
     STDERR:     MOVDIAGMSG
                 MONMSG     MSGID(CPF0000 MCH0000)
    
                 RSNESCMSG
                 MONMSG     MSGID(CPF0000 MCH0000)
    
    
                 RETURN
    
    
                 ENDPGM



    There are 3 commands in the CPP: RTVSPLFAST, MOVDIAGMSG & RSNESCMSG

    RTVSPLFAST:
    Code:
    /*           CRTCMD     CMD(mylib/RTVSPLFAST) +                       */
    /*                      PGM(QSYS/QUSRSPLA) +                          */
    /*                      SRCFILE(mylib/mysrcf) +                       */
    /*                      SRCMBR(RTVSPLFAST) +                          */
    /*                      TEXT('Retrieve Spool File Attribute Struture  */
    /*                      ALLOW( +                                      */
    /*                        *IREXX +                                    */
    /*                        *BREXX +                                    */
    /*                        *BPGM +                                     */
    /*                        *IPGM)                                      */
    
                 CMD        PROMPT('Retrieve *splf attr struct')
    
                 PARM       KWD(SPLFA) TYPE(*CHAR) LEN(1142) RTNVAL(*YES) MIN(1) +
                              PROMPT('Attributes structure')
                 PARM       KWD(STRUCLEN) TYPE(*INT4) CONSTANT(1142) MIN(1)
                 PARM       KWD(FORMATNAM) TYPE(*NAME) LEN(8) CONSTANT(SPLA0100) MIN(1)
    
                 PARM       KWD(JOB) TYPE(Q0161) SNGVAL( (* )) MIN(1) PROMPT('Qualified job name')
     Q0161:      QUAL       TYPE(*NAME) LEN(10) MIN(1) EXPR(*YES)
    
                 QUAL       TYPE(*NAME) LEN(10) EXPR(*YES) PROMPT('Job user')
                 QUAL       TYPE(*CHAR) LEN(6) RANGE( '000000' '999999') EXPR(*YES) PROMPT('Job +
                              number')
    
                 PARM       KWD(INTJOBID) TYPE(*CHAR) LEN(16) CONSTANT('                ') MIN(1)
                 PARM       KWD(INTSPLFID) TYPE(*CHAR) LEN(16) CONSTANT('                ') MIN(1)
                 PARM       KWD(SPLFNAM) TYPE(*NAME) LEN(10) MIN(1) EXPR(*YES) PROMPT('*SPLF name')
                 PARM       KWD(SPLFNBR) TYPE(*INT4) DFT(*LAST) RANGE( -1 9999) SPCVAL( (*ONLY 0) +
                              (*LAST -1)) EXPR(*YES) PROMPT('*SPLF number')
    MOVDIAGMSG:
    Code:
    /*           CRTCMD     CMD(mylib/MOVDIAGMSG) +                    */
    /*                      PGM(QSYS/QMHMOVPM) +                       */
    /*                      SRCFILE(mylib/mysrc) +                     */
    /*                      SRCMBR(MOVDIAGMSG) +                       */
    /*                      ALLOW( +                                   */
    /*                        *IREXX +                                 */
    /*                        *BREXX +                                 */
    /*                        *BPGM +                                  */
    /*                        *IPGM)                                   */
    
                 CMD        PROMPT('Move Diagnostic Message')
    
                 PARM       KWD(MSGKEY) TYPE(*CHAR) LEN(4) CONSTANT('    ')
                 PARM       KWD(MSGTYP) TYPE(*CHAR) LEN(10) CONSTANT(*DIAG)
                 PARM       KWD(NBRTYPS) TYPE(*INT4) CONSTANT(1)
                 PARM       KWD(MSGQ) TYPE(*CHAR) LEN(10) CONSTANT(*)
                 PARM       KWD(STCKCNT) TYPE(*INT4) CONSTANT(1)
                 PARM       KWD(ERRCOD) TYPE(*INT4) CONSTANT(0)
    RSNESCMSG:
    Code:
    /*           CRTCMD     CMD(mylib/RSNESCMSG) +                     */
    /*                      PGM(QSYS/QMHRSNEM) +                       */
    /*                      SRCFILE(mylib/mysrc) +                     */
    /*                      SRCMBR(RSNESCMSG)                          */
    
                 CMD        PROMPT('Resend Escape Message')
    
                 PARM       KWD(MSGKEY) TYPE(*CHAR) LEN(4) CONSTANT('    ')
                 PARM       KWD(ERRCOD) TYPE(*INT4) CONSTANT(0)
    http://www.linkedin.com/in/chippermiller

  • #2
    Re: Problems with SNDDST

    i cheat...i downloaded MMAIL from easy400.net it has a command that will do everything you are trying to do but it uses the IFS and the QTMMSENDMAIL API which is more flexible.
    I'm not anti-social, I just don't like people -Tommy Holden

    Comment


    • #3
      Re: Problems with SNDDST

      Originally posted by tomholden View Post
      i cheat...i downloaded MMAIL from easy400.net it has a command that will do everything you are trying to do but it uses the IFS and the QTMMSENDMAIL API which is more flexible.
      I don't mind cheating if it accomplishes the goal.
      Thanks for the link -- let me see if this method works.
      http://www.linkedin.com/in/chippermiller

      Comment


      • #4
        Re: Problems with SNDDST

        THis may help if you need something quick



        jamie
        All my answers were extracted from the "Big Dummy's Guide to the As400"
        and I take no responsibility for any of them.

        www.code400.com

        Comment


        • #5
          Re: Problems with SNDDST

          Thanks for the help. I downloaded MMail to my PC but am having trouble doing the ftp to the 400. Need to review Jamie's link in more detail when my brain isn't so fried.
          http://www.linkedin.com/in/chippermiller

          Comment


          • #6
            Re: Problems with SNDDST

            Please take a look at this one for attachments (my bad)

            All my answers were extracted from the "Big Dummy's Guide to the As400"
            and I take no responsibility for any of them.

            www.code400.com

            Comment


            • #7
              Re: Problems with SNDDST

              Hi Chipper:

              I think you also have to add some directory entries for snddst to work. ( *any comes to mind)Google "snddst setup". This is the first one to come up for me.



              Also see Scott Klement's comments here:



              Best of Luck
              GLS
              Last edited by GLS400; February 14, 2008, 08:14 AM. Reason: added S.K. Link
              The problem with quotes on the internet is that it is hard to verify their authenticity.....Abraham Lincoln

              Comment


              • #8
                Re: Problems with SNDDST

                Update: it looks like our e-mail provider is filtering out the e-mail. I have had some discussions with some people (not the e-mail provider) who say this is probably what is happening. I have had a suspicion that this is what was happening (due to previous research on this project), but was hoping that it might be something else that was the problem. (I thought if I asked the question again, I might get a different answer.)
                http://www.linkedin.com/in/chippermiller

                Comment


                • #9
                  Re: Problems with SNDDST

                  Hi Chipper

                  sorry to jump in on the back end here and I'm almost positive that you've done all of these already:
                  (I am on holiday so I cannot provide you with names etc)

                  Have the 2 wrkdire (gateway & 1 other) entries been setup?
                  Have you tried ending then starting the mail server?
                  (and inbetween maybe resetting the dtaara that controls the start of the mailserver? (If I remember correctly, a 'C' clears all messages not yet sent and a 'W' clears only the one that's causing the problem.)
                  Regards

                  Kit
                  http://www.ecofitonline.com
                  DeskfIT - ChangefIT - XrefIT
                  ___________________________________
                  There are only 3 kinds of people -
                  Those that can count and those that can't.

                  Comment


                  • #10
                    Re: Problems with SNDDST

                    Originally posted by kitvb1 View Post
                    Hi Chipper

                    sorry to jump in on the back end here and I'm almost positive that you've done all of these already:
                    (I am on holiday so I cannot provide you with names etc)

                    Have the 2 wrkdire (gateway & 1 other) entries been setup?
                    Have you tried ending then starting the mail server?
                    (and inbetween maybe resetting the dtaara that controls the start of the mailserver? (If I remember correctly, a 'C' clears all messages not yet sent and a 'W' clears only the one that's causing the problem.)
                    Hi Kit --

                    Thanks for the info -- I'm really new at this and am sort of in a "baptism by fire" situation. Let me do a little bit of research and see if this is what is causing the situation. I've done a little bit with the wrkdire (a consultant helped with that part so I'm not totally sure what he did here). However, I've gotten my feet wet a little between when he set things up and now. I'll also try the mailserver thing as well. Again, thanks for your help.
                    http://www.linkedin.com/in/chippermiller

                    Comment


                    • #11
                      Re: Problems with SNDDST

                      Hi Superiors,
                      Need help
                      Already able to send email using SMTP
                      Strange thing happen when use SNDDST *DOC
                      The subject is always changed to TEST
                      when using LMSG and MSG the subject is the same with DSTD.
                      Help help


                      Br,
                      Union123

                      Comment


                      • #12
                        Re: Problems with SNDDST

                        Pls create a new thread if you're posing a new question. Thanks.
                        Philippe

                        Comment


                        • #13
                          Re: Problems with SNDDST

                          Very sorry, and thank you

                          Comment

                          Working...
                          X