Nov 20, 2014

Epicor Adapter in ABL code

{bo/UD14/UD14_ds.i}
define variable morePages as logical.
define variable i as integer.
define variable hUD14 as handle.
define variable iOrderNum as integer.
define variable cRepList as character.
find first ttUD108 where ttUD108.Company = cur-comp
                                        and ttUD108.RowMod = "D" no-lock no-error.
if available ttUD108 then do:
    {lib/PublishInfoMsg.i &InfoMsg= "'Assign LegalNumner: ' + ttUD108.Character01"}
    RUN bo\UD14\UD14.p PERSISTENT SET hUD14.
  if VALID-HANDLE (hUD14) THEN DO:
        RUN GetRows IN hUD14 (input "Key1 = '" + STRING(iOrderNum) + "'", input "", {&output_dataset_UD14DataSet}, input 0, input 0, output morePages) NO-ERROR.
    /* Delete existing rows for this sales order before rebuilding */
        for each ttUD14:
         RUN DeleteByID IN hUD14 (input ttUD14.Key1, input ttUD14.Key2, input ttUD14.Key3, input ttUD14.Key4, input ttUD14.Key5) NO-ERROR.
    end.
        /* rerun to clear out temp tables */
    RUN GetRows IN hUD14 (input "Key1 = '" + STRING(iOrderNum) + "'", input "", {&output_dataset_UD14DataSet}, input 0, input 0, output morePages) NO-ERROR.
        repeat i = 1 TO num-entries(cRepList,"~~"):
            RUN GetaNewUD14 IN hUD14 ( {&input-output_dataset_UD14DataSet} ) NO-ERROR.
            for each ttUD14 where ttUD14.RowMod = "A":
                assign ttUD14.Key1 = STRING(iOrderNum).
          assign ttUD14.Key2 = STRING(i).
          assign ttUD14.ShortChar01 = entry(i, cRepList, "~~").
          assign ttUD14.Number01 = iOrderNum.
                if i = 1 then do:
            assign ttUD14.Number02 = 1.
            assign ttUD14.Number03 = 2.
        end.
        else if i = 2 then do:
            assign ttUD14.Number02 = 2.
            assign ttUD14.Number03 = 1.
        end.    
                RUN Update IN hUD14 ({&input-output_dataset_UD14DataSet}) NO-ERROR.    
            end.
        end.
    end.
  else do:
        message "Could not create handle to UD14.p!".
  end.
    delete object hUD14.
end.

           
                      
                       
                       
                       
                                   
               
                                        
           

0 comments:

Post a Comment

Nam Le © 2014 - Designed by Templateism.com, Distributed By Templatelib