|
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。如果您注册时有任何问题请联系客服QQ: 83569622 。
您需要 登录 才可以下载或查看,没有帐号?注册
x
*&---------------------------------------------------------------------*
*& Report ZSDB03
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ZSDB03. "订单回款明细报表
TYPE-POOLS: SLIS. "alv输出类型池声明
TABLES IPS,VBAP,VBKD,VBRP,BSEG,VBRK,BKPF.
DATA:BEGIN OF TAB1 OCCURS 0,
VBELN LIKE LIPS-VBELN, "交货单号
VGBEL LIKE LIPS-VGBEL, "订单号
KUNNR LIKE VBAK-KUNNR, "客编
NETWR LIKE VBAP-NETWR, "金额
WAERK LIKE VBAP-WAERK, "订单币种
ZTERM LIKE VBKD-ZTERM, "付款方式
ERNAM LIKE VBAP-ERNAM, "业务员
KZWI1 LIKE VBRP-KZWI1, "发票金额
DMBTR LIKE BSEG-DMBTR, "收款金额
PSWSL LIKE BSEG-PSWSL, "收款币种
AUGDT LIKE BSEG-AUGDT, "日期
* DDJE(15) TYPE C VALUE '',
* FPJE(15) TYPE C VALUE '',
* HKJE(15) TYPE C VALUE '',
TEXT_ETA(50) TYPE C VALUE '', "定义ETA变量
TEXT_ETD(50) TYPE C VALUE '', "定义ETD变量
TEXT_BZ(50) TYPE C VALUE '',
END OF TAB1.
DATA: GT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV, "定义alv所需要的标题和抬头信息变量
L_GRID_TITLE(70) TYPE C VALUE '订 单 回 款 信 息 查 询'.
*- 用户输入参数(选择屏幕)
SELECT-OPTIONS: S_VGBEL FOR LIPS-VGBEL MEMORY ID DD, "OBLIGATORY 强制输入 查询条件:订单号
S_VBELN FOR LIPS-VBELN MEMORY ID DD1. "查询条件:交货单号
SELECT
A~VBELN "交货单号 lips
A~VGBEL "订单 lips
B~KUNNR "客编 vbak
C~NETWR "金额 vbap
C~WAERK "订单币种 vbap
C~ERNAM "业务员 vbaP
D~ZTERM "付款方式 vbkd
E~KZWI1 "发票金额 vbrp
FROM LIPS AS A
INNER JOIN VBAK AS B
ON A~VGBEL = B~VBELN
INNER JOIN VBAP AS C
ON A~VGBEL = C~VBELN
INNER JOIN VBKD AS D
ON B~VBELN = D~VBELN
INNER JOIN VBRP AS E
ON A~VBELN = E~VGBEL
INTO CORRESPONDING FIELDS OF TABLE TAB1
WHERE A~VBELN IN S_VBELN
AND A~VGBEL IN S_VGBEL.
LOOP AT TAB1.
SELECT SINGLE DMBTR
INTO TAB1-DMBTR
FROM BSEG
WHERE VBELN = TAB1-VBELN.
MODIFY TAB1.
SELECT SINGLE PSWSL
INTO TAB1-PSWSL
FROM BSEG
WHERE VBELN = TAB1-VBELN.
MODIFY TAB1.
SELECT SINGLE AUGDT
INTO TAB1-AUGDT
FROM BSEG
WHERE VBELN = TAB1-VBELN.
MODIFY TAB1.
* CONCATENATE TAB1-NETWR TAB1-WAERK INTO TAB1-DDJE .
* MODIFY TAB1.
* CONCATENATE TAB1-KZWI1 TAB1-WAERK INTO TAB1-FPJE .
* MODIFY TAB1.
* CONCATENATE TAB1-DMBTR TAB1-PSWSL INTO TAB1-HKJE .
* MODIFY TAB1.
ENDLOOP.
*&---------------------------------------------------------------------*
*& Form frm_getlongtext
*&---------------------------------------------------------------------*
* 获取抬头长文本信息
*----------------------------------------------------------------------*
*FORM FRM_GETHEADERTEXT.
DATA: IL_TLINE LIKE TLINE OCCURS 0 WITH HEADER LINE,
LWK_NAME TYPE THEAD-TDNAME.
LOOP AT TAB1.
LWK_NAME = S_VBELN-LOW.
**——————获取 ETA
*
CALL FUNCTION 'READ_TEXT'
EXPORTING
CLIENT = SY-MANDT
ID = 'Z431'
LANGUAGE = '1'
NAME = LWK_NAME
OBJECT = 'VBBK'
** ARCHIVE_HANDLE = 0
** LOCAL_CAT = ' '
** IMPORTING
** HEADER =
TABLES
LINES = IL_TLINE
EXCEPTIONS
ID = 1
LANGUAGE = 2
NAME = 3
NOT_FOUND = 4
OBJECT = 5
REFERENCE_CHECK = 6
WRONG_ACCESS_TO_ARCHIVE = 7
OTHERS = 8
.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
LOOP AT IL_TLINE.
TAB1-TEXT_ETA = IL_TLINE-TDLINE .
MODIFY TAB1.
"WRITE: / TAB1-TEXT_ETA.
ENDLOOP.
*——————获取 ETD
CALL FUNCTION 'READ_TEXT'
EXPORTING
CLIENT = SY-MANDT
ID = 'Z413'
LANGUAGE = '1'
NAME = LWK_NAME
OBJECT = 'VBBK'
** ARCHIVE_HANDLE = 0
** LOCAL_CAT = ' '
** IMPORTING
* HEADER =
TABLES
LINES = IL_TLINE
EXCEPTIONS
ID = 1
LANGUAGE = 2
NAME = 3
NOT_FOUND = 4
OBJECT = 5
REFERENCE_CHECK = 6
WRONG_ACCESS_TO_ARCHIVE = 7
OTHERS = 8
.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
LOOP AT IL_TLINE.
TAB1-TEXT_ETD = IL_TLINE-TDLINE .
MODIFY TAB1.
"WRITE: / TAB1-TEXT_ETD.
ENDLOOP.
**——————获取 ETA
*
CALL FUNCTION 'READ_TEXT'
EXPORTING
CLIENT = SY-MANDT
ID = 'Z410'
LANGUAGE = '1'
NAME = LWK_NAME
OBJECT = 'VBBK'
** ARCHIVE_HANDLE = 0
** LOCAL_CAT = ' '
** IMPORTING
** HEADER =
TABLES
LINES = IL_TLINE
EXCEPTIONS
ID = 1
LANGUAGE = 2
NAME = 3
NOT_FOUND = 4
OBJECT = 5
REFERENCE_CHECK = 6
WRONG_ACCESS_TO_ARCHIVE = 7
OTHERS = 8
.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
LOOP AT IL_TLINE.
TAB1-TEXT_BZ = IL_TLINE-TDLINE .
MODIFY TAB1.
"WRITE: / TAB1-TEXT_BZ.
ENDLOOP.
ENDLOOP.
*ENDFORM. "frm_getlongtext
* 填充标题
PERFORM FIELDCAT_INIT.
*- 输出结果
PERFORM ALV_OTPT.
*&-------------------------------------------------
*& Form alv_otpt
*&-------------------------------------------------
* text
*--------------------------------------------------
* --> p1 text
* <-- p2 text
*--------------------------------------------------
FORM ALV_OTPT.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
* I_INTERFACE_CHECK = ' '
* I_BYPASSING_BUFFER =
* I_BUFFER_ACTIVE = ' '
* I_CALLBACK_PROGRAM = ' '
* I_CALLBACK_PF_STATUS_SET = ' '
* I_CALLBACK_USER_COMMAND = ' '
* I_STRUCTURE_NAME =
* IS_LAYOUT =
IT_FIELDCAT = GT_FIELDCAT[]
* IT_EXCLUDING =
* IT_SPECIAL_GROUPS =
* IT_SORT =
* IT_FILTER =
* IS_SEL_HIDE =
* I_DEFAULT = 'X'
* I_SAVE = 'X'
* IS_VARIANT =
* IT_EVENTS =
* IT_EVENT_EXIT =
* IS_PRINT =
* IS_REPREP_ID =
* I_SCREEN_START_COLUMN = 0
* I_SCREEN_START_LINE = 0
* I_SCREEN_END_COLUMN = 0
* I_SCREEN_END_LINE = 0
* IR_SALV_LIST_ADAPTER =
* IT_EXCEPT_QINFO =
* I_SUPPRESS_EMPTY_DATA = ABAP_FALSE
* IMPORTING
* E_EXIT_CAUSED_BY_CALLER =
* ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB = TAB1
* EXCEPTIONS
* PROGRAM_ERROR = 1
* OTHERS = 2
.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. "ALV_OTPT
*&-------------------------------------------------
*& Form FIELDCAT_INIT
*&-------------------------------------------------
* text
*--------------------------------------------------
* --> p1 text
* <-- p2 text
*--------------------------------------------------
FORM FIELDCAT_INIT.
DATA: LS_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'VBELN'.
LS_FIELDCAT-SELTEXT_L = '交货单号'.
APPEND LS_FIELDCAT TO GT_FIELDCAT.
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'VGBEL'.
LS_FIELDCAT-SELTEXT_L = '订单号码'.
APPEND LS_FIELDCAT TO GT_FIELDCAT.
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'KUNNR'.
LS_FIELDCAT-SELTEXT_L = '售达方'.
APPEND LS_FIELDCAT TO GT_FIELDCAT.
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'TEXT_ETD'.
LS_FIELDCAT-SELTEXT_L = 'ETD'.
* ls_fieldcat-do_sum = 'X'.
APPEND LS_FIELDCAT TO GT_FIELDCAT.
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'TEXT_ETA'.
LS_FIELDCAT-SELTEXT_L = 'ETA'.
* ls_fieldcat-do_sum = 'X'.
APPEND LS_FIELDCAT TO GT_FIELDCAT.
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'NETWR'.
LS_FIELDCAT-SELTEXT_L = '订单金额'.
* ls_fieldcat-do_sum = 'X'.
APPEND LS_FIELDCAT TO GT_FIELDCAT.
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'WAERK'.
LS_FIELDCAT-SELTEXT_L = '订单币种'.
* ls_fieldcat-do_sum = 'X'.
APPEND LS_FIELDCAT TO GT_FIELDCAT.
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'ZTERM'.
LS_FIELDCAT-SELTEXT_L = '付款方式'.
* ls_fieldcat-do_sum = 'X'.
APPEND LS_FIELDCAT TO GT_FIELDCAT.
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'ERNAM'.
LS_FIELDCAT-SELTEXT_L = '业务员'.
* ls_fieldcat-do_sum = 'X'.
APPEND LS_FIELDCAT TO GT_FIELDCAT.
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'KZWI1'.
LS_FIELDCAT-SELTEXT_L = '发票金额'.
* ls_fieldcat-do_sum = 'X'.
APPEND LS_FIELDCAT TO GT_FIELDCAT.
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'WAERK'.
LS_FIELDCAT-SELTEXT_L = '发票币种'.
* ls_fieldcat-do_sum = 'X'.
APPEND LS_FIELDCAT TO GT_FIELDCAT.
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'DMBTR'.
LS_FIELDCAT-SELTEXT_L = '收款金额'.
* ls_fieldcat-do_sum = 'X'.
APPEND LS_FIELDCAT TO GT_FIELDCAT.
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'PSWSL'.
LS_FIELDCAT-SELTEXT_L = '收款币种'.
* ls_fieldcat-do_sum = 'X'.
APPEND LS_FIELDCAT TO GT_FIELDCAT.
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'AUGDT'.
LS_FIELDCAT-SELTEXT_L = '日期'.
* ls_fieldcat-do_sum = 'X'.
APPEND LS_FIELDCAT TO GT_FIELDCAT.
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'TEXT_BZ'.
LS_FIELDCAT-SELTEXT_L = '备注'.
* ls_fieldcat-do_sum = 'X'.
APPEND LS_FIELDCAT TO GT_FIELDCAT.
CLEAR LS_FIELDCAT.
ENDFORM. |
|