标签:审批 font 初始 lock toolbar stl val elf case
根据选定的单、多行会计凭证进行审批,双击单个会计凭证跳转会计订单明细。将审批的凭证记录在一张自定义表中
*&---------------------------------------------------------------------* *& Report ZFI_SP *&---------------------------------------------------------------------* *&参考FB03 *&---------------------------------------------------------------------* REPORT zfi_sp. TYPE-POOLS:slis,icon. TABLES:t001,bkpf,skat. DATA: ok_code LIKE sy-ucomm, save_ok LIKE ok_code. INCLUDE zfi_sp_alldata. "会计编号的详细会计科目的数据类型 DATA gt_fieldcat TYPE slis_t_fieldcat_alv. DATA gs_fieldcat TYPE slis_fieldcat_alv. "表字段 DATA gs_layout TYPE slis_layout_alv. "布局 DATA gt_events TYPE slis_t_event. DATA gs_event TYPE slis_alv_event. "事件 TYPES:BEGIN OF ty_type, sel TYPE c, "选择按钮列 bukrs TYPE bukrs, belnr TYPE belnr_d, "会计凭证编号 gjahr TYPE gjahr, blart TYPE blart, "类型` bldat TYPE bldat, "凭证中的凭证日期 budat TYPE budat, "凭证中的过帐日期 bktxt TYPE bktxt, "文本 sp TYPE c, END OF ty_type. DATA:gt_itab TYPE TABLE OF ty_type WITH HEADER LINE. DATA:wa_insert TYPE zfi_sp_table, wa_itab TYPE ty_type. DATA:fi_itab TYPE TABLE OF zfi_sp_table WITH HEADER LINE. DATA:fieldcat TYPE lvc_t_fcat, "1001 屏幕数据定义 grid TYPE REF TO cl_gui_alv_grid, g_container TYPE scrfname VALUE ‘CONT1‘, g_custom_container TYPE REF TO cl_gui_custom_container. DATA: gt_fieldcat02 TYPE lvc_t_fcat, gs_variant02 TYPE disvariant, gs_layout02 TYPE lvc_s_layo. SELECTION-SCREEN BEGIN OF BLOCK blk_001 WITH FRAME TITLE blk_001 . SELECT-OPTIONS:t_bukrs FOR t001-bukrs OBLIGATORY. PARAMETERS:b_gjahr LIKE bkpf-gjahr DEFAULT sy-datum(4) OBLIGATORY. SELECT-OPTIONS:b_belnr FOR bkpf-belnr , b_bldat FOR bkpf-bldat, b_budat FOR bkpf-budat, b_blart FOR bkpf-blart, s_txt50 FOR skat-txt50, b_usnam FOR bkpf-usnam. PARAMETERS:a_check AS CHECKBOX. **PARAMETERS:b_check AS CHECKBOX DEFAULT ‘X‘. SELECTION-SCREEN END OF BLOCK blk_001. AT SELECTION-SCREEN. "新增公司权限对象检查 PERFORM frm_authority_check. START-OF-SELECTION. IF a_check = ‘‘. IF b_blart = ‘‘. SELECT bkpf~bukrs "公司代码 bkpf~belnr "凭证编号 bkpf~gjahr "年度 bkpf~blart "凭证类型 bkpf~budat "过帐日期 bkpf~bldat "凭证日期 bkpf~bktxt "抬头文本 z~sp "审批标识 INTO CORRESPONDING FIELDS OF TABLE gt_itab FROM bkpf LEFT JOIN zfi_sp_table AS z ON z~belnr = bkpf~belnr AND z~belnr = bkpf~belnr AND z~bukrs = bkpf~bukrs WHERE bkpf~bukrs IN t_bukrs "公司代码 AND bkpf~belnr IN b_belnr "凭证编号 AND bkpf~gjahr = b_gjahr "会计年度 AND bkpf~bldat IN b_bldat "凭证日期 AND bkpf~budat IN b_budat "过帐日期 AND bkpf~blart IN (‘SA‘,‘AB‘,‘AA‘,‘RV‘,‘DZ‘,‘RE‘,‘KZ‘) "凭证类型 AND bkpf~usnam IN b_usnam. "制作人 ELSE. SELECT bkpf~bukrs "公司代码 bkpf~belnr "凭证编号 bkpf~gjahr "年度 bkpf~blart "凭证类型 bkpf~budat "过帐日期 bkpf~bldat "凭证日期 bkpf~bktxt "抬头文本 z~sp "审批标识 INTO CORRESPONDING FIELDS OF TABLE gt_itab FROM bkpf LEFT JOIN zfi_sp_table AS z ON z~belnr = bkpf~belnr AND z~belnr = bkpf~belnr AND z~bukrs = bkpf~bukrs WHERE bkpf~bukrs IN t_bukrs "公司代码 AND bkpf~belnr IN b_belnr "凭证编号 AND bkpf~gjahr = b_gjahr "会计年度 AND bkpf~bldat IN b_bldat "凭证日期 AND bkpf~budat IN b_budat "过帐日期 AND bkpf~blart IN b_blart "凭证类型 AND bkpf~usnam IN b_usnam. "制作人 ENDIF. DELETE gt_itab WHERE sp = ‘X‘. PERFORM all_data. PERFORM set_event. ELSE. SELECT * FROM zfi_sp_table INTO CORRESPONDING FIELDS OF TABLE fi_itab WHERE bukrs IN t_bukrs "公司代码 AND belnr IN b_belnr "凭证编号 AND gjahr = b_gjahr "会计年度 AND zerdt IN b_bldat "凭证日期 AND blart IN b_blart "凭证类型 AND uname IN b_usnam. "审核人 ENDIF. PERFORM set_layout. PERFORM set_fieldname. PERFORM result_alv. *&---------------------------------------------------------------------* *& Form alv_user_command *&---------------------------------------------------------------------* * 定义初始屏幕操作逻辑 *----------------------------------------------------------------------* * -->P_UCOMM text * -->P_SELFIELD text *----------------------------------------------------------------------* FORM alv_user_command USING p_ucomm TYPE sy-ucomm p_selfield TYPE slis_selfield. p_selfield-refresh = ‘X‘. "控制grid产生新屏幕 CLEAR wa_insert. CASE p_ucomm. WHEN ‘&IC1‘. READ TABLE gt_itab INDEX p_selfield-tabindex. "定位双击的行号 LOOP AT itab1 WHERE belnr = gt_itab-belnr. APPEND itab1 TO itab2. ENDLOOP. IF itab2[] IS NOT INITIAL. CALL SCREEN ‘1001‘. ENDIF. WHEN ‘SP‘. "多个会计凭证一起审批 LOOP AT gt_itab WHERE sel = ‘X‘. CLEAR wa_insert. MOVE-CORRESPONDING gt_itab TO wa_insert. wa_insert-zerdt = sy-datum. wa_insert-uzeit = sy-uzeit. wa_insert-uname = sy-uname. wa_insert-sp = ‘X‘. INSERT zfi_sp_table FROM wa_insert. DELETE gt_itab. ENDLOOP. p_selfield-refresh = ‘X‘. "审批完成刷新 ENDCASE. ENDFORM. "MALV_USER_COMMAND *&---------------------------------------------------------------------* *& Form alvshow *&---------------------------------------------------------------------* * 显示双击选中会计编号的详细会计科目 * CL_GUI_ALV_GRID->set_table_for_first_display *----------------------------------------------------------------------* FORM alvshow. gs_layout02-no_rowmark = ‘X‘. "禁用行选择 gs_layout02-cwidth_opt = ‘X‘. "优化列宽度 gs_layout02-no_toolbar = ‘X‘. "隐藏工具栏 gs_variant02-report = sy-repid. CREATE OBJECT g_custom_container EXPORTING container_name = g_container. "创建容器 CREATE OBJECT grid EXPORTING i_parent = g_custom_container."创建ALV对象 PERFORM f_grid_build_fieldcat CHANGING gt_fieldcat02. SORT itab2 BY hkont DESCENDING. CALL METHOD grid->set_table_for_first_display EXPORTING is_layout = gs_layout02 is_variant = gs_variant02 CHANGING it_outtab = itab2[] it_fieldcatalog = gt_fieldcat02. CLEAR:gt_fieldcat02,gs_layout02,gs_variant02. ENDFORM. "alvshow *&---------------------------------------------------------------------* *& Form f_grid_build_fieldcat *&---------------------------------------------------------------------* * *----------------------------------------------------------------------* * -->PT_FIELDCAT text *----------------------------------------------------------------------* FORM f_grid_build_fieldcat CHANGING pt_fieldcat TYPE lvc_t_fcat. DATA ls_fcat TYPE lvc_s_fcat. CLEAR ls_fcat. ls_fcat-fieldname = ‘BUKRS‘. ls_fcat-coltext = ls_fcat-tooltip = ls_fcat-seltext = ‘公司‘. ls_fcat-outputlen = 4. APPEND ls_fcat TO pt_fieldcat. CLEAR ls_fcat. ls_fcat-fieldname = ‘BELNR‘. ls_fcat-coltext = ls_fcat-tooltip = ls_fcat-seltext = ‘凭证‘. ls_fcat-outputlen = 10. APPEND ls_fcat TO pt_fieldcat. CLEAR ls_fcat. ls_fcat-fieldname = ‘HKONT‘. ls_fcat-coltext = ls_fcat-tooltip = ls_fcat-seltext = ‘科目‘. ls_fcat-outputlen = 10. APPEND ls_fcat TO pt_fieldcat. CLEAR ls_fcat. ls_fcat-fieldname = ‘SHKZG‘. ls_fcat-coltext = ls_fcat-tooltip = ls_fcat-seltext = ‘借方/贷方标识‘. ls_fcat-outputlen = 1. APPEND ls_fcat TO pt_fieldcat. CLEAR ls_fcat. ls_fcat-fieldname = ‘BUZEI‘. ls_fcat-coltext = ls_fcat-tooltip = ls_fcat-seltext = ‘会计凭证中的行项目数‘. ls_fcat-outputlen = 3. APPEND ls_fcat TO pt_fieldcat. CLEAR ls_fcat. ls_fcat-fieldname = ‘DMBTR‘. ls_fcat-coltext = ls_fcat-tooltip = ls_fcat-seltext = ‘按本位币计的金额本‘. ls_fcat-outputlen = 13. APPEND ls_fcat TO pt_fieldcat. CLEAR ls_fcat. ls_fcat-fieldname = ‘WRBTR‘. ls_fcat-coltext = ls_fcat-tooltip = ls_fcat-seltext = ‘凭证货币金额‘. ls_fcat-outputlen = 13. APPEND ls_fcat TO pt_fieldcat. CLEAR ls_fcat. ls_fcat-fieldname = ‘SGTXT‘. ls_fcat-coltext = ls_fcat-tooltip = ls_fcat-seltext = ‘摘要‘. ls_fcat-outputlen = 50. APPEND ls_fcat TO pt_fieldcat. CLEAR ls_fcat. ls_fcat-fieldname = ‘KUNNR‘. ls_fcat-coltext = ls_fcat-tooltip = ls_fcat-seltext = ‘客户编号‘. ls_fcat-outputlen = 10. APPEND ls_fcat TO pt_fieldcat. CLEAR ls_fcat. ls_fcat-fieldname = ‘LIFNR‘. ls_fcat-coltext = ls_fcat-tooltip = ls_fcat-seltext = ‘供应商或债权人的帐号‘. ls_fcat-outputlen = 8. APPEND ls_fcat TO pt_fieldcat. CLEAR ls_fcat. ls_fcat-fieldname = ‘TXT50‘. ls_fcat-coltext = ls_fcat-tooltip = ls_fcat-seltext = ‘科目名称‘. ls_fcat-outputlen = 50. APPEND ls_fcat TO pt_fieldcat. CLEAR ls_fcat. ls_fcat-fieldname = ‘KOSTL‘. ls_fcat-coltext = ls_fcat-tooltip = ls_fcat-seltext = ‘成本中心‘. ls_fcat-outputlen = 10. APPEND ls_fcat TO pt_fieldcat. CLEAR ls_fcat. ls_fcat-fieldname = ‘FKBER_LONG‘. ls_fcat-coltext = ls_fcat-tooltip = ls_fcat-seltext = ‘功能范围‘. ls_fcat-outputlen = 16. APPEND ls_fcat TO pt_fieldcat. CLEAR ls_fcat. ls_fcat-fieldname = ‘KTEXT‘. ls_fcat-coltext = ls_fcat-tooltip = ls_fcat-seltext = ‘客户名称‘. ls_fcat-outputlen = 35. APPEND ls_fcat TO pt_fieldcat. CLEAR ls_fcat. ls_fcat-fieldname = ‘NAME‘. ls_fcat-coltext = ls_fcat-tooltip = ls_fcat-seltext = ‘供应商名称‘. ls_fcat-outputlen = 35. APPEND ls_fcat TO pt_fieldcat. CLEAR ls_fcat. ls_fcat-fieldname = ‘BLDAT‘. ls_fcat-coltext = ls_fcat-tooltip = ls_fcat-seltext = ‘凭证日期‘. ls_fcat-outputlen = 8. APPEND ls_fcat TO pt_fieldcat. CLEAR ls_fcat. ls_fcat-fieldname = ‘BUDAT‘. ls_fcat-coltext = ls_fcat-tooltip = ls_fcat-seltext = ‘过账日期‘. ls_fcat-outputlen = 8. APPEND ls_fcat TO pt_fieldcat. CLEAR ls_fcat. ls_fcat-fieldname = ‘BLART‘. ls_fcat-coltext = ls_fcat-tooltip = ls_fcat-seltext = ‘类型‘. ls_fcat-outputlen = 2. APPEND ls_fcat TO pt_fieldcat. CLEAR ls_fcat. ls_fcat-fieldname = ‘HWAER‘. ls_fcat-coltext = ls_fcat-tooltip = ls_fcat-seltext = ‘本币‘. ls_fcat-outputlen = 5. APPEND ls_fcat TO pt_fieldcat. ENDFORM. "F_GRID_BUILD_FIELDCAT *&---------------------------------------------------------------------* *& Form alv_status_set *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * -->PT_EXTAB text *----------------------------------------------------------------------* FORM alv_status_set USING pt_extab TYPE slis_t_extab. SET PF-STATUS ‘COPY_GUI‘." OF PROGRAM ‘SAPLKKBL‘. ENDFORM. "ALV_STATUS_SET *&---------------------------------------------------------------------* *& Form set_layout *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* FORM set_layout . gs_layout-zebra = ‘X‘. gs_layout-colwidth_optimize = ‘X‘. gs_layout-cell_merge = ‘X‘. "内容能够复制到剪贴板 IF a_check <> ‘X‘. "显示已审批数据不用指定 不然点击按钮会报错 gs_layout-box_fieldname = ‘SEL‘. "指定这个字段为【选择块】 ENDIF. ENDFORM. " SET_LAYOUT *&---------------------------------------------------------------------* *& Form set_fieldname *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* FORM set_fieldname. DEFINE setfieldcat. clear: gs_fieldcat. gs_fieldcat-col_pos = &1. gs_fieldcat-fieldname = &2. gs_fieldcat-seltext_m = &3. gs_fieldcat-no_zero = ‘X‘. append gs_fieldcat to gt_fieldcat. END-OF-DEFINITION. setfieldcat 1 ‘BUKRS‘ ‘工厂‘. setfieldcat 2 ‘BELNR‘ ‘凭证编号‘. setfieldcat 3 ‘GJAHR‘ ‘年度‘. setfieldcat 4 ‘BLART‘ ‘类型‘. IF a_check = ‘X‘. setfieldcat 5 ‘ZERDT‘ ‘审批日期‘. setfieldcat 6 ‘UZEIT‘ ‘审批时间‘. setfieldcat 7 ‘UNAME‘ ‘审批人‘. setfieldcat 8 ‘SP‘ ‘审批完成标识‘. ELSE. setfieldcat 5 ‘BLDAT‘ ‘凭证日期‘. setfieldcat 6 ‘BUDAT‘ ‘过帐日期‘. setfieldcat 7 ‘BKTXT‘ ‘抬头文本‘. * setfieldcat 8 ‘SP‘ ‘审批标识‘. ENDIF. ENDFORM. "set_fieldname *&---------------------------------------------------------------------* *& Form result_alv *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* FORM result_alv . IF a_check = ‘‘. CALL FUNCTION ‘REUSE_ALV_GRID_DISPLAY‘ EXPORTING i_callback_program = sy-repid is_layout = gs_layout it_fieldcat = gt_fieldcat it_events = gt_events i_callback_user_command = ‘ALV_USER_COMMAND‘ "按钮功能(这个功能也能在is_layout中定义) TABLES t_outtab = gt_itab EXCEPTIONS program_error = 1 OTHERS = 2. ELSE. CALL FUNCTION ‘REUSE_ALV_GRID_DISPLAY‘ EXPORTING i_callback_program = sy-repid is_layout = gs_layout it_fieldcat = gt_fieldcat TABLES t_outtab = fi_itab EXCEPTIONS program_error = 1 OTHERS = 2. ENDIF. CLEAR a_check. ENDFORM. " RESULT_ALV *&---------------------------------------------------------------------* *& Form set_event *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* FORM set_event . CLEAR gs_event. MOVE ‘PF_STATUS_SET‘ TO gs_event-name."调用PF_STATUS_SET签名的Form,ALV工具栏显示前,可自定义工具条 MOVE ‘ALV_STATUS_SET‘ TO gs_event-form. "工具栏设置 APPEND gs_event TO gt_events. ENDFORM. " SET_EVENT *&---------------------------------------------------------------------* *& Form all_data *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* FORM all_data. SELECT SINGLE * FROM t001 WHERE bukrs = t_bukrs. comtitle = t001-butxt. SELECT bukrs "公司代码 belnr "凭证编号 blart "凭证类型 usnam "用户名 ppnam "凭证制作人 budat "过帐日期 bldat "凭证日期 waers hwaer "本位币 kursf "汇率 INTO CORRESPONDING FIELDS OF TABLE itab_bkpf FROM bkpf WHERE bukrs IN t_bukrs "公司代码 AND belnr IN b_belnr "凭证编号 AND gjahr = b_gjahr "会计年度 AND bldat IN b_bldat "凭证日期 AND budat IN b_budat "过帐日期 AND blart IN b_blart "凭证类型 AND usnam IN b_usnam. "制作人 SORT itab_bkpf BY belnr ASCENDING . IF sy-subrc <> 0. MESSAGE ‘输入的凭证编号不存在!‘ TYPE ‘E‘. ENDIF. LOOP AT itab_bkpf. SELECT belnr "凭证编号 hkont "总分类帐帐目 shkzg "借方/贷方标识 dmbtr "按本位币计的金额 wrbtr "凭证货币金额 sgtxt "项目文本 kunnr "客户编号1 lifnr "供应商或债权人的帐号 zuonr "分配编号 buzei "会计凭证中的行项目数 kostl "成本中心 fkber_long "功能范围 APPENDING CORRESPONDING FIELDS OF TABLE itab_bseg FROM bseg WHERE belnr = itab_bkpf-belnr AND gjahr = b_gjahr AND bukrs IN t_bukrs . "修改日元问题 by hua.su. IF itab_bkpf-waers = ‘JPY‘ . LOOP AT itab_bseg WHERE belnr = itab_bkpf-belnr. itab_bseg-wrbtr = itab_bseg-wrbtr * 100. MODIFY itab_bseg. CLEAR itab_bseg. ENDLOOP. ENDIF. SELECT SINGLE butxt INTO itab_bkpf-butxt FROM t001 WHERE bukrs = itab_bkpf-bukrs. SELECT SINGLE ltext FROM t003t INTO itab_bkpf-ltext WHERE blart = itab_bkpf-blart AND t003t~spras = ‘1‘. IF itab_bkpf-blart = ‘KR‘ OR itab_bkpf-blart = ‘KZ‘ OR itab_bkpf-blart = ‘DR‘ OR itab_bkpf-blart = ‘DZ‘ OR itab_bkpf-blart = ‘SA‘. SELECT SINGLE xblnr INTO itab_bkpf-xblnr "参考凭证号 FROM bkpf WHERE belnr = itab_bkpf-belnr. ENDIF. SELECT SINGLE name_last name_first INTO (itab_bkpf-name_last,itab_bkpf-name_first) FROM user_addr WHERE bname = itab_bkpf-usnam. CONCATENATE itab_bkpf-name_last itab_bkpf-name_first INTO itab_bkpf-name_last. SELECT SINGLE bseg~kunnr INTO itab_bkpf-kunnr FROM bseg WHERE bseg~belnr = itab_bkpf-belnr AND kunnr <> ‘‘. IF itab_bkpf-blart = ‘RV‘. SELECT SINGLE kna1~name1 INTO itab_bkpf-sgtxt FROM kna1 WHERE kunnr = itab_bkpf-kunnr. CONCATENATE ‘销售-‘ itab_bkpf-sgtxt INTO itab_bkpf-sgtxt. ENDIF. MODIFY itab_bkpf INDEX sy-tabix. ENDLOOP. IF NOT itab_bseg[] IS INITIAL. DATA temp_sgtxt LIKE bseg-sgtxt. SORT itab_bseg DESCENDING BY belnr lifnr. LOOP AT itab_bseg. SELECT SINGLE txt50 FROM skat INTO itab_bseg-txt50 WHERE skat~saknr = itab_bseg-hkont. SELECT SINGLE cskt~ktext INTO itab_bseg-ktext FROM cskt WHERE cskt~kostl = itab_bseg-kostl AND cskt~spras = ‘1‘. IF itab_bseg-lifnr <> ‘‘. CALL FUNCTION ‘CONVERSION_EXIT_ALPHA_OUTPUT‘ EXPORTING input = itab_bseg-lifnr IMPORTING output = itab_bseg-lifnr. CONCATENATE itab_bseg-txt50 ‘-‘ itab_bseg-lifnr INTO itab_bseg-txt50. ENDIF. IF itab_bseg-kunnr <> ‘‘. CALL FUNCTION ‘CONVERSION_EXIT_ALPHA_OUTPUT‘ EXPORTING input = itab_bseg-kunnr IMPORTING output = itab_bseg-kunnr. CONCATENATE itab_bseg-txt50 ‘-‘ itab_bseg-kunnr INTO itab_bseg-txt50. ENDIF. IF itab_bseg-fkber_long = ‘1000‘. CONCATENATE itab_bseg-txt50 ‘-‘ itab_bseg-ktext ‘-‘ itab_bseg-kostl ‘-‘ ‘制造费用‘ INTO itab_bseg-txt50. ELSEIF itab_bseg-fkber_long = ‘2000‘ . CONCATENATE itab_bseg-txt50 ‘-‘ itab_bseg-ktext ‘-‘ itab_bseg-kostl ‘-‘ ‘管理费用‘ INTO itab_bseg-txt50. ELSEIF itab_bseg-fkber_long = ‘3000‘. CONCATENATE itab_bseg-txt50 ‘-‘ itab_bseg-ktext ‘-‘ itab_bseg-kostl ‘-‘ ‘销售费用‘ INTO itab_bseg-txt50. ELSEIF itab_bseg-fkber_long = ‘4000‘. CONCATENATE itab_bseg-txt50 ‘-‘ itab_bseg-ktext ‘-‘ itab_bseg-kostl ‘-‘ ‘研发费用‘ INTO itab_bseg-txt50. ELSEIF itab_bseg-fkber_long = ‘5000‘. CONCATENATE itab_bseg-txt50 ‘-‘ itab_bseg-ktext ‘-‘ itab_bseg-kostl ‘-‘ ‘材料附加费‘ INTO itab_bseg-txt50. ENDIF. MODIFY itab_bseg INDEX sy-tabix. ENDLOOP. ENDIF. *************读取供应商或客户描述************* IF NOT itab_bseg[] IS INITIAL."确定为已过帐的凭证 SELECT saknr txt50 INTO TABLE itab_skat FROM skat FOR ALL ENTRIES IN itab_bseg WHERE saknr = itab_bseg-hkont AND spras = sy-langu AND ktopl = t001-ktopl. * READ TABLE ITAB_SKAT. SELECT kunnr name1 INTO TABLE itab_kna1 FROM kna1 FOR ALL ENTRIES IN itab_bseg WHERE kunnr = itab_bseg-kunnr. SELECT lifnr name1 INTO TABLE itab_lfa1 FROM lfa1 FOR ALL ENTRIES IN itab_bseg WHERE lifnr = itab_bseg-lifnr. ENDIF. SORT itab_bseg BY shkzg DESCENDING buzei ASCENDING belnr ASCENDING . LOOP AT itab_bseg. COLLECT itab_bseg INTO itab. ENDLOOP. SORT itab BY belnr. LOOP AT itab. "FBY 2015 READ TABLE itab_bkpf WITH KEY belnr = itab-belnr. IF sy-subrc = 0. itab1-bukrs = itab_bkpf-bukrs. itab1-belnr = itab_bkpf-belnr."会计凭证编号 itab1-hkont = itab-hkont. "科目编码 itab1-shkzg = itab-shkzg. "借方/贷方标识 itab1-buzei = itab-buzei. itab1-dmbtr = itab-dmbtr. "按本位币计的金额 itab1-wrbtr = itab-wrbtr. "凭证货币金额 itab1-sgtxt = itab-sgtxt. "摘要 itab1-kunnr = itab-kunnr. "客户编号1 itab1-lifnr = itab-lifnr. "供应商或债权人的帐号 itab1-txt50 = itab-txt50. "科目名称 itab1-kostl = itab-kostl. "成本中心 itab1-fkber_long = itab-fkber_long. "功能范围 itab1-ktext = itab-ktext. "成本中心描述 itab1-name1 = itab-name1. "客户名称 itab1-name = itab-name. "供应商名称 itab1-bldat = itab_bkpf-bldat. "凭证日期 "fby itab1-budat = itab_bkpf-budat. "过账日期 itab1-blart = itab_bkpf-blart. "类型 itab1-hwaer = itab_bkpf-hwaer. "本币 APPEND itab1. CLEAR itab1. ENDIF. ENDLOOP. ENDFORM. "FRM_GET_DATA *&---------------------------------------------------------------------* *& Form frm_authority_check *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* FORM frm_authority_check . DATA: BEGIN OF lt_werks OCCURS 0 , werks LIKE t001w-werks, END OF lt_werks . SELECT werks INTO CORRESPONDING FIELDS OF TABLE lt_werks FROM t001w WHERE werks IN t_bukrs. LOOP AT lt_werks . AUTHORITY-CHECK OBJECT ‘ZWERKS‘ ID ‘WERKS‘ FIELD lt_werks-werks . IF sy-subrc <> 0. MESSAGE e001(00) WITH ‘你没有 ‘ lt_werks-werks ‘公司的操作权限!‘. ENDIF. ENDLOOP . ENDFORM. "frm_authority_check INCLUDE zfi_sp_pbo . INCLUDE zfi_sp_pai .
*&---------------------------------------------------------------------* *& 包括 ZFI_SP_ALLDATA *&---------------------------------------------------------------------* *--------------------------------------------------------------------------------------------------------------------------------* DATA:comtitle LIKE t001-butxt. TYPES:BEGIN OF ty_itab1, bukrs LIKE bkpf-bukrs, belnr LIKE bseg-belnr, "会计凭证编号 hkont LIKE bseg-hkont, "科目编码 shkzg LIKE bseg-shkzg, "借方/贷方标识 buzei LIKE bseg-buzei, dmbtr LIKE bseg-dmbtr, "按本位币计的金额 wrbtr LIKE bseg-wrbtr, "凭证货币金额 sgtxt LIKE bseg-sgtxt, "摘要 kunnr LIKE bseg-kunnr, "客户编号1 lifnr LIKE bseg-lifnr, "供应商或债权人的帐号 txt50 LIKE skat-txt50, "科目名称 kostl LIKE bseg-kostl, "成本中心 fkber_long LIKE bseg-fkber_long, "功能范围 ktext LIKE cskt-ktext, "成本中心描述 name1 LIKE kna1-name1, "客户名称 name LIKE lfa1-name1, "供应商名称 bldat LIKE bkpf-bldat, "凭证日期 "fby budat LIKE bkpf-budat, "过账日期 blart LIKE bkpf-blart, "类型 hwaer LIKE bkpf-hwaer, "本币 END OF ty_itab1. DATA:itab1 TYPE TABLE OF ty_itab1 WITH HEADER LINE, itab2 TYPE TABLE OF ty_itab1 WITH HEADER LINE. DATA:BEGIN OF itab_bkpf OCCURS 0, bukrs LIKE bkpf-bukrs, butxt LIKE t001-butxt, belnr LIKE bseg-belnr,"会计凭证编号 blart LIKE bkpf-blart, bktxt LIKE bkpf-bktxt, usnam LIKE bkpf-usnam,"过帐人 ppnam LIKE bkpf-ppnam,"预制人 budat LIKE bkpf-budat, bldat LIKE bkpf-bldat, xblnr LIKE bkpf-xblnr,"参照 waers LIKE bkpf-waers,"币别码 hwaer LIKE bkpf-hwaer,"本位币 by snowchen 10/05/25 ltext LIKE t003t-ltext, "凭证类型描述 name_first LIKE user_addr-name_first, "名 name_last LIKE user_addr-name_last, "姓 sgtxt LIKE bseg-sgtxt, "摘要 kunnr LIKE bseg-kunnr, "客户代码 kursf LIKE bkpf-kursf, "汇率 END OF itab_bkpf. DATA:BEGIN OF itab_bseg OCCURS 0, belnr LIKE bseg-belnr, "会计凭证编号 hkont LIKE bseg-hkont, "科目编码 shkzg LIKE bseg-shkzg, "借方/贷方标识 buzei LIKE bseg-buzei, dmbtr LIKE bseg-dmbtr, "按本位币计的金额 wrbtr LIKE bseg-wrbtr, "凭证货币金额 sgtxt LIKE bseg-sgtxt, "摘要 kunnr LIKE bseg-kunnr, "客户编号1 lifnr LIKE bseg-lifnr, "供应商或债权人的帐号 txt50 LIKE skat-txt50, "科目名称 kostl LIKE bseg-kostl, "成本中心 fkber_long LIKE bseg-fkber_long, "功能范围 ktext LIKE cskt-ktext, "成本中心描述 name1 LIKE kna1-name1, "客户名称 name LIKE lfa1-name1, "供应商名称 END OF itab_bseg. DATA: itab LIKE TABLE OF itab_bseg WITH HEADER LINE. DATA: BEGIN OF itab_skat OCCURS 10 , saknr LIKE skat-saknr, "会计科目 txt50 LIKE skat-txt50, "科目描述 END OF itab_skat. DATA: BEGIN OF itab_kna1 OCCURS 0 , kunnr LIKE kna1-kunnr,"客户编码 name1 LIKE kna1-name1,"客户名称 END OF itab_kna1. DATA: BEGIN OF itab_lfa1 OCCURS 0 , lifnr LIKE lfa1-lifnr,"供应商编码 name1 LIKE lfa1-name1,"供应商名称 END OF itab_lfa1. DATA: BEGIN OF itab_sgtxt OCCURS 0 , sgtxt LIKE bseg-sgtxt, END OF itab_sgtxt. *--------------------------------------------------------------------------------------------------、
PBO
*&---------------------------------------------------------------------* *& Include ZFI_SP_PBO *&---------------------------------------------------------------------* *&---------------------------------------------------------------------* *& Module STATUS_1001 OUTPUT *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* MODULE status_1001 OUTPUT. SET PF-STATUS ‘T001‘. PERFORM alvshow. "展示双击选中会计编号的详细会计科目 * SET TITLEBAR ‘凭证科目‘. ENDMODULE. " STATUS_1001 OUTPUT
PAI
*&---------------------------------------------------------------------* *& Include ZFI_SP_PAI *&---------------------------------------------------------------------* *&---------------------------------------------------------------------* *& Module USER_COMMAND_1001 INPUT *&---------------------------------------------------------------------* * 单个记录已审批的的会计凭证 *----------------------------------------------------------------------* MODULE user_command_1001 INPUT. save_ok = ok_code. CLEAR ok_code. CASE save_ok. WHEN ‘SP‘. MOVE-CORRESPONDING gt_itab TO wa_insert. wa_insert-zerdt = sy-datum. wa_insert-uzeit = sy-uzeit. wa_insert-uname = sy-uname. wa_insert-sp = ‘X‘. INSERT zfi_sp_table FROM wa_insert. MOVE-CORRESPONDING gt_itab TO wa_itab. DELETE TABLE gt_itab FROM wa_itab. CLEAR:wa_itab,gt_itab. CLEAR:itab2[],itab2. LEAVE TO SCREEN 0. WHEN ‘BACK‘ OR ‘EXIT‘ OR ‘CANCEL‘. CLEAR:itab2[],itab2,wa_itab,gt_itab. LEAVE TO SCREEN 0. ENDCASE. ENDMODULE. " USER_COMMAND_1001 INPUT
模拟会计凭证审批 OO ALV(屏幕跳转、定位行数据、审批按钮)
标签:审批 font 初始 lock toolbar stl val elf case
原文地址:https://www.cnblogs.com/freeandeasy/p/13665832.html