The iSeries machines that have been the mainstay of my application career offers a pretty incredible variety of development tools and disciplines. In addition to Higher Level Languages (HLL) such as RPG, COBOL, and Java, there are tag languages (UIM) and CGI script elements that find their way into iSeries development efforts.

Odds and Ends

UIM is an IBM function that has been around for a number of years. It is a tag language which takes advantage of Presentation Manager. The source defines the data and functions that are to appear, and Presentation Manager contols the display (presentation).

NetData is IBM built CGI script tool that exists on the iSeries. It is similar in structure to PHP, creating a method of generating dynamic web pages using SQL and HLL applicaiton programs.

XML is becoming a much more prevalent form of data exchange. The example here is an X12 EDI ASN (856) document based on a FIDX schema. The unique thing about this document is that it was written by an RPG application program!

Some people think check digits are a pain in the neck. Quite frankly, I have a much lower opinion of them. The idea of a check digit is not new, but that hasn't stopped certain organizations from trying to re-invent them.

Bound RPG writing IFS file data

 *================================================================
 * Write header portion of file
 *================================================================
CSR   @MIME         BEGSR
C                   TIME                    $$DATE
C                   TIME                    $$TIME
C                   EXTRCT    $$DATE:*M     W$MN2
C                   EXTRCT    $$DATE:*D     W$DY2
C                   EXTRCT    $$DATE:*Y     W$YR2
C                   EXTRCT    $$TIME:*H     TIMEH2
C                   EXTRCT    $$TIME:*MN    TIMEM2
C                   EXTRCT    $$TIME:*S     TIMES2
 * Open file
C                   EVAL      FullName = %TRIMR(FileName) + Null
C                   EVAL      FileDesc = open(%ADDR(FullName)
C                               : O_CREAT + O_WRONLY + O_TRUNC +
C                                 O_CODEPAGE
C                               : S_IRWXU + S_IROTH
C                               : AsciiCodePage)
C                   EVAL      ReturnInt = close(FileDesc)
C                   EVAL      FileDesc = open(%ADDR(FullName)
C                               : O_TEXTDATA + O_RDWR)
 * Build MIME header fields
C                   EVAL      MSender =
C                             'Sender: ' + SndOrg
C                   EVAL      MDateTime =
C                             'Date: '
 *                            %Trimr(W$DATE) + ' ' +
 *                            %Trimr(W$TIME2)
 *
C                   EVAL      MFrom =
C                             'From: ' +
C                             %Trimr(P$ORIG) + ' <' +
C                             %Trimr(SndOrg) + '>'
C                   EVAL      MMimeVer =
C                             'MIME-Version: 1.0'
 *
C                   IF        P$NAME > *Blanks
C                   EVAL      MTo =
C                             'To: ' + %TRIMR(P$NAME) +
C                             ' <' + %TRIMR(Address) + '>'
C                   ELSE
C                   EVAL      MTo =
C                             'To: ' + %TRIMR(Address)
C                   ENDIF
C                   IF        P$SUBJ > *Blanks
C                   EVAL      MSubject =
C                             'Subject: ' + P$SUBJ
C                   ELSE
C                   EVAL      MSubject =
C                             'Subject: ' + 'Thank You'
C                   ENDIF
C                   EVAL      MsgData = %Trimr(MSender) +
C                             EOR +
C                             %Trimr(MDateTime) +
C                             EOR +
C                             %Trimr(MFrom) +
C                             EOR +
C                             %Trimr(MTo) +
C                             EOR +
C                             %Trimr(MSubject) +
C                             EOR +
C                             %Trimr(MMimeVer) +
C                             EOR +
C                             'Content-Type: multipart/alternative; ' +
C                             'boundary =' +
C                             '"' + %Trimr(MBoundary) + '"' +
C                             EOR + EOR +
C                             'This is a multipart message in MIME ' +
C                             'format.' + eor
 *---------------------------------------------------------------------
 * Set boundary for text, get text message
 *---------------------------------------------------------------------
C                   IF        (P$TYPE  = '*TEXT') or (P$TYPE  = '*BOTH')
C                   Eval      MsgData = %Trimr(MsgData) + EOR +
C                             '--' + %Trim(MBoundary) + EOR +
C                             'Content-Type: text/plain; ' +
C                             'charset="us-ascii"' +
C                             EOR +
C                             'Content-Transfer-Encoding: 7bit' +
C                             EOR + EOR +
C                             %Trimr(Textmsg) +
C                             EOR + EOR + EOR + EOR +
C                             '--' + %Trimr(MBoundary)
C                   ENDIF
 * Trim data
C                   IF        P$TYPE  = '*BOTH'
C                   Eval      MsgData = %trim(MsgData) + EOR + EOR
C                   ENDIF
 *---------------------------------------------------------------------
 * Set boundary for HTML, get text message
 *---------------------------------------------------------------------
C                   IF        (P$TYPE  = '*HTML') or (P$TYPE  = '*BOTH')
C                   Eval      MsgData = %Trimr(MsgData) + EOR +
C                             '--' + %Trimr(MBoundary) + eor +
C                             'Content-Type: text/html; ' +
C                             'charset="us-ascii"' +
C                             EOR +
C                             'Content-Transfer-Encoding: 7bit' +
C                             EOR + EOR + EOR + EOR +
C                             %Trimr(HTMLmsg) +
C                             EOR + EOR + EOR + EOR +
C                             '--' + %Trimr(MBoundary)
C                   ENDIF
 *---------------------------------------------------------------------
 * Add attachment file(s) if requested
 *---------------------------------------------------------------------
C                   IF        NbrFiles > *Zero
C                             and AttachFile(1) <> '*NONE'
C                   Exsr      @WRITE
C                   DO        NbrFiles      Z                 5 0
C                   Clear                   SavePos
C                   Eval      Pos = %Scan('/':AttachFile(Z):1)
C                   DOW       Pos > *Zero
C                   Eval      SavePos = Pos
C                   Eval      Pos = %Scan('/':AttachFile(Z):Pos+1)
C                   ENDDO
C                   IF        SavePos <> *Zero
C                   Eval      AttachName = %Subst(AttachFile(Z):SavePos+1)
C                   ELSE
C                   Eval      AttachName = AttachFile(Z)
C                   ENDIF
C                   Eval      MsgData = EOR +
C                             'Content-Type: application/octet' +
C                             '-stream; name="' +
C                             %Trimr(AttachName) + '"' +
C                             EOR +
C                             'Content-Transfer-Encoding: 7bit' +
C                             EOR +
C                             'Content-Disposition: inline; filename="' +
C                             %Trimr(AttachName) + '"' +
C                             EOR + EOR
C                   Exsr      @WRITE
 * Open file
C                   Eval      FullName = %TRIMR(AttachFile(Z)) + Null
C                   Eval      AttachDesc = open(%ADDR(FullName)
C                               : O_RDONLY + O_TEXTDATA)
 *---------------------------------------------------------------------
 * Read from file and write to MIME file
 *---------------------------------------------------------------------
C                   Eval      BytesRead = read(AttachDesc
C                               : %Addr(DataRead)
C                               : %Size(DataRead))
C                   DOW       BytesRead > 0
C                   Eval      MsgData = %Subst(DataRead:1:BytesRead)
C                   Eval      BytesWrt = write(FileDesc
C                               : %ADDR(MsgData)
C                               : %LEN(%TRIMR(MsgData)))
C                   Eval      BytesRead = read(AttachDesc
C                               : %Addr(DataRead)
C                               : %Size(DataRead))
C                   ENDDO
 * Close attachment file and write to MIME
C                   Eval      ReturnInt = close(AttachDesc)
C                   IF        Z >= NbrFiles
C                   Eval      MsgData = EOR +
C                             '--' + %Trimr(MBoundary) +
C                             EOR + EOR
C                   ELSE
                   Eval      MsgData = EOR +
C                             '--' + %Trimr(MBoundary)
C                   ENDIF
C                   Exsr      @WRITE
C                   ENDDO
                   ELSE
 * Write end of MIME file for e-mail
C                   EVAL      MsgData = %Trimr(MsgData) + '--' + EOR + EOR
C                   EXSR      @WRITE
C                   ENDIF
 * Close file
C                   EVAL      ReturnInt = close(FileDesc)
 *
CSR                 ENDSR
	  
	

Contents