昨天听到一个好玩的需求,自开发交货单批次拆分的界面和实现批次拆分。
批次拆分的函数就不提了,这里来说说自开发程序怎么模拟出批次拆分的那种样子。、
效果图:
1,首先定义一个交货行项目表和拆分出来的批次表:
REPORT zvl02n. TYPES:BEGIN OF ty_item, vbeln TYPE vbeln_vl, "Delivery posnr TYPE posnr_vl, "Delivery Item matnr TYPE matnr, "Material Number charg TYPE charg_d, "Batch Number icon TYPE icon_d, " hi_item TYPE posnr_vl, " END OF ty_item. DATA:gt_item TYPE TABLE OF ty_item,"交货主行 gt_fitem TYPE TABLE OF ty_item,"交货拆分行 gw_item LIKE LINE OF gt_item, ls_item LIKE LINE OF gt_item, gv_field TYPE string,"光标列 gv_line TYPE i,"光标行 ok_code TYPE sy-ucomm. *&SPWIZARD: DECLARATION OF TABLECONTROL 'TC_9000' ITSELF CONTROLS: tc_9000 TYPE TABLEVIEW USING SCREEN 9000. *&SPWIZARD: LINES OF TABLECONTROL 'TC_9000' DATA: g_tc_9000_lines LIKE sy-loopc. INITIALIZATION. "初始化内表 gw_item-vbeln = '1000000000'. gw_item-posnr = '10'. gw_item-matnr = 'A1'. gw_item-icon = '@3S@'. APPEND gw_item TO gt_item. gw_item-vbeln = '1000000000'. gw_item-posnr = '20'. gw_item-matnr = 'A1'. gw_item-icon = '@3S@'. APPEND gw_item TO gt_item. gw_item-vbeln = '1000000000'. gw_item-posnr = '30'. gw_item-matnr = 'A1'. gw_item-icon = '@3S@'. APPEND gw_item TO gt_item. gw_item-vbeln = '1000000000'. gw_item-posnr = '40'. gw_item-matnr = 'A1'. gw_item-icon = '@3S@'. APPEND gw_item TO gt_item. gw_item-vbeln = '1000000000'. gw_item-posnr = '50'. gw_item-matnr = 'A1'. gw_item-icon = '@3S@'. APPEND gw_item TO gt_item. gw_item-vbeln = '1000000000'. gw_item-posnr = '60'. gw_item-matnr = 'A1'. gw_item-icon = '@3S@'. APPEND gw_item TO gt_item. gw_item-vbeln = '1000000000'. gw_item-posnr = '70'. gw_item-matnr = 'A1'. gw_item-icon = '@3S@'. APPEND gw_item TO gt_item. gw_item-vbeln = '1000000000'. gw_item-posnr = '900001'. gw_item-matnr = 'A1'. gw_item-hi_item = '10'. gw_item-icon = ''. APPEND gw_item TO gt_fitem. gw_item-vbeln = '1000000000'. gw_item-posnr = '900002'. gw_item-matnr = 'A1'. gw_item-hi_item = '10'. gw_item-icon = ''. APPEND gw_item TO gt_fitem. gw_item-vbeln = '1000000000'. gw_item-posnr = '900001'. gw_item-matnr = 'A1'. gw_item-hi_item = '20'. gw_item-icon = ''. APPEND gw_item TO gt_fitem. gw_item-vbeln = '1000000000'. gw_item-posnr = '900002'. gw_item-matnr = 'A1'. gw_item-hi_item = '20'. gw_item-icon = ''. APPEND gw_item TO gt_fitem. gw_item-vbeln = '1000000000'. gw_item-posnr = '900001'. gw_item-matnr = 'A1'. gw_item-hi_item = '70'. gw_item-icon = ''. APPEND gw_item TO gt_fitem. gw_item-vbeln = '1000000000'. gw_item-posnr = '900002'. gw_item-matnr = 'A1'. gw_item-hi_item = '70'. gw_item-icon = ''. APPEND gw_item TO gt_fitem. START-OF-SELECTION. CALL SCREEN 9000.
其中添加了7个主行项目,10,20,70分别加了2个次行项目
2,PAI开头获取光标行,这里获取的行号存到全局变量里,为了后面折叠展开事件使用
MODULE get_field INPUT. GET CURSOR FIELD gv_field LINE gv_line. IF ( gv_line + tc_9000-top_line - 1 ) > tc_9000-lines. gv_line = tc_9000-lines. ELSE. gv_line = gv_line + tc_9000-top_line - 1. ENDIF. ENDMODULE.
3,根据点击的按钮图标添加次行
FORM show_fitem . DATA:lv_index TYPE i. lv_index = gv_line. READ TABLE gt_item INTO gw_item INDEX lv_index. IF sy-subrc = 0. IF gw_item-icon = '@3S@'. gw_item-icon = '@3T@'. LOOP AT gt_fitem INTO ls_item WHERE hi_item = gw_item-posnr. lv_index = lv_index + 1. INSERT ls_item INTO gt_item INDEX lv_index. ENDLOOP. ELSEIF gw_item-icon = '@3T@'. gw_item-icon = '@3S@'. DELETE gt_item WHERE hi_item = gw_item-posnr. ENDIF. MODIFY gt_item FROM gw_item INDEX gv_line TRANSPORTING icon. ENDIF. ENDFORM.
最后说明下,TC里怎么把文本转成ICON
1,取消输入:
2,右键TC里的列转换BUTTON
并添加事件FOD
MODULE user_command_9000 INPUT. CASE ok_code. WHEN 'BACK'. LEAVE TO SCREEN 0. WHEN 'EXIT'. LEAVE PROGRAM. WHEN 'FOD'. PERFORM show_fitem. WHEN OTHERS. ENDCASE. ENDMODULE.
^_^很多人都把资料锁进了note里,以后还怎么百度呢^_^