The problem we need to solve: * In this particular field on the interface file, we want to show the work order, if the work order has been defined. * BUT, if it has not been defined, we want to use the distribution code. * UNLESS the transaction is for a BURDEN posting, then we need to replace the last four characters of the work order with a constant 8299. A pseudo-code interpretation could look like this: {{{ decode (WORK_ORDER, <--- Check the Work Order null , DISTR_CODE <--- If it is NULL (not provided) then use the Distribution Code , <--- otherwise (not a paired set of values for the DECODE ... decode (GL_ACCOUNT_CODE, <--- Check the GL ACCOUNT CODE 'D-BURDEN EXP', <--- If it is the code used for Burden then ... substr(WORK_ORDER,1, <--- Get the Work Order from the first character to where the ‘/’ is in WORK_ORDER) ||'/8299', <--- Concatenate the constant value WORK_ORDER) <--- Otherwise just use the WORK ORDER ) }}} We see that these pieces are available in the GL BUFFER: * WORK_ORDER 523 for 50 chars. * DISTR_CODE 51 for 50 chars. * GL_ACCOUNT_CODE 101 for 16 chars. We will want to remove trailing blanks and so we can replace them as follows |WORK_ORDER | {{rtrim(substr(~,523,50))}} |DISTR_CODE | {{trim(substr(~,51,50))}} |GL_ACCOUNT_CODE | {{rtrim(substr(~,101,16))}} Now we can replace the pseudo code with the real derivations: {{{ decode (rtrim(substr(~,523,50)), null,rtrim(substr(~,51,50)) , decode (substr(~,101,12), 'D-BURDEN EXP', substr(rtrim(substr(~,523,50)),1, instr(substr(~,523,50),'/')-1) || '/8299', rtrim(substr(~,523,50))) ) }}}