应付暂估的明细查询

更新时间:2022-11-09 07:59:42 阅读: 评论:0


2022年11月9日发
(作者:关于学习的英语作文)

SAP方丈:如何建立应付暂估明细查询

应付暂估的明细查询还是很麻烦的一件事情,系统本身并不提供相关功能。其开发源代码如下:



*---------------------------------------------------------------------*

* Report ZRFI0950

* Created By : SAP target=_blank class=link_tag>SAP方丈 *

* Created On : 2008/04/17 *

* Description: 1、查询暂估帐 *

*----------------------------------------------------------------------*

* Modification Log *

*----------------------------------------------------------------------*

* 01 Changed By : *

* Changed On : *

* Description : *

************************************************************************



REPORT ZRFI0950.

***********************************************************************

* TABLES

***********************************************************************

tables:

bkpf,

kna1, "客户账户

knb1, "公司代码

knc1, "会计年度

bsid. "凭证日期



***********************************************************************

* ALV ABOUT

***********************************************************************

type-pools:

slis.



DATA: i_events TYPE slis_t_event WITH HEADER LINE,

i_fieldcat TYPE slis_t_fieldcat_alv WITH HEADER LINE,

i_listcomm TYPE slis_t_listheader WITH HEADER LINE,

i_layout TYPE slis_layout_alv.

***********************************************************************

* GLOBAL VARIABLES

***********************************************************************

data: begin of gt_detail occurs 0, " 暂估入库列表

hkont like bsis-hkont, " 科目号

belnr like bsis-belnr, " 凭证编号

buzei like bsis-buzei, " 凭证行项目

shkzg like bsis-shkzg, " 借贷标识

budat like bsis-budat, " 过帐日期

dmbtr like bsis-dmbtr, " 发生金额

ebeln like bg-ebeln, " 采购凭证

lifnr like ekko-lifnr, " 供应商号

lname LIKE lfa1-name1,

dnume type i, " 帐龄

end of gt_detail,

BEGIN OF gt_out OCCURS 0,

id type i, " 序号

lifnr LIKE ekko-lifnr, "供应商号

lname like lfa1-name1, "供应商名

ncdat like bsis-dmbtr, "年初余额

qmdat like bsis-dmbtr, "期末余额

qjone like bsis-dmbtr, "0-90天

qjtwo like bsis-dmbtr, "91-180

qjthr like bsis-dmbtr, "181-270

qjfou like bsis-dmbtr, "271-360

qjfiv like bsis-dmbtr, ">360

END OF gt_out.

data: gt_ebeln LIKE STANDARD TABL

ON 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = sy-repid

i_save = ''

i_callback_ur_command = 'USER_COMMAND'

is_layout = i_layout

it_events = i_events[]

it_fieldcat = i_fieldcat[]

TABLES

t_outtab = gt_out.



ENDFORM. "data_output



FORM events_build .

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

EXPORTING

i_list_type = 0

IMPORTING

et_events = i_events[].

READ TABLE i_events WITH KEY name = slis_ev_top_of_page.

IF sy-subrc = 0.

i_events-form = 'ALV_TOP_OF_PAGE'.

MODIFY i_events INDEX sy-tabix.

ENDIF.

ENDFORM. "events_build



*&---------------------------------------------------------------------*

*& Form alv_top_of_page

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

FORM alv_top_of_page.

DATA itoc(10) TYPE c.

DATA: lv_temp(60).

CLEAR: i_listcomm,i_listcomm[].

i_listcomm-typ = 'H'.

i_listcomm-key = ''.

i_listcomm-info = '材料暂估表'.

APPEND i_listcomm.

CLEAR i_listcomm.



i_listcomm-typ = 'S'.

lv_temp = '编制单位:'.

APPEND i_listcomm.

CLEAR i_listcomm.



i_listcomm-typ = 'S'.

CONCATENATE '查询时间: ' p_budat+0(4) '年' p_budat+4(2) '月' p_budat+6(2) '日'

INTO lv_temp.

i_listcomm-info = lv_temp.

APPEND i_listcomm.

CLEAR i_listcomm.



CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

it_list_commentary = i_listcomm[].

ENDFORM. "alv_top_of_page



*&---------------------------------------------------------------------*

*& Form layout_build

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

FORM layout_build .

i_layout-zebra = 'X'.

i_layout-detail_popup = 'X'.

i_layout-no_vline = ''.

i_layout-colwidth_optimize = 'X'.

i_layout-detail_initial_lines = 'X'.

i_layout-detail_titlebar = '物料暂估明细'.

ENDFORM. " layout_build



* alv ??

FORM fields_build.

i_fieldcat-key = 'X'.

PERFORM alv_field_column USING 'ID' '序号'.

i_fieldcat-key = 'X'.

PERFORM alv_field_column USING 'LIFNR' '供应商号'.

i_fieldcat-key = 'X'.

PERFORM alv_field_column USING 'LNAME' '供应商名称'.

i_fieldcat-key = 'X'.

PERFORM alv_field_column USING 'NCDAT' '年初余额'.

i_fieldcat-key = 'X'.

PERFORM alv_field_column USING 'QMDAT' '期末余额'.

PERFORM alv_field_column USING 'QJONE' '0-90天'.

PERFORM alv_field_column USING 'QJTWO' '91-180天'.

PERFORM alv_field_column USING 'QJTHR' '181-270天'.

PERFORM alv_field_column

USING 'QJFOU' '271-360天'.

PERFORM alv_field_column USING 'QJFIV' '大于360天'.

ENDFORM. "fields_build



*&---------------------------------------------------------------------*

*& Form alv_field_column

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

* -->VALUE(P_FIELDNAME) text

* -->VALUE(P_SELTEXT_L) text

*----------------------------------------------------------------------*

FORM alv_field_column USING value(p_fieldname)

value(p_ltext_l).



i_fieldcat-fieldname = p_fieldname.

i_fieldcat-ltext_l = p_ltext_l.

IF p_fieldname+0(2) CP 'QJ' OR p_fieldname+0(2) CP 'NC' OR p_fieldname+0(2) = 'QM'.

i_fieldcat-edit_mask = '==Z001'.

ENDIF.

APPEND i_fieldcat.

CLEAR i_fieldcat.

ENDFORM. "alv_field_column



FORM ur_command USING r_ucomm LIKE sy-ucomm

rs_lfield TYPE slis_lfield.



CASE r_ucomm.

WHEN '&IC1'.

if rs_lfield-fieldname = 'LIFNR'. "供应商.

CLEAR gt_ebeln[].

PERFORM data_reapp using rs_lfield-value.

perform data_outputb.

endif.



ENDCASE.

ENDFORM.



form data_reapp using lifnr.

SELECT single name1 from lfa1 into wa_lname.

loop at gt_detail where lifnr = lifnr.

lect single aedat from ekko into gt_ebeln-budat WHERE ebeln = gt_detail-ebeln.

gt_ebeln-lifnr = lifnr.

gt_ebeln-lname = wa_lname.

gt_ebeln-ebeln = gt_detail-ebeln.

gt_ebeln-dmbtr = gt_detail-dmbtr.

COLLECT gt_ebeln.

CLEAR: gt_detail, gt_ebeln.

ENDLOOP.

sort gt_ebeln by ebeln.

endform.

FORM data_outputb.

CLEAR: i_layout,i_events[],i_fieldcat[].

PERFORM events_buildb.

PERFORM layout_buildb.

PERFORM fields_buildb.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = sy-repid

i_save = ''

i_callback_ur_command = 'USER_COMMANDB'

is_layout = i_layout

it_events = i_events[]

it_fieldcat = i_fieldcat[]

TABLES

t_outtab = gt_ebeln.



ENDFORM. "data_output



FORM events_buildb .

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

EXPORTING

i_list_type = 0

IMPORTING

et_events = i_events[].

READ TABLE i_events WITH KEY name = slis_ev_top_of_page.

IF sy-subrc = 0.

i_events-form = 'ALV_TOP_OF_PAGEB'.

MODIFY i_events INDEX sy-tabix.

ENDIF.

ENDFORM. "events_build



*&---------------------------------------------------------------------*

*& Form alv_top_of_page

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

FORM alv_top_of_pageb.

DATA itoc(10) TY

PE c.

DATA: lv_temp(60).

CLEAR: i_listcomm,i_listcomm[].

i_listcomm-typ = 'H'.

i_listcomm-key = ''.

i_listcomm-info = '材料暂估表-供应商明细'.

APPEND i_listcomm.

CLEAR i_listcomm.



i_listcomm-typ = 'S'.

lv_temp = '编制单位:'.

APPEND i_listcomm.

CLEAR i_listcomm.



i_listcomm-typ = 'S'.

CONCATENATE '供应商:' wa_lname '. 查询时间: ' p_budat+0(4) '年' p_budat+4(2) '月' p_budat+6(2) '日'

INTO lv_temp.

i_listcomm-info = lv_temp.

APPEND i_listcomm.

CLEAR i_listcomm.



CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

it_list_commentary = i_listcomm[].

ENDFORM. "alv_top_of_page



*&---------------------------------------------------------------------*

*& Form layout_build

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

FORM layout_buildb .

i_layout-zebra = 'X'.

i_layout-detail_popup = 'X'.

i_layout-no_vline = ''.

i_layout-colwidth_optimize = 'X'.

i_layout-detail_initial_lines = 'X'.

i_layout-detail_titlebar = '采购凭证明细'.

ENDFORM. " layout_build



* alv ??

FORM fields_buildb.

PERFORM alv_field_columnb USING 'LIFNR' '供应商'.

PERFORM alv_field_columnb USING 'LNAME' '供应名称'.

PERFORM alv_field_columnb USING 'EBELN' '采购凭证'.

PERFORM alv_field_columnb USING 'BUDAT' '订单创建时间'.

PERFORM alv_field_columnb USING 'DMBTR' '采购成交金额'.

ENDFORM. "fields_build



*&---------------------------------------------------------------------*

*& Form alv_field_column

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

* -->VALUE(P_FIELDNAME) text

* -->VALUE(P_SELTEXT_L) text

*----------------------------------------------------------------------*

FORM alv_field_columnb USING value(p_fieldname)

value(p_ltext_l).



i_fieldcat-fieldname = p_fieldname.

i_fieldcat-ltext_l = p_ltext_l.

IF p_fieldname+0(2) CP 'DM'.

i_fieldcat-edit_mask = '==Z001'.

ENDIF.

APPEND i_fieldcat.

CLEAR i_fieldcat.

ENDFORM. "alv_field_column



FORM ur_commandb USING r_ucomm LIKE sy-ucomm

rs_lfield TYPE slis_lfield.



CASE r_ucomm.

WHEN '&IC1'.

if rs_lfield-fieldname = 'EBELN'. "供应商.

SET PARAMETER ID 'BES' FIELD rs_lfield-value.

CALL TRANSACTION 'ME23N' AND SKIP FIRST SCREEN.

endif.



ENDCASE.

ENDFORM.






本文发布于:2022-11-09 07:59:42,感谢您对本站的认可!

本文链接:http://www.wtabcd.cn/fanwen/fan/82/457745.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:detail
相关文章
留言与评论(共有 0 条评论)
   
验证码:
推荐文章
排行榜
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图