ERP查詢Q報表開發程式碼

2023-07-06 12:00:30

一,按照一般ERP開發流程可參考ERP開發流程,直到下載程式。

當我們的查詢頁籤存在欄位需要判斷或者特殊處理時,在global中的自定義模組變數下新增,例如:

 1 #add-point:自定義模組變數-客製(Module Variable) name="global.variable_customerization"
 2 
 3 DEFINE g_first_flag           LIKE type_t.num5
 4 PRIVATE TYPE type_master      RECORD
 5    startdate               LIKE type_t.dat, 
 6    enddate                 LIKE type_t.dat
 7 END RECORD
 8 DEFINE g_master            type_master 
 9 
10 #end add-point

init下是對頁面初始化,在頁面資產初始化可以對欄位賦初值,設定下拉框等

   #add-point:畫面資料初始化 name="init.init"
   LET g_first_flag = TRUE
   LET g_master.startdate = ''
   LET g_master.enddate = ''
   ## CALL cpmq700_cre_tmp_table()
   #end add-point

#或者

   #add-point:畫面資料初始化 name="init.init"
   CALL cl_set_combo_scc_part('b_imaaud001','18006','1,2')    #b_imaaud001代表那個頁面欄位,18006是下拉框程式碼
   LET g_first_flag = TRUE
   #end add-point

 ui_dialog下搜尋DIALOG ATTRIBUTES,裡面新增欄位的邏輯。可參考filter下的欄位邏輯。

CONSTRUCT BY NAME g_wc ON imaastus,imaa001,imaal003,imaal004,imaa009,imaa003,imaa010,imaa004,imaaud001,imaaud006
         
            BEFORE CONSTRUCT
            
            ON ACTION controlp INFIELD imaastus
               
            ON ACTION controlp INFIELD imaa001          
               INITIALIZE g_qryparam.* TO NULL
               LET g_qryparam.state = 'c'
               LET g_qryparam.reqry = FALSE
               CALL q_imaa001()                           #呼叫開窗
               DISPLAY g_qryparam.return1 TO imaa001      #顯示到畫面上
               NEXT FIELD imaa001                         #返回原欄位
               
            ON ACTION controlp INFIELD imaal003
               
            ON ACTION controlp INFIELD imaal004
               
            ON ACTION controlp INFIELD imaa009          
               INITIALIZE g_qryparam.* TO NULL
               LET g_qryparam.state = 'c'
               LET g_qryparam.reqry = FALSE
               CALL q_rtax001()                           #呼叫開窗
               DISPLAY g_qryparam.return1 TO imaa009      #顯示到畫面上
               NEXT FIELD imaa009                         #返回原欄位
            
            ON ACTION controlp INFIELD imaa003          
               INITIALIZE g_qryparam.* TO NULL
               LET g_qryparam.state = 'c'
               LET g_qryparam.reqry = FALSE
               CALL q_imca001_1()                         #呼叫開窗
               DISPLAY g_qryparam.return1 TO imaa003      #顯示到畫面上
               NEXT FIELD imaa003                         #返回原欄位
            
            ON ACTION controlp INFIELD imaa010          
               INITIALIZE g_qryparam.* TO NULL
               LET g_qryparam.state = 'c'
               LET g_qryparam.reqry = FALSE
               CALL q_imaa010_1()                           #呼叫開窗
               DISPLAY g_qryparam.return1 TO imaa010      #顯示到畫面上
               NEXT FIELD imaa010                         #返回原欄位
            
            ON ACTION controlp INFIELD imaa004
                     
            ON ACTION controlp INFIELD imaaud001
                                 
            ON ACTION controlp INFIELD imaaud006
         
         END CONSTRUCT

ui_dialog下搜尋accept,對判斷點選後變數賦值

           LET g_first_flag = FALSE

b_fill下搜尋b_fill.array_clear,在裡面新增呼叫函數的邏輯

   IF g_first_flag THEN
      RETURN
   ELSE
      LET ls_wc = cl_replace_str(ls_wc,'1=2','1=1')
      CALL cimq200_b_fill_sc(ls_wc)
      RETURN
   END IF

寫自己的方法

PRIVATE FUNCTION cimq200_b_fill_sc(p_wc)
DEFINE p_wc                STRING
DEFINE l_sql               STRING

   CALL g_imaa_d.clear()
   LET g_cnt = l_ac
   IF g_cnt = 0 THEN
      LET g_cnt = 1
   END IF
   LET l_ac = 1

   LET l_sql = " SELECT 0 imaaseq,imaastus,imaa001,imaal003, ",
               " imaal004,imaa009,rtaxl003,imaa003, ",
               " a.oocql004,imaa004,imaa010,b.oocql004 oocql010,imaa006,imaaud001, ",
               " imaaud004,imaaud006,imaaud011 ",
               "   FROM imaa_t ",
               "   LEFT JOIN imaal_t ON imaa001=imaal001 AND imaaent=imaalent AND imaal002 = '",g_dlang,"'",
               "   LEFT JOIN rtaxl_t ON imaa009=rtaxl001 AND imaaent=rtaxlent AND rtaxl002 = '",g_dlang,"'",
               "   LEFT JOIN oocql_t a ON imaa003=a.oocql002 AND imaaent=a.oocqlent AND a.oocql001 = '200' AND a.oocql003 = '",g_dlang,"'",
               "   LEFT JOIN oocql_t b ON imaa010=b.oocql002 AND imaaent=b.oocqlent AND b.oocql001 = '210' AND b.oocql003 = '",g_dlang,"'",
               "  WHERE imaaent = ",g_enterprise,
               "    AND ",p_wc CLIPPED
   DISPLAY l_sql            
   PREPARE cimq200_b_fill_cs_pre FROM l_sql
   DECLARE cimq200_b_fill_cs_cur CURSOR FOR cimq200_b_fill_cs_pre
   FOREACH cimq200_b_fill_cs_cur INTO g_imaa_d[l_ac].*
   
      #加項次
      LET g_imaa_d[l_ac].imaaseq=l_ac
      #料件屬性顯示漢字代替
      CASE g_imaa_d[l_ac].imaaud001
         WHEN 1
            LET g_imaa_d[l_ac].imaaud001 = '五金'
         WHEN 2
            LET g_imaa_d[l_ac].imaaud001 = '注塑'
      END CASE
      #料件是否關鍵物料
      CASE g_imaa_d[l_ac].imaaud006
         WHEN 'Y'
            LET g_imaa_d[l_ac].imaaud006 = ''
         WHEN 'N'
            LET g_imaa_d[l_ac].imaaud006 = ''
      END CASE
      LET l_ac = l_ac + 1
   
   END FOREACH
               
   
   
   CALL g_imaa_d.deleteElement(g_imaa_d.getLength())
 
   #add-point:陣列長度調整 name="b_fill.array_deleteElement"

   #end add-point
 
   LET g_error_show = 0
 
   LET g_detail_cnt = g_imaa_d.getLength()
   LET l_ac = g_cnt
   LET g_cnt = 0
 

   #調整單身index指標,避免翻頁後指到空白筆數
   CALL cimq200_detail_index_setting()
 
   #重新計算單身筆數並呈現
#  CALL cimq200_detail_action_trans()   #(ver:36) mark
 
   LET l_ac = 1
   IF g_imaa_d.getLength() > 0 THEN
      CALL cimq200_b_fill2()
   END IF
 
   CALL cimq200_detail_action_trans()   #(ver:36)
   

END FUNCTION