Baanboard.com

Go Back   Baanboard.com > Forum > Baan Quick Support: Functional & Technical > Tools Development

User login

Frontpage Sponsor

Main

Poll
For ERP LN feature pack upgrade, what method of install are you using?
Installation Wizard into existing VRC
35%
Installation Wizard into new VRC
42%
Manual into existing VRC
3%
Manual into new VRC
19%
Total votes: 31

Baanboard at LinkedIn


Reference Content

Reply
 
Thread Tools Display Modes
  #1  
Old 30th May 2008, 18:08
manojsharma's Avatar
manojsharma manojsharma is offline
Senior Member
 
Join Date: Sep 2002
Location: Delhi
Posts: 200
manojsharma is on a distinguished road
Baan: 4C4, 5, Baan LN - DB: Oracle,informix - OS: Unix, NT, Windows-2000
bshell received SIGTERM
Baan: Other/Unknown
C/S: None/Unknown

Hi,

sometimes, when I run a session manually or through Job, it get hang. On viewing the bshell log, I found the error "log msg : bshell received SIGTERM"

Can anybody help me, what is this problem and how to solve this.

Thanks in advance
__________________
Together we can and we will make a difference
Reply With Quote
  #2  
Old 30th May 2008, 18:51
shah_bs's Avatar
shah_bs shah_bs is offline
Guru
 
Join Date: Jan 2002
Location: Lewisville, Texas
Posts: 387
shah_bs is on a distinguished road
Baan: BAAN IVc3 with A&D2.2b - DB: ORACLE 9 - OS: HPUX
Well, the SIGTERM message is logged AFTER you have quit out of the session BECAUSE you forcefully quit the session. The hanging is because of some other reasons. The only way I know is to run the session under debug to see where it seems to slow down.
Reply With Quote
  #3  
Old 30th May 2008, 19:13
NPRao's Avatar
NPRao NPRao is offline
Guru
 
Join Date: Aug 2001
Location: Pacific NW, USA
Posts: 3,028
NPRao will become famous soon enough
Baan: iBaanERP-5.2a(Reger),SSA-ERP-LN-6.1,Infor LN-10.x - DB: Oracle-10g,11g,12c,MS-SQL - OS: HP-UX, Linux, Windows
If you are on UNIX look for man kill
Quote:
signum signame Name Description
___________________________________________________________________________
0 SIGNULL Null Check access to pid
1 SIGHUP Hangup Terminate; can be trapped
2 SIGINT Interrupt Terminate; can be trapped
3 SIGQUIT Quit Terminate with core dump; can be trapped
9 SIGKILL Kill Forced termination; cannot be trapped
15 SIGTERM Terminate Terminate; can be trapped
24 SIGSTOP Stop Pause the process; cannot be trapped
25 SIGTSTP Terminal stop Pause the process; can be trapped
26 SIGCONT Continue Run a stopped process
SIGTERM (15), the (default) terminate signal, can be trapped by the
receiving process, allowing the receiver to execute an orderly
shutdown or to ignore the signal entirely. For orderly operations,
this is the perferred choice.
__________________
The art of perfection does not lie in doing extraordinary things but, doing ordinary things extraordinarily well. [-N. Prashanth Rao]
How To Ask Questions The Smart Way,BaaNBoard,NPRao
Reply With Quote
  #4  
Old 30th May 2008, 19:53
loveneesh loveneesh is offline
Member
 
Join Date: Oct 2002
Location: Delhi
Posts: 37
loveneesh is on a distinguished road
Baan: Baan 5c - DB: Oracle - OS: Unix
Hi

When I run the session in debug mode, it work fine. Actually, its a processing session which read files from a specified path on server, process the file and update baan table and session complete in 10-12 minutes.

I am running the session through Job after every one hour but sometimes, it get hang and the error "log msg : bshell received SIGTERM" reported in log.bshell and sometime "errno 0 bdb_errno213 (Transaction is started but not updated) log msg : bshell received SIGTERM .

Thanks in advance
Reply With Quote
  #5  
Old 31st May 2008, 09:02
loveneesh loveneesh is offline
Member
 
Join Date: Oct 2002
Location: Delhi
Posts: 37
loveneesh is on a distinguished road
Baan: Baan 5c - DB: Oracle - OS: Unix
Thanks NPR,

I am on HP Unix, Oracle, Baan IV c4, but how to solve this problem
Reply With Quote
  #6  
Old 2nd June 2008, 14:34
mark_h's Avatar
mark_h mark_h is offline
Guru
 
Join Date: Sep 2001
Location: Kentucky, USA
Posts: 6,905
mark_h will become famous soon enough
Baan: Baan 4C4 A&D1 - DB: Oracle - OS: Sun Solaris
Quote:
Originally Posted by loveneesh View Post
When I run the session in debug mode, it work fine. Actually, its a processing session which read files from a specified path on server, process the file and update baan table and session complete in 10-12 minutes.

I am running the session through Job after every one hour but sometimes, it get hang and the error "log msg : bshell received SIGTERM" reported in log.bshell and sometime "errno 0 bdb_errno213 (Transaction is started but not updated) log msg : bshell received SIGTERM .

Thanks in advance
It sounds to me like something is causing it to abort while processing - causing the transaction is started, but not updated message. Are you killing the job when it hangs? That would cause these messages. Have you checked the data it is processing in the file? Looking for things like control characters or escape sequences?
__________________
Mark

GO Cards!
My latest mantra - make sure you have latest stpapi patches and the latest session object. If on LN then please explore the option of using DAL2 functionality.

Shared Solutions for Baan systems provided free by Baan Board.
Play the Google game and help Baanboard get better rankings. Do your part. Click here to find how.
Reply With Quote
  #7  
Old 3rd June 2008, 06:53
loveneesh loveneesh is offline
Member
 
Join Date: Oct 2002
Location: Delhi
Posts: 37
loveneesh is on a distinguished road
Baan: Baan 5c - DB: Oracle - OS: Unix
hi

I found in log.cleandefunct that after every 10 min it killing ideal session but my session is contineously running and my session takes around 12-14 min. I dont know why it is hanging or killing out.

Actully, my session is scanning files from a particular folder on server and if the file is valid then it moves to another folder otherwise it delete file and then from the another folder it start processing the file.

Thanks in advance
Reply With Quote
  #8  
Old 3rd June 2008, 17:22
mark_h's Avatar
mark_h mark_h is offline
Guru
 
Join Date: Sep 2001
Location: Kentucky, USA
Posts: 6,905
mark_h will become famous soon enough
Baan: Baan 4C4 A&D1 - DB: Oracle - OS: Sun Solaris
Can you try changing how often that runs? Maybe instead of 10 minutes how about every 15 minutes. Just to see if that fixes the problem.
__________________
Mark

GO Cards!
My latest mantra - make sure you have latest stpapi patches and the latest session object. If on LN then please explore the option of using DAL2 functionality.

Shared Solutions for Baan systems provided free by Baan Board.
Play the Google game and help Baanboard get better rankings. Do your part. Click here to find how.
Reply With Quote
  #9  
Old 3rd June 2008, 20:01
NPRao's Avatar
NPRao NPRao is offline
Guru
 
Join Date: Aug 2001
Location: Pacific NW, USA
Posts: 3,028
NPRao will become famous soon enough
Baan: iBaanERP-5.2a(Reger),SSA-ERP-LN-6.1,Infor LN-10.x - DB: Oracle-10g,11g,12c,MS-SQL - OS: HP-UX, Linux, Windows
loveneesh,

Please post your code, it appears the bshell/session timeouts are terminating it.

Also post the contents of $BSE/lib/bse_vars, $BSE/lib/defaults/all
__________________
The art of perfection does not lie in doing extraordinary things but, doing ordinary things extraordinarily well. [-N. Prashanth Rao]
How To Ask Questions The Smart Way,BaaNBoard,NPRao
Reply With Quote
  #10  
Old 4th June 2008, 07:59
loveneesh loveneesh is offline
Member
 
Join Date: Oct 2002
Location: Delhi
Posts: 37
loveneesh is on a distinguished road
Baan: Baan 5c - DB: Oracle - OS: Unix
Thanks NPR,

Here is my code

PHP Code:
declaration:
    
#include <bic_tt>    
    
table    ttdwms610    |* ASN Header
    table    ttdwms611    
|* ASN Header Details
    table    ttdwms615    
|* ASN Lines
    table    ttdwms616    
|* ASN Lines Noof Packages Detail
    table    ttdwms650    
|* ASN Header History
    table    ttdwms651    
|* ASN Header Details History
    table    ttdwms655    
|* ASN Lines History...
    
table    ttdwms656    |* ASN Lines Noof Packages Detail History
    table    ttdwms600    
|* ASN Receiving Parameter

    table    ttdwms609    
|* ASN Log table
    table   ttdwms608
    
    
#define RECORDLN 600
    #define    RETLN     1500
    #define DIM1     1400
    #define    DIM2     100000
    #define PATHLEN     250
    
    
|Form Variable
    extern    domain    tcmcs
.str80    disp.messg
    
    
    
THESE ARE THE VARIABLES DEFINED FOR DIFFRENT PATHS            
            
    
INITIAL PATHS DEFINED FOR THE FILES
        string        path
.input.o(PATHLEN)                 | INPUT FILE
        string        path
.proc.o(PATHLEN)                  | PROCESSED FILE
        string        path
.log.o(PATHLEN)                   | LOG FILE
        
ACTUAL PATHS TO OPEN THE FILES                    
        string        path
.log.tmp(PATHLEN)                | LOG FILE FOR TMP FILE
        string        path
.input(PATHLEN)                    | INPUT FILE
        string        path
.proc(PATHLEN)                     | PROCESSED FILE
        string        bckp
.path(PATHLEN)                     | PROCESSED FILE for backup directory
        string        ls
.path.name(PATHLEN)                  | LIST COMMAND   
        string        mv
.path.name(PATHLEN)               | MOVE COMMAND
        string        cv
.path.name(PATHLEN)               | MOVE COMMAND            
        string        path
.move.o(PATHLEN)                | PATH FROM ASN MOVE    POLCUS1O.n    
        string        path
.move(PATHLEN)                    | FILE TO BE MOVED FROM POLCUS10.n
    
|FILE NAMES            
        string        file
.name(PATHLEN)                |FILE NAME VARIABLE
    
    
|VARIABLES FOR DIFFRENT FILE POINTERS
        long        retval
,fp,rec.ctr,ifile.ctrj,file.val ,fp.tmp,fp.log.tmp

    
    
|VARIABLE FOR STORING THE RECORD OF THE FILE
        string        retline
(RETLN),file.line(RETLN),current.record(RETLN)
    
    | ARRAY 
VARIABLE FOR STORING ALL THE DATA OF THE FILE            
        string      str_arr
(DIM1,DIM2),file_arr(DIM1,DIM2)
    
    |
OTHER REQUIRED VARIABLE
    string             str_date
(12)                | STORE TODAY'S DATE
    domain    tcyesno        file.blank                | CHECK FOR BLANK FILE
    domain    tcncmp        home.company                | EXTRACT THE HOME COMPAY IN THIS
        long         dd,yy,mm                 | TEMPORARY VARIABLES FOR DATE/YEAR/MONTH
        long         ret                    | RETURN VALUE FOR COMMANDS
    
    | THESE ARE THE VARIABLES DEFINED FOR THE ERROR

    domain     tcyesno        err.hap
    domain    tcmcs.str80    error.code, x.error.code
    
    |VARIABLES FOR APPL. LOCK
    domain    tcmcs.str20    lockedkey
    domain  tcmcs.str12    lockedby
        long        ret.key        
        
    domain    tctime        curr.time
    domain    tcdate        curr.date
            


    |VARIABLES FOR THE RETRIEVING DATA FROM THE FILE
        |Leader Fields - Position 1 to 55 of each record
|         string        file.duns.number(9),        |DUNS Number
        string        file.plant.code(3),        |Plant Code
                file.supplier(12),        |Supplier Code
                file.trans.date(6),        |Transaction Date (YYMMDD)
                file.trans.time(4),        |Transaction Time (HHMM)
                file.ship.id(15),        |Shipment ID(ASN Number)
|                 file.ship.item.no(4),        |Shipment Item Number
|                 file.edi.std.indicator(1),    |EDI Standard Indicator
                file.rec.type(1)        |File Record Type
                
        |Data Fields - Record Type 0 - Header
|         string        file.ship.from(35),        |Ship Form Name    
        string        file.pack.list.0(15),        |Packing List Number - Record type 0 Zero
                file.bill.lading.no(15),    |Bill of Lading Number
                file.carrier.ref.no(15),    |Carrier Reference Number
                file.freight.bill.no(30),    |Freight Bill Number
|                 file.ship.century(2),        |Ship Date Century
                file.ship.date(6),        |Ship Date    
                file.ship.time(4),        |Ship Time
|                 file.arrival.century(2),    |Arrival Date Century
                file.arrival.date(6),        |Arrival Date    
                file.arrival.time(4),        |Arrival Time
                file.no.container(7),        |No. of Containers
|                 file.no.container.sign(1),    |No. of Containers Sign
                file.wght.shipment(11),        |Gross Weight of Shipment
|                 file.wght.shipment.sign(1),    |Gross Weight of Shipment Sign
                file.wght.uom(2),        |Weight Unit of Measure
|                 file.board.code(2),        |Free on Board code
                file.scac.code(17),        |SCAC Code
|                 file.ship.equp.type(2),        |Shipment Equipment Type
|                 file.ship.equp.id1(4),        |Shipment Equipment ID 1
|                 file.ship.equp.id2(10),        |Shipment Equipment ID 2        
|                 file.spec.hand.code(3),        |Special Handling code
|                 file.hzd.mat.qual(1),        |Hazardous Material Qualifier
|                 file.hzd.mat.code(4),        |Hazardous Material Code
                file.purpose.code(2),        |Purpose Code
|                 file.pack.list.header(1),    |Packing List In Header
                file.seq.no(15)            |File Sequence No
|                 file.filler.0(28)        |Filler - Record type 0(Zero)
                
        |Data Fields - Record Type 1 - Header        
|         string        file.ship.to.name(35),        |Ship To Name
        string        file.ship.to.code(10)        |Ship To Code
|                 file.ship.to.add1(30),        |Ship-to address line 1
|                 file.ship.to.add2(30),        |Ship-to address line 2
|                 file.ship.to.add3(30),        |Ship-to address line 3
|                 file.ship.to.add4(30),        |Ship-to address line 4
|                 file.ship.to.add5(30),        |Ship-to address line 5
|                 file.ship.to.add6(30)        |Ship-to address line 6
|                 file.filler.1(20)        |Filler - Record type 1(One)
                
        |Data Fields - Record Type 2 - Detail
|         string        file.po(25),            |PO Number
|                 file.release.no(3),        |Release Number
        string        file.item(30),            |Part Number
                file.vendor.item(30),        |Vendor Part Number
                file.revision(2),        |Revision Number
                file.pack.list.2(15),        |Packing List Number - Record type 2 Two
                file.unit.ship(11),        |Units shipped
|                 file.unit.ship.sign(1),        |Units shipped Sign
                file.uom(2)            |Unit of Measure
|                 file.item.stat(2),        |PO item status
|                 file.vendor.code2(12),        |Vendor code 2
|                 file.call.off(12),        |Call-off reference number
|                 file.del.loca(15),        |Delivery location
|                 file.po.line(5)            |PO Line Item Number
|                 file.filler.2(80)        |Filler - Record type 2(Two)
                
        |Data Fields - Record Type 3 - Detail
|         string        file.cont.type(5),        |Type of container
|         string        file.unit.cont(11),        |Units per container
|         string        file.unit.cont.sign(1),        |Units per container sign
|                 file.cont.size(5)        |Container size
|                 file.total.cont(5)        |Total No of Containers
|                 file.filler.3(218)        |Filler - Record type 3(Three)
                
        |Data Fields - Record Type 4 - Detail        
|         string        file.total.lines(4),        |Count of Detail Lines        
|         string        file.filler.4(241)        |Filler - Record type 4(Four)
                
    |*********************** variables for table insertion/ Baan Comparison **************
    
    domain    tcmcs.str3    plant.code
    domain    tcmcs.str15    asn.no
    domain    tcsuno        supplier
    domain    tcorno        rec.type
    domain    tcorno        seq.no
    domain    tcdate        trans.date
    domain    tctime        trans.time
    domain    tcdate        ship.date
    domain    tcdate        arrival.date
    domain    tctime        ship.time
    domain    tctime        arrival.time
    domain    tcmcs.str15    packing.list.no,
                bill.lading.no,    
                carrier.ref.no
    domain    tcmcs.str30    freight.bill.no
    domain    tcwght        wght.shipment
    domain    tccuni        wght.uom
    domain    tdwms.purpose    purpose.code
    domain    tdwms.cont    no.container
    domain    tcmcs.str35    ship.to.name
    domain    tcmcs.str10    ship.to.code
    domain    tcitem        item    
    domain    tdpsc.cpno    vendor.item
    domain    tcmcs.str2    revision
    domain    tcmcs.str15    pack.list.2
    domain    tcqiv1        unit.ship
    domain    tccuni        uom
    domain    tcdate        temp.date
    
    domain    tcncmp        company
    
    domain    tcorno        m.seqn
    domain  tcmcs.str17    scac.code
    domain  tcbool        file.load
    domain  tcorno        m.srno
    
    domain  tcmcs.str9    table.name
    long    table.eror
    domain  tcbool        error.found
    domain    tcsuno        m.suno            | POLCUS10.n

before.program:
    if not initialization() then
        exit()
    endif    
    lockedkey = "tdwms6210m002"
    ret.key = appl.get.user(lockedkey,lockedby)
|     ret.key = appl.set(lockedkey,APPL.EXCL)
     if ret.key = 0 then
|         appl.get.user(lockedkey,lockedby)
        mess("tdwms26210.01",1,lockedby)
        |* %s User is using this session.....
        end()
     endif    
|****************************** form section **********************************

form.1:
init.form:
    get.screen.defaults()

|****************************** choice section ********************************

choice.cont.process:
on.choice:
    lockedkey = "tdwms6210m002"
    ret.key = appl.set(lockedkey,APPL.EXCL)
    if ret.key <> 0 then
        appl.get.user(lockedkey,lockedby)
        mess("tdwms26210.01",1,lockedby)
        |* %s User is using this session.....
        end()
    endif    
    
    curr.date = date.num()
    curr.time = tcqms.dll0001.num.to.time(time.num())
    
    move.valid.files()        | POLCUS10.n
    read.main.table()
    

    select tdwms608.*
    from   tdwms608 for update
    where  tdwms608._index1 = {:curr.date,:curr.time}
    selectdo
        tdwms608.endt = date.num()
        tdwms608.entm = tcqms.dll0001.num.to.time(time.num())
        db.update(ttdwms608,db.retry)
        commit.transaction()
    selectempty
        tdwms608.srno = 1
        tdwms608.endt = date.num()
        tdwms608.entm = tcqms.dll0001.num.to.time(time.num())
        db.insert(ttdwms608,db.retry)
        commit.transaction()        
    endselect        
    
    display.form.message(form.text$("tdwms26210.16"))
    |* Process Complete.
    ret.key = appl.delete(lockedkey)
|****************************** function section ******************************

functions:
function domain tcbool initialization()
{    
    company = get.compnr()

    select    tdwms600.ncmp
    from    tdwms600
    where    tdwms600._index1 = {:company}
    selectdo
    selectempty    
        mess("tdwms26102.02",1)
        |* Parameters not Defined...
        return(false)
    endselect
    
    select    tdwms601.code
    from    tdwms601
    as set with 1 rows
    selectdo
    selectempty
        mess("tdwms26102.03",1)
        |* Validation Codes not Defined....
        return(false)    
    endselect    
    return(true)
}

function move.valid.files()                    | POLCUS10.sn
{
    db.retry.point()        
    
    
    select tdwms608.*
    from   tdwms608 for update
    where  tdwms608._index1 = {:curr.date,:curr.time}
    selectdo
|         tdwms608.stdt = date.num()
|         tdwms608.sttm = tcqms.dll0001.num.to.time(time.num())
|         tdwms608.endt = 0
|         tdwms608.entm = 0
|         db.update(ttdwms608,db.retry)
|         commit.transaction()
    selectempty
        tdwms608.srno = 1
        tdwms608.stdt = curr.date
        tdwms608.sttm = curr.time
        tdwms608.endt = 0
        tdwms608.entm = 0
    
        db.insert(ttdwms608,db.retry)
        commit.transaction()        
    endselect    
    
    initailize.variables.level1()            
    
    | PROCEDURE 1 STARTS 
        | EXTRACT DIR INFO FROM CSCN PARAMETERS AND CREATE LOG FILE. 
        | IF LOG FILE IS NOT CREATED THEN END THE PROGRAM AFTER MESSAGE
    initial_actions()
    if err.hap = tcyesno.yes then
        err.hap = tcyesno.no
        end()
    endif
    | PROCEDURE 1 END
    
    | PROCEDURE 2 STARTS 
    | GET THE FILE NAMES IN THE DIRECTORIES AND STORE IT IN AN FILE.
    | GIVE ERROR IF THERE IS SOME PROBLEM

    get.filenames.new()
    if err.hap = tcyesno.yes then
        err.hap = tcyesno.no
        seq.close(fp.log.tmp)
|         end()                    | POLCUS10.n
    endif
    display.form.message(sprintf$(form.text$("tdwms26210.14"),file.ctr))
    |* Total Number Of Files : %d
    

}                                | POLCUS10.en

function read.main.table()
{
    db.retry.point()        |LK.N            
|     curr.date = date.num()                    | POLCUS10.so
|     curr.time = tcqms.dll0001.num.to.time(time.num())
    initailize.variables.level1()            
|     
|     | PROCEDURE 1 STARTS 
|         | EXTRACT DIR INFO FROM CSCN PARAMETERS AND CREATE LOG FILE. 
|         | IF LOG FILE IS NOT CREATED THEN END THE PROGRAM AFTER MESSAGE
|     initial_actions()
|     if err.hap = tcyesno.yes then
|         err.hap = tcyesno.no
|         end()
|     endif
|     | PROCEDURE 1 END
|     
|     | PROCEDURE 2 STARTS 
|     | GET THE FILE NAMES IN THE DIRECTORIES AND STORE IT IN AN FILE.
|     | GIVE ERROR IF THERE IS SOME PROBLEM

    get.filenames()
    if err.hap = tcyesno.yes then
        err.hap = tcyesno.no
        seq.close(fp.log.tmp)
        end()
    endif
|     display.form.message(sprintf$(form.text$("tdwms26210.14"),file.ctr))
|     |* Total Number Of Files : %d
|     | PROCEDURE 2 END

|     | PROCEDURE 3 STARTS 
|         | PROCESS EACH FILE ATE AT A TIME,  IN A LOOP         | POLCUS10.eo
    
    for i = 1 to file.ctr
    |    db.retry.point()        |san    |LK.O
        display.form.message(sprintf$(form.text$("tdwms26210.15"),i,file.ctr))
        |* Processing File No: %d of %d Files
        initailize.variables.level2()
        file.name = strip$(file_arr(1,i))

        | PROCEDURE 3.1 STARTS Validate File Name
|         validate.filename()            | POLCUS10.o
|         copy_files()    |#POLCUS02.n    
|         if err.hap = tcyesno.yes then
|             err.hap = tcyesno.no
|         |    copy_files()    |#POLCUS02.o    
|             dele_files()    |#POLCUS02.n            
|             continue
|         endif
        | PROCEDURE 3.1 END
    
        | PROCEDURE 3.2 STARTS Read ASN file
        asn.read.file()
        copy_files()        | POLCUS01.n    
        if err.hap = tcyesno.yes then
            err.hap = tcyesno.no
            seq.close(fp)
        |    copy_files()    |#POLCUS02.o    
            dele_files()    |#POLCUS02.n    
            continue
        endif
        | PROCEDURE 3.2 END
    
        | PROCEDURE 3.3 STARTS
        m.suno = ""                                | POLCUS10.n
        for j = 1 to rec.ctr 
|             db.retry.point()    |san
            initailize.variables.level3()
            current.record = str_arr(1,j)
            file.ship.id = current.record(35;15)
            asn.no = strip$(shiftl$(file.ship.id))
            
            file.rec.type = current.record(55;1)
            if j = 1 then
                file.seq.no = current.record(258;15)
                seq.no = val(file.seq.no)
                file.supplier = current.record(13;12)            | POLCUS10.n
                supplier = strip$(shiftl$(file.supplier))        | POLCUS10.n    
                tt.align.according.domain(supplier, supplier, "tcsuno") | POLCUS10.n
            endif

            rec.type = val(file.rec.type)
            
            on case rec.type
            case 0:
                get.variables.rec.0()        |(Rec type 0 Variables)
                break
            case 1:    
                get.variables.rec.1()        |(Rec type 1 Variables)
                break
            case 2:
                file.plant.code = current.record(10;3)
                file.supplier = current.record(13;12)            
                file.ship.id = current.record(35;15)
                
                plant.code = strip$(shiftl$(file.plant.code))
|                 supplier = strip$(shiftl$(file.supplier))        | POLCUS10.o
|                 tt.align.according.domain(supplier, supplier, "tcsuno") | POLCUS10.o
                asn.no = strip$(shiftl$(file.ship.id))
                m.suno = strip$(shiftl$(file.supplier))            | POLCUS10.n
                tt.align.according.domain(m.suno, m.suno, "tcsuno") | POLCUS10.n
                if m.suno <> supplier then
                    break
                endif    
                assign.file.variables()
                populate.table.fields()
                break
            default:
                break
            endcase    
            if error.found then        
                break            
            endif
            
        endfor
        | PROCEDURE 3.3 END
        commit.transaction()
    |    copy_files()    |#POLCUS02.o    
        dele_files()    |#POLCUS02.n    
|        tdwmsdll0017.sendmail(asn.no,asn.no)        | san to finalised
    endfor    
    seq.close(fp.log.tmp)
    | PROCEDURE 3 END 

    commit.transaction()
}

function initailize.variables.level1()
{
    ret = set.mem(file_arr,"")
    ret = set.mem(str_arr,"")
    file.blank = tcyesno.yes
    file.ctr = 0
}


function initial_actions()
{
    
    home.company = get.compnr()
    select tdwms600.*
    from tdwms600
    where tdwms600._index1 = {:home.company}
    selectdo
        path.move.o  = tdwms600.mpth
        path.input.o = tdwms600.path
        path.proc.o  = tdwms600.hpth
        path.log.o   = tdwms600.lpth
    endselect
    
    
    str_date = dte$()
    path.log.tmp = concat$("/",strip$(path.log.o),"log")
    path.log.tmp = path.log.tmp &"_"& str_date(5;2) & str_date(1;2) & str_date(3;2) & str_date(7;6) 
    fp.log.tmp = seq.open(path.log.tmp,"w")
    
    if fp.log.tmp < 1 then
        mess("tdwms26210.02",1) 
        |* Unable to Open the base CSCN ASN log file!
        err.hap = tcyesno.yes
        return
    endif
}

function get.filenames()
{

    ls.path.name = "ls " & strip$(path.input.o) &" > " & strip$(path.log.o) & "/CSCN_ASN_files"
    ret = shell(ls.path.name, 0)
        
    fp.tmp = seq.open(concat$("/",strip$(path.log.o),"CSCN_ASN_files"),"r")
        
    if fp.tmp < 1 then
        |ERROR MESSAGE IS :    Unable to Open the base log file!
        seq.puts(form.text$("tdwms26210.02"),fp.log.tmp)
        |* Unable to Open the base CSCN ASN log file!
        err.hap = tcyesno.yes
        return
    endif
    
    while (seq.eof(fp.tmp) = 0) 
        file.val = seq.gets(file.line,RECORDLN, fp.tmp)
        |* To check if any file is available to upload
        
        if (file.val < 0 and file.blank = tcyesno.yes) then
            |ERROR MESSAGE IS :No File Available To Upload !
            seq.puts(form.text$("tdwms26210.03"),fp.log.tmp)
            |* No File Available To Upload !
            err.hap = tcyesno.yes
            return
        else
            if file.val = 0 then
                file.blank = tcyesno.no
                file.ctr = file.ctr + 1    
                file_arr(1,file.ctr) = file.line
            endif
        endif
    
    endwhile
        
    if file.ctr = 0 then
        |ERROR MESSAGE IS :No Files to Upload!    
        seq.puts(form.text$("tdwms26210.03"),fp.log.tmp)
        |* No File Available To Upload !
        err.hap = tcyesno.yes
        return
    endif
        
    seq.close(fp.tmp)
}


function get.filenames.new()
{

    ls.path.name = "ls " & strip$(path.move.o) &" > " & strip$(path.log.o) & "/VALID_ASN_files"
    ret = shell(ls.path.name, 0)
        
    fp.tmp = seq.open(concat$("/",strip$(path.log.o),"VALID_ASN_files"),"r")
        
    if fp.tmp < 1 then
        |ERROR MESSAGE IS :    Unable to Open the base log file!
        seq.puts(form.text$("tdwms26210.27"),fp.log.tmp)
        |* tdwms26210.27  ????????????????????????????????????????
        err.hap = tcyesno.yes
        return
    endif
    
    while (seq.eof(fp.tmp) = 0) 
        file.val = seq.gets(file.line,RECORDLN, fp.tmp)
        |* To check if any file is available to upload
        
        if (file.val < 0 and file.blank = tcyesno.yes) then
            |ERROR MESSAGE IS :No File Available To Upload !
            seq.puts(form.text$("tdwms26210.03"),fp.log.tmp)
            |* No File Available To Upload !
            err.hap = tcyesno.yes
            return
        else
            if file.val = 0 then
                file.blank = tcyesno.no
                file.ctr = file.ctr + 1    
                file_arr(1,file.ctr) = file.line
                
                file.name = strip$(file_arr(1,file.ctr))
                validate.filename.new()

                if err.hap = tcyesno.yes then
                    err.hap = tcyesno.no
                    dele_source_files()    
                    continue
                endif
                asn.read.file.new()   
                if err.hap = tcyesno.yes then
                    err.hap = tcyesno.no
                    seq.close(fp)
                    dele_source_files()    
                    continue
                else
                    move_source_files()
                endif                
                
            endif
        endif
    
    endwhile
        
    if file.ctr = 0 then                        
        |ERROR MESSAGE IS :No Files to Upload!    
        seq.puts(form.text$("tdwms26210.03"),fp.log.tmp)
        |* No File Available To Upload !
        err.hap = tcyesno.yes
        return
    endif                                
        
    seq.close(fp.tmp)
}


function initailize.variables.level2()
{
    ret         = set.mem(str_arr,"")
    rec.ctr     = 0
    plant.code    = ""
    supplier    = ""
    asn.no        = ""
    trans.date    = 0
    seq.no        = 0
    packing.list.no    = ""
    bill.lading.no     = ""
    carrier.ref.no     = ""
    freight.bill.no    = ""
    ship.date    = 0
    ship.time    = 0
    arrival.date    = 0
    arrival.time    = 0
    no.container    = 0
    wght.shipment    = 0
    wght.uom    = ""
    purpose.code    = empty
    ship.to.name    = ""
    ship.to.code    = ""
    scac.code       = ""
}

function asn.read.file.new()
{
    |OPEN THE MAIN FILE
    path.input = strip$(concat$("/",strip$(path.input.o),file.name))
    fp = seq.open(path.move,"r")
    rec.ctr = 0
    
    if fp < 1 then
        |ERROR MESSGE : Unable to open the input file! File Skipped!
        seq.puts(sprintf$(form.text$("tdwms26210.05"),file.name),fp.log.tmp)
        |* Unable to open the input file %s! File Skipped!
        err.hap = tcyesno.yes
        return
    endif

    while (seq.eof(fp) = 0) 
        retval = seq.gets(retline,RECORDLN, fp)

        if (retval < 0 and file.blank = tcyesno.yes) then
            |ERROR MESSAGE IS :Given file is blank!
            seq.puts(sprintf$(form.text$("tdwms26210.06"),file.name),fp.log.tmp)
            |* Given file %s is blank!
            err.hap = tcyesno.yes
            return
        else
            if retval = 0 then
                file.blank = tcyesno.no
                rec.ctr = rec.ctr + 1    
                if rec.ctr  = 1 then
                    if not valid.asn.file.new() then
                        err.hap = tcyesno.yes
                        return
                    else
                        seq.close(fp)
                        return
                    endif    
                endif    
|                 str_arr(1,rec.ctr) = retline
            endif
        endif
    endwhile
    seq.close(fp)
}

function domain tcbool valid.asn.file.new()            | POLCUS10.sn
{
    file.rec.type = retline(55;1)
    rec.type = val(file.rec.type)
    
    if rec.type = 0 then
        file.plant.code = retline(10;3)
        file.supplier = retline(13;12)
        file.ship.id = retline(35;15)
        
        asn.no = strip$(shiftl$(file.ship.id))
        plant.code = strip$(shiftl$(file.plant.code))
        supplier = strip$(shiftl$(file.supplier))
    
        file.trans.date = retline(25;6)
        file.trans.time = retline(31;4)
        file.seq.no = retline(258;15)
        file.purpose.code = retline(255;2)
        
        dd = lval(file.trans.date(5;2))                    
        mm = lval(file.trans.date(3;2))
        yy = 2000 + lval(file.trans.date(1;2))                    
        trans.date = date.to.num(yy,mm,dd)                
        
        x.error.code = ""
        file.load = false
        If isspace(asn.no)then
            seq.puts(sprintf$(form.text$("tdwms26210.23"),file.name),fp.log.tmp)
            |* ASN number is blank, Not valid file %s
            return(false)
        endif

        if isspace(supplier) then
            x.error.code = form.text$("tdwms26210.08")
            |* Supplier Doesn'
t exists in BAAN File Skipped !
            
write.log.table() 
            return(
false)
        endif        

        if 
plant.code <> strip$(tdwms600.plntthen 
            x
.error.code form.text$("tdwms26210.07")
            |* 
Plant Code Different from Parameter definationFile Skipped!
            
write.log.table() 
            return(
false)
        endif    
        
        if 
trans.date <= 0 then                        
            x
.error.code form.text$("tdwms26210.24")
            |* 
Transaction Date is Blank in FileFile Skipped
            write
.log.table() 
            return(
false)
        endif                            
        
trans.time lval(file.trans.time) * 100
        seq
.no val(file.seq.no)
    
        
find.seq()
        if 
seq.no m.seqn then
            x
.error.code sprintf$(form.text$("tdwms26210.22"),m.seqn)
            |* 
File is already loaded for Seqn : %s
        
endif
        if 
seq.no m.seqn then
            x
.error.code sprintf$(form.text$("tdwms26210.13"),m.seqn)
            |* 
Higher Seqn : %s is already Loaded
        
endif
        if 
not isspace(x.error.codethen
            write
.log.table()
            return(
false)
        else
            return(
true)
        endif
    endif    
    return(
true)
}                                | 
POLCUS10.en

function asn.read.file()
{
    |
OPEN THE MAIN FILE
    path
.input strip$(concat$("/",strip$(path.input.o),file.name))
    
fp seq.open(path.input,"r")
    
    if 
fp 1 then
        
|ERROR MESSGE Unable to open the input fileFile Skipped!
        
seq.puts(sprintf$(form.text$("tdwms26210.05"),file.name),fp.log.tmp)
        |* 
Unable to open the input file %sFile Skipped!
        
err.hap tcyesno.yes
        
return
    endif

    while (
seq.eof(fp) = 0
        
retval seq.gets(retline,RECORDLNfp)

        if (
retval and file.blank tcyesno.yesthen
            
|ERROR MESSAGE IS :Given file is blank!
            
seq.puts(sprintf$(form.text$("tdwms26210.06"),file.name),fp.log.tmp)
            |* 
Given file %s is blank!
            
err.hap tcyesno.yes
            
return
        else
            if 
retval 0 then
                file
.blank tcyesno.no
                rec
.ctr rec.ctr 1    
                
if rec.ctr  1 then
                    
if not valid.asn.file() then
                        err
.hap tcyesno.yes
                        
return
                    endif    
                endif    
                
str_arr(1,rec.ctr) = retline
            
endif
        endif
    endwhile
    
seq.close(fp)
}

function 
domain tcbool valid.asn.file()
{
    
file.rec.type retline(55;1)
    
rec.type val(file.rec.type)
    
    if 
rec.type 0 then
        file
.plant.code retline(10;3)
        
file.supplier retline(13;12)
        
file.ship.id retline(35;15)
        
        
asn.no strip$(shiftl$(file.ship.id))
        
plant.code strip$(shiftl$(file.plant.code))
        
supplier strip$(shiftl$(file.supplier))
    
        
file.trans.date retline(25;6)
        
file.trans.time retline(31;4)
        
file.seq.no retline(258;15)
        
file.purpose.code retline(255;2)
        
        
dd lval(file.trans.date(5;2))                    
        
mm lval(file.trans.date(3;2))
        
yy 2000 lval(file.trans.date(1;2))                    
        
trans.date date.to.num(yy,mm,dd)                
        
        
x.error.code ""
        
file.load false
        
If isspace(asn.no)then
            seq
.puts(sprintf$(form.text$("tdwms26210.23"),file.name),fp.log.tmp)
            |* 
ASN number is blankNot valid file %s
            
return(false)
        endif
            
        if 
plant.code <> strip$(tdwms600.plntthen 
            x
.error.code form.text$("tdwms26210.07")
            |* 
Plant Code Different from Parameter definationFile Skipped!
            
write.log.table() 
            return(
false)
        endif    
        
        if 
trans.date <= 0 then                        
            x
.error.code form.text$("tdwms26210.24")
            |* 
Transaction Date is Blank in FileFile Skipped
            write
.log.table() 
            return(
false)
        endif                            
        
trans.time lval(file.trans.time) * 100
        seq
.no val(file.seq.no)
    
        
find.seq()
        if 
seq.no m.seqn then
            x
.error.code sprintf$(form.text$("tdwms26210.22"),m.seqn)
            |* 
File is already loaded for Seqn : %s
        
endif
        if 
seq.no m.seqn then
            x
.error.code sprintf$(form.text$("tdwms26210.13"),m.seqn)
            |* 
Higher Seqn : %s is already Loaded
        
endif
        if 
seq.no m.seqn then
            
if m.seqn 0 then
                file
.load true
            
else    
                if 
rec.processed() then
                    x
.error.code sprintf$(form.text$("tdwms26210.11"),m.seqn)
                    |* 
Seq.%s Already Processed... Cannot Replace
                
else    
                    if 
file.purpose.code "00" or  file.purpose.code "05" then
                        cancel
.asnn.data()
                        if 
m.seqn <> 0 then
                            x
.error.code sprintf$(form.text$("tdwms26210.20"),m.seqn)
                            |* 
Seq.%s moved to Archieve Table - For Add Replacement
                        
endif                        
                        
file.load true
                    
endif

                    if 
file.purpose.code "01" then
                         cancel
.asnn.data()    
                        if 
m.seqn <> 0 then
                            x
.error.code sprintf$(form.text$("tdwms26210.19"),m.seqn)
                            |* 
Seq.%s moved to Archieve Table - For Deletation
                        
endif
                     endif

                endif
            endif
        endif
        if 
not isspace(x.error.codethen
            write
.log.table()    
        endif
        if 
file.load then
            
return(true)
        else
            return(
false)
        endif
    endif    
    return(
true)
}

function 
copy_files()
{
    
long retret1
    string    dat
(12)
    
long file.size,c.time,m.time,a.time    |#POLCUS01.n
    
dat dte$()
    
bckp.path strip$(concat$("/",strip$(path.proc.o),"bkp"))
    
bckp.path strip$(concat$("/",strip$(bckp.path),file.name))
    
    
path.proc strip$(concat$("/",strip$(path.proc.o),file.name)) &"_"dat(5;2) & dat(1;2) & dat(3;2) & dat(7;6
    
    
cv.path.name "cp " path.input &" " bckp.path
|    mv.path.name "mv " path.input &" " path.proc    |lk.o
    mv
.path.name "cp " path.input &" " path.proc    |lk.n
    
if file.stat(bckp.path,file.size,c.time,m.time,a.time) <> 0 then    |#POLCUS01.n    
        
    
|    ret shell(cv.path.name0)    |lk.o    |#POLCUS01.o
        
ret shell(cv.path.name0)    |lk.o    |#POLCUS01.n
    
|    suspend(90) |lktest
    
|    ret shell(mv.path.name0)    |lk.o    |#POLCUS01.o
        
ret shell(mv.path.name0)    |lk.o    |#POLCUS01.n    
    
|    suspend(90) |lktest
    
endif                    |#POLCUS01.n
|     mv.path.name "rm " path.input     |lk.n    |#POLCUS02.so
| |    ret shell(mv.path.name0)    |lk.n    |#POLCUS01.o
|     ret shell(mv.path.name1)    |lk.n    |#POLCUS01.n
|     suspend(80) |lktest
| |     ret shell(cv.path.name1)    |lk.n
| |     ret shell(mv.path.name1)    |lk.n
|                            |#POLCUS02.eo
}

function 
dele_files()        |#POLCUS02.sn
{
    
mv.path.name "rm " path.input
    ret 
shell(mv.path.name0)
|    
suspend(70) |lktest    
    
}                |#POLCUS02.en
function write.log.table()
{
    
m.srno 0
    select tdwms609
.*
    
from   tdwms609 
    where  tdwms609
._index1 = {:asn.no,:seq.no}
    
order by tdwms609._index1 desc
    
as set with 1 rows
    selectdo
        m
.srno tdwms609.srno
    endselect
    m
.srno m.srno 1
    
    select tdwms609
.*
    
from   tdwms609 
    where  tdwms609
._index1 = {:asn.no,:seq.no,:m.srno}
    
selectdo
    selectempty
        tdwms609
.asnn asn.no
        tdwms609
.seqn seq.no
        tdwms609
.srno m.srno
        tdwms609
.rema x.error.code
        tdwms609
.date curr.date
        tdwms609
.time curr.time
        db
.insert(ttdwms609,db.retry)
        
commit.transaction()
    
endselect
}

function 
initailize.variables.level3()
{
    
item        ""
    
vendor.item    ""
    
revision    ""
    
pack.list.2    ""
    
unit.ship    0    
    uom        
""
}

function 
get.variables.rec.0()        |(Rec type 0 Variables)
{
    
file.ship.id current.record(35;15)
    
    
file.pack.list.0 current.record(91;15)
    
file.bill.lading.no current.record(106;15)
    
file.carrier.ref.no current.record(121;15
    
file.freight.bill.no current.record(136;30)
    
    
file.ship.date current.record(168;6)
    
file.ship.time current.record(174;4)
    
    
file.arrival.date current.record(180;6)
    
file.arrival.time current.record(186;4)
    
file.no.container current.record(190;7)
    
file.wght.shipment current.record(198;11)
    
file.wght.uom current.record(210;2)
    
file.scac.code current.record(214;17)
    
file.purpose.code current.record(255;2)
    
    
asn.no strip$(shiftl$(file.ship.id))
    
    
packing.list.no file.pack.list.0
    bill
.lading.no file.bill.lading.no
    carrier
.ref.no file.carrier.ref.no
    freight
.bill.no file.freight.bill.no
    
    dd 
lval(file.ship.date(5;2))                    
    
mm lval(file.ship.date(3;2))
    
yy 2000 lval(file.ship.date(1;2))                    
    
ship.date date.to.num(yy,mm,dd)                
    if 
ship.date 0 then                        
        ship
.date 0
    
endif                
    
    
ship.time lval(file.ship.time) * 100
    scac
.code strip$(shiftl$(file.scac.code))
    
    
dd lval(file.arrival.date(5;2))                    
    
mm lval(file.arrival.date(3;2))
    
yy 2000 lval(file.arrival.date(1;2))                    
    
arrival.date date.to.num(yy,mm,dd)                
    if 
arrival.date 0 then                        
        arrival
.date 0
    
endif                    
    
    
arrival.time lval(file.arrival.time) * 100
    no
.container lval(file.no.container)
    
    
wght.shipment val(file.wght.shipment)
    if 
not isspace(file.wght.uomthen
        get
.unit.from.unit.master(file.wght.uom,wght.uom)
    endif
    
    if 
not isspace(file.purpose.codethen
        on 
case file.purpose.code
        
case "00":
            
purpose.code tdwms.purpose.new
            break
        case 
"01":
            
purpose.code tdwms.purpose.delete
            
break
        case 
"05":
            
purpose.code tdwms.purpose.replacement
            
break
        
endcase
    
endif
    
}

function 
get.unit.from.unit.master(    domain tcmcs.str2 i.cuni,
                   
ref    domain tccuni     o.cuni)
{
    
o.cuni =  ""
    
select    tdwms605.cuni:o.cuni
    from    tdwms605
    where    tdwms605
._index1 = {:i.cuni}
    
selectdo
    endselect    
}

function 
get.variables.rec.1()        |(Rec type 1 Variables)
{
    
file.ship.to.code current.record(91;10)
    
ship.to.code file.ship.to.code
}


function 
assign.file.variables()
{
    
error.code ""
    
file.item current.record(84;30)
    
file.vendor.item current.record(114;30)
    
file.revision current.record(144;2)
    
file.pack.list.2 current.record(146;15)
    
file.unit.ship current.record(161;11)
    
file.uom current.record(173;4)
    
    
item strip$(shiftl$(file.item))
    
tt.align.according.domain(itemitem"tcitem")
    
vendor.item strip$(shiftl$(file.vendor.item))
    
revision strip$(shiftl$(file.revision))
    
pack.list.2 strip$(shiftl$(file.pack.list.2))
    
unit.ship val(file.unit.ship)
    if 
not isspace(file.uomthen
        get
.unit.from.unit.master(file.uom,uom)
    endif
}

function 
populate.table.fields()
{
    if 
purpose.code <> tdwms.purpose.delete then
        fill
.header()
        if 
error.found then    
            
return        
        endif            
        
fill.lines()
    endif    
}

function 
fill.header()
{
    
x.error.code ""
    
table.name ""
    
error.found false

|     select    tdwms610.asnn                    POLCUS10.o
    select    tdwms610
.asnn,tdwms610.suno,tdwms610.seqn    POLCUS10.n
    from    tdwms610
    where    tdwms610
._index1 = {:asn.no, :supplier, :seq.no}
    
selectdo
    selectempty
        
|tdwms610 fields
        tdwms610
.asnn asn.no
        tdwms610
.suno supplier
        tdwms610
.seqn seq.no
        tdwms610
.tsdt trans.date
        tdwms610
.tstm trans.time
        tdwms610
.stat purpose.code
        tdwms610
.proc tcyesno.no
        tdwms610
.updt curr.date        
        tdwms610
.uptm curr.time        
        
        table
.name "tdwms610"                
        
table.eror db.insert(ttdwms610,db.retry,db.return.error)
        if 
table.eror <> 0 then
            abort
.transaction()
            
x.error.code form.text$("tdwms26210.26")
            |* 
Error : %s on Table %s
            x
.error.code sprintf$(x.error.code,table.eror,table.name)
             
write.log.table()
            
error.found true
            
return
        endif                        
        
        |
tdwms611 fields
        tdwms611
.asnn asn.no
        tdwms611
.suno supplier
        tdwms611
.seqn seq.no
        tdwms611
.pack packing.list.no
        tdwms611
.bill bill.lading.no 
        tdwms611
.crer carrier.ref.no 
        tdwms611
.frgh freight.bill.no
        tdwms611
.shdt ship.date
        tdwms611
.shtm ship.time
        tdwms611
.ardt arrival.date
        tdwms611
.artm arrival.time
        tdwms611
.cont no.container
        tdwms611
.wght wght.shipment
        tdwms611
.unit wght.uom
        tdwms611
.shto ship.to.code
        tdwms611
.scac scac.code
        
        table
.name "tdwms611"                
        
table.eror db.insert(ttdwms611,db.retry,db.return.error)
        if 
table.eror <> 0 then
            abort
.transaction()
            
x.error.code form.text$("tdwms26210.26")
            |* 
Error : %s on Table %s
            x
.error.code sprintf$(x.error.code,str$(db.error.message()),table.name)
             
write.log.table()
            
error.found true
            
return
        endif                        
        
commit.transaction()
        
        
temp.date arrival.date
        
if temp.date 0 then
            temp
.date curr.date
        
endif
        
    
endselect    
    
}

function 
fill.lines()
{
    
select    tdwms615.item
    from    tdwms615
    where    tdwms615
._index1 = {:tdwms610.asnn,:tdwms610.suno,:tdwms610.seqn,:pack.list.2,:item}
    
selectdo
    selectempty
        tdwms615
.asnn tdwms610.asnn
        tdwms615
.suno tdwms610.suno
        tdwms615
.seqn tdwms610.seqn
        tdwms615
.item item
        tdwms615
.cpno vendor.item
        tdwms615
.plno pack.list.2
        tdwms615
.revi revision
        tdwms615
.cuni uom
        tdwms615
.quan unit.ship
        tdwms615
.aqun unit.ship
        tdwms615
.pkgs 1
        tdwms615
.apkg 1
        tdwms615
.proc tcyesno.no
        tdwms615
.recp tcyesno.no
        tdwms615
.prdt 0            
        tdwms615
.prtm 0            
        tdwms615
.vald =    tcyesno.no
        tdwms615
.fcun file.uom
        tdwms615
.cont 0
        tdwms615
.copo 0
        tdwms615
.schn 0
        tdwms615
.orno 0
        tdwms615
.pono 0
        tdwms615
.reno 0
        tdwms615
.ecod ""
        
tdwms615.eafs ""
        
tdwms615.eror ""
        
if validate.record(tdwms615.asnn,        |Function From DLL tdwmsdll0016
                   tdwms615
.item,
                   
tdwms615.suno,
                   
tdwms615.cuni,
                   
tdwms615.aqun,
                   
temp.date,
                   
false,            |FLAG
                   tdwms615
.ecod,
                   
tdwms615.eror,
                   
tdwms615.eafs,
                   
tdwms615.cont,
                   
tdwms615.copo,
                   
tdwms615.schn,
                   
tdwms615.plnothen        
            
            tdwms615
.vald =    tcyesno.yes
        
endif    
        
tdwms615.aqun unit.ship

        table
.name "tdwms615"                
        
table.eror db.insert(ttdwms615,db.retry,db.return.error)
        if 
table.eror <> 0 then
            abort
.transaction()
            
x.error.code form.text$("tdwms26210.25")
            |* 
Error : %s on Table %for Item %s
            x
.error.code sprintf$(x.error.code,str$(db.error.message()),table.name,item)
             
write.log.table()
            
error.found true
            
return
        endif                            

    
endselect
|     commit.transaction()
    
}

function 
long rec.processed()
{
    
m.seqn 0
    select    tdwms615
.proc,tdwms615.seqn:m.seqn
    from    tdwms615
    where    tdwms615
._index1 = {:asn.no}
    and     
tdwms615.proc tcyesno.yes    
    
as set with 1 rows
    selectdo
        
return(true)
    
selectempty
        select    tdwms650
.seqn:m.seqn,tdwms650.asnn,tdwms650.suno
        from    tdwms650
        where    tdwms650
._index1 = {:asn.no}
        
order by tdwms650._index1 desc
        
as set with 1 rows
        selectdo
            select    tdwms655
.proc,tdwms655.seqn
            from    tdwms655
            where    tdwms655
._index1 = {:tdwms650.asnn,:tdwms650.suno,:m.seqn}
            and     
tdwms655.proc tcyesno.yes    
            
as set with 1 rows
            selectdo
                
return(true)
            
endselect
        endselect
    endselect    
    
return(false)
}

function 
long find.seq()
{
    
m.seqn 0
    select    tdwms610
.seqn:m.seqn
    from    tdwms610
    where    tdwms610
._index1 = {:asn.no}
    as 
set with 1 rows
    selectdo
        
return(true)
    
selectempty
        select    tdwms650
.seqn:m.seqn,tdwms650.asnn,tdwms650.suno
        from    tdwms650
        where    tdwms650
._index1 = {:asn.no}
        
order by tdwms650._index1 desc
        
as set with 1 rows
        selectdo
            
return(true)
        
endselect
    endselect    
    
return(false)
}


function 
cancel.asnn.data()
{
    
select    tdwms610.* 
    
from    tdwms610 for update
    where   tdwms610
._index1 = {:asn.no}
    
selectdo
        rcd
.ttdwms650 rcd.ttdwms610
        tdwms650
.asns tdwms.arcv.can
        tdwms650
._compnr tdwms610._compnr
        db
.insert(ttdwms650,db.retry,db.skip.dupl)
        
select    tdwms611.*
        
from    tdwms611 for update
        where    tdwms611
._index1 = {:tdwms610.asnn,:tdwms610.suno,:tdwms610.seqn}
        
selectdo
            rcd
.ttdwms651 rcd.ttdwms611
            tdwms651
._compnr tdwms611._compnr
            db
.insert(ttdwms651,db.retry,db.skip.dupl)
            
db.delete(ttdwms611,db.retry)
        
endselect    
        
        select    tdwms615
.*
        
from    tdwms615 for update
        where    tdwms615
._index1 = {:tdwms610.asnn,:tdwms610.suno,:tdwms610.seqn}
        
selectdo
            rcd
.ttdwms655 rcd.ttdwms615
            tdwms655
._compnr tdwms615._compnr
            db
.insert(ttdwms655,db.retry,db.skip.dupl)
            
            
select    tdwms616.*
            
from    tdwms616 for update
            where    tdwms616
._index1 = {:tdwms615.asnn,:tdwms615.suno,:tdwms615.seqn,:tdwms615.plno,:tdwms615.item}
            
selectdo
                rcd
.ttdwms656 rcd.ttdwms616
                tdwms656
._compnr tdwms616._compnr
                db
.insert(ttdwms656,db.retry,db.skip.dupl)
                
db.delete(ttdwms616,db.retry)
            
endselect    
|             rcd.ttdwms655 rcd.ttdwms615
|             tdwms655._compnr tdwms615._compnr
|             db.insert(ttdwms655,db.retry,db.skip.dupl)
            
db.delete(ttdwms615,db.retry)
        
endselect    

        db
.delete(ttdwms610,db.retry,db.return.ref.exists)
        
commit.transaction()
    
selectempty
        m
.seqn 0
    endselect
}

function 
display.form.message(domain tcmcs.str60 mess.desc)
{
    
string dat(12)
    
string ndat(15)
    
disp.messg ""
    
dat dte$()
    
ndat dat(3;2) & "-" dat(1;2) & "-"  &dat(5;2) & ":" dat(7;2) & ":" dat(9;2) & ":" dat(11;2)
    
disp.messg ndat "-" mess.desc
    display
("disp.messg")
}

function 
validate.filename()
{
    
path.input strip$(concat$("/",strip$(path.input.o),file.name))
    if 
file.name(1;5) <> strip$(tdwms600.filethen
        seq
.puts(sprintf$(form.text$("tdwms26210.04"),file.name),fp.log.tmp)
        |* 
Invalid File Name %sFile Skipped!
        
err.hap tcyesno.yes
        
return
    endif    
}

function 
validate.filename.new()
{
    
path.move strip$(concat$("/",strip$(path.move.o),file.name))
    if 
file.name(1;5) <> strip$(tdwms600.filethen
        seq
.puts(sprintf$(form.text$("tdwms26210.04"),file.name),fp.log.tmp)
        |* 
Invalid File Name %sFile Skipped!
        
err.hap tcyesno.yes
        
return
    endif    
}


function 
move_source_files()            | POLCUS10.sn
{
    
long retret1
    string    dat
(12)
    
long file.size,c.time,m.time,a.time    
    dat 
dte$()
|     
bckp.path strip$(concat$("/",strip$(path.proc.o),"bkp"))
|     
bckp.path strip$(concat$("/",strip$(bckp.path),file.name))
    
|     
path.proc strip$(concat$("/",strip$(path.proc.o),file.name)) &"_"dat(5;2) & dat(1;2) & dat(3;2) & dat(7;6
    
    
mv.path.name "mv " path.move &" " path.input      

    
if file.stat(path.move,file.size,c.time,m.time,a.time) = 0 then    
|         ret shell(cv.path.name0)    
        
ret shell(mv.path.name0)    
    endif                    
}                        | 
POLCUS10.en

function dele_source_files()        |#POLCUS10.sn
{
    
mv.path.name "rm " path.move 
    ret 
shell(mv.path.name0)
    
}                |
#POLCUS10.en 
Here is $BSE/lib/defaults/all

PHP Code:
session_timeout:30
use_mbtextconv
:
There is no file bse_vars in $BSE/lib

Thanks in advance
Reply With Quote
  #11  
Old 4th June 2008, 09:47
NPRao's Avatar
NPRao NPRao is offline
Guru
 
Join Date: Aug 2001
Location: Pacific NW, USA
Posts: 3,028
NPRao will become famous soon enough
Baan: iBaanERP-5.2a(Reger),SSA-ERP-LN-6.1,Infor LN-10.x - DB: Oracle-10g,11g,12c,MS-SQL - OS: HP-UX, Linux, Windows
loveneesh,

Few things I noticed is the use of shell() commands. You are hard-coding the OS commands into Baan code, instead of using the available tools functions. Refer to the Programmer's manual - Directory and file operations synopsis
You can replace all the cp, mv, rm commands by file.cp(), file.mv() and file.rm() which are platform independent.
Quote:
ls.path.name = "ls " & strip$(path.input.o) &" > " & strip$(path.log.o) & "/CSCN_ASN_files"
ret = shell(ls.path.name, 0)
Refer to the thread for the sample code to read the files in the directory - reading Ascii file
The script does need some code clean up to use arrays, coding standards etc.
Code:
if not valid.asn.file.new() then
	err.hap = tcyesno.yes
	return
else
	seq.close(fp)
	return
endif
...
        db.insert(ttdwms608,db.retry)
        commit.transaction()
The file pointer should be closed before the 1st return. The other statement will fail in case of duplicate records, missing db.skip.dupl option.
__________________
The art of perfection does not lie in doing extraordinary things but, doing ordinary things extraordinarily well. [-N. Prashanth Rao]
How To Ask Questions The Smart Way,BaaNBoard,NPRao

Last edited by NPRao : 5th June 2008 at 22:24.
Reply With Quote
Sponsored Links
  #12  
Old 5th June 2008, 09:22
loveneesh loveneesh is offline
Member
 
Join Date: Oct 2002
Location: Delhi
Posts: 37
loveneesh is on a distinguished road
Baan: Baan 5c - DB: Oracle - OS: Unix
Thanks NPR,

I will try and check the outcome
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Background info for bshell options (BaanIV) victor_cleto Tools Administration & Installation 61 26th January 2010 18:17
Session Startup and Key Map not working wricks Tools Administration & Installation 9 27th November 2006 07:48
Active Bshell... LittleJohn Tools Development 1 13th August 2004 02:36
Changing bshell in ipc_info gcharles Tools Administration & Installation 10 4th January 2002 18:50


All times are GMT +2. The time now is 03:17.


©2001-2017 - Baanboard.com - Baanforums.com