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

时间: 2024-10-07 04:49:56

ZPPR032-批量展BOM的相关文章

批量清除BOM头

批量清除BOM头 (2012-03-05 13:28:30) 转载▼ 标签: 杂谈   有些php文件由于不小心保存成了含bom头的格式而导致出现一系列的问题.以下是批量清除bom头的代码,复制代码,保存成.php文件,放在想执行的文件夹,运行就可以了 <?php if (isset ( $_GET ['dir'] )) { //config the basedir $basedir = $_GET ['dir']; } else { $basedir = '.'; } $auto = 1; c

PHP批量去除bom头代码

最近遇到一个问题编码问题,有点让人头痛,百度的方法好像不太好用,所以我自己也找了很久,现在总结一个小方法去除utf-8bom的方法,页面总会出现 }else{ $basedir = '.'; } $auto = 1; checkdir($basedir); function checkdir($basedir){ if ($dh = opendir($basedir)) { while (($file = readdir($dh)) !== false) { if ($file != '.'

批量去BOM头 遍历目录及子文件,文件夹 PHP源码

1 <?php 2 class KillBom 3 { 4     public static $m_Ext = ['txt', 'php', 'js', 'css'];//检查的扩展名 5     /** 6      * 传入一个任意文件 ,自动区分定义的扩展名,然后过滤bom 7      * @param string $file 8      * @return boolean 9      */ 10     public static  function killBomByFile

BOM批量修改

在项目中,有时候会批量修改BOM的一些属性,利用的函数有三个,CSAP_MAT_BOM_OPEN :CSAP_BOM_ITEM_MAINTAIN:CSAP_MAT_BOM_CLOSE,以下代码的需求是批量刷新BOM组件的展开类型,可根据需要,刷新其他的属性,也可以利用这三个函数做一些其他对BOM修改的操作的程序,分享一下,希望对用到的兄弟有帮助. *&---------------------------------------------------------------------* *&a

BOM展开

BOM展开: BOM_EXPLOSION_temp是一个临时表,在展BOM的时候,是一个很有用的表,存放了组成料件层次.默认时是没有记录的,加入下列的语句: DECLARE l_group_id NUMBER; l_error_message VARCHAR2(1000); l_error_code NUMBER; BEGIN SELECT bom.bom_explosion_temp_s.NEXTVAL --取下一个序列 INTO l_group_id FROM DUAL; BEGIN app

ZPPR101-批量更改BOM组件

************************************************************************ Title : ZPPR101 ** Application : PP ** Subject : 批量更改BOM组件 ** Requested by : PP ** Execution : any time ** Ref no: : B221 ** Author : rainy ** Req Date : 20150701 **************

有关BOM头的一些知识

在psr开发标准中,有一条是讲的,php只能使用无bom的utf8格式 . 那么这个bom是几个意思.  说一些理论内容 . 在UCS编码中有一个叫做"ZERO WIDTH NO-BREAK SPACE"的字符,它的编码是FEFF.而FFFE在UCS中是不存在的字符,所以不应该出现在实际传输中.UCS规范建议我们在传输字节流前,先传输字符"ZERO WIDTH NO-BREAK SPACE".这样如果接收者收到FEFF,就表明这个字节流是Big-Endian的:如果

[易飞]累计组成用量=组成用量/(底数*标准用量)

建BOM人员报告系统程序出问题啦,有图有证据. BOM不准确可问题大?第一反应,可是为何其他产品展BOM不存在这样的问题呢?挑选这个最简单的成品下阶就是采购件且组成用量和底数都是1,累计组成用量都算不出是0.997009!无论怎么更新程序都出错误. 是否差异一个倍数,1/0.99009=1.003 查看录入BOM **标准批量**1.003 恍然大悟:累计组成用量=组成用量/(底数*标准用量)

IDEA初次使用

重点说明: IntelliJ IDEA 是没有类似 Eclipse 的工作空间的概念(Workspaces ),最大单元就是 Project.如果你同时观察多个项目的情况,IntelliJ IDEA 提供的解决方案是打开多个项目实例,你可以理解为开多个项目窗口. 命令 Create New Project 创建一个新项目. 命令 Import Project 导入一个已有项目. 命令 Open 打开一个已有项目,可以直接打开 Eclipse 项目,但是由于两者 IDE 下的项目配置不一样,所以项