ZPPR032-批量展BOM
*-----------------------------------------------------------------------
REPORT zppr032 NO STANDARD PAGE HEADING
MESSAGE-ID ymm
LINE-COUNT 81
LINE-SIZE 650. "207
************************************************************************
*INCLUDE
************************************************************************
INCLUDE <line>.
************************************************************************
*DDIC
************************************************************************
TABLES:mara,marc,bkpf,mard,mast.
************************************************************************
*ALV层级关系定义
************************************************************************
TYPE-POOLS: slis.
DATA: wt_fieldcat TYPE slis_t_fieldcat_alv,
wt_layout TYPE slis_layout_alv,
wt_events TYPE slis_t_event.
DATA: ws_events LIKE LINE OF wt_events.
************************************************************************
*DATA
************************************************************************
DATA: BEGIN OF wt_itab OCCURS 0,
matnr LIKE mast-matnr,
ustufe(11) TYPE c,
stufe LIKE stpox-stufe, " 层次
posnr LIKE stpox-posnr, "项目号
idnrk LIKE stpox-idnrk, "子件物料编码
ojtxp LIKE stpox-ojtxp, "子件物料描述
mtart LIKE stpox-mtart,"物料类别
dumps LIKE stpox-dumps,"虚拟项目标识
* MNGKO LIKE STPOX-MNGKO,"组件数量
menge LIKE stpox-menge,"组件数量,
mngko LIKE stpox-mngko, "以组件计量单位为准的已计算的组件数量 ,MNGLG
* mngko TYPE p DECIMALS 6,
mmein LIKE stpox-mmein, "单位
potx2 LIKE stpox-potx2,"行2
potx1 LIKE stpox-potx1,"客户物料编码
blatt LIKE stpox-blatt,"SAF
datuv LIKE stpox-datuv,
datub LIKE stpox-datub,
ebort(500) TYPE c,
werks LIKE stpox-werks,
stlnr LIKE stpox-stlnr,
stlkn LIKE stpox-stlkn,
spart LIKE mara-spart.
DATA: END OF wt_itab.
DATA test TYPE c.
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
* PARAMETERS: p_matnr LIKE mast-matnr OBLIGATORY. "物料号
SELECT-OPTIONS: p_matnr FOR mast-matnr.
SELECT-OPTIONS: p_werks FOR mast-werks."工厂
PARAMETERS: p_stlal LIKE stko-stlal DEFAULT '01'.
PARAMETERS: p_capid LIKE tc04-capid DEFAULT 'PP01'.
*call selection-screen 100.
SELECTION-SCREEN END OF BLOCK b1.
*selection-screen end of screen 100.
*SELECTION-SCREEN BEGIN OF screen 100.
SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-002.
PARAMETERS: p_datuv LIKE rc29l-datuv DEFAULT sy-datum OBLIGATORY.
PARAMETERS: p_aennr LIKE stpo-aennr. "AENR
PARAMETERS: p_revlv LIKE rc29l-revlv.
PARAMETERS: p_bmeng LIKE stko-bmeng DEFAULT 1."需求数量 "STKO BOM表头
PARAMETERS: p_stlan LIKE mast-stlan DEFAULT '1'NO-DISPLAY."BOM 用途
SELECTION-SCREEN END OF BLOCK b2.
*AT SELECTION-SCREEN OUTPUT.
* LOOP AT SCREEN.
* if not P_aennr is initial.
* message 'no data'type 'I'.
* endif.
*
* ENDLOOP.
INITIALIZATION.
START-OF-SELECTION.
*得到物料的子项目
PERFORM get_data.
*打印该BOM的数据
PERFORM print_alv_data.
END-OF-SELECTION.
*&---------------------------------------------------------------------*
*& Form get_data
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM get_data .
*数据定义
DATA: BEGIN OF wtl_matnr OCCURS 0,
werks LIKE marc-werks,
matnr LIKE mara-matnr.
* BMENG LIKE stko-bmeng."需求数量
DATA: END OF wtl_matnr.
DATA: wtl_stb LIKE stpox OCCURS 50 WITH HEADER LINE.
DATA: wa_tab1 LIKE wt_itab OCCURS 50 WITH HEADER LINE.
DATA: BEGIN OF matcat OCCURS 50.
INCLUDE STRUCTURE cscmat.
DATA: END OF matcat.
DATA: BEGIN OF mats.
INCLUDE STRUCTURE cscmat.
DATA: END OF mats.
*展开BOM的字阶
SELECT mast~werks mast~matnr
APPENDING CORRESPONDING FIELDS OF TABLE wtl_matnr
FROM mast
WHERE matnr IN p_matnr
AND werks IN p_werks
AND stlal EQ p_stlal .
*根据选项产生不同BOM的结构
*展多层BOM
* IF P_MULT EQ 'X'.
LOOP AT wtl_matnr.
REFRESH wtl_stb.
CLEAR wtl_stb.
CALL FUNCTION 'CS_BOM_EXPL_MAT_V2'
EXPORTING
capid = 'PP01' "BOM Application
datuv = p_datuv "SY-DATUM
emeng = p_bmeng "BASE QUANTITY
* emeng = wtl_matnr-BMENG "BASE QUANTITY
* AENNR = P_AENNR
* REVLV = P_REVLV
mtnrv = wtl_matnr-matnr "MATERAIL NUMBER
stlan = p_stlan
stlal = p_stlal "可选BOM
mktls = 'X'
mehrs = 'X'
werks = wtl_matnr-werks "'PDGM'
* STLAL = P_STLAL
* CUOBJ = CUOBJ
TABLES
stb = wtl_stb
matcat = matcat
EXCEPTIONS
alt_not_found = 1
call_invalid = 2
material_not_found = 3
missing_authorization = 4
no_bom_found = 5
no_plant_data = 6
no_suitable_bom_found = 7
OTHERS = 8.
IF sy-subrc EQ 0.
LOOP AT wtl_stb.
wt_itab-matnr = wtl_matnr-matnr.
* WT_ITAB-OJTXP = WTL_STB-OJTXP.
* WT_ITAB-IDNRK = WTL_STB-IDNRK.
* WT_ITAB-MEINS = WTL_STB-MEINS.
* WT_ITAB-MNGLG = WTL_STB-MNGLG.
wt_itab-stufe = wtl_stb-stufe. " 层次
wt_itab-posnr = wtl_stb-posnr. "项目号
wt_itab-idnrk = wtl_stb-idnrk. "子件物料编码
wt_itab-ojtxp = wtl_stb-ojtxp. "子件物料描述
wt_itab-mtart = wtl_stb-mtart."物料类别
wt_itab-dumps = wtl_stb-dumps."虚拟项目标识
wt_itab-menge = wtl_stb-menge."组件数量,以基本计量单位为准的已计算的组件数量
wt_itab-mngko = wtl_stb-mngko. "以组件计量单位为准的已计算的组件数量
* WT_ITAB-MNGKO = WTL_STB-MNGKO / wtl_matnr-BMENG ."MNGLG wtl_matnr
wt_itab-mmein = wtl_stb-mmein. ""基本计量单位
wt_itab-potx2 = wtl_stb-potx2."行2
wt_itab-potx1 = wtl_stb-potx1."客户物料编码
wt_itab-blatt = wtl_stb-blatt."SAF
* LOC(40) TYPE C,
wt_itab-datuv = wtl_stb-datuv.
wt_itab-datub = wtl_stb-datub.
wt_itab-werks = wtl_stb-werks.
wt_itab-stlnr = wtl_stb-stlnr.
wt_itab-stlkn = wtl_stb-stlkn.
*查找物料的库存
IF wt_itab-werks ='3120' OR wt_itab-werks = '3130'.
SELECT SINGLE spart FROM mara
INTO wt_itab-spart
WHERE mara~matnr = wt_itab-idnrk.
ENDIF.
PERFORM get_othdata USING wt_itab-stlnr wt_itab-stlkn
CHANGING wt_itab-ebort wt_itab-mngko.
PERFORM format_stufe USING wt_itab-stufe
CHANGING wt_itab-ustufe .
APPEND wt_itab.
CLEAR wt_itab.
ENDLOOP.
ENDIF.
ENDLOOP.
ENDFORM. " GET_DATA
*&---------------------------------------------------------------------*
*& Form print_alv_data
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM print_alv_data .
DATA: wlt_fieldcat LIKE LINE OF wt_fieldcat.
* PERFORM FILL_EVENTCAT_ALV.
CLEAR wlt_fieldcat.
wlt_fieldcat-fieldname = 'MATNR'.
wlt_fieldcat-tabname = 'WT_ITAB'.
wlt_fieldcat-no_out = ' '.
wlt_fieldcat-seltext_l = 'MODEL'.
wlt_fieldcat-no_zero = 'X'.
wlt_fieldcat-intlen = '18'.
APPEND wlt_fieldcat TO wt_fieldcat.
CLEAR wlt_fieldcat.
wlt_fieldcat-fieldname = 'USTUFE'.
wlt_fieldcat-tabname = 'WT_ITAB'.
wlt_fieldcat-no_out = ' '.
wlt_fieldcat-seltext_l = '展阶层'.
APPEND wlt_fieldcat TO wt_fieldcat.
CLEAR wlt_fieldcat.
wlt_fieldcat-fieldname = 'POSNR'.
wlt_fieldcat-tabname = 'WT_ITAB'.
wlt_fieldcat-no_out = ' '.
wlt_fieldcat-seltext_l = '项目'.
APPEND wlt_fieldcat TO wt_fieldcat.
CLEAR wlt_fieldcat.
wlt_fieldcat-fieldname = 'IDNRK'.
wlt_fieldcat-tabname = 'WT_ITAB'.
wlt_fieldcat-no_out = ' '.
wlt_fieldcat-seltext_l = '物料编码'.
wlt_fieldcat-intlen = '18'.
wlt_fieldcat-no_zero = 'X'.
APPEND wlt_fieldcat TO wt_fieldcat.
CLEAR wlt_fieldcat.
wlt_fieldcat-fieldname = 'OJTXP'.
wlt_fieldcat-tabname = 'WT_ITAB'.
wlt_fieldcat-no_out = ' '.
wlt_fieldcat-seltext_l = '描述'.
APPEND wlt_fieldcat TO wt_fieldcat.
CLEAR wlt_fieldcat.
wlt_fieldcat-fieldname = 'MTART'.
wlt_fieldcat-tabname = 'WT_ITAB'.
wlt_fieldcat-no_out = ' '.
wlt_fieldcat-seltext_l = 'MTyp'.
APPEND wlt_fieldcat TO wt_fieldcat.
CLEAR wlt_fieldcat.
wlt_fieldcat-fieldname = 'DUMPS'.
wlt_fieldcat-tabname = 'WT_ITAB'.
wlt_fieldcat-no_out = ' '.
wlt_fieldcat-seltext_l = '虚拟项目'.
APPEND wlt_fieldcat TO wt_fieldcat.
CLEAR wlt_fieldcat.
wlt_fieldcat-fieldname = 'MENGE'.
wlt_fieldcat-tabname = 'WT_ITAB'.
wlt_fieldcat-no_out = ' '.
wlt_fieldcat-seltext_l = '组件数量'.
APPEND wlt_fieldcat TO wt_fieldcat.
CLEAR wlt_fieldcat.
wlt_fieldcat-fieldname = 'MNGKO'.
wlt_fieldcat-tabname = 'WT_ITAB'.
wlt_fieldcat-no_out = ' '.
wlt_fieldcat-seltext_l = '组件数量(CUn)'.
wlt_fieldcat-decimals_out = 3.
APPEND wlt_fieldcat TO wt_fieldcat.
CLEAR wlt_fieldcat.
wlt_fieldcat-fieldname = 'MMEIN'.
wlt_fieldcat-tabname = 'WT_ITAB'.
wlt_fieldcat-ddictxt = 'L'.
wlt_fieldcat-no_out = ' '.
wlt_fieldcat-seltext_l = '单位'.
APPEND wlt_fieldcat TO wt_fieldcat.
CLEAR wlt_fieldcat.
wlt_fieldcat-fieldname = 'POTX2'.
wlt_fieldcat-tabname = 'WT_ITAB'.
wlt_fieldcat-no_out = ' '.
wlt_fieldcat-seltext_l = '行2'.
APPEND wlt_fieldcat TO wt_fieldcat.
CLEAR wlt_fieldcat.
wlt_fieldcat-fieldname = 'POTX1'.
wlt_fieldcat-tabname = 'WT_ITAB'.
wlt_fieldcat-no_out = ' '.
wlt_fieldcat-seltext_l = '客户物料编码'.
APPEND wlt_fieldcat TO wt_fieldcat.
CLEAR wlt_fieldcat.
wlt_fieldcat-fieldname = 'BLATT'.
wlt_fieldcat-tabname = 'WT_ITAB'.
wlt_fieldcat-no_out = ' '.
wlt_fieldcat-seltext_l = 'SAF'.
APPEND wlt_fieldcat TO wt_fieldcat.
CLEAR wlt_fieldcat.
wlt_fieldcat-fieldname = 'EBORT'.
wlt_fieldcat-tabname = 'WT_ITAB'.
wlt_fieldcat-no_out = ' '.
wlt_fieldcat-seltext_l = '安装位置'.
APPEND wlt_fieldcat TO wt_fieldcat.
CLEAR wlt_fieldcat.
wlt_fieldcat-fieldname = 'WERKS'.
wlt_fieldcat-tabname = 'WT_ITAB'.
wlt_fieldcat-no_out = ' '.
wlt_fieldcat-seltext_l = '工厂'.
APPEND wlt_fieldcat TO wt_fieldcat.
CLEAR wlt_fieldcat.
wlt_fieldcat-fieldname = 'SPART'.
wlt_fieldcat-tabname = 'WT_ITAB'.
wlt_fieldcat-no_out = ' '.
wlt_fieldcat-seltext_l = '产品组'.
APPEND wlt_fieldcat TO wt_fieldcat.
CLEAR wlt_fieldcat.
wlt_fieldcat-fieldname = 'DATUV'.
wlt_fieldcat-tabname = 'WT_ITAB'.
wlt_fieldcat-no_out = ' '.
wlt_fieldcat-seltext_l = '有效起始日'.
APPEND wlt_fieldcat TO wt_fieldcat.
CLEAR wlt_fieldcat.
wlt_fieldcat-fieldname = 'DATUB'.
wlt_fieldcat-tabname = 'WT_ITAB'.
wlt_fieldcat-no_out = ' '.
wlt_fieldcat-seltext_l = '有效截止日'.
APPEND wlt_fieldcat TO wt_fieldcat.
wt_layout-zebra = 'X'.
wt_layout-f2code = '&ETA'.
wt_layout-colwidth_optimize = 'X'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-cprog
is_layout = wt_layout
i_callback_html_top_of_page = 'ALV_TOP_OF_PAGE'
* I_callback_pf_status_set = 'STANDARD1'
i_default = 'X'
i_save = 'X'
* I_CALLBACK_USER_COMMAND = 'PROCESS_USER_COMMAND'
it_fieldcat = wt_fieldcat[]
it_events = wt_events
TABLES
t_outtab = wt_itab.
ENDFORM. " PRINT_ALV_DATA
*&---------------------------------------------------------------------*
*& Form alv_top_of_page
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->CL_DD text
*----------------------------------------------------------------------*
FORM alv_top_of_page USING cl_dd TYPE REF TO cl_dd_document.
* SET PF-STATUS 'STANDARD1'.
DATA: m_p TYPE i.
DATA: m_buff TYPE string.
*表头其实完全可以是一个html文件,自己使用html语言进行格式控制
m_buff = '<html>'.
CALL METHOD cl_dd->html_insert
EXPORTING
contents = m_buff
CHANGING
position = m_p.
m_buff = '<center><font size="5">****Teamwise Electronic Co. Ltd.**** </font></center>'.
CALL METHOD cl_dd->html_insert
EXPORTING
contents = m_buff
CHANGING
position = m_p.
CONCATENATE '<center> Indentied Bill of Material' '<BR></center>' INTO m_buff .
CALL METHOD cl_dd->html_insert
EXPORTING
contents = m_buff
CHANGING
position = m_p.
CONCATENATE '报表日期 :' sy-datum '<BR>' INTO m_buff.
CALL METHOD cl_dd->html_insert
EXPORTING
contents = m_buff
CHANGING
position = m_p.
DATA: wtl_name1 LIKE t001w-name1.
CLEAR wtl_name1.
SELECT SINGLE name1
INTO wtl_name1
FROM t001w
WHERE werks IN p_werks.
CONCATENATE '工 厂:' p_werks wtl_name1 '<BR>' INTO m_buff.
CALL METHOD cl_dd->html_insert
EXPORTING
contents = m_buff
CHANGING
position = m_p.
CONCATENATE 'MODEL:' p_matnr-low '~' p_matnr-high '<BR>' INTO m_buff.
CALL METHOD cl_dd->html_insert
EXPORTING
contents = m_buff
CHANGING
position = m_p.
m_buff = '</html>'.
CALL METHOD cl_dd->html_insert
EXPORTING
contents = m_buff
CHANGING
position = m_p.
ENDFORM. "ALV_TOP_OF_PAGE
FORM get_othdata USING p_wt_itab_stlnr p_wt_itab_stlkn
CHANGING p_wt_itab-ebort p_wt_itab-mngko.
DATA: ls TYPE i.
CLEAR ls.
DATA: BEGIN OF wtl_itab OCCURS 0,
* MAKTX LIKE MAKT-MAKTX,
ebort(500) TYPE c,
END OF wtl_itab.
DATA: BEGIN OF wtp_itab OCCURS 0,
menge TYPE P decimals 6,
bmeng TYPE P decimals 6,
END OF wtp_itab.
SELECT ebort
INTO CORRESPONDING FIELDS OF TABLE wtl_itab
FROM stpu
WHERE stlnr = p_wt_itab_stlnr and stlkn = p_wt_itab_stlkn and ebort <> '' .
IF sy-subrc = 0.
LOOP AT wtl_itab.
CONCATENATE p_wt_itab-ebort wtl_itab-ebort ',' INTO p_wt_itab-ebort.
ENDLOOP.
ls = strlen( p_wt_itab-ebort ).
if ls > 1.
ls = ls - 1.
p_wt_itab-ebort = p_wt_itab-ebort+0(ls).
else.
p_wt_itab-ebort = ''.
endif.
ENDIF.
* select BMENG menge into corresponding fields of table wtp_itab
* from STKO inner join STPO on STKO~STLNR = STPO~STLNR
* where STPO~STLNR = p_wt_itab_stlnr AND STPO~stlkn = p_wt_itab_stlkn.
* loop at wtp_itab.
* p_wt_itab-mngko = wtp_itab-menge / wtp_itab-bmeng.
* endloop.
ENDFORM. " GET_KCDATA
FORM format_stufe USING p_wt_itab-stufe
CHANGING p_wt_itab-ustufe.
* DATA LS(11) TYPE C.
p_wt_itab-ustufe = p_wt_itab-stufe.
TRANSLATE p_wt_itab-ustufe USING ' .'.
p_wt_itab-ustufe+10(1) = ' '.
IF p_wt_itab-stufe < 9.
p_wt_itab-stufe = 9 - p_wt_itab-stufe.
SHIFT p_wt_itab-ustufe BY p_wt_itab-stufe PLACES.
ENDIF.
ENDFORM. "stufe_aufbereiten
ZPPR032-批量展BOM的更多相关文章
- 批量清除BOM头
批量清除BOM头 (2012-03-05 13:28:30) 转载▼ 标签: 杂谈 有些php文件由于不小心保存成了含bom头的格式而导致出现一系列的问题.以下是批量清除bom头的代码,复制代码, ...
- php 批量检测bom头,去除bom头工具
<?php //有些php文件由于不小心保存成了含bom头的格式而导致出现一系列的问题.以下是批量清除bom头的代码 if (isset ( $_GET ['dir'] )) { //confi ...
- 展BOM
CS_BOM_EXPL_MAT_V2 *&---------------------------------------------------------------------* *&am ...
- 批量去BOM头 遍历目录及子文件,文件夹 PHP源码
任意php文件,把最后一行替换成自己的目录 即可 <?php class KillBom { public static $m_Ext = ['txt', 'php', 'js', 'c ...
- PHP批量去除bom头代码的小工具
在 aitecms 群里有网友抱怨了好几天说本地的验证码一直无法显示,后来听说解决了,问其如何解决的,说是去除了文件 bom 就好了.后来百度到一篇文章也说 dedecms 的验证码不能显示,某次解决 ...
- Node.js批量去除BOM文件
之前的同事写了一个工具,但有bug,就是在替换文件后原文件的格式变成utf8 BOM了,这种带BOM的XML在Mac下可能读取不出来,所以就需要写个工具处理一下- 其实思路比较简单,首先遍历目录, ...
- php批量检测和去掉bom头(转)
<?php //有些php文件由于不小心保存成了含bom头的格式而导致出现一系列的问题.以下是批量清除bom头的代码 if (isset ( $_GET ['dir'] )) { //confi ...
- ZPPR101-批量更改BOM组件
************************************************************************ Title : ZPPR101 ** Applicat ...
- 有关BOM头的一些知识
在psr开发标准中,有一条是讲的,php只能使用无bom的utf8格式 . 那么这个bom是几个意思. 说一些理论内容 . 在UCS编码中有一个叫做"ZERO WIDTH NO-BREAK ...
随机推荐
- Phonegap hello world 不容易啊~!
今天一个项目要用phonegap,当初就是觉得phonegap配置太tmd的麻烦了,所以转头appcan,但今天项目必须用-- 先是看到官方说用nodejs装,tmd的,总是重复同一个错误,安装不起, ...
- UVa 11427 - Expect the Expected
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&p ...
- CodeForces 86D(Yandex.Algorithm 2011 Round 2)
思路:莫队算法,离线操作,将所有询问的左端点进行分块(分成sqrt(n) 块每块sqrt(n)个),用左端点的块号进行排序小的在前,块号相等的,右端点小的在前面. 这样要是两个相邻的查询在同一块内左端 ...
- ubnutu安装sougou 输入法
先安百度经验安装fcitx 1.首先下载sogoupinyin_2.0.0.0068_amd64.deb,点击安装后,会通过ubuntu软件中心安装,安装玩成后,任然是无法使用.然后: 2.然后执行下 ...
- powershell ise好字库和diy配色文件分享
Windows PowerShell ISE (集成脚本环境) 是 Win中自带的脚本编写工具. 在 Windows PowerShell ISE 中,可以在单个基于 Windows 的图形用户界面中 ...
- ODI中查看变更及对象查找
ODI中可以查看每个对象的修改时间.修改人,当ETL作业失败之后,可以根据这些信息了解到是否有人修改过相关的对象. 另外,在ODI的菜单项中,也可以查看按修改时间.人员等搜索指定的对象,如查找最近7天 ...
- opencv中的Mat类型
Mat类型主要是跟matlab中的数据类型一样.故用起来很方便. Mat最大的优势跟STL很相似,都是对内存进行动态的管理,不需要之前用户手动的管理内存,对于一些大型的开发,有时候投入的lpImage ...
- Ogre1.8地形和天空盒的建立(一块地形)
转自:http://www.cnblogs.com/WindyMax/ 研究Ogre的程序笔记 编译环境 WIN7 32 VS2008 Ogre的版本 1.8 Ogre的地形算法是采用Geome ...
- explain分析查询
参考以下文章,在此非常感谢原作者 explain分析查询
- 如何为Eclipse设置代理
看图,不解释: