ABAP 客户报表
*&---------------------------------------------------------------------*
*& Report ZSDR014
*&
*&---------------------------------------------------------------------*
*&程序名称:
*&事物代码:
*&导入模板:无
*&作者:
*&时间:
*&更新时间:
*&-------
REPORT zsdr014.
TABLES:kna1,knvv,knkk ,t001l.
DATA: gs_fcat TYPE lvc_s_fcat,
gt_fcat TYPE lvc_t_fcat,
gs_layo TYPE lvc_s_layo,
gs_grid TYPE lvc_s_glay.
DATA: gt_event TYPE slis_t_event WITH HEADER LINE,
gt_event_exit TYPE slis_t_event_exit WITH HEADER LINE.
DATA: ref_grid TYPE REF TO cl_gui_alv_grid .
DATA stbl TYPE lvc_s_stbl."ALV稳定刷新
TYPES: BEGIN OF ty_all,
kunnr LIKE kna1-kunnr, "客户代码
kunnr_name LIKE kna1-name1, "客户名称
bukrs LIKE knb1-bukrs, "公司
bukrs_name LIKE t001-butxt, "公司描述
knkli LIKE knkk-knkli, "信贷账户
ktokd LIKE kna1-ktokd, "客户账目组
ktokd_txt LIKE t077x-txt30, "客户账目组描述
akont LIKE knb1-akont, "统驭科目
akont_txt LIKE skat-txt50, "统驭科目描述
stras LIKE kna1-stras, "地址
tel_number LIKE adr2-tel_number, "电话
ort01 LIKE kna1-ort01, "城市
stceg LIKE kna1-stceg, "增值税号
vkorg LIKE knvv-vkorg, "销售组织
vkorg_txt LIKE tvkot-vtext, "销售组织描述
vtweg LIKE knvv-vtweg, "分销渠道
vtweg_txt LIKE tvtwt-vtext, "分销渠道描述
spart LIKE knvv-spart, "产品组
spart_txt LIKE tspat-vtext, "产品组描述
kukla LIKE kna1-kukla, "客户分类
kukla_txt LIKE tkukt-vtext, "客户分类描述
vkbur LIKE knvv-vkbur, "销售部门
vkbur_txt LIKE tvkbt-bezei, "销售部门描述
vkgrp LIKE knvv-vkgrp, "销售组
vkgrp_txt LIKE tvgrt-bezei, "销售组描述
konda LIKE knvv-konda, "价格组
konda_txt LIKE t188t-vtext, "价格组描述
kalks LIKE knvv-kalks, "定价过程
kalks_txt LIKE tvkdt-vtext, "定价过程描述
lprio LIKE knvv-lprio, "交货优先权
lprio_txt LIKE tprit-bezei, "交货优先权描述
lzone LIKE kna1-lzone, "运输区域
lzone_txt LIKE tzont-vtext, "运输区域描述
kdgrp LIKE knvv-kdgrp, "客户组
bzirk LIKE knvv-bzirk, "销售地区
bzirk_txt LIKE t171t-bztxt, "销售地区描述
vwerk LIKE knvv-vwerk, "交货工厂
vwerk_txt LIKE t001w-name1, "交货工厂描述
lgort LIKE kna1-lgort, "交货仓库
lgort_txt LIKE t001l-lgobe, "交换仓库描述
zbatch LIKE kna1-zbatch, "客户批次
erdat_knvv LIKE knvv-erdat, "客户系统创建日期
erdat_vbak LIKE vbak-erdat, "最后下单日期
vbeln LIKE vbak-vbeln, "最后下单号
oeikw LIKE s066-oeikw, "未清销售订单
olikw LIKE s067-olikw, "未清交货单
ofakw LIKE s067-ofakw, "未清开票
skfor LIKE knkk-skfor, "客户往来余额
klimk LIKE knkk-klimk, "客户信用额度
keyong LIKE s066-oeikw, "目前可用金额
beizhu(30) TYPE c,
END OF ty_all.
*TYPES:BEGIN OF ty_header,
*
* END OF ty_header.
**单据抬头结束
*
**单据明细开始
*TYPES:BEGIN OF ty_items,
*
* END OF ty_items.
**单据明细结束
DATA:wa_all TYPE ty_all,
gt_all TYPE ty_all OCCURS 0.
*定义传入到smartforms的变量开始
DATA:fm_name TYPE rs38l_fnam.
DATA:itemsname(32) TYPE c.
DATA:headername(32) TYPE c.
*定义传入到smartforms的变量结束
"控制smartforms参数声明开始
DATA :control_parameters TYPE ssfctrlop.
"控制smartforms参数声明结束
SELECT-OPTIONS:
p_kunnr FOR kna1-kunnr,
p_ktokd FOR kna1-ktokd,
p_vkorg FOR knvv-vkorg,
p_vtweg FOR knvv-vtweg,
p_bzirk FOR knvv-bzirk,
p_vkbur FOR knvv-vkbur,
p_vkgrp FOR knvv-vkgrp,
p_konda FOR knvv-konda,
p_lgort FOR t001l-lgort,
p_zbatch FOR kna1-zbatch.
INITIALIZATION.
START-OF-SELECTION.
PERFORM getdata.
PERFORM outdata.
FORM getdata.
TYPES: BEGIN OF ty_col ,"
knkli LIKE s066-knkli , "客户代码
oeikw LIKE s066-oeikw, "未清订单
END OF ty_col.
TYPES: BEGIN OF ty_col2 ,"
knkli LIKE s066-knkli , "客户代码
END OF ty_col2.
DATA : hs_col TYPE HASHED TABLE OF ty_col WITH UNIQUE KEY knkli WITH HEADER LINE .
DATA: hs_item TYPE STANDARD TABLE OF ty_col WITH HEADER LINE.
DATA : hs_col2 TYPE HASHED TABLE OF ty_col2 WITH UNIQUE KEY knkli WITH HEADER LINE .
DATA:BEGIN OF vbeln_erdat OCCURS 0 ,
vbeln TYPE vbak-vbeln,
erdat LIKE vbak-erdat,
END OF vbeln_erdat.
DATA: wa_vbeln_erdat LIKE LINE OF vbeln_erdat.
SELECT *
INTO CORRESPONDING FIELDS OF TABLE gt_all
FROM kna1 AS ka1
INNER JOIN knb1 AS kb
ON kb~kunnr = ka1~kunnr
INNER JOIN knkk AS kk
ON ka1~kunnr = kk~kunnr
INNER JOIN knvv AS kv
ON ka1~kunnr = kv~kunnr
INNER JOIN s066 AS s6
ON s6~knkli = ka1~kunnr
INNER JOIN s067 AS s7
ON ka1~kunnr = s7~knkli
INNER JOIN adr2 AS ad
ON ad~addrnumber = ka1~adrnr AND ad~r3_user = '3'
WHERE ka1~kunnr IN p_kunnr AND
ka1~ktokd IN p_ktokd AND
kv~vkorg IN p_vkorg AND
kv~vtweg IN p_vtweg AND
kv~bzirk IN p_bzirk AND
kv~vkbur IN p_vkbur AND
kv~vkgrp IN p_vkgrp AND
kv~konda IN p_konda AND
ka1
~lgort IN p_lgort AND
ka1
~zbatch IN p_zbatch.
.
CLEAR wa_all.
LOOP AT gt_all INTO wa_all.
hs_col2
-knkli = wa_all-knkli.
COLLECT hs_col2.
ENDLOOP.
SELECT * INTO CORRESPONDING FIELDS OF TABLE hs_item
FROM s066.
LOOP AT hs_item.
hs_col
-knkli = hs_item-knkli.
hs_col
-oeikw = hs_item-oeikw.
COLLECT hs_col.
ENDLOOP.
CLEAR wa_all.
LOOP AT gt_all INTO wa_all.
"检查用户销售区域与分销渠道的权限
AUTHORITY-CHECK OBJECT 'V_VBAK_VKO'
ID 'VKORG' FIELD wa_all-vkorg
ID 'VTWEG' FIELD wa_all-vtweg
ID 'SPART' DUMMY
ID 'ACTVT' DUMMY."FIELD '03'.
IF sy-subrc NE 0.
"MESSAGE i001(00) WITH '没有销售组织' && wa_all-vkorg && '和分销渠道' && wa_all-vtweg && '的权限'.
DELETE TABLE gt_all FROM wa_all.
CONTINUE.
ENDIF.
SELECT SINGLE erdat INTO wa_all-erdat_knvv
FROM knvv
WHERE kunnr EQ wa_all-kunnr AND vkorg EQ wa_all-vkorg
AND vtweg EQ wa_all-vtweg AND spart EQ wa_all-spart.
SELECT SINGLE name1 INTO wa_all-kunnr_name
FROM kna1
WHERE kunnr EQ wa_all-kunnr.
SELECT SINGLE butxt INTO wa_all-bukrs_name
FROM t001
WHERE bukrs EQ wa_all-bukrs.
SELECT SINGLE txt50 INTO wa_all-akont_txt
FROM skat
WHERE saknr EQ wa_all-akont.
SELECT SINGLE txt30 INTO wa_all-ktokd_txt
FROM t077x
WHERE ktokd EQ wa_all-ktokd.
SELECT SINGLE bztxt INTO wa_all-bzirk_txt
FROM t171t
WHERE bzirk EQ wa_all-bzirk.
SELECT SINGLE bezei INTO wa_all-vkbur_txt
FROM tvkbt
WHERE vkbur EQ wa_all-vkbur.
SELECT SINGLE bezei INTO wa_all-vkgrp_txt
FROM tvgrt
WHERE vkgrp EQ wa_all-vkgrp.
SELECT SINGLE vtext INTO wa_all-vkorg_txt
FROM tvkot
WHERE vkorg EQ wa_all-vkorg.
SELECT SINGLE vtext INTO wa_all-vtweg_txt
FROM tvtwt
WHERE vtweg EQ wa_all-vtweg.
SELECT SINGLE vtext INTO wa_all-spart_txt
FROM tspat
WHERE spart EQ wa_all-spart.
SELECT SINGLE vtext INTO wa_all-kukla_txt
FROM tkukt
WHERE kukla EQ wa_all-kukla.
SELECT SINGLE vtext INTO wa_all-konda_txt
FROM t188t
WHERE konda EQ wa_all-konda.
SELECT SINGLE vtext INTO wa_all-kalks_txt
FROM tvkdt
WHERE kalks EQ wa_all-kalks.
SELECT SINGLE bezei INTO wa_all-lprio_txt
FROM tprit
WHERE lprio EQ wa_all-lprio.
SELECT SINGLE vtext INTO wa_all-lzone_txt
FROM tzont
WHERE zone1 EQ wa_all-lzone.
SELECT SINGLE name1 INTO wa_all-vwerk_txt
FROM t001w
WHERE werks EQ wa_all-vwerk.
SELECT SINGLE lgobe INTO wa_all-lgort_txt
FROM t001l
WHERE werks EQ wa_all-vwerk AND lgort EQ wa_all-lgort.
SELECT vbeln erdat INTO CORRESPONDING FIELDS OF TABLE vbeln_erdat
FROM vbak
WHERE kunnr EQ wa_all-kunnr .
SORT vbeln_erdat DESCENDING BY erdat.
READ TABLE vbeln_erdat INTO wa_vbeln_erdat INDEX 1.
wa_all
-vbeln = wa_vbeln_erdat-vbeln.
wa_all
-erdat_vbak = wa_vbeln_erdat-erdat.
CLEAR wa_vbeln_erdat.
CLEAR vbeln_erdat[].
READ TABLE hs_col WITH KEY knkli = wa_all-kunnr.
wa_all
-oeikw = hs_col-oeikw.
wa_all
-keyong = wa_all-klimk - wa_all-skfor - wa_all-oeikw
- wa_all-ofakw - wa_all-olikw.
MODIFY gt_all FROM wa_all.
ENDLOOP.
ENDFORM. " GETDATA
*&---------------------------------------------------------------------*
*& Form FIXDATA
*&---------------------------------------------------------------------*
FORM frm_catlg_set USING p_field p_text p_key p_edit p_no_out
p_f4availabl p_ref_table p_ref_field p_no_zero
.
gs_fcat
-fieldname = p_field.
gs_fcat
-reptext = p_text.
gs_fcat
-key = p_key.
gs_fcat
-edit = p_edit.
gs_fcat
-no_out = p_no_out.
gs_fcat
-ref_field = p_ref_field.
gs_fcat
-ref_table = p_ref_table.
gs_fcat
-f4availabl = p_f4availabl.
gs_fcat
-no_zero = p_no_zero.
APPEND gs_fcat TO gt_fcat .
CLEAR gs_fcat .
ENDFORM. "frm_catlg_set
FORM fieldcat_init .
DATA: c(2) TYPE n,txt(20) TYPE c .
PERFORM frm_catlg_set USING:
'kunnr' '客户代码' 'X' '' '' '' '' '' 'X',
'kunnr_name' '客户名称' 'X' '' '' '' '' '' '',
'bukrs' '公司' 'X' '' '' '' '' '' '',
'bukrs_name' '公司描述' 'X' '' '' '' '' '' '',
'knkli' '信贷账户' '' '' '' '' '' '' 'X',
'ktokd' '客户账目组' '' '' '' '' '' '' '',
'ktokd_txt' '客户账目组描述' '' '' '' '' '' '' '',
'akont' '统驭科目' '' '' '' '' '' '' '',
'akont_txt' '统驭科目描述' '' '' '' '' '' '' '',
'stras' '地址' '' '' '' '' '' '' '',
'tel_number' '电话' '' '' '' '' '' '' '',
'ort01' '城市' '' '' '' '' '' '' '',
'stceg' '增值税号' '' '' '' '' '' '' '',
'vkorg' '销售组织' '' '' '' '' '' '' '',
'vkorg_txt' '销售组织描述' '' '' '' '' '' '' '',
'vtweg' '分销渠道' '' '' '' '' '' '' '',
'vtweg_txt' '分销渠道描述' '' '' '' '' '' '' '',
'spart' '产品组' '' '' '' '' '' '' '',
'spart_txt' '产品组描述' '' '' '' '' '' '' '',
'kukla' '客户分类' '' '' '' '' '' '' '',
'kukla_txt' '客户分类描述' '' '' '' '' '' '' '',
'vkbur' '销售部门' '' '' '' '' '' '' '',
'vkbur_txt' '销售部门描述' '' '' '' '' '' '' '',
'vkgrp' '销售组' '' '' '' '' '' '' '',
'vkgrp_txt' '销售组描述' '' '' '' '' '' '' '',
'konda' '价格组' '' '' '' '' '' '' '',
'konda_txt' '价格组描述' '' '' '' '' '' '' '',
'kalks' '定价过程' '' '' '' '' '' '' '',
'kalks_txt' '定价过程描述' '' '' '' '' '' '' '',
'lprio' '交货优先权' '' '' '' '' '' '' '',
'lprio_txt' '交货优先权描述' '' '' '' '' '' '' '',
'lzone' '运输区域' '' '' '' '' '' '' '',
'lzone_txt' '运输区域描述' '' '' '' '' '' '' '',
'kdgrp' '客户组' '' '' '' '' '' '' '',
'bzirk' '销售地区' '' '' '' '' '' '' '',
'bzirk_txt' '销售地区描述' '' '' '' '' '' '' '',
'vwerk' '交货工厂' '' '' '' '' '' '' '',
'vwerk_txt' '交货工厂描述' '' '' '' '' '' '' '',
'lgort' '交货仓库' '' '' '' '' '' '' '',
'lgort_txt' '交换仓库描述' '' '' '' '' '' '' '',
'zbatch' '客户批次' '' '' '' '' '' '' '',
'erdat_knvv' '客户系统创建日期' '' '' '' '' '' '' '',
'erdat_vbak' '最后下单日期' '' '' '' '' '' '' '',
'vbeln' '最后下单号' '' '' '' '' '' '' 'X',
'oeikw' '未清销售订单' '' '' '' '' '' '' '',
'olikw' '未清交货单' '' '' '' '' '' '' '',
'ofakw' '未清开票' '' '' '' '' '' '' '',
'skfor' '客户往来余额' '' '' '' '' '' '' '',
'klimk' '客户信用额度' '' '' '' '' '' '' '',
'keyong' '客户信用额度' '' '' '' '' '' '' ''.
gs_layo
-zebra = 'X'.
gs_layo
-cwidth_opt = 'X'.
* gs_layo-grid_title = 'dongdong'.
* gs_layo-smalltitle = 'X'.
ENDFORM. "fieldcat_init
FORM outdata .
PERFORM fieldcat_init .
PERFORM show_alv TABLES gt_fcat gt_all[]
USING gs_layo.
ENDFORM. " outdata
FORM show_alv TABLES pt_fcat pt_tab USING ps_layout.
gs_grid
-edt_cll_cb = 'X'."当屏幕失去焦点时,自动刷新
gt_event
-name = 'CALLER_EXIT'. "slis_ev_caller_exit_at_start事件
gt_event
-form = 'FM_BUTTON'.
APPEND gt_event .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
EXPORTING
i_callback_program
= sy-repid
i_callback_user_command
= 'USER_COMMAND'
i_grid_settings
= gs_grid
i_callback_pf_status_set
= 'SET_PF_STATUS'
is_layout_lvc
= ps_layout
it_fieldcat_lvc
= pt_fcat[]
it_events
= gt_event[]
i_save
= 'X'
* it_event_exit = gt_event_exit[]
TABLES
t_outtab
= pt_tab
EXCEPTIONS
program_error
= 1
OTHERS = 2.
"PERFORM frm_fresh_alv.
ENDFORM. "csalv_set_fcat
FORM user_command USING r_ucomm LIKE sy-ucomm rs_selfield TYPE slis_selfield.
CASE r_ucomm.
WHEN '&DATA_SAVE'.
WHEN '&XSL' OR '&EXPORT' .
WHEN '&BACK' OR '&UP' OR '&EXIT'.
LEAVE TO SCREEN 0.
ENDCASE.
ENDFORM. "user_command
*&---------------------------------------------------------------------*
*& Form SET_PF_STATUS
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->RT_EXTAB text
*----------------------------------------------------------------------*
FORM set_pf_status USING rt_extab TYPE slis_t_extab..
SET PF-STATUS 'STANDARD'.
ENDFORM. "SET_PF_STATUS
*&---------------------------------------------------------------------*
*& Form fm_button
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->E_GRID text
*----------------------------------------------------------------------*
FORM fm_button USING e_grid TYPE slis_data_caller_exit.
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
* EXPORTING
* IR_SALV_FULLSCREEN_ADAPTER =
IMPORTING
* ET_EXCLUDING =
* E_REPID =
* E_CALLBACK_PROGRAM =
* E_CALLBACK_ROUTINE =
e_grid
= ref_grid
* ET_FIELDCAT_LVC =
* ER_TRACE =
* E_FLG_NO_HTML =
* ES_LAYOUT_KKBLO =
* ES_SEL_HIDE =
* ET_EVENT_EXIT =
* ER_FORM_TOL =
* ER_FORM_EOL =
.
* CALL METHOD ref_grid->check_changed_data.
* 设置enter事件
CALL METHOD ref_grid->register_edit_event
EXPORTING
i_event_id
= cl_gui_alv_grid=>mc_evt_enter
EXCEPTIONS
error
= 1
OTHERS = 2.
"CREATE OBJECT gt_event_receiver.
"SET HANDLER gt_event_receiver->handle_modify FOR ref_grid.
ENDFORM. "FM_BUTTON
FORM frm_fresh_alv.
stbl
-row = 'X'." 基于行的稳定刷新
stbl
-col = 'X'." 基于列稳定刷新
CALL METHOD ref_grid->refresh_table_display
EXPORTING
is_stable
= stbl.
ENDFORM.
ABAP 客户报表的更多相关文章
- ABAP:SAP报表性能的优化
大部分ABAPer都是从SAP报表及打印开始学起的,大家也都认为写个SAP报表程序是最简单不过的事了. 但是实际情况真的如此吗?写报表时除了保证数据的准确性,您可曾考虑过报表的性能问题吗? 由于报表程 ...
- ABAP QUERY报表添加双击事件
问题:一个query报表程序,客户想要每一条能编辑并打印. 解决:直接给query添加双击事件,调用新report. 1.创建report,用paramater定义要从query结果中传过来的数据. ...
- ALV报表——发送Excel报表邮件
ABAP发送报表邮件 运行效果: 代码: *&---------------------------------------------------------------------* *& ...
- SAP 经常使用T-CODE
Plant Maintenance (PM) IW32 - Change Plant Maintenance Order IW33 - Display Plant Maintenance Order ...
- PDF2
itex生成PDF文档示例 package dao.other; import java.awt.Color; import java.io.File; import java.io.FileInpu ...
- Account Team使用说明
Account Team Account Team 以下简称客户小组. 背景介绍 帐户是与您的业务相关的公司和组织,每个帐户都存储了商家名称.地址和电话号码等信息.可以针对每个帐户存储相关的联系人. ...
- 华为V-ISA信誉安全体系:对付新型DDoS攻击的利器
华为Anti-DDoS解决方案基于华为颇具传统优势的专业软硬件平台开发,在防护机制中,引入先进的检测机制,提供了业内首创的“V-ISA”信誉安全体系,是业界唯一单机可提供超百G DDoS防御能 ...
- Google揭开Mesa的神秘面纱——一个具备跨地域复制和近实时特性的可伸缩数据仓库
http://www.infoq.com/cn/news/2014/08/google-data-warehouse-mesa Google发表了一篇新的论文,该论文描述了他们内部所使用的一个被称为M ...
- ABAP-关于COMMIT WORK 和COMMIT WORK AND WAIT
转载:https://blog.csdn.net/champaignwolf/article/details/6925019 首先说明一点:更新是异步的,更新是由SAP中UPD1和UPD2两个进程执行 ...
随机推荐
- 链接rel属性external、nofollow、external nofollow三种写法的区别
<script language="javascript" type="text/javascript" src="http://files.c ...
- iframe异步加载技术及性能
我们会经常使用iframes来加载第三方的内容.广告或者插件.使用iframe是因为它可以和主页面并行加载,不会阻塞主页面.当然使用iframe也是有利有弊的:Steve Souders在他的blog ...
- js/jquery的应用
1.JS限制文本框只能输入整数或小数 <script language="JavaScript" type="text/javascript"> f ...
- php面向对象编程(二)
现在我们来了解一下面向对象的一个封装性的问题 封装性:在我的理解里面 可以理解为一个u盘 我们使用u盘的接口与电脑进行数据之间的交互 但是我们不能看到里面的结构 这个特性我们可以称为封装性 好处:利用 ...
- Leetcode 94. Binary Tree Inorder Traversal
Given a binary tree, return the inorder traversal of its nodes' values. For example:Given binary tre ...
- signalr服务端-基础搭建
signalr 支持 iis托管.winform.windowsservices.wpf 托管 这里我采用winfrom托管 首先画一个这样的窗体 在服务项目通过项目管理包安装signalr类库 安装 ...
- gRPC+etcd的优势分析
相比webService等可跨平台,跨语言的服务相比,gRPC更增加了以下优势 1.可以采用二进制传输,速度更快 (使用TCP传输层,而不是Http2应用层) 2.集群服务,统一注册,可靠性高( 好的 ...
- js获取url信息
设置或获取对象指定的文件名或路径. alert(window.location.pathname) 设置或获取整个 URL 为字符串. alert(window.location.href); 设置或 ...
- [NHibernate]O/R Mapping基础
系列文章 [Nhibernate]体系结构 [NHibernate]ISessionFactory配置 [NHibernate]持久化类(Persistent Classes) 引言 对象和关系数据库 ...
- [NHibernate]一对多关系(关联查询)
目录 写在前面 文档与系列文章 一对多查询 总结 写在前面 上篇文章介绍了nhibernate的一对多关系如何配置,以及级联删除,级联添加数据的内容.这篇文章我们将学习nhibernate中的一对多关 ...