ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

converting graphic data types in CLP

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

  • converting graphic data types in CLP

    Hello all,

    I have a table with the field CCSDSC. It is of type graphic,
    Code:
    CCSDSC     GRAPHIC        15      30       119        Both     Short Description
      Field text  . . . . . . . . . . . . . . . :  Short Description                
      Coded Character Set Identifier  . . . . . :  13488                            
      UCS2 or Unicode conversion  . . . . . . . :  *CONVERT
    I am using this in a CLP program like so:
    Code:
    DCLF   FILE(*LIBL/ZCC) ALWGRAPHIC(*YES)
    DCL &CHCCSDSC *CHAR
    
    OVRDBF     FILE(ZCC) SHARE(*YES)                    
    OPNQRYF    FILE((ZCC)) QRYSLT('CCTABL = "EDIASNCT"')
    
    DOWHILE COND('1')                                  
    RCVF                                                
    CHGVAR VAR(&CHCCSDSC) VALUE(&CCSDSC)                // my attempt to convert to CHAR
    
    MONMSG  MSGID(CPF0864) EXEC(LEAVE)                  
    SBMJOB  CMD(CALL ADDMBXPGM (&CHCCSDSC &CCCODE)) +  
            JOBQ(*LIBL/EDIASNCLJQ)                        
    ENDDO                                              
    
    CLOF OPNID(ZCC)
    the ADDMBXPGM command has 2 parameters, &CHCCSDC and &CCCODE. CCCODE is a CHAR, so that is not causing any problems, but CCSDSC is a graphic, and even though I am using CHGVAR to convert it into CHAR, it is still giving me a value in graphic (attached SS of the value). What am I doing wrong here? Any help would be appreciated!

    EDIT: in the job log, I see that it passes in the correct parameter from the ZCC table but in USC2 form...I have attached a screenshot (some things masked)
    so I guess all I need to do is to convert this USC2 to normal characters...I tried CHGVAR VAR(&CHCCSDSC) VALUE(%CHAR(&CCSDSC)) but it says built in function %CHAR is not a valid...Please help
    Attached Files

  • #2
    CL doesn't handle graphic data. The %CHAR() function makes numeric values available in character form, and CHGVAR doesn't do character encoding conversions.

    I've never needed to use graphic data in CL, and it's been quite a while since I needed to do encoding conversions. I might start with the iconv()--Code Conversion APIs. (There might be newer options.)
    Tom

    There are only two hard things in Computer Science: cache invalidation, naming things and off-by-one errors.

    Why is it that all of the instruments seeking intelligent life in the universe are pointed away from Earth?

    Comment


    • #3
      I think you might be able to handle this in the OPNQRYF command by using the MAPFLD parameter. You might be able to map the field to itself:
      Code:
      OPNQRYF    FILE((ZCC)) QRYSLT('CCTABL = "EDIASNCT"') MAPFLD((CCSDSC '1.ccsdsc' *CHAR length *N 37))
      Or if that doesn't work, map the field into another character field in the ZCC file and use the other field on the SBMJOB:
      Code:
      OPNQRYF    FILE((ZCC)) QRYSLT('CCTABL = "EDIASNCT"') MAPFLD(([I]fieldname[/I] '1.ccsdsc'))
      
      SBMJOB  CMD(CALL ADDMBXPGM (&[I]fieldname[/I] &CCCODE)) +
              JOBQ(*LIBL/EDIASNCLJQ)

      Comment

      Working...
      X