Using IBM i? Need to create Excel, CSV, HTML, JSON, PDF, SPOOL reports? Learn more about the fastest and least expensive tool for the job: SQL iQuery.
Here's a routine I wrote a couple years ago that mimics the MOVE opcode for character fields. Remember that free format has the EVALR opcode which works similar to this, except it clears the target/results unless %SUBST is used on that target/result variable.
D CEEGSI PR extproc('CEEGSI') D nParmNum 10I 0 Const D nParmDataType 10I 0 D nParmCurLen 10I 0 D nParmMaxLen 10I 0 D szParmError 12A OPTIONS(*OMIT) D moveR PR OPDESC D target 32767A OPTIONS(*VARSIZE) D source 32767A OPTIONS(*VARSIZE) Const P moveR B D moveR PI OPDESC D target 32767A OPTIONS(*VARSIZE) D source 32767A OPTIONS(*VARSIZE) Const D tLen S 10I 0 D tDataType S 10I 0 D tMaxLen S 10I 0 D sLen S 10I 0 D sDataType S 10I 0 D sMaxLen S 10I 0 /free ceegsi(1 : tdataType : tLen : tMaxLen : *OMIT); ceegsi(2 : sdataType : sLen : sMaxLen : *OMIT); if (sLen > tLen); EVALR %subst(target:1:tLen) = %subst(source:1:tLen); else; %subst(target:tLen-(sLen-1):sLen) = %subst(source:1:sLen); endif; /end-free P moveR E