GL BUFFER EXAMPLE 01

The problem we need to solve:

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:

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)))
      )


Notes#

Click to create a new notes page