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两个进程执行 ...
随机推荐
- 仿原生app,native特效
为解决手机端wap项目中页面跳转响应慢的问题,基于jquery开发了fr.routeApp.js,使得wap项目拥有原生app的流畅,跳转时亦有native的特效 html部分 <!--定义容器 ...
- 使用Nancy.Host实现脱离iis的Web应用
本篇将介绍如何使用Nancy.Host实现脱离iis的Web应用,在开源任务管理平台TaskManagerV2.0代码里面已经使用了Nancy.Host实现自宿主的Web应用.学习Nancy之前最好了 ...
- EF批量添加数据性能慢的问题的解决方案
//EF批量添加数据性能慢的问题的解决方案 public ActionResult BatchAdd() { using (var db = new ToneRoad.CEA.DbContext.Db ...
- Asp.Net MVC3 简单入门详解过滤器Filter(转)
前言 在开发大项目的时候总会有相关的AOP面向切面编程的组件,而MVC(特指:Asp.Net MVC,以下皆同)项目中不想让MVC开发人员去关心和写类似身份验证,日志,异常,行为截取等这部分重复的代码 ...
- javascript 中断函数的使用 setInterval();
<script type="text/javascript"> var i=1; var IR1 = setInterval("myMethod()" ...
- 常见排序java实现
public class Sort { public static void main(String[] args) { int[] data = {49,38,65,97,76,13,27,49}; ...
- 解决:dpkg:处理 xxx (--configure)或E: Sub-process /usr/bin/dpkg returned an error code (1)
问题重现: 问题解决办法: #先备份原来的,然后重新新建 sudo mv /var/lib/dpkg/info /var/lib/dpkg/info.bak //现将info文件夹更名 sudo mk ...
- Bzoj1208 [HNOI2004]宠物收养所
Time Limit: 10 Sec Memory Limit: 162 MBSubmit: 7457 Solved: 2960 Description 最近,阿Q开了一间宠物收养所.收养所提供两 ...
- Day2-python基础2
本次学习内容 1.for循环 2.continue and break 3.while循环 4.运算符 5.数据类型 数字 字符串 列表 1.for循环 猜年龄的游戏完善下,只有三次机会 for i ...
- jquery + header
官网上搜索headers 基本用法(直接用下楼上的代码了) $.ajax({ //请求类型,这里为POST type: 'POST', //你要请求的api的URL url: url , //是否使用 ...