× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Chris,

Sorry for not getting back to you sooner, but work keeps getting in
the way...

Anyway, here is a sample ILE RPG program which basically creates an
EBCDIC (37) to ASCII (819) conversion table and then converts some
CCSID 37 data to CCSID 819 using MI.  I think you will see that it
can be easily changed to work with any of the SBCS encodings you may
want to use.

Bruce Vining

     D* compile with DFTACTGRP(*NO)
     D* sample program assumes that the *SRCF is CCSID(37) as variable
     D*        TestData values are imbedded in the program source
     D* no error checking is provided (if you give "bad" CCSIDs to
     D*        QTQCVRT)
     D*
     D* Mapping tables
     D*
     DStartMap         s            256
     DTo819            s            256
     D*
     D* Data variables
     D*
     DTestData         s             50    inz('This is test data')
     D*
     D* Parameters for QTQCVRT/CDRCVRT API, see API Reference for details
     D*
     DCCSID1           s             10i 0 inz(37)
     DST1              s             10i 0 inz(0)
     DL1               s             10i 0 inz(%size(StartMap))
     DCCSID2           s             10i 0 inz(819)
     DST2              s             10i 0 inz(0)
     DGCCASN           s             10i 0 inz(0)
     DL2               s             10i 0 inz(%size(To819))
     DL3               s             10i 0
     DL4               s             10i 0
     DFB               s             12
     D*
     D* Prototype the MI instruction
     D*
     DConvert          PR                  EXTPROC('_XLATEB')
     D                                 *   VALUE
     D                                 *   VALUE
     D                               10u 0 VALUE
     D*
     D* Working area to get hex values
     D*
     D                 ds
     D x                              5i 0
     D LowX                    2      2
     C*
     C* Initialize StartMap from x'00' to x'FF'
     C*
     C     0             do        255           x
     C                   eval      %subst(StartMap:x+1:1) = LowX
     C                   enddo
     C*
     C* Now get translate table values for CCSID 37 to CCSID 819
     C*
     C                   call      'QTQCVRT'
     C                   parm                    CCSID1
     C                   parm                    ST1
     C                   parm                    StartMap
     C                   parm                    L1
     C                   parm                    CCSID2
     C                   parm                    ST2
     C                   parm                    GCCASN
     C                   parm                    L2
     C                   parm                    To819
     C                   parm                    L3
     C                   parm                    L4
     C                   parm                    FB
     C*
     C* Now convert 'This is test data' to 819 from 37 using MI
     C*
     C                   callp     Convert( %addr(TestData)
     C                                     :%addr(To819)
     C                                     :%size(TestData))
     C*
     C* Look at TestData under debug at this point, and you should
     C* find x'5468697320697320746573742064617461202020...' which is
     C* the CCSID 819 equivalent of 'This is test data'
     C*
     C                   eval      *inlr = '1'
     C                   return
>
>WOW,
>
>Can't beat MI in any program.  How do you execute MI from RPGLE?
>

+---
| This is the RPG/400 Mailing List!
| To submit a new message, send your mail to RPG400-L@midrange.com.
| To subscribe to this list send email to RPG400-L-SUB@midrange.com.
| To unsubscribe from this list send email to RPG400-L-UNSUB@midrange.com.
| Questions should be directed to the list owner/operator: david@midrange.com
+---


As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.