Do not let any software impress you!

Only let it convince your intellect.
Slider img 1
Do not look for a business paradise!

It is a waste of time.
Slider img 2
Only yourself can push you uphill.

There is no easy road to prizes.
Slider img 3
Productivity is the name of the game.

And you have to conquer it.
Slider img 4
As long as you understand it,

you will start to build your know-how.
Slider img 5
We can help with that.

We have the tools and the method.
Slider img 6

Materials
Sch Qty
Act Qty
UOM
Comments
-1/1
Location
Material Consumtion
Position
Product Quantity
No
Event Type
Date
Bill Of Materials

Title : Production Order

Toolbars

call BrowseEditDelete()
call CloseForm(True)
call CloseForm(False)

Buttons

Fields


 (AU_GOOD.TITLE)
 (AU_KE_GOOD.COMMENT)
 (AU_KE_GOOD.COEF)
 (AU_UNITMEAS.DESCR)
 (AU_KE_GOOD.QUANT2)
 (AU_KE_GOOD.QUANT)
 (AU_WAREHOUSE.DESCR)
Position (AU_POS.POS_D)
Product Quantity (AU_EVENT.QUANT)
 (AU_UNITMEAS.DESCR)
No (AU_EVENT.NUMBER)
Event Type (AU_T_EVENT.CODE)
 (AU_T_EVENT.DESCR)
Date (AU_EVENT.DATE)
Bill Of Materials (AU_PROD_FORM.DESCR)


AutoScript

lib

{================================== Form_Start ==============================}

proc Form_Start()

     f = TopForm()
     task = FormTask(f)
     p = PByName(f,"AU_EVENT")
     t = TByName(p,"AU_EVENT")
     p_synt = PByName(f,"AU_KE_GOOD")
     t_synt = TByName(p_synt,"AU_KE_GOOD")

     call SetCaption("Production Order")

     if (task = ptAppend) then

        if (__params[6] > 0) then {...from sales order}

         call TEdit(t)
         call TSetFld(t,"EVENT_E",__params[6])
         call TPost(t)

        endif

        str = SelectFrom("SELECT AU_T_EVENT, DESCR, CODE FROM AU_T_EVENT WHERE (CODE='AU_PRDORD')")
        tevent = GetSQLSelectItem(str,1)
        tevent_descr = GetSQLSelectItem(str,2)
        tevent_code = GetSQLSelectItem(str,3)

        call TEdit(t)
        call TSetFld(t,"AU_T_EVENT",tevent)
        call TSetFld(t,"F_AU_T_EVENT_CODE",tevent_code)
        call TSetFld(t,"F_AU_T_EVENT_DESCR",tevent_descr)
        call TPost(t)

        call ReLoadEditFields(f)

     endif

     {......................................selection lists..............}
     start_sql "DESCR_SEL" "KOSMOS"
       SELECT AU_T_EVENT.DESCR, AU_T_EVENT.CODE, AU_T_EVENT.AU_T_EVENT
       FROM AU_KEVENT INNER JOIN AU_T_EVENT
       ON AU_KEVENT.AU_KEVENT = AU_T_EVENT.KEVENT1
       WHERE (AU_T_EVENT.KEVENT1=15)
       AND (AU_T_EVENT.DESCR LIKE :E & '%')
       ORDER BY AU_T_EVENT.DESCR
     end_sql
     start_sql "CODE_SEL" "KOSMOS"
       SELECT AU_T_EVENT.CODE, AU_T_EVENT.DESCR, AU_T_EVENT.AU_T_EVENT
       FROM AU_KEVENT INNER JOIN AU_T_EVENT
       ON AU_KEVENT.AU_KEVENT = AU_T_EVENT.KEVENT1
       WHERE (AU_T_EVENT.KEVENT1=15)
       AND (AU_T_EVENT.CODE LIKE :E & '%')
       ORDER BY AU_T_EVENT.CODE
     end_sql

end

proc Select_DESCR_SEL_Params()

   s = GetEditedText()
   call ParamsEmbSQL("DESCR_SEL",s)

end

proc Select_CODE_SEL_Params()

   s = GetEditedText()
   call ParamsEmbSQL("CODE_SEL",s)

end

{=================================== quant_exit ==================================}

proc quant_exit()

     synt_id = TGetFld(t,"AU_PROD_FORM")
     eposot = TGetFld(t,"QUANT")
     eposot0 = LookUpId("AU_PROD_FORM",synt_id,"PQUANT")

     start_sql "*" "KOSMOS"
       SELECT * FROM AU_PROD_FORM_GOOD
       WHERE (AU_PROD_FORM = :F)
     end_sql
     q = QueryByName()
     call TSetParam(q,"F",synt_id)
     call TExecute(q)
     count_synt = TRecordCount(q)

     call TFirst(q)
     for i = 1 to count_synt

         eidh0 = TGetFld(q,"AU_GOOD")
         descr = LookUpId("AU_GOOD",eidh0,"TITLE")
         unit_id = TGetFld(q,"AU_UNITMEAS")
         unit_descr = LookUpId("AU_UNITMEAS",unit_id,"DESCR")
         spc0 = TGetFld(q,"SPC")
         spc        = spc0 * eposot / eposot0

         call TAppend(t_synt)
         call TSetFld(t_synt,"AU_GOOD",eidh0)
         call TSetFld(t_synt,"F_AU_GOOD_TITLE",descr)
         call TSetFld(t_synt,"AU_UNITMEAS",unit_id)
         call TSetFld(t_synt,"F_AU_UNITMEAS_DESCR",unit_descr)
         call TSetFld(t_synt,"QUANT2",spc)
         call TSetFld(t_synt,"COEF","-1")
         call TPost(t_synt)

         call TNext(q)
     next
     call FreeEmbSQL(q)

     eidh0      = LookUpId("AU_PROD_FORM",synt_id,"AU_GOOD")
     descr      = LookUpId("AU_GOOD",eidh0,"TITLE")
     unit_id = TGetFld(t,"AU_UNITMEAS")
     unit_descr = LookUpId("AU_UNITMEAS",unit_id,"DESCR")

     call TAppend(t_synt)
     call TSetFld(t_synt,"AU_GOOD",eidh0)
     call TSetFld(t_synt,"F_AU_GOOD_TITLE",descr)
     call TSetFld(t_synt,"AU_UNITMEAS",unit_id)
     call TSetFld(t_synt,"F_AU_UNITMEAS_DESCR",unit_descr)
     call TSetFld(t_synt,"QUANT2",eposot)
     call TSetFld(t_synt,"COEF","1")
     call TPost(t_synt)

     call ReLoadEditFields(f)

end

{============================== Form_BeforeClose ===============================}

fun Form_BeforeClose()

    result = 1

    good = TGetFld(t,"F_AU_PROD_FORM_DESCR")
    quant = TGetFld(t,"QUANT")
    meas = TGetFld(t,"F_AU_UNITMEAS_DESCR")

    comm1 = strcat(good," / ",quant," ",meas)
    comm1 = Copy(comm1,1,80)

    call TEdit(t)
    call TSetFld(t,"REASON1",comm1)
    call TPost(t)

    {..............check for au_ke_good valitity}
    count = TRecordCount(t_synt)
    call TFirst(t_synt)
    for i = 1 to count
        id = TGetFld(t_synt,"AU_GOOD")
        id = val(id)
        if (id = 0) then
         call message("Line ",i," misses good!")
         result = 0
        endif

        qnt = TGetFld(t_synt,"QUANT2")
        qnt = val(qnt)
        if (qnt = 0) then
         call message("Line ",i," misses scheduled quantity!")
         result = 0
        endif

        coef = TGetFld(t_synt,"COEF")
        coef = Abs(coef)
        if (coef <> 1) then
         call message("Line ",i," has wrong coefficient!")
         result = 0
        endif

        id = TGetFld(t_synt,"AU_UNITMEAS")
        id = val(id)
        if (id = 0) then
         call message("Line ",i," misses unit!")
         result = 0
        endif

        id = TGetFld(t_synt,"WAREHOUSE")
        id = val(id)
        if (id = 0) then
         call message("Line ",i," misses warehouse!")
         result = 0
        endif

        call TNext(t_synt)
    next

end

{============================= Form_End ============================}

proc Form_End ( uvalue )

     if (task = ptAppend) then

        call bpm_startcoordinator ( "AU_PRODUCTION_COORDINATOR", uvalue, "AU_PROD_ORDER_E.FM", comm1 )

     else

        call bpm_clientchangescomments(f,comm1)

     endif

end