美文网首页ERP
最新核价表

最新核价表

作者: jiandanyaobai | 来源:发表于2019-09-25 23:24 被阅读0次

    业务需求、需要抓出系统现有供应商+料件的最新核价情况
    问题解决基本思路
    1、数据库中抓取供应商+料件分组(group by )
    2、针对抓出的每笔数据循环查出第一笔核价资料(时间最新,价格最大)
    3、目前数据量在20W以内速度还可以接受,后续数据量在大,需要采用后台计算后写表的方式提升性能。

    IMPORT os
    IMPORT util
    IMPORT JAVA com.fourjs.fgl.lang.FglRecord  #(ver:38) add
    #add-point:增加匯入項目 name="global.import"
    
    #end add-point
     
    SCHEMA ds
     
    GLOBALS "../../cfg/top_global.inc"
    #(ver:38) ---add start---
    GLOBALS
    #單身匯excel POI變數
    TYPE rec_arr_type           ARRAY [] OF com.fourjs.fgl.lang.FglRecord
    DEFINE g_export_tag         DYNAMIC ARRAY OF rec_arr_type                 #畫面欄位數
    DEFINE g_export_tabname     DYNAMIC ARRAY OF STRING                       #畫面名稱
    END GLOBALS
    #(ver:38) --- add end ---
    #add-point:增加匯入變數檔 name="global.inc"
    
    #end add-point
     
    #單身 type 宣告
    PRIVATE TYPE type_g_pmdi_d RECORD
           
           sel LIKE type_t.chr1, 
       pmdi001 LIKE pmdi_t.pmdi001, 
       pmdi004 LIKE pmdi_t.pmdi004, 
       pmdi004_desc LIKE type_t.chr500, 
       pmdi005 LIKE pmdi_t.pmdi005, 
       pmdi005_desc LIKE type_t.chr500, 
       pmdi006 LIKE pmdi_t.pmdi006, 
       pmdi006_desc LIKE type_t.chr500, 
       pmdi007 LIKE pmdi_t.pmdi007, 
       pmdi008 LIKE pmdi_t.pmdi008, 
       pmdi009 LIKE pmdi_t.pmdi009, 
       pmdi009_desc LIKE type_t.chr500, 
       pmdi011 LIKE pmdi_t.pmdi011, 
       pmdi011_desc LIKE type_t.chr500, 
       pmdi015 LIKE pmdi_t.pmdi015, 
       pmdi030 LIKE pmdi_t.pmdi030, 
       pmdi034 LIKE pmdi_t.pmdi034, 
       pmdj002 LIKE pmdj_t.pmdj002, 
       pmdj002_desc LIKE type_t.chr500, 
       pmdj008 LIKE pmdj_t.pmdj008, 
       pmdj008_desc LIKE type_t.chr500, 
       pmdj009 LIKE pmdj_t.pmdj009, 
       pmdj010 LIKE pmdj_t.pmdj010, 
       pmdj011 LIKE pmdj_t.pmdj011, 
       pmdj012 LIKE pmdj_t.pmdj012, 
       pmdj016 LIKE pmdj_t.pmdj016, 
       pmdj016_desc LIKE type_t.chr500, 
       pmdj030 LIKE pmdj_t.pmdj030, 
       pmdjud011 LIKE pmdj_t.pmdjud011, 
       pmdjud012 LIKE pmdj_t.pmdjud012, 
       pmdk001 LIKE pmdk_t.pmdk001, 
       pmdk002 LIKE pmdk_t.pmdk002, 
       pmdkseq LIKE pmdk_t.pmdkseq, 
       pmdk003 LIKE pmdk_t.pmdk003
           END RECORD
     
     
    #add-point:自定義模組變數-標準(Module Variable)  (請盡量不要在客製環境修改此段落內容, 否則將後續patch的調整需人工處理) name="global.variable"
    DEFINE l_pmdidocno         LIKE pmdi_t.pmdidocno
    
    DEFINE l_pmdi  RECORD         #add by huzhou
       pmdient  LIKE pmdi_t.pmdient,
       pmdisite LIKE pmdi_t.pmdisite,
       pmdi004  LIKE pmdi_t.pmdi004,
       pmdj002  LIKE pmdj_t.pmdj002
         END RECORD    
       
    #end add-point
     
    #模組變數(Module Variables)
    DEFINE g_pmdi_d            DYNAMIC ARRAY OF type_g_pmdi_d
    DEFINE g_pmdi_d_t          type_g_pmdi_d
     
     
     
     
    DEFINE g_wc                  STRING                        #儲存 user 的查詢條件
    DEFINE g_wc_t                STRING                        #儲存 user 的查詢條件
    DEFINE g_wc2                 STRING
    DEFINE g_wc_filter           STRING
    DEFINE g_wc_filter_t         STRING
    DEFINE g_sql                 STRING                        #組 sql 用 
    DEFINE g_forupd_sql          STRING                        #SELECT ... FOR UPDATE  SQL    
    DEFINE g_cnt                 LIKE type_t.num10              
    DEFINE l_ac                  LIKE type_t.num10             #目前處理的ARRAY CNT 
    DEFINE g_curr_diag           ui.Dialog                     #Current Dialog     
    DEFINE gwin_curr             ui.Window                     #Current Window
    DEFINE gfrm_curr             ui.Form                       #Current Form
    DEFINE g_current_page        LIKE type_t.num5              #目前所在頁數
    DEFINE g_current_row         LIKE type_t.num10             #目前所在筆數
    DEFINE g_current_idx         LIKE type_t.num10
    DEFINE g_detail_cnt          LIKE type_t.num10             #單身 總筆數(所有資料)
    DEFINE g_page                STRING                        #第幾頁
    DEFINE g_ch                  base.Channel                  #外串程式用
    DEFINE g_ref_fields          DYNAMIC ARRAY OF VARCHAR(500) #ap_ref用陣列
    DEFINE g_ref_vars            DYNAMIC ARRAY OF VARCHAR(500) #ap_ref用陣列
    DEFINE g_rtn_fields          DYNAMIC ARRAY OF VARCHAR(500) #ap_ref用陣列
    DEFINE g_error_show          LIKE type_t.num5
    DEFINE g_row_index           LIKE type_t.num10
    DEFINE g_master_idx          LIKE type_t.num10
    DEFINE g_detail_idx          LIKE type_t.num10             #單身 所在筆數(所有資料)
    DEFINE g_detail_idx2         LIKE type_t.num10
    DEFINE g_hyper_url           STRING                        #hyperlink的主要網址
    DEFINE g_qbe_hidden          LIKE type_t.num5              #qbe頁籤折疊
    DEFINE g_tot_cnt             LIKE type_t.num10             #計算總筆數
    DEFINE g_num_in_page         LIKE type_t.num10             #每頁筆數
    DEFINE g_page_act_list       STRING                        #分頁ACTION清單
    DEFINE g_current_row_tot     LIKE type_t.num10             #目前所在總筆數
    DEFINE g_page_start_num      LIKE type_t.num10             #目前頁面起始筆數
    DEFINE g_page_end_num        LIKE type_t.num10             #目前頁面結束筆數
     
    #多table用wc
    DEFINE g_wc_table           STRING
    DEFINE g_detail_page_action STRING
    DEFINE g_pagestart          LIKE type_t.num10
     
     
     
    DEFINE g_wc_filter_table           STRING
     
     
     
    #add-point:自定義模組變數-客製(Module Variable) name="global.variable_customerization"
    
    #end add-point
     
    #add-point:傳入參數說明 name="global.argv"
    
    #end add-point
    
    {</section>}
    
    {<section id="cpmq001.main" type="s" >}
     #應用 a26 樣板自動產生(Version:7)
    #+ 作業開始(主程式類型)
    MAIN
       #add-point:main段define(客製用) name="main.define_customerization"
    
       #end add-point   
       #add-point:main段define(請盡量不要在客製環境修改此段落內容, 否則將後續patch的調整需人工處理) name="main.define"
    
       #end add-point   
       
       OPTIONS
       INPUT NO WRAP
       DEFER INTERRUPT
       
       #設定SQL錯誤記錄方式 (模組內定義有效)
       WHENEVER ERROR CALL cl_err_msg_log
           
       #依模組進行系統初始化設定(系統設定)
       CALL cl_ap_init("cpm","")
     
       #add-point:作業初始化 name="main.init"
    
       #end add-point
       
       
     
       #LOCK CURSOR (identifier)
       #add-point:SQL_define name="main.define_sql"
    
       #end add-point
       LET g_forupd_sql = " ", 
                          " FROM ",
                          " "
       #add-point:SQL_define name="main.after_define_sql"
    
       #end add-point
       LET g_forupd_sql = cl_sql_forupd(g_forupd_sql)                #轉換不同資料庫語法
       LET g_forupd_sql = cl_sql_add_mask(g_forupd_sql)              #遮蔽特定資料
       DECLARE cpmq001_cl CURSOR FROM g_forupd_sql                 # LOCK CURSOR
     
       LET g_sql = " SELECT  ",
                   " FROM  t0",
                   
                   " WHERE  "
       LET g_sql = cl_sql_add_mask(g_sql)              #遮蔽特定資料
       #add-point:SQL_define name="main.after_refresh_sql"
    
       #end add-point
       PREPARE cpmq001_master_referesh FROM g_sql
     
       #add-point:main段define_sql name="main.body.define_sql"
    
       #end add-point 
       LET g_forupd_sql = ""
       #add-point:main段define_sql name="main.body.after_define_sql"
    
       #end add-point 
       LET g_forupd_sql = cl_sql_forupd(g_forupd_sql)
       LET g_forupd_sql = cl_sql_add_mask(g_forupd_sql)              #遮蔽特定資料
       DECLARE cpmq001_bcl CURSOR FROM g_forupd_sql
        
     
       
       IF g_bgjob = "Y" THEN
          #add-point:Service Call name="main.servicecall"
    
          #end add-point
       ELSE
          #畫面開啟 (identifier)
          OPEN WINDOW w_cpmq001 WITH FORM cl_ap_formpath("cpm",g_code)
       
          #瀏覽頁簽資料初始化
          CALL cl_ui_init()
       
          #程式初始化
          CALL cpmq001_init()   
     
          #進入選單 Menu (="N")
          CALL cpmq001_ui_dialog() 
          
          #add-point:畫面關閉前 name="main.before_close"
    
          #end add-point
     
          #畫面關閉
          CLOSE WINDOW w_cpmq001
          
       END IF 
       
       CLOSE cpmq001_cl
       
       
     
       #add-point:作業離開前 name="main.exit"
    
       #end add-point
     
       #離開作業
       CALL cl_ap_exitprogram("0")
    END MAIN
     
     
     
    
    {</section>}
    
    {<section id="cpmq001.init" type="s" >}
    #+ 瀏覽頁簽資料初始化
    PRIVATE FUNCTION cpmq001_init()
       #add-point:init段define-客製 name="init.define_customerization"
    
       #end add-point
       #add-point:init段define-標準  (請盡量不要在客製環境修改此段落內容, 否則將後續patch的調整需人工處理) name="init.define"
    
       #end add-point
     
       #add-point:FUNCTION前置處理 name="init.before_function"
    
       #end add-point
     
       LET g_wc_filter   = "  1 = 1  "   #171117-00042 modify  將1=1改為空白   #171219-00006 改為"  1 = 1  "
       LET g_wc_filter_t = ""   #171117-00042 modify  將1=1改為空白
       LET g_error_show  = 1
       LET g_detail_idx  = 1
       LET g_detail_idx2 = 1
       
         
     
       #add-point:畫面資料初始化 name="init.init"
    
       #end add-point
     
       CALL cpmq001_default_search()
    END FUNCTION
    
    {</section>}
    
    {<section id="cpmq001.default_search" type="s" >}
    PRIVATE FUNCTION cpmq001_default_search()
       #add-point:default_search段define-客製 name="default_search.define_customerization"
    
       #end add-point
       #add-point:default_search段define-標準  (請盡量不要在客製環境修改此段落內容, 否則將後續patch的調整需人工處理) name="default_search.define"
    
       #end add-point
     
     
       #add-point:default_search段開始前 name="default_search.before"
    
       #end add-point
     
       #應用 qs27 樣板自動產生(Version:3)
       #+ 組承接外部參數時資料庫欄位對應條件(單身)
       IF NOT cl_null(g_argv[01]) THEN
          LET g_wc = g_wc, " pmdidocno = '", g_argv[01], "' AND "
       END IF
     
     
     
     
     
     
     
       IF NOT cl_null(g_wc) THEN
          LET g_wc = g_wc.subString(1,g_wc.getLength()-5)
       ELSE
          #預設查詢條件
          LET g_wc = " 1=2"
       END IF
     
       #add-point:default_search段結束前 name="default_search.after"
    
       #end add-point
     
    END FUNCTION
    
    {</section>}
    
    {<section id="cpmq001.ui_dialog" type="s" >}
    #+ 選單功能實際執行處
    PRIVATE FUNCTION cpmq001_ui_dialog() 
       #add-point:ui_dialog段define-客製 name="ui_dialog.define_customerization"
    
       #end add-point
       DEFINE li_exit   LIKE type_t.num5    #判別是否為離開作業
       DEFINE li_idx    LIKE type_t.num10
       DEFINE ls_result STRING
       DEFINE ls_wc     STRING
       DEFINE lc_action_choice_old   STRING
       DEFINE ls_js     STRING
       DEFINE la_param  RECORD
                        prog       STRING,
                        actionid   STRING,
                        background LIKE type_t.chr1,
                        param      DYNAMIC ARRAY OF STRING
                        END RECORD
       #(ver:38) ---add start---
       DEFINE l_arr_len       INTEGER
       DEFINE l_arr_cnt       INTEGER
       DEFINE lb_get_type     LIKE type_t.chr20
       #(ver:38) --- add end ---
       #add-point:ui_dialog段define-標準  (請盡量不要在客製環境修改此段落內容, 否則將後續patch的調整需人工處理) name="ui_dialog.define"
    
       #end add-point
       
     
       #add-point:FUNCTION前置處理 name="ui_dialog.before_function"
    
       #end add-point
     
       CALL cl_set_act_visible("accept,cancel", FALSE)
       CALL cl_get_num_in_page() RETURNING g_num_in_page
     
       LET li_exit = FALSE
       LET gwin_curr = ui.Window.getCurrent()
       LET gfrm_curr = gwin_curr.getForm()   
       LET g_current_idx = 1
       LET g_action_choice = " "
       LET lc_action_choice_old = ""
       LET g_current_row_tot = 0
       LET g_page_start_num = 1
       LET g_page_end_num = g_num_in_page
       LET g_detail_idx = 1
       LET g_detail_idx2 = 1
       LET l_ac = 1
     
       #add-point:ui_dialog段before dialog  name="ui_dialog.before_dialog"
    
       LET g_wc = " 1=2"
    
       #end add-point
     
       
       CALL cpmq001_b_fill()
      
       WHILE li_exit = FALSE
     
          IF g_action_choice = "logistics" THEN
             #清除畫面及相關資料
             CLEAR FORM
             CALL g_pmdi_d.clear()
     
             LET g_wc  = " 1=2"
             LET g_wc2 = " 1=1"
             LET g_action_choice = ""
             LET g_detail_page_action = "detail_first"
             LET g_pagestart = 1
             LET g_current_row_tot = 0
             LET g_page_start_num = 1
             LET g_page_end_num = g_num_in_page
             LET g_detail_idx = 1
             LET g_detail_idx2 = 1
     
             CALL cpmq001_init()
          END IF
     
          DIALOG ATTRIBUTES(UNBUFFERED,FIELD ORDER FORM)
             #add-point:input段落 name="ui_dialog.input"
    
             #end add-point
     
             #add-point:construct段落 name="ui_dialog.construct"
             CONSTRUCT BY NAME g_wc ON pmdi004,pmdi015,pmdj002
    
                ON ACTION controlp INFIELD pmdidocno
                   INITIALIZE g_qryparam.* TO NULL
                   LET g_qryparam.state = 'c'
                   LET g_qryparam.reqry = FALSE
                   CALL q_pmdidocno()                         #呼叫開窗
                   DISPLAY g_qryparam.return1 TO pmdidocno    #顯示到畫面上
                   NEXT FIELD pmdidocno                       #返回原欄位
    
                ON ACTION controlp INFIELD pmdi004
                   INITIALIZE g_qryparam.* TO NULL
                   LET g_qryparam.state = 'c'
                   LET g_qryparam.reqry = FALSE
                   CALL q_pmaa001_3()                         #呼叫開窗
                   DISPLAY g_qryparam.return1 TO pmdi004    #顯示到畫面上
                   NEXT FIELD pmdi004      
           
             END CONSTRUCT         
                   
             #end add-point
         
             DISPLAY ARRAY g_pmdi_d TO s_detail1.* ATTRIBUTE(COUNT=g_detail_cnt)
     
                BEFORE DISPLAY
                   LET g_current_page = 1
     
                BEFORE ROW
                   LET g_detail_idx = DIALOG.getCurrentRow("s_detail1")
                   LET l_ac = g_detail_idx
                #  CALL cpmq001_detail_action_trans()   #(ver:36) mark
     
                   LET g_master_idx = l_ac
                   #為避免按上下筆時影響執行效能,所以做一些處理
                   LET lc_action_choice_old = g_action_choice
                   LET g_action_choice = "fetch"
                   CALL cpmq001_b_fill2()
                   CALL cpmq001_detail_action_trans()   #(ver:36)
                   LET g_action_choice = lc_action_choice_old
     
                   #add-point:input段before row name="input.body.before_row"
    
                   #end add-point
     
                
     
                #自訂ACTION(detail_show,page_1)
                
     
                #add-point:page1自定義行為 name="ui_dialog.body.page1.action"
    
                #end add-point
     
             END DISPLAY
     
             #add-point:第一頁籤程式段mark結束用 name="ui_dialog.page1.mark.end"
    
             #end add-point
     
     
     
             #add-point:ui_dialog段自定義display array name="ui_dialog.more_displayarray"
    
             #end add-point
     
             BEFORE DIALOG
                CALL cl_ap_code_set_action() #171110-00013#1
                LET g_curr_diag = ui.DIALOG.getCurrent()
                CALL DIALOG.setSelectionMode("s_detail1", 1)
                LET g_detail_idx = DIALOG.getCurrentRow("s_detail1")
                CALL cpmq001_detail_action_trans()
     
                #add-point:ui_dialog段before dialog name="ui_dialog.bef_dialog"
    
                #end add-point
                NEXT FIELD pmdi004
     
             AFTER DIALOG
                #add-point:ui_dialog段 after dialog name="ui_dialog.after_dialog"
    
                #end add-point
                
             ON ACTION exit
                LET g_action_choice="exit"
                LET INT_FLAG = FALSE
                LET li_exit = TRUE
                EXIT DIALOG 
          
             ON ACTION close
                LET INT_FLAG=FALSE
                LET li_exit = TRUE
                EXIT DIALOG
     
             ON ACTION accept
             #  INITIALIZE g_wc_filter TO NULL   #171117-00042 mark
                IF cl_null(g_wc) THEN
                   LET g_wc = " 1=1"
                END IF
     
     
             
                IF cl_null(g_wc2) THEN
                   LET g_wc2 = " 1=1"
                END IF
     
     
     
                #add-point:ON ACTION accept name="ui_dialog.accept"
    
                #end add-point
     
                LET g_detail_idx = 1
                LET g_detail_idx2 = 1
                CALL cpmq001_b_fill()
     
                IF g_detail_cnt = 0 AND NOT INT_FLAG THEN
                   INITIALIZE g_errparam TO NULL
                   LET g_errparam.extend = ""
                   LET g_errparam.code = -100
                   LET g_errparam.popup = TRUE
                   CALL cl_err()
                END IF
     
     
             ON ACTION agendum   # 待辦事項
                #add-point:ON ACTION agendum name="ui_dialog.agendum"
    
                #end add-point
                CALL cl_user_overview()
     
             ON ACTION exporttoexcel   #匯出excel
                LET g_action_choice="exporttoexcel"
                IF cl_auth_chk_act("exporttoexcel") THEN
                   #(ver:38) ---start---
                   #因應匯出excel規則調整,需同時符合新舊做法
                   LET lb_get_type = cl_get_exporttoexcel_type()
                   #add-point:ON ACTION exporttoexcel name="ui_dialog.exporttoexcel_type_change"
    
                   #END add-point
                   DISPLAY "lb_get_type:",lb_get_type
     
                   CASE
                      WHEN lb_get_type = "poi"   #使用poi樣板
                         CALL g_export_node.clear()
                         LET l_arr_len = g_pmdi_d.getLength()
                         LET g_export_tag[1] = rec_arr_type.create(l_arr_len)
                         LET g_export_tabname[1] = "s_detail1"
                         FOR l_arr_cnt = 1 TO l_arr_len
                            LET g_export_tag[1][l_arr_cnt] = g_pmdi_d[l_arr_cnt]
                         END FOR
     
     
                         
                         #add-point:ON ACTION exporttoexcel name="menu.exporttoexcel_poi"
    
                         #END add-point
                         CALL cl_export_to_excel_getpage()
                         CALL cl_export_poi()
                         #add-point:ON ACTION exporttoexcel name="menu.exporttoexcel_after_poi"
    
                         #END add-point
     
                      OTHERWISE   #使用原始樣板
                   #(ver:38) --- end ---
                         CALL g_export_node.clear()
                         LET g_export_node[1] = base.typeInfo.create(g_pmdi_d)
                         LET g_export_id[1]   = "s_detail1"
     
                         #add-point:ON ACTION exporttoexcel name="menu.exporttoexcel"
    
                         #END add-point
                         CALL cl_export_to_excel_getpage()
                         CALL cl_export_to_excel()
                         #add-point:ON ACTION exporttoexcel name="menu.exporttoexcel_after"   #(ver:35)
    
                         #END add-point
                   END CASE   #(ver:38) add
                END IF
     
             ON ACTION datarefresh   # 重新整理
                CALL cpmq001_b_fill()
     
             ON ACTION qbehidden     #qbe頁籤折疊
                IF g_qbe_hidden THEN
                   CALL gfrm_curr.setElementHidden("qbe",0)
                   CALL gfrm_curr.setElementImage("qbehidden","16/mainhidden.png")
                   LET g_qbe_hidden = 0     #visible
                ELSE
                   CALL gfrm_curr.setElementHidden("qbe",1)
                   CALL gfrm_curr.setElementImage("qbehidden","16/worksheethidden.png")
                   LET g_qbe_hidden = 1     #hidden
                END IF
     
             ON ACTION detail_first               #page first
                LET g_action_choice = "detail_first"
                LET g_detail_page_action = "detail_first"
                CALL cpmq001_b_fill()
     
             ON ACTION detail_previous                #page previous
                LET g_action_choice = "detail_previous"
                LET g_detail_page_action = "detail_previous"
                CALL cpmq001_b_fill()
     
             ON ACTION detail_next               #page next
                LET g_action_choice = "detail_next"
                LET g_detail_page_action = "detail_next"
                CALL cpmq001_b_fill()
     
             ON ACTION detail_last               #page last
                LET g_action_choice = "detail_last"
                LET g_detail_page_action = "detail_last"
                CALL cpmq001_b_fill()
     
             #應用 qs19 樣板自動產生(Version:3)
             #有關於sel欄位選取的action段落
             #選擇全部
             ON ACTION selall
                CALL DIALOG.setSelectionRange("s_detail1", 1, -1, 1)
                FOR li_idx = 1 TO g_pmdi_d.getLength()
                   LET g_pmdi_d[li_idx].sel = "Y"
                END FOR
     
                #add-point:ui_dialog段on action selall name="ui_dialog.onaction_selall"
    
                #end add-point
     
             #取消全部
             ON ACTION selnone
                CALL DIALOG.setSelectionRange("s_detail1", 1, -1, 0)
                FOR li_idx = 1 TO g_pmdi_d.getLength()
                   LET g_pmdi_d[li_idx].sel = "N"
                END FOR
     
                #add-point:ui_dialog段on action selnone name="ui_dialog.onaction_selnone"
    
                #end add-point
     
             #勾選所選資料
             ON ACTION sel
                FOR li_idx = 1 TO g_pmdi_d.getLength()
                   IF DIALOG.isRowSelected("s_detail1", li_idx) THEN
                      LET g_pmdi_d[li_idx].sel = "Y"
                   END IF
                END FOR
     
                #add-point:ui_dialog段on action sel name="ui_dialog.onaction_sel"
    
                #end add-point
     
             #取消所選資料
             ON ACTION unsel
                FOR li_idx = 1 TO g_pmdi_d.getLength()
                   IF DIALOG.isRowSelected("s_detail1", li_idx) THEN
                      LET g_pmdi_d[li_idx].sel = "N"
                   END IF
                END FOR
     
                #add-point:ui_dialog段on action unsel name="ui_dialog.onaction_unsel"
    
                #end add-point
     
     
     
     
     
             #應用 qs16 樣板自動產生(Version:3)
             ON ACTION filter
                LET g_action_choice="filter"
                CALL cpmq001_filter()
                #add-point:ON ACTION filter name="menu.filter"
    
                #END add-point
                EXIT DIALOG
     
     
     
     
             
             #應用 a43 樣板自動產生(Version:4)
             ON ACTION insert
                LET g_action_choice="insert"
                IF cl_auth_chk_act("insert") THEN
                   
                   #add-point:ON ACTION insert name="menu.insert"
    
                   #END add-point
                   
                   
                END IF
     
     
     
     
             #應用 a43 樣板自動產生(Version:4)
             ON ACTION modify_deatil
                LET g_action_choice="modify_deatil"
                IF cl_auth_chk_act("modify_deatil") THEN
                   
                   #add-point:ON ACTION modify_deatil name="menu.modify_deatil"
    
                   #END add-point
                   
                   
                END IF
     
     
     
     
             #應用 a43 樣板自動產生(Version:4)
             ON ACTION output
                LET g_action_choice="output"
                IF cl_auth_chk_act("output") THEN
                   
                   #add-point:ON ACTION output name="menu.output"
    
                   #END add-point
                   
                   
                END IF
     
     
     
     
             #應用 a43 樣板自動產生(Version:4)
             ON ACTION quickprint
                LET g_action_choice="quickprint"
                IF cl_auth_chk_act("quickprint") THEN
                   
                   #add-point:ON ACTION quickprint name="menu.quickprint"
    
                   #END add-point
                   
                   
                END IF
     
     
     
     
             #應用 a43 樣板自動產生(Version:4)
             ON ACTION query
                LET g_action_choice="query"
                IF cl_auth_chk_act("query") THEN
                   
                   #add-point:ON ACTION query name="menu.query"
    
                   #END add-point
                   
                   
                END IF
     
     
     
     
             #應用 a43 樣板自動產生(Version:4)
             ON ACTION datainfo
                LET g_action_choice="datainfo"
                IF cl_auth_chk_act("datainfo") THEN
                   
                   #add-point:ON ACTION datainfo name="menu.datainfo"
    
                   #END add-point
                   
                   
                END IF
     
     
     
     
          
             #主選單用ACTION
             &include "main_menu_exit_dialog.4gl"
             &include "relating_action.4gl"
             #交談指令共用ACTION
             &include "common_action.4gl"
     
             #add-point:查詢方案相關ACTION設定前 name="ui_dialog.set_qbe_action_before"
    
             #end add-point
     
             ON ACTION qbeclear   # 條件清除
                CLEAR FORM
                #add-point:條件清除後 name="ui_dialog.qbeclear"
    
                #end add-point
     
             #add-point:查詢方案相關ACTION設定後 name="ui_dialog.set_qbe_action_after"
    
             #end add-point
     
          END DIALOG 
       
       END WHILE
     
    END FUNCTION
    
    {</section>}
    
    {<section id="cpmq001.b_fill" type="s" >}
    #+ 單身陣列填充
    PRIVATE FUNCTION cpmq001_b_fill()
       #add-point:b_fill段define-客製 name="b_fill.define_customerization"
    
       #end add-point
       DEFINE ls_wc           STRING
       DEFINE l_pid           LIKE type_t.chr50
       DEFINE ls_sql_rank     STRING
       #add-point:b_fill段define-標準  (請盡量不要在客製環境修改此段落內容, 否則將後續patch的調整需人工處理) name="b_fill.define"
       DEFINE l_cnt         LIKE type_t.num10          #add by zhouge 
       #end add-point
     
       #add-point:b_fill段sql_before name="b_fill.sql_before"
    
       #end add-point
     
     
       #171117-00042 ---mark start---
    #  IF cl_null(g_wc_filter) THEN
    #     LET g_wc_filter = " 1=1"
    #  END IF
       #171117-00042 --- mark end ---
     
       IF cl_null(g_wc) THEN
          LET g_wc = " 1=1"
       END IF
       IF cl_null(g_wc2) THEN
          LET g_wc2 = " 1=1"
       END IF
     
    #  LET ls_wc = g_wc, " AND ", g_wc2, " AND ", g_wc_filter, cl_sql_auth_filter()   #(ver:34) add cl_sql_auth_filter()   #171117-00042 mark
       LET ls_wc = g_wc, " AND ", g_wc2, " ",cl_sql_auth_filter()   #(ver:34) add cl_sql_auth_filter()   #171117-00042 modify
     
       CALL g_pmdi_d.clear()
       #(ver:36) ---modify start---
       #單身陣列清除
     
       #(ver:36) --- modify end ---
       #add-point:陣列清空 name="b_fill.array_clear"
       
       #end add-point
     
       LET g_cnt = l_ac
       IF g_cnt = 0 THEN
          LET g_cnt = 1
       END IF
       LET l_ac = 1
     
       # b_fill段sql組成及FOREACH撰寫
       #應用 qs04 樣板自動產生(Version:9)
       #+ b_fill段資料取得(包含sql組成及FOREACH段撰寫)
       LET ls_sql_rank = "SELECT  UNIQUE '',pmdi001,pmdi004,'',pmdi005,'',pmdi006,'',pmdi007,pmdi008,pmdi009, 
           '',pmdi011,'',pmdi015,pmdi030,pmdi034,'','','','','','','','','','','','','','','','',''  ,DENSE_RANK() OVER( ORDER BY pmdi_t.pmdidocno) AS RANK FROM pmdi_t", 
    
     
     
                         "",
                         " WHERE pmdient= ? AND 1=1 AND ", ls_wc
       LET ls_sql_rank = ls_sql_rank, cl_sql_add_filter("pmdi_t"),
                         " ORDER BY pmdi_t.pmdidocno"
     
       #add-point:b_fill段rank_sql_after name="b_fill.rank_sql_after"
       LET l_cnt = 1
       #end add-point
     
       LET g_sql = "SELECT COUNT(1) FROM (",ls_sql_rank,")"
     
       PREPARE b_fill_cnt_pre FROM g_sql  #總筆數
       EXECUTE b_fill_cnt_pre USING g_enterprise INTO g_tot_cnt
       FREE b_fill_cnt_pre
     
       #add-point:b_fill段rank_sql_after_count name="b_fill.rank_sql_after_count"
    
       #end add-point
     
       CASE g_detail_page_action
          WHEN "detail_first"
              LET g_pagestart = 1
     
          WHEN "detail_previous"
              LET g_pagestart = g_pagestart - g_num_in_page
              IF g_pagestart < 1 THEN
                  LET g_pagestart = 1
              END IF
     
          WHEN "detail_next"
             LET g_pagestart = g_pagestart + g_num_in_page
             IF g_pagestart > g_tot_cnt THEN
                LET g_pagestart = g_tot_cnt - (g_tot_cnt mod g_num_in_page) + 1
                WHILE g_pagestart > g_tot_cnt
                   LET g_pagestart = g_pagestart - g_num_in_page
                END WHILE
             END IF
     
          WHEN "detail_last"
             LET g_pagestart = g_tot_cnt - (g_tot_cnt mod g_num_in_page) + 1
             WHILE g_pagestart > g_tot_cnt
                LET g_pagestart = g_pagestart - g_num_in_page
             END WHILE
     
          OTHERWISE
             LET g_pagestart = 1
     
       END CASE
     
       LET g_sql = "SELECT '',pmdi001,pmdi004,'',pmdi005,'',pmdi006,'',pmdi007,pmdi008,pmdi009,'',pmdi011, 
           '',pmdi015,pmdi030,pmdi034,'','','','','','','','','','','','','','','','',''",
                   " FROM (",ls_sql_rank,")",
                  " WHERE RANK >= ",g_pagestart,
                    " AND RANK < ",g_pagestart + g_num_in_page
     
       #add-point:b_fill段sql_after name="b_fill.sql_after"
       CALL cpmq001_create_tmp()
    
       LET g_sql = " SELECT 'N',pmdi001, pmdi004,pmaal004, pmdi005, '', pmdi006, '',  pmdi007,  pmdi008, pmdi009, '', pmdi011,
                          '',pmdi015,pmdi030,pmdi034,pmdj002,imaal003,pmdj008,'',pmdj009,pmdj010,pmdj011,pmdj012,pmdj016,
                        '',pmdj030,pmdjud011,pmdjud012,'','','',''
                     FROM pmdi_t
                     LEFT join pmdj_t on pmdient = pmdjent and pmdisite = pmdjsite and pmdidocno = pmdjdocno      
                     left join imaal_t on imaalent=pmdjent and imaal001=pmdj002 and imaal002='zh_CN' 
                     left join pmaal_t on pmaal001=pmdi004 and pmaalent=pmdient 
                    WHERE pmdient = ?
                      AND pmdistus = 'Y'
                      AND pmdisite = ?
                      AND pmdi004= ?
                      AND pmdj002 = ?
                      AND ROWNUM = 1
                      ORDER BY pmdi015 DESC, pmdj011 DESC "
       PREPARE cpmq001_pb FROM g_sql  
       DISPLAY g_sql   
    
       LET g_sql =  " INSERT INTO cpmq001_tmp ",
                    " SELECT pmdient,pmdisite,pmdi004,pmdj002 FROM pmdi_t ", 
                    "   LEFT JOIN pmdj_t  ON pmdient=pmdjent AND pmdisite=pmdjsite AND pmdidocno=pmdjdocno ",
                    "  WHERE pmdient= ? AND pmdisite= ?  and ",ls_wc,
                    "  GROUP BY pmdient,pmdisite,pmdi004,pmdj002 "
                    
       PREPARE cpmq001_pr FROM g_sql
       EXECUTE cpmq001_pr USING g_enterprise,g_site
       IF SQLCA.sqlcode THEN
          INITIALIZE g_errparam TO NULL
          LET g_errparam.code   = SQLCA.sqlcode
          LET g_errparam.extend = "EXECUTE cpmq001_tmp"
          LET g_errparam.popup  = TRUE
          CALL cl_err()
       END IF  
       
       
       DECLARE b_fill_curs CURSOR FOR SELECT pmdient,pmdisite,pmdi004,pmdj002 FROM cpmq001_tmp 
       FOREACH b_fill_curs INTO l_pmdi.pmdient,l_pmdi.pmdisite,l_pmdi.pmdi004,l_pmdi.pmdj002  
       IF SQLCA.sqlcode THEN
          INITIALIZE g_errparam TO NULL 
          LET g_errparam.extend = "FOREACH:" 
          LET g_errparam.code   = SQLCA.sqlcode 
          LET g_errparam.popup  = TRUE 
          CALL cl_err()
          
          EXIT FOREACH
       END IF
           
       EXECUTE cpmq001_pb USING l_pmdi.pmdient,l_pmdi.pmdisite,l_pmdi.pmdi004,l_pmdi.pmdj002 INTO 
           g_pmdi_d[l_ac].sel,g_pmdi_d[l_ac].pmdi001,g_pmdi_d[l_ac].pmdi004,g_pmdi_d[l_ac].pmdi004_desc, 
           g_pmdi_d[l_ac].pmdi005,g_pmdi_d[l_ac].pmdi005_desc,g_pmdi_d[l_ac].pmdi006,g_pmdi_d[l_ac].pmdi006_desc, 
           g_pmdi_d[l_ac].pmdi007,g_pmdi_d[l_ac].pmdi008,g_pmdi_d[l_ac].pmdi009,g_pmdi_d[l_ac].pmdi009_desc, 
           g_pmdi_d[l_ac].pmdi011,g_pmdi_d[l_ac].pmdi011_desc,g_pmdi_d[l_ac].pmdi015,g_pmdi_d[l_ac].pmdi030, 
           g_pmdi_d[l_ac].pmdi034,g_pmdi_d[l_ac].pmdj002,g_pmdi_d[l_ac].pmdj002_desc,g_pmdi_d[l_ac].pmdj008, 
           g_pmdi_d[l_ac].pmdj008_desc,g_pmdi_d[l_ac].pmdj009,g_pmdi_d[l_ac].pmdj010,g_pmdi_d[l_ac].pmdj011, 
           g_pmdi_d[l_ac].pmdj012,g_pmdi_d[l_ac].pmdj016,g_pmdi_d[l_ac].pmdj016_desc,g_pmdi_d[l_ac].pmdj030, 
           g_pmdi_d[l_ac].pmdjud011,g_pmdi_d[l_ac].pmdjud012,g_pmdi_d[l_ac].pmdk001,g_pmdi_d[l_ac].pmdk002, 
           g_pmdi_d[l_ac].pmdkseq,g_pmdi_d[l_ac].pmdk003      
    
          #end add-point
     
          CALL cpmq001_detail_show("'1'")
     
          CALL cpmq001_pmdi_t_mask()
     
          IF l_ac > g_max_rec THEN
             IF g_error_show = 1 THEN
                INITIALIZE g_errparam TO NULL 
                LET g_errparam.extend =  "" 
                LET g_errparam.code   =  9035 
                LET g_errparam.popup  = TRUE 
                CALL cl_err()
     
             END IF
             EXIT FOREACH
          END IF
          LET l_ac = l_ac + 1
     
       END FOREACH
     
     
     
     
     
       #應用 qs05 樣板自動產生(Version:4)
       #+ b_fill段其他table資料取得(包含sql組成及資料填充)
     
     
     
     
     
     
       #add-point:b_fill段資料填充(其他單身) name="b_fill.others.fill"
    
    
    
    
    
    
       #end add-point
     
       CALL g_pmdi_d.deleteElement(g_pmdi_d.getLength())
     
       #add-point:陣列長度調整 name="b_fill.array_deleteElement"
    
       #end add-point
     
       LET g_error_show = 0
     
       LET g_detail_cnt = g_pmdi_d.getLength()
       LET l_ac = g_cnt
       LET g_cnt = 0
     
       #應用 qs06 樣板自動產生(Version:3)
       #+ b_fill段CURSOR釋放
       CLOSE b_fill_curs
       FREE cpmq001_pb
     
     
     
     
     
     
       #調整單身index指標,避免翻頁後指到空白筆數
       CALL cpmq001_detail_index_setting()
     
       #重新計算單身筆數並呈現
    #  CALL cpmq001_detail_action_trans()   #(ver:36) mark
     
       LET l_ac = 1
       IF g_pmdi_d.getLength() > 0 THEN
          CALL cpmq001_b_fill2()
       END IF
     
       CALL cpmq001_detail_action_trans()   #(ver:36)
     
          CALL cpmq001_filter_show('pmdi001','b_pmdi001')
       CALL cpmq001_filter_show('pmdi004','b_pmdi004')
       CALL cpmq001_filter_show('pmdi005','b_pmdi005')
       CALL cpmq001_filter_show('pmdi006','b_pmdi006')
       CALL cpmq001_filter_show('pmdi007','b_pmdi007')
       CALL cpmq001_filter_show('pmdi008','b_pmdi008')
       CALL cpmq001_filter_show('pmdi009','b_pmdi009')
       CALL cpmq001_filter_show('pmdi011','b_pmdi011')
       CALL cpmq001_filter_show('pmdi015','b_pmdi015')
       CALL cpmq001_filter_show('pmdi030','b_pmdi030')
       CALL cpmq001_filter_show('pmdi034','b_pmdi034')
       CALL cpmq001_filter_show('pmdj002','b_pmdj002')
       CALL cpmq001_filter_show('pmdj008','b_pmdj008')
       CALL cpmq001_filter_show('pmdj009','b_pmdj009')
       CALL cpmq001_filter_show('pmdj010','b_pmdj010')
       CALL cpmq001_filter_show('pmdj011','b_pmdj011')
       CALL cpmq001_filter_show('pmdj012','b_pmdj012')
       CALL cpmq001_filter_show('pmdj016','b_pmdj016')
       CALL cpmq001_filter_show('pmdj030','b_pmdj030')
       CALL cpmq001_filter_show('pmdjud011','b_pmdjud011')
       CALL cpmq001_filter_show('pmdjud012','b_pmdjud012')
       CALL cpmq001_filter_show('pmdk001','b_pmdk001')
       CALL cpmq001_filter_show('pmdk002','b_pmdk002')
       CALL cpmq001_filter_show('pmdkseq','b_pmdkseq')
       CALL cpmq001_filter_show('pmdk003','b_pmdk003')
     
     
    END FUNCTION
    
    {</section>}
    
    {<section id="cpmq001.b_fill2" type="s" >}
    #+ 單身陣列填充2
    PRIVATE FUNCTION cpmq001_b_fill2()
       #add-point:b_fill2段define-客製 name="b_fill2.define_customerization"
    
       #end add-point
       DEFINE li_ac           LIKE type_t.num10
       #add-point:b_fill2段define-標準  (請盡量不要在客製環境修改此段落內容, 否則將後續patch的調整需人工處理) name="b_fill2.define"
    
       #end add-point
     
       #add-point:FUNCTION前置處理 name="b_fill2.before_function"
    
       #end add-point
     
       LET li_ac = l_ac
     
       #單身組成
       #應用 qs07 樣板自動產生(Version:8)
       #+ b_fill2段table資料取得(包含sql組成及資料填充)
     
       #add-point:陣列清空 name="b_fill2.array_clear"
    
       #end add-point
     
     
     
     
       #add-point:陣列長度調整 name="b_fill2.array_deleteElement"
    
       #end add-point
     
       #(ver:8) ---mark start---
     
    #  DISPLAY li_ac TO FORMONLY.cnt
    #  LET g_detail_idx2 = 1
    #  DISPLAY g_detail_idx2 TO FORMONLY.idx
       #(ver:8) --- mark end ---
     
     
     
     
     
       #add-point:單身填充後 name="b_fill2.after_fill"
    
       #end add-point
     
       LET l_ac = li_ac
     
    END FUNCTION
    
    {</section>}
    
    {<section id="cpmq001.detail_show" type="s" >}
    #+ 顯示相關資料
    PRIVATE FUNCTION cpmq001_detail_show(ps_page)
       #add-point:show段define-客製 name="detail_show.define_customerization"
    
       #end add-point
       DEFINE ps_page    STRING
       DEFINE ls_sql     STRING
       #add-point:show段define-標準  (請盡量不要在客製環境修改此段落內容, 否則將後續patch的調整需人工處理) name="detail_show.define"
    
       #end add-point
     
       #add-point:detail_show段之前 name="detail_show.before"
    
       #end add-point
     
       
     
       #讀入ref值
       IF ps_page.getIndexOf("'1'",1) > 0 THEN
          #帶出公用欄位reference值page1
          
     
          #add-point:show段單身reference name="detail_show.body.reference"
    
       END IF
     
       #add-point:detail_show段之後 name="detail_show.after"
    
       #end add-point
     
    END FUNCTION
    
    {</section>}
    
    {<section id="cpmq001.filter" type="s" >}
    #應用 qs13 樣板自動產生(Version:9)
    #+ filter段相關程式段
    #+ filter過濾功能
    PRIVATE FUNCTION cpmq001_filter()
       #add-point:filter段define-客製 name="filter.define_customerization"
    
       #end add-point
       DEFINE  ls_result   STRING
       #add-point:filter段define-標準  (請盡量不要在客製環境修改此段落內容, 否則將後續patch的調整需人工處理) name="filter.define"
    
       #end add-point
     
       #add-point:FUNCTION前置處理 name="filter.before_function"
    
       #end add-point
     
       LET INT_FLAG = 0
     
       LET g_qryparam.state = 'c'
       LET g_detail_idx  = 1
       LET g_detail_idx2 = 1
     
       LET g_wc_filter_t = g_wc_filter.trim()   #171117-00042 modify
       LET g_wc_t = g_wc
     
       CALL gfrm_curr.setFieldHidden("formonly.sel", TRUE)
       CALL gfrm_curr.setFieldHidden("formonly.b_statepic", TRUE)
     
       
     
       LET g_wc = cl_replace_str(g_wc, g_wc_filter_t, '')   #171117-00042 modify
     
       #使用DIALOG包住 單頭CONSTRUCT及單身CONSTRUCT
       #應用 qs08 樣板自動產生(Version:5)
       #+ filter段DIALOG段的組成
       DIALOG ATTRIBUTES(UNBUFFERED,FIELD ORDER FORM)
     
          #單頭
          CONSTRUCT g_wc_filter ON pmdi001,pmdi004,pmdi005,pmdi006,pmdi007,pmdi008,pmdi009,pmdi011,pmdi015, 
              pmdi030,pmdi034,pmdj002,pmdj008,pmdj009,pmdj010,pmdj011,pmdj012,pmdj016,pmdj030,pmdjud011, 
              pmdjud012,pmdk001,pmdk002,pmdkseq,pmdk003
                              FROM s_detail1[1].b_pmdi001,s_detail1[1].b_pmdi004,s_detail1[1].b_pmdi005, 
                                  s_detail1[1].b_pmdi006,s_detail1[1].b_pmdi007,s_detail1[1].b_pmdi008,s_detail1[1].b_pmdi009, 
                                  s_detail1[1].b_pmdi011,s_detail1[1].b_pmdi015,s_detail1[1].b_pmdi030,s_detail1[1].b_pmdi034, 
                                  s_detail1[1].b_pmdj002,s_detail1[1].b_pmdj008,s_detail1[1].b_pmdj009,s_detail1[1].b_pmdj010, 
                                  s_detail1[1].b_pmdj011,s_detail1[1].b_pmdj012,s_detail1[1].b_pmdj016,s_detail1[1].b_pmdj030, 
                                  s_detail1[1].b_pmdjud011,s_detail1[1].b_pmdjud012,s_detail1[1].b_pmdk001, 
                                  s_detail1[1].b_pmdk002,s_detail1[1].b_pmdkseq,s_detail1[1].b_pmdk003
     
             BEFORE CONSTRUCT
                         DISPLAY cpmq001_filter_parser('pmdi001') TO s_detail1[1].b_pmdi001
                DISPLAY cpmq001_filter_parser('pmdi004') TO s_detail1[1].b_pmdi004
                DISPLAY cpmq001_filter_parser('pmdi005') TO s_detail1[1].b_pmdi005
                DISPLAY cpmq001_filter_parser('pmdi006') TO s_detail1[1].b_pmdi006
                DISPLAY cpmq001_filter_parser('pmdi007') TO s_detail1[1].b_pmdi007
                DISPLAY cpmq001_filter_parser('pmdi008') TO s_detail1[1].b_pmdi008
                DISPLAY cpmq001_filter_parser('pmdi009') TO s_detail1[1].b_pmdi009
                DISPLAY cpmq001_filter_parser('pmdi011') TO s_detail1[1].b_pmdi011
                DISPLAY cpmq001_filter_parser('pmdi015') TO s_detail1[1].b_pmdi015
                DISPLAY cpmq001_filter_parser('pmdi030') TO s_detail1[1].b_pmdi030
                DISPLAY cpmq001_filter_parser('pmdi034') TO s_detail1[1].b_pmdi034
                DISPLAY cpmq001_filter_parser('pmdj002') TO s_detail1[1].b_pmdj002
                DISPLAY cpmq001_filter_parser('pmdj008') TO s_detail1[1].b_pmdj008
                DISPLAY cpmq001_filter_parser('pmdj009') TO s_detail1[1].b_pmdj009
                DISPLAY cpmq001_filter_parser('pmdj010') TO s_detail1[1].b_pmdj010
                DISPLAY cpmq001_filter_parser('pmdj011') TO s_detail1[1].b_pmdj011
                DISPLAY cpmq001_filter_parser('pmdj012') TO s_detail1[1].b_pmdj012
                DISPLAY cpmq001_filter_parser('pmdj016') TO s_detail1[1].b_pmdj016
                DISPLAY cpmq001_filter_parser('pmdj030') TO s_detail1[1].b_pmdj030
                DISPLAY cpmq001_filter_parser('pmdjud011') TO s_detail1[1].b_pmdjud011
                DISPLAY cpmq001_filter_parser('pmdjud012') TO s_detail1[1].b_pmdjud012
                DISPLAY cpmq001_filter_parser('pmdk001') TO s_detail1[1].b_pmdk001
                DISPLAY cpmq001_filter_parser('pmdk002') TO s_detail1[1].b_pmdk002
                DISPLAY cpmq001_filter_parser('pmdkseq') TO s_detail1[1].b_pmdkseq
                DISPLAY cpmq001_filter_parser('pmdk003') TO s_detail1[1].b_pmdk003
     
     
             #單身公用欄位開窗相關處理
             
     
             #單身一般欄位開窗相關處理
                      #----<<sel>>----
             #----<<b_pmdi001>>----
             #Ctrlp:construct.c.filter.page1.b_pmdi001
             #應用 a03 樣板自動產生(Version:3)
             ON ACTION controlp INFIELD b_pmdi001
                #add-point:ON ACTION controlp INFIELD b_pmdi001 name="construct.c.filter.page1.b_pmdi001"
    
                #END add-point
     
     
             #----<<b_pmdi004>>----
             #Ctrlp:construct.c.page1.b_pmdi004
             #應用 a03 樣板自動產生(Version:3)
             ON ACTION controlp INFIELD b_pmdi004
                #add-point:ON ACTION controlp INFIELD b_pmdi004 name="construct.c.filter.page1.b_pmdi004"
                #應用 a08 樣板自動產生(Version:3)
                #開窗c段
                INITIALIZE g_qryparam.* TO NULL
                LET g_qryparam.state = 'c' 
                LET g_qryparam.reqry = FALSE
                CALL q_pmaa001_3()                           #呼叫開窗
                DISPLAY g_qryparam.return1 TO b_pmdi004  #顯示到畫面上
                NEXT FIELD b_pmdi004                     #返回原欄位
        
    
    
    
                #END add-point
     
     
             #----<<b_pmdi004_desc>>----
             #----<<b_pmdi005>>----
             #Ctrlp:construct.c.page1.b_pmdi005
             #應用 a03 樣板自動產生(Version:3)
             ON ACTION controlp INFIELD b_pmdi005
                #add-point:ON ACTION controlp INFIELD b_pmdi005 name="construct.c.filter.page1.b_pmdi005"
                #應用 a08 樣板自動產生(Version:3)
                #開窗c段
                INITIALIZE g_qryparam.* TO NULL
                LET g_qryparam.state = 'c' 
                LET g_qryparam.reqry = FALSE
                CALL q_ooaj002_1()                           #呼叫開窗
                DISPLAY g_qryparam.return1 TO b_pmdi005  #顯示到畫面上
                NEXT FIELD b_pmdi005                     #返回原欄位
        
    
    
    
                #END add-point
     
     
             #----<<b_pmdi005_desc>>----
             #----<<b_pmdi006>>----
             #Ctrlp:construct.c.page1.b_pmdi006
             #應用 a03 樣板自動產生(Version:3)
             ON ACTION controlp INFIELD b_pmdi006
                #add-point:ON ACTION controlp INFIELD b_pmdi006 name="construct.c.filter.page1.b_pmdi006"
                #應用 a08 樣板自動產生(Version:3)
                #開窗c段
                INITIALIZE g_qryparam.* TO NULL
                LET g_qryparam.state = 'c' 
                LET g_qryparam.reqry = FALSE
                CALL q_oodb002_2()                           #呼叫開窗
                DISPLAY g_qryparam.return1 TO b_pmdi006  #顯示到畫面上
                NEXT FIELD b_pmdi006                     #返回原欄位
        
    
    
    
                #END add-point
     
     
             #----<<b_pmdi006_desc>>----
             #----<<b_pmdi007>>----
             #Ctrlp:construct.c.filter.page1.b_pmdi007
             #應用 a03 樣板自動產生(Version:3)
             ON ACTION controlp INFIELD b_pmdi007
                #add-point:ON ACTION controlp INFIELD b_pmdi007 name="construct.c.filter.page1.b_pmdi007"
    
                #END add-point
     
     
             #----<<b_pmdi008>>----
             #Ctrlp:construct.c.filter.page1.b_pmdi008
             #應用 a03 樣板自動產生(Version:3)
             ON ACTION controlp INFIELD b_pmdi008
                #add-point:ON ACTION controlp INFIELD b_pmdi008 name="construct.c.filter.page1.b_pmdi008"
    
                #END add-point
     
     
             #----<<b_pmdi009>>----
             #Ctrlp:construct.c.page1.b_pmdi009
             #應用 a03 樣板自動產生(Version:3)
             ON ACTION controlp INFIELD b_pmdi009
                #add-point:ON ACTION controlp INFIELD b_pmdi009 name="construct.c.filter.page1.b_pmdi009"
                #應用 a08 樣板自動產生(Version:3)
                #開窗c段
                INITIALIZE g_qryparam.* TO NULL
                LET g_qryparam.state = 'c' 
                LET g_qryparam.reqry = FALSE
                CALL q_pmad002_2()                           #呼叫開窗
                DISPLAY g_qryparam.return1 TO b_pmdi009  #顯示到畫面上
                NEXT FIELD b_pmdi009                     #返回原欄位
        
    
    
    
                #END add-point
     
     
             #----<<b_pmdi009_desc>>----
             #----<<b_pmdi011>>----
             #Ctrlp:construct.c.page1.b_pmdi011
             #應用 a03 樣板自動產生(Version:3)
             ON ACTION controlp INFIELD b_pmdi011
                #add-point:ON ACTION controlp INFIELD b_pmdi011 name="construct.c.filter.page1.b_pmdi011"
                #應用 a08 樣板自動產生(Version:3)
                #開窗c段
                INITIALIZE g_qryparam.* TO NULL
                LET g_qryparam.state = 'c' 
                LET g_qryparam.reqry = FALSE
                CALL q_oocq002()                           #呼叫開窗
                DISPLAY g_qryparam.return1 TO b_pmdi011  #顯示到畫面上
                NEXT FIELD b_pmdi011                     #返回原欄位
        
    
    
    
                #END add-point
     
     
             #----<<b_pmdi011_desc>>----
             #----<<b_pmdi015>>----
             #Ctrlp:construct.c.filter.page1.b_pmdi015
             #應用 a03 樣板自動產生(Version:3)
             ON ACTION controlp INFIELD b_pmdi015
                #add-point:ON ACTION controlp INFIELD b_pmdi015 name="construct.c.filter.page1.b_pmdi015"
    
                #END add-point
     
     
             #----<<b_pmdi030>>----
             #Ctrlp:construct.c.filter.page1.b_pmdi030
             #應用 a03 樣板自動產生(Version:3)
             ON ACTION controlp INFIELD b_pmdi030
                #add-point:ON ACTION controlp INFIELD b_pmdi030 name="construct.c.filter.page1.b_pmdi030"
    
                #END add-point
     
     
             #----<<b_pmdi034>>----
             #Ctrlp:construct.c.filter.page1.b_pmdi034
             #應用 a03 樣板自動產生(Version:3)
             ON ACTION controlp INFIELD b_pmdi034
                #add-point:ON ACTION controlp INFIELD b_pmdi034 name="construct.c.filter.page1.b_pmdi034"
    
                #END add-point
     
     
             #----<<b_pmdj002>>----
             #Ctrlp:construct.c.page1.b_pmdj002
             #應用 a03 樣板自動產生(Version:3)
             ON ACTION controlp INFIELD b_pmdj002
                #add-point:ON ACTION controlp INFIELD b_pmdj002 name="construct.c.filter.page1.b_pmdj002"
                #應用 a08 樣板自動產生(Version:3)
                #開窗c段
                INITIALIZE g_qryparam.* TO NULL
                LET g_qryparam.state = 'c' 
                LET g_qryparam.reqry = FALSE
                CALL q_imaa001()                           #呼叫開窗
                DISPLAY g_qryparam.return1 TO b_pmdj002  #顯示到畫面上
                NEXT FIELD b_pmdj002                     #返回原欄位
        
    
    
    
                #END add-point
     
     
             #----<<b_pmdj002_desc>>----
             #----<<b_pmdj008>>----
             #Ctrlp:construct.c.page1.b_pmdj008
             #應用 a03 樣板自動產生(Version:3)
             ON ACTION controlp INFIELD b_pmdj008
                #add-point:ON ACTION controlp INFIELD b_pmdj008 name="construct.c.filter.page1.b_pmdj008"
                #應用 a08 樣板自動產生(Version:3)
                #開窗c段
                INITIALIZE g_qryparam.* TO NULL
                LET g_qryparam.state = 'c' 
                LET g_qryparam.reqry = FALSE
                CALL q_ooca001_1()                           #呼叫開窗
                DISPLAY g_qryparam.return1 TO b_pmdj008  #顯示到畫面上
                NEXT FIELD b_pmdj008                     #返回原欄位
        
    
    
    
                #END add-point
     
     
             #----<<b_pmdj008_desc>>----
             #----<<b_pmdj009>>----
             #Ctrlp:construct.c.filter.page1.b_pmdj009
             #應用 a03 樣板自動產生(Version:3)
             ON ACTION controlp INFIELD b_pmdj009
                #add-point:ON ACTION controlp INFIELD b_pmdj009 name="construct.c.filter.page1.b_pmdj009"
    
                #END add-point
     
     
             #----<<b_pmdj010>>----
             #Ctrlp:construct.c.filter.page1.b_pmdj010
             #應用 a03 樣板自動產生(Version:3)
             ON ACTION controlp INFIELD b_pmdj010
                #add-point:ON ACTION controlp INFIELD b_pmdj010 name="construct.c.filter.page1.b_pmdj010"
    
                #END add-point
     
     
             #----<<b_pmdj011>>----
             #Ctrlp:construct.c.filter.page1.b_pmdj011
             #應用 a03 樣板自動產生(Version:3)
             ON ACTION controlp INFIELD b_pmdj011
                #add-point:ON ACTION controlp INFIELD b_pmdj011 name="construct.c.filter.page1.b_pmdj011"
    
                #END add-point
     
     
             #----<<b_pmdj012>>----
             #Ctrlp:construct.c.filter.page1.b_pmdj012
             #應用 a03 樣板自動產生(Version:3)
             ON ACTION controlp INFIELD b_pmdj012
                #add-point:ON ACTION controlp INFIELD b_pmdj012 name="construct.c.filter.page1.b_pmdj012"
    
                #END add-point
     
     
             #----<<b_pmdj016>>----
             #Ctrlp:construct.c.page1.b_pmdj016
             #應用 a03 樣板自動產生(Version:3)
             ON ACTION controlp INFIELD b_pmdj016
                #add-point:ON ACTION controlp INFIELD b_pmdj016 name="construct.c.filter.page1.b_pmdj016"
                #應用 a08 樣板自動產生(Version:3)
                #開窗c段
                INITIALIZE g_qryparam.* TO NULL
                LET g_qryparam.state = 'c' 
                LET g_qryparam.reqry = FALSE
                CALL q_oodb002_2()                           #呼叫開窗
                DISPLAY g_qryparam.return1 TO b_pmdj016  #顯示到畫面上
                NEXT FIELD b_pmdj016                     #返回原欄位
        
    
    
    
                #END add-point
     
     
             #----<<b_pmdj016_desc>>----
             #----<<b_pmdj030>>----
             #Ctrlp:construct.c.filter.page1.b_pmdj030
             #應用 a03 樣板自動產生(Version:3)
             ON ACTION controlp INFIELD b_pmdj030
                #add-point:ON ACTION controlp INFIELD b_pmdj030 name="construct.c.filter.page1.b_pmdj030"
    
                #END add-point
     
     
             #----<<b_pmdjud011>>----
             #Ctrlp:construct.c.filter.page1.b_pmdjud011
             #應用 a03 樣板自動產生(Version:3)
             ON ACTION controlp INFIELD b_pmdjud011
                #add-point:ON ACTION controlp INFIELD b_pmdjud011 name="construct.c.filter.page1.b_pmdjud011"
    
                #END add-point
     
     
             #----<<b_pmdjud012>>----
             #Ctrlp:construct.c.filter.page1.b_pmdjud012
             #應用 a03 樣板自動產生(Version:3)
             ON ACTION controlp INFIELD b_pmdjud012
                #add-point:ON ACTION controlp INFIELD b_pmdjud012 name="construct.c.filter.page1.b_pmdjud012"
    
                #END add-point
     
     
             #----<<b_pmdk001>>----
             #Ctrlp:construct.c.filter.page1.b_pmdk001
             #應用 a03 樣板自動產生(Version:3)
             ON ACTION controlp INFIELD b_pmdk001
                #add-point:ON ACTION controlp INFIELD b_pmdk001 name="construct.c.filter.page1.b_pmdk001"
    
                #END add-point
     
     
             #----<<b_pmdk002>>----
             #Ctrlp:construct.c.filter.page1.b_pmdk002
             #應用 a03 樣板自動產生(Version:3)
             ON ACTION controlp INFIELD b_pmdk002
                #add-point:ON ACTION controlp INFIELD b_pmdk002 name="construct.c.filter.page1.b_pmdk002"
    
                #END add-point
     
     
             #----<<b_pmdkseq>>----
             #Ctrlp:construct.c.filter.page1.b_pmdkseq
             #應用 a03 樣板自動產生(Version:3)
             ON ACTION controlp INFIELD b_pmdkseq
                #add-point:ON ACTION controlp INFIELD b_pmdkseq name="construct.c.filter.page1.b_pmdkseq"
    
                #END add-point
     
     
             #----<<b_pmdk003>>----
             #Ctrlp:construct.c.filter.page1.b_pmdk003
             #應用 a03 樣板自動產生(Version:3)
             ON ACTION controlp INFIELD b_pmdk003
                #add-point:ON ACTION controlp INFIELD b_pmdk003 name="construct.c.filter.page1.b_pmdk003"
    
                #END add-point
     
     
     
     
          END CONSTRUCT
     
          #add-point:filter段add_cs name="filter.add_cs"
    
          #end add-point
     
          BEFORE DIALOG
             #add-point:filter段b_dialog name="filter.b_dialog"
    
             #end add-point
     
          ON ACTION accept
             ACCEPT DIALOG
     
          ON ACTION cancel
             LET INT_FLAG = 1
             EXIT DIALOG
     
          #交談指令共用ACTION
          &include "common_action.4gl"
             CONTINUE DIALOG
     
       END DIALOG
     
     
     
     
     
       
     
       #add-point:離開DIALOG後相關處理 name="filter.after_dialog"
    
       #end add-point
     
       #171117-00042 ---modify start---
       IF NOT INT_FLAG THEN
       #  LET g_wc_filter = g_wc_filter, " "
     
          LET g_wc_filter = "   AND   ", g_wc_filter, "   "
          LET g_wc = g_wc , g_wc_filter
       ELSE
          LET g_wc_filter = g_wc_filter_t
          LET g_wc = g_wc_t
       END IF
       #171117-00042 --- modify end ---
     
          CALL cpmq001_filter_show('pmdi001','b_pmdi001')
       CALL cpmq001_filter_show('pmdi004','b_pmdi004')
       CALL cpmq001_filter_show('pmdi005','b_pmdi005')
       CALL cpmq001_filter_show('pmdi006','b_pmdi006')
       CALL cpmq001_filter_show('pmdi007','b_pmdi007')
       CALL cpmq001_filter_show('pmdi008','b_pmdi008')
       CALL cpmq001_filter_show('pmdi009','b_pmdi009')
       CALL cpmq001_filter_show('pmdi011','b_pmdi011')
       CALL cpmq001_filter_show('pmdi015','b_pmdi015')
       CALL cpmq001_filter_show('pmdi030','b_pmdi030')
       CALL cpmq001_filter_show('pmdi034','b_pmdi034')
       CALL cpmq001_filter_show('pmdj002','b_pmdj002')
       CALL cpmq001_filter_show('pmdj008','b_pmdj008')
       CALL cpmq001_filter_show('pmdj009','b_pmdj009')
       CALL cpmq001_filter_show('pmdj010','b_pmdj010')
       CALL cpmq001_filter_show('pmdj011','b_pmdj011')
       CALL cpmq001_filter_show('pmdj012','b_pmdj012')
       CALL cpmq001_filter_show('pmdj016','b_pmdj016')
       CALL cpmq001_filter_show('pmdj030','b_pmdj030')
       CALL cpmq001_filter_show('pmdjud011','b_pmdjud011')
       CALL cpmq001_filter_show('pmdjud012','b_pmdjud012')
       CALL cpmq001_filter_show('pmdk001','b_pmdk001')
       CALL cpmq001_filter_show('pmdk002','b_pmdk002')
       CALL cpmq001_filter_show('pmdkseq','b_pmdkseq')
       CALL cpmq001_filter_show('pmdk003','b_pmdk003')
     
     
       CALL cpmq001_b_fill()
     
       CALL gfrm_curr.setFieldHidden("formonly.sel", FALSE)
       CALL gfrm_curr.setFieldHidden("formonly.b_statepic", FALSE)
     
    END FUNCTION
    
    {</section>}
    
    {<section id="cpmq001.filter_parser" type="s" >}
    #應用 qs14 樣板自動產生(Version:6)
    #+ filter pasara段
    #+ filter欄位解析
    PRIVATE FUNCTION cpmq001_filter_parser(ps_field)
       #add-point:filter段define-客製 name="filter_parser.define_customerization"
    
       #end add-point
       {<Local define>}
       DEFINE ps_field   STRING
       DEFINE ls_tmp     STRING
       DEFINE li_tmp     LIKE type_t.num5
       DEFINE li_tmp2    LIKE type_t.num5
       DEFINE ls_var     STRING
       {</Local define>}
       #add-point:filter段define-標準  (請盡量不要在客製環境修改此段落內容, 否則將後續patch的調整需人工處理) name="filter_parser.define"
    
       #end add-point
     
       #add-point:FUNCTION前置處理 name="filter_parser.before_function"
    
       #end add-point
     
       #一般條件解析
       LET ls_tmp = ps_field, "='"
       LET li_tmp = g_wc_filter.getIndexOf(ls_tmp,1)
       IF li_tmp > 0 THEN
          LET li_tmp = ls_tmp.getLength() + li_tmp
          LET li_tmp2 = g_wc_filter.getIndexOf("'",li_tmp + 1) - 1
          LET ls_var = g_wc_filter.subString(li_tmp,li_tmp2)
       END IF
     
       #模糊條件解析
       LET ls_tmp = ps_field, " like '"
       LET li_tmp = g_wc_filter.getIndexOf(ls_tmp,1)
       IF li_tmp > 0 THEN
          LET li_tmp = ls_tmp.getLength() + li_tmp
          LET li_tmp2 = g_wc_filter.getIndexOf("'",li_tmp + 1) - 1
          LET ls_var = g_wc_filter.subString(li_tmp,li_tmp2)
          LET ls_var = cl_replace_str(ls_var,'%','*')
       END IF
     
       RETURN ls_var
     
    END FUNCTION
     
    
    {</section>}
    
    {<section id="cpmq001.filter_show" type="s" >}
    #應用 qs15 樣板自動產生(Version:6)
    #+ filter標題欄位顯示搜尋條件
    PRIVATE FUNCTION cpmq001_filter_show(ps_field,ps_object)
       #add-point:filter_show段define-客製 name="filter_show.define_customerization"
    
       #end add-point
       DEFINE ps_field         STRING
       DEFINE ps_object        STRING
       DEFINE lnode_item       om.DomNode
       DEFINE ls_title         STRING
       DEFINE ls_name          STRING
       DEFINE ls_condition     STRING
       #add-point:filter_show段define-標準  (請盡量不要在客製環境修改此段落內容, 否則將後續patch的調整需人工處理) name="filter_show.define"
    
       #end add-point
     
       #add-point:FUNCTION前置處理 name="filter_show.before_function"
    
       #end add-point
     
       LET ls_name = "formonly.", ps_object
     
     
       LET lnode_item = gfrm_curr.findNode("TableColumn", ls_name)
       LET ls_title = lnode_item.getAttribute("text")
       IF ls_title.getIndexOf('※',1) > 0 THEN
          LET ls_title = ls_title.subString(1,ls_title.getIndexOf('※',1)-1)
       END IF
     
       #顯示資料組合
       LET ls_condition = cpmq001_filter_parser(ps_field)
       IF NOT cl_null(ls_condition) THEN
          LET ls_title = ls_title, '※', ls_condition, '※'
       END IF
     
       #將資料顯示回去
       CALL lnode_item.setAttribute("text",ls_title)
     
    END FUNCTION
     
    
    {</section>}
    
    {<section id="cpmq001.detail_action_trans" type="s" >}
    #+ 單身分頁筆數顯示及action圖片顯示切換功能
    PRIVATE FUNCTION cpmq001_detail_action_trans()
       #add-point:detail_action_trans段define-客製 name="detail_action_trans.define_customerization"
    
       #end add-point
       #add-point:detail_action_trans段define-標準  (請盡量不要在客製環境修改此段落內容, 否則將後續patch的調整需人工處理) name="detail_action_trans.define"
    
       #end add-point
     
     
       #add-point:FUNCTION前置處理 name="detail_action_trans.before_function"
    
       #end add-point
     
       #因應單身切頁功能,筆數計算方式調整
       #(ver:33) ---start---
       IF g_pagestart = 0 THEN
          LET g_pagestart = 1
       END IF
       #(ver:36) --- end ---
     
       LET g_current_row_tot = g_pagestart + g_detail_idx - 1
       #(ver:36) ---modify start---
       IF g_tot_cnt > 0 THEN
          DISPLAY g_current_row_tot TO FORMONLY.h_index
          DISPLAY g_tot_cnt TO FORMONLY.h_count
       ELSE
          IF g_pmdi_d.getLength() > 0 THEN
             DISPLAY g_current_row_tot TO FORMONLY.h_index
             DISPLAY g_pmdi_d.getLength() TO FORMONLY.h_count
          ELSE
             DISPLAY '' TO FORMONLY.h_index
             DISPLAY '' TO FORMONLY.h_count
          END IF
       END IF
     
     
       #(ver:36) --- modify end ---
     
       #顯示單身頁面的起始與結束筆數
       LET g_page_start_num = g_pagestart
       LET g_page_end_num = g_pagestart + g_num_in_page - 1
       DISPLAY g_page_start_num TO FORMONLY.p_start
       DISPLAY g_page_end_num TO FORMONLY.p_end
     
       #目前不支援跳頁功能
       LET g_page_act_list = "detail_first,detail_previous,'',detail_next,detail_last"
       CALL cl_navigator_detail_page_setting(g_page_act_list,g_current_row_tot,g_pagestart,g_num_in_page,g_tot_cnt)
     
    END FUNCTION
    
    {</section>}
    
    {<section id="cpmq001.detail_index_setting" type="s" >}
    #+ 單身切頁後,index重新調整,避免翻頁後指到空白筆數
    PRIVATE FUNCTION cpmq001_detail_index_setting()
       #add-point:detail_index_setting段define-客製 name="detail_index_setting.define_customerization"
    
       #end add-point
       DEFINE li_redirect     BOOLEAN
       DEFINE ldig_curr       ui.Dialog
       #add-point:detail_index_setting段define-標準  (請盡量不要在客製環境修改此段落內容, 否則將後續patch的調整需人工處理) name="detail_index_setting.define"
    
       #end add-point
     
       #add-point:FUNCTION前置處理 name="detail_index_setting.before_function"
    
       #end add-point
     
       IF g_curr_diag IS NOT NULL THEN
          CASE
             WHEN g_curr_diag.getCurrentRow("s_detail1") <= "0"
                LET g_detail_idx = 1
                IF g_pmdi_d.getLength() > 0 THEN
                   LET li_redirect = TRUE
                END IF
             WHEN g_curr_diag.getCurrentRow("s_detail1") > g_pmdi_d.getLength() AND g_pmdi_d.getLength() > 0
                LET g_detail_idx = g_pmdi_d.getLength()
                LET li_redirect = TRUE
             WHEN g_curr_diag.getCurrentRow("s_detail1") != g_detail_idx
                IF g_detail_idx > g_pmdi_d.getLength() THEN
                   LET g_detail_idx = g_pmdi_d.getLength()
                END IF
                LET li_redirect = TRUE
          END CASE
       END IF
     
       IF li_redirect THEN
          LET ldig_curr = ui.Dialog.getCurrent()
          CALL ldig_curr.setCurrentRow("s_detail1", g_detail_idx)
       END IF
     
    END FUNCTION
    
    {</section>}
    
    {<section id="cpmq001.mask_functions" type="s" >}
     &include "erp/cpm/cpmq001_mask.4gl"
    
    {</section>}
    
    {<section id="cpmq001.other_function" readonly="Y" type="s" >}
    
    ################################################################################
    # Descriptions...: 描述说明
    # Memo...........:
    # Usage..........: CALL s_aooi150_ins (传入参数)
    #                  RETURNING 回传参数
    # Input parameter: 传入参数变量1   传入参数变量说明1
    #                : 传入参数变量2   传入参数变量说明2
    # Return code....: 回传参数变量1   回传参数变量说明1
    #                : 回传参数变量2   回传参数变量说明2
    # Date & Author..: 日期 By 作者
    # Modify.........:
    ################################################################################
    PRIVATE FUNCTION cpmq001_create_tmp()
    
       WHENEVER ERROR CONTINUE
       
       #单位转换的临时表
       DROP TABLE cpmq001_tmp;
       CREATE TEMP TABLE cpmq001_tmp (
       pmdient  LIKE pmdi_t.pmdient,
       pmdisite LIKE pmdi_t.pmdisite,
       pmdi004  LIKE pmdi_t.pmdi004,
       pmdj002  LIKE pmdj_t.pmdj002
       )
    
          
    END FUNCTION
    
    {</section>}
    

    相关文章

      网友评论

        本文标题:最新核价表

        本文链接:https://www.haomeiwen.com/subject/gotguctx.html