ME11/ME12拷贝采购信息记录
注意点:
ECC没有好用的修改/创建采购信息记录BAPI所以使用BDC处理,
因为BDC执行过程如果遇到黄色提示消息就会暂停,所以如果遇到黄色提示需要增强处理
还有就是价格的小数位数问题,如JPY不能使用小数位数问题处理
增强调整
如下是复制代码-有个记录日志的自荐表,可以自行设计
REPORT zmm315.
INCLUDE zmm315_top.
INCLUDE zmm315_frm.
*-----------------------------------------------------------------------
- I N I T I A L I Z A T I O N
*-----------------------------------------------------------------------
INITIALIZATION.
AT SELECTION-SCREEN OUTPUT.
LOOP AT SCREEN.
IF screen-group1 = ‘SP1’.
screen-active = ‘0’.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
*-----------------------------------------------------------------------
- A T S E L E C T I O N - S C R E E N
*-----------------------------------------------------------------------
AT SELECTION-SCREEN.
START-OF-SELECTION.
PERFORM frm_get_data."获取数据
IF p_job = ‘X’.
PERFORM frm_bapi_creat USING 'X'.
ELSE.
PERFORM frm_get_fieldcat TABLES gt_fieldcat.."alv显示列
PERFORM frm_get_layout CHANGING gw_alv_layout."格式设置
PERFORM frm_show_alv."alv显示
ENDIF.
END-OF-SELECTION.
&---------------------------------------------------------------------
*& 包含 ZMM315_TOP
&---------------------------------------------------------------------
TABLES:mara,lfa1,lfm1,eina,eine,a017,konp.
DATA:BEGIN OF gs_alv,
sel,"选择
light TYPE char10, "红绿灯 icon_led_red icon_led_green
msg TYPE char100, "消息
infnr LIKE eina-infnr , "采购信息记录编号
infnr_n LIKE eina-infnr , "采购信息记录编号
bismt LIKE mara-bismt , "旧物料编号
maktx_o LIKE makt-maktx , "旧物料描述
meins_o LIKE mara-meins , "旧物料基本单位
lifnr LIKE a017-lifnr , "供应商
name1 LIKE lfa1-name1 , "供应商名称
matnr LIKE mara-matnr , "PLM物料编号(NEW)
maktx_n LIKE makt-maktx , "PLM物料描述)
meins_n LIKE mara-meins , "PLM物料基本单位
ekorg LIKE a017-ekorg , "采购组织
werks LIKE a017-werks , "工厂
esokz LIKE a017-esokz , "采购类型
aplfz LIKE eine-aplfz , "计划交货时间
ekgrp LIKE eine-ekgrp , "采购组
norbm LIKE eine-norbm , "标准定单数量
webre LIKE eine-webre , "基于收货的发票验证
mwskz LIKE eine-mwskz , "税码
kbetr LIKE eine-netpr , "含税价
konwa LIKE konp-konwa , "币别
kpein LIKE konp-kpein , "价格基数
datab LIKE a017-datab , "开始日期
datbi LIKE a017-datbi , "结束日期
kosrt LIKE konh-kosrt, "暂估价标识
zjj TYPE eine-netpr, "净价(未乘基数)
mtart TYPE mara-mtart, "物料类型
meins TYPE mara-meins, "单位
knumh TYPE a017-knumh, "条件号
kumne TYPE konp-kumne, "条件号
kmein TYPE konp-kmein, "条件号
kumza TYPE konp-kumza, "条件号
waers TYPE eine-waers, "条件号
verkf TYPE eina-verkf,
telf1 TYPE eina-telf1,
esokz_x TYPE c,
END OF gs_alv.
DATA:gt_alv LIKE TABLE OF gs_alv.
DATA:
gt_fieldcat TYPE lvc_t_fcat, "fieldcat
gw_fieldcat TYPE lvc_s_fcat,
gw_alv_layout TYPE lvc_s_layo. " ALV 布局
DATA: gv_grid TYPE REF TO cl_gui_alv_grid. " alv 对象
DATA lv_check TYPE c."检查按钮
DATA:gt_ztmm315_log TYPE STANDARD TABLE OF ztmm315_log,
gs_ztmm315_log TYPE ztmm315_log.
DEFINE init_fieldcat."fieLdcat 宏
GW_FIELDCAT-KEY = &2.
GW_FIELDCAT-FIELDNAME = &3.
GW_FIELDCAT-SELTEXT = &4.
GW_FIELDCAT-SCRTEXT_L = &4.
GW_FIELDCAT-SCRTEXT_M = &4.
GW_FIELDCAT-SCRTEXT_S = &4.
GW_FIELDCAT-REF_FIELD = &5.
GW_FIELDCAT-REF_TABLE = &6.
GW_FIELDCAT-EDIT = &7.
GW_FIELDCAT-CHECKBOX = &8.
GW_FIELDCAT-NO_ZERO = &9.
APPEND GW_FIELDCAT TO &1.
CLEAR GW_FIELDCAT.
END-OF-DEFINITION.
DATA: lt_bdcdata TYPE TABLE OF bdcdata, " BDC执行内表
lt_msgtab TYPE TABLE OF bdcmsgcoll WITH HEADER LINE, " BDC返回信息表
ls_bdcdata TYPE bdcdata,
ls_msgtab TYPE bdcmsgcoll. " BDC返回信息表
*-----------------------------------------------------------------------
- P A R A M E T E R S & S E L E C T - O P T I O N S
*----------------------------------------------------------------------- - 功能选择界面
SELECT-OPTIONS:s_werks FOR a017-werks OBLIGATORY,
s_ekorg FOR a017-ekorg,
s_matnr FOR mara-matnr,
s_bismt FOR mara-bismt,
s_lifnr FOR lfa1-lifnr.
PARAMETERS:p_esokz LIKE eine-esokz DEFAULT ‘0’,
p_datbi LIKE a017-datbi DEFAULT ‘20240201’,
p_job AS CHECKBOX . "MODIF ID sp1.
&---------------------------------------------------------------------
*& 包含 ZMM315_FRM
&---------------------------------------------------------------------
&---------------------------------------------------------------------
*& Form FRM_GET_DATA
&---------------------------------------------------------------------
-
取数
----------------------------------------------------------------------
FORM frm_get_data .
DATA lv_bapicurr_d TYPE bapicurr_d.
DATA:lv_tabix TYPE sy-tabix.
DATA:lv_lfa1_werks_mes TYPE char100.
REFRESH gt_ztmm315_log.
REFRESH gt_alv.
SELECT mara~matnr AS bismt,
mara~bismt AS matnr,
mara~mtart,
a017~knumh,
a017~lifnr,
a017~ekorg,
a017~werks,
a017~esokz,
a017~datab,
a017~datbi
FROM mara INNER JOIN a017 ON mara~matnr = a017~matnr
INTO CORRESPONDING FIELDS OF TABLE @gt_alv
WHERE mara~matnr IN @s_matnr
AND mara~bismt IN @s_bismt
AND a017~esokz EQ @p_esokz
AND a017~werks IN @s_werks
AND a017~ekorg IN @s_ekorg
AND a017~lifnr IN @s_lifnr
AND a017~datab <= @p_datbi
AND a017~datbi >= @p_datbi
AND ( mara~mtart = ‘ZKG’ OR mara~mtart = ‘ZYD’ ).
IF gt_alv[] IS INITIAL.
MESSAGE ‘没有符合条件的数据’ TYPE ‘S’ DISPLAY LIKE ‘E’.
LEAVE LIST-PROCESSING.
ENDIF.
IF gt_alv[] IS NOT INITIAL.
SELECT
maktx ,
matnr
FROM makt INTO TABLE @DATA(lt_makt_n)
FOR ALL ENTRIES IN @gt_alv
WHERE matnr = @gt_alv-matnr
AND spras = @sy-langu.
SORT lt_makt_n BY matnr.
SELECT
meins,
matnr,
lvorm,
mstae
FROM mara INTO TABLE @DATA(lt_mara_n)
FOR ALL ENTRIES IN @gt_alv
WHERE matnr = @gt_alv-matnr.
SORT lt_mara_n BY matnr.
SELECT
matnr,
werks,
lvorm,
mmsta
INTO TABLE @DATA(lt_marc)
FROM marc
FOR ALL ENTRIES IN @gt_alv
WHERE matnr = @gt_alv-matnr
AND werks = @gt_alv-werks
-
AND lvorm = 'X' .
SORT lt_marc BY matnr werks.
SELECT
meins,
bismt
FROM mara INTO TABLE @DATA(lt_mara_o)
FOR ALL ENTRIES IN @gt_alv
WHERE bismt = @gt_alv-bismt.
SORT lt_mara_o BY bismt.SELECT
maktx ,
matnr
FROM makt INTO TABLE @DATA(lt_makt_o)
FOR ALL ENTRIES IN @gt_alv
WHERE matnr = @gt_alv-bismt
AND spras = @sy-langu.
SORT lt_makt_o BY matnr.SELECT
lfa1~lifnr,
lfa1~name1,
lfa1~nodel,
lfa1~sperq,
lfa1~loevm,
lfa1~sperr,
lfa1~sperm,
lfm1~sperm AS sperm_1 ,
lfm1~loevm AS loevm_1 ,
lfm1~ekorg
FROM lfa1 INNER JOIN lfm1 ON lfa1~lifnr = lfm1~lifnr
INTO TABLE @DATA(lt_lfa1)
FOR ALL ENTRIES IN @gt_alv
WHERE lfa1~lifnr = @gt_alv-lifnr
AND lfm1~ekorg = @gt_alv-ekorg.
SORT lt_lfa1 BY lifnr ekorg.SELECT eina~infnr,
eina~matnr,
eina~verkf,
eina~telf1,
eine~aplfz,
eine~esokz,
eine~ekorg,
eine~ekgrp,
eine~norbm,
eine~mwskz,
eine~webre,
eina~lifnr,
eine~waers,
eine~werks,
eine~loekz AS loekz_1,
eina~loekz AS loekz_2
FROM eina INNER JOIN eine ON eina~infnr = eine~infnr
INTO TABLE @DATA(lt_eina)
FOR ALL ENTRIES IN @gt_alv
WHERE eina~matnr = @gt_alv-bismt
AND eine~ekorg = @gt_alv-ekorg
AND eine~esokz = @gt_alv-esokz
AND eina~lifnr = @gt_alv-lifnr.
SORT lt_eina BY matnr ekorg esokz lifnr.SELECT eina~infnr,
eina~matnr,
eine~esokz,
eina~lifnr,
eine~ekorg
FROM eina INNER JOIN eine ON eina~infnr = eine~infnr
INTO TABLE @DATA(lt_eina_n)
FOR ALL ENTRIES IN @gt_alv
WHERE eina~matnr = @gt_alv-matnr
AND eine~ekorg = @gt_alv-ekorg -
AND eine~esokz = @gt_alv-esokz AND eina~lifnr = @gt_alv-lifnr.
SORT lt_eina_n BY matnr ekorg lifnr esokz."
SELECT konp~knumh,
konp~kbetr,
konp~konwa,
konp~kumne,
konp~kumza,
konp~kmein,
konp~kpein,
konh~kosrt
FROM konp
LEFT JOIN konh ON konp~knumh = konh~knumh
INTO TABLE @DATA(lt_konp)
FOR ALL ENTRIES IN @gt_alv
WHERE konp~knumh = @gt_alv-knumh
AND konp~loevm_ko NE ‘X’.
SORT lt_konp BY knumh.SELECT t001k~bukrs,
t001k~bwkey,
lfb1~sperr,
lfb1~loevm,
lfb1~lifnr,
lfb1~nodel
FROM t001k INNER JOIN lfb1 ON t001k~bukrs = lfb1~bukrs
INTO TABLE @DATA(lt_t001k)
FOR ALL ENTRIES IN @gt_alv
WHERE t001k~bwkey = @gt_alv-werks
AND lfb1~lifnr = @gt_alv-lifnr.
SORT lt_t001k BY bwkey lifnr.SELECT
lifnr,
werks
INTO TABLE @DATA(lt_lfa1_werks)
FROM lfa1
FOR ALL ENTRIES IN @gt_alv
WHERE lifnr = @gt_alv-lifnr
AND werks <> ‘’.
SORT lt_lfa1_werks BY lifnr werks.SELECT
matnr,
werks,
pstat
INTO TABLE @DATA(lt_matnr_werks)
FROM marc
FOR ALL ENTRIES IN @gt_alv
WHERE matnr = @gt_alv-matnr.
SORT lt_matnr_werks BY matnr werks.ENDIF.
LOOP AT gt_alv ASSIGNING FIELD-SYMBOL(<fs_alv>).
lv_tabix = sy-tabix.
IF <fs_alv>-matnr IS INITIAL.
PERFORM frm_ztmm315_log USING <fs_alv> ‘已排除’ ‘没有对应的新物料’."记录日志
DELETE gt_alv INDEX lv_tabix.
CONTINUE.
ENDIF.READ TABLE lt_lfa1_werks INTO DATA(ls_lfa1_werks) WITH KEY lifnr = <fs_alv>-lifnr
-
werks = <fs_alv>-werks BINARY SEARCH.
IF sy-subrc = 0.
READ TABLE lt_matnr_werks INTO DATA(ls_matnr_werks) WITH KEY matnr = <fs_alv>-matnr
werks = ls_lfa1_werks-werks
BINARY SEARCH.
IF sy-subrc = 0.
IF ls_matnr_werks-pstat CA ‘E’.ELSE. PERFORM frm_ztmm315_log USING <fs_alv> '已排除' '工厂视图不完整'."记录日志 DELETE gt_alv INDEX lv_tabix. CONTINUE. ENDIF. ELSE. lv_lfa1_werks_mes = '物料没有扩充到供货工厂' && ls_lfa1_werks-werks. PERFORM frm_ztmm315_log USING <fs_alv> '已排除' lv_lfa1_werks_mes."记录日志 DELETE gt_alv INDEX lv_tabix. CONTINUE. ENDIF.
ENDIF.
READ TABLE lt_t001k INTO DATA(ls_t001k) WITH KEY bwkey = <fs_alv>-werks
lifnr = <fs_alv>-lifnr
BINARY SEARCH.
IF sy-subrc = 0.
IF ls_t001k-sperr = ‘X’ OR ls_t001k-loevm = ‘X’ OR ls_t001k-nodel = ‘X’.
PERFORM frm_ztmm315_log USING <fs_alv> ‘已排除’ ‘供应商主数据 (公司代码)删除标识’."记录日志
DELETE gt_alv INDEX lv_tabix.
CONTINUE.
ENDIF.
ENDIF.READ TABLE lt_marc INTO DATA(ls_marc) WITH KEY matnr = <fs_alv>-matnr
werks = <fs_alv>-werks
BINARY SEARCH.
IF sy-subrc = 0.
IF ls_marc-lvorm = 'X’OR ls_marc-mmsta = ‘01’ OR ls_marc-mmsta = ‘L’.
PERFORM frm_ztmm315_log USING <fs_alv> ‘已排除’ ‘物料工厂视图删除标识’."记录日志
DELETE gt_alv INDEX lv_tabix.
CONTINUE.
ENDIF.
ELSE.
PERFORM frm_ztmm315_log USING <fs_alv> ‘已排除’ ‘物料工厂视图不存在’."记录日志
DELETE gt_alv INDEX lv_tabix.
CONTINUE.ENDIF.
READ TABLE lt_lfa1 INTO DATA(ls_lfa1) WITH KEY lifnr = <fs_alv>-lifnr
ekorg = <fs_alv>-ekorg
BINARY SEARCH.
IF sy-subrc = 0.
<fs_alv>-name1 = ls_lfa1-name1.
IF ls_lfa1-nodel = ‘X’ "OR ls_lfa1-sperq <> ‘’
OR ls_lfa1-loevm = ‘X’
OR ls_lfa1-sperr = ‘X’
OR ls_lfa1-sperm = ‘X’
OR ( <fs_alv>-esokz = ‘E’ AND <fs_alv>-mtart = ‘ZYF’ )
OR ( ls_lfa1-ekorg = <fs_alv>-ekorg AND ls_lfa1-sperm_1 = ‘X’ )
OR ( ls_lfa1-ekorg = <fs_alv>-ekorg AND ls_lfa1-loevm_1 = ‘X’ ).
PERFORM frm_ztmm315_log USING <fs_alv> ‘已排除’ ‘供应商删除标识’."记录日志
DELETE gt_alv INDEX lv_tabix.
CONTINUE.
ENDIF.
ENDIF.READ TABLE lt_eina INTO DATA(ls_eina) WITH KEY matnr = <fs_alv>-bismt
ekorg = <fs_alv>-ekorg
esokz = <fs_alv>-esokz
lifnr = <fs_alv>-lifnr
BINARY SEARCH.
IF sy-subrc = 0.
<fs_alv>-infnr = ls_eina-infnr.
<fs_alv>-aplfz = ls_eina-aplfz.
<fs_alv>-ekgrp = ls_eina-ekgrp.
<fs_alv>-norbm = ls_eina-norbm.
<fs_alv>-webre = ls_eina-webre.
<fs_alv>-mwskz = ls_eina-mwskz. -
<fs_alv>-kosrt = ls_eina-kosrt. <fs_alv>-waers = ls_eina-waers. <fs_alv>-verkf = ls_eina-verkf. <fs_alv>-telf1 = ls_eina-telf1. IF ls_eina-loekz_1 = 'X' OR ls_eina-loekz_2 = 'X'
-
AND <fs_alv>-esokz = 'E' AND <fs_alv>-mtart = 'ZYF' . PERFORM frm_ztmm315_log USING <fs_alv> '已排除' '采购信息记录删除标识'."记录日志 DELETE gt_alv INDEX lv_tabix. CONTINUE. ENDIF.
ENDIF.
READ TABLE lt_mara_n INTO DATA(ls_mara_n) WITH KEY matnr = <fs_alv>-matnr BINARY SEARCH.
IF sy-subrc = 0.IF ls_mara_n-lvorm = 'X' OR ls_mara_n-mstae = '01'OR ls_mara_n-mstae = 'L'. PERFORM frm_ztmm315_log USING <fs_alv> '已排除' '物料视图删除标识'."记录日志 DELETE gt_alv INDEX lv_tabix.. CONTINUE. ENDIF. <fs_alv>-meins_n = ls_mara_n-meins.
ELSE.
PERFORM frm_ztmm315_log USING <fs_alv> ‘已排除’ ‘新物料不存在’."记录日志
DELETE gt_alv INDEX lv_tabix.
CONTINUE.ENDIF.
READ TABLE lt_konp INTO DATA(ls_konp) WITH KEY knumh = <fs_alv>-knumh BINARY SEARCH.
IF sy-subrc = 0 .
<fs_alv>-kbetr = ls_konp-kbetr.
<fs_alv>-konwa = ls_konp-konwa.
<fs_alv>-kpein = ls_konp-kpein.
<fs_alv>-kumne = ls_konp-kumne.
<fs_alv>-kumza = ls_konp-kumza.
<fs_alv>-kmein = ls_konp-kmein.
<fs_alv>-kosrt = ls_konp-kosrt.
ENDIF.IF <fs_alv>-kbetr = ‘’."剔除含税单价为0数据
PERFORM frm_ztmm315_log USING <fs_alv> ‘已排除’ ‘含税单价为0数据’."记录日志
DELETE gt_alv INDEX lv_tabix.
CONTINUE.
ENDIF.CALL FUNCTION ‘BAPI_CURRENCY_CONV_TO_EXTERNAL’
EXPORTING
currency = <fs_alv>-waers
amount_internal = <fs_alv>-kbetr
IMPORTING
amount_external = lv_bapicurr_d.<fs_alv>-kbetr = lv_bapicurr_d.
IF <fs_alv>-kpein IS NOT INITIAL.
<fs_alv>-zjj = <fs_alv>-kbetr / <fs_alv>-kpein.
ENDIF.READ TABLE lt_makt_o INTO DATA(ls_makt_o) WITH KEY matnr = <fs_alv>-bismt BINARY SEARCH.
IF sy-subrc = 0.
<fs_alv>-maktx_o = ls_makt_o-maktx.
ENDIF.READ TABLE lt_makt_n INTO DATA(ls_makt_n) WITH KEY matnr = <fs_alv>-matnr BINARY SEARCH.
IF sy-subrc = 0.
<fs_alv>-maktx_n = ls_makt_n-maktx.
ENDIF.READ TABLE lt_mara_o INTO DATA(ls_mara_o) WITH KEY bismt = <fs_alv>-bismt BINARY SEARCH.
IF sy-subrc = 0.
<fs_alv>-meins_o = ls_mara_o-meins.
ENDIF.READ TABLE lt_eina_n INTO DATA(ls_eina_n) WITH KEY matnr = <fs_alv>-matnr
ekorg = <fs_alv>-ekorg -
esokz = <fs_alv>-esokz lifnr = <fs_alv>-lifnr BINARY SEARCH.
IF sy-subrc = 0.
<fs_alv>-infnr_n = ls_eina_n-infnr.
ENDIF.READ TABLE lt_eina_n INTO ls_eina_n WITH KEY matnr = <fs_alv>-matnr
ekorg = <fs_alv>-ekorg
lifnr = <fs_alv>-lifnr
esokz = <fs_alv>-esokz
BINARY SEARCH.
IF sy-subrc <> 0.
<fs_alv>-esokz_x = ‘X’.
ENDIF.ENDLOOP.
IF gt_ztmm315_log[] IS NOT INITIAL.
MODIFY ztmm315_log FROM TABLE gt_ztmm315_log.
COMMIT WORK AND WAIT.
ENDIF.IF gt_alv[] IS INITIAL.
MESSAGE ‘没有符合条件的数据’ TYPE ‘S’ DISPLAY LIKE ‘E’.
LEAVE LIST-PROCESSING.
ENDIF.
ENDFORM.
&---------------------------------------------------------------------
*& Form FRM_SHOW_ALV
&---------------------------------------------------------------------
-
text
----------------------------------------------------------------------
FORM frm_show_alv .
CALL FUNCTION ‘REUSE_ALV_GRID_DISPLAY_LVC’
EXPORTING
i_callback_program = sy-repid
is_layout_lvc = gw_alv_layout
i_callback_user_command = ‘FRM_USER_COMMAND’
i_callback_pf_status_set = ‘SET_ALV_STATUS’
it_fieldcat_lvc = gt_fieldcat[]
i_save = ‘A’
i_default = ‘’
TABLES
t_outtab = gt_alv
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.
&---------------------------------------------------------------------
*& Form FRM_GET_FIELDCAT
&---------------------------------------------------------------------
-
text
----------------------------------------------------------------------
- –> p1 text
- <-- p2 text
----------------------------------------------------------------------
FORM frm_get_fieldcat TABLES pt_fieldcat STRUCTURE gw_fieldcat…
init_fieldcat pt_fieldcat ‘’ ‘SEL’ ‘选择’ ‘’ ‘’ ‘X’ ‘X’ ‘’ .
init_fieldcat pt_fieldcat ‘’ ‘LIGHT’ ‘状态’ ‘’ ‘’ ‘’ ‘’ ‘’ .
init_fieldcat pt_fieldcat ‘’ ‘MSG’ ‘消息’ ‘’ ‘’ ‘’ ‘’ ‘’ .
init_fieldcat pt_fieldcat ‘’ ‘INFNR’ ‘采购信息记录编号’ ‘’ ‘’ ‘’ ‘’ ‘’ .
init_fieldcat pt_fieldcat ‘’ ‘INFNR_N’ ‘(新)采购信息记录编号’ ‘’ ‘’ ‘’ ‘’ ‘’ .
init_fieldcat pt_fieldcat ‘’ ‘BISMT’ ‘旧物料编号’ ‘’ ‘’ ‘’ ‘’ ‘X’ .
init_fieldcat pt_fieldcat ‘’ ‘MAKTX_O’ ‘旧物料描述’ ‘’ ‘’ ‘’ ‘’ ‘’ .
init_fieldcat pt_fieldcat ‘’ ‘LIFNR’ ‘供应商’ ‘’ ‘’ ‘’ ‘’ ‘’ .
init_fieldcat pt_fieldcat ‘’ ‘NAME1’ ‘供应商描述’ ‘’ ‘’ ‘’ ‘’ ‘’ .
init_fieldcat pt_fieldcat ‘’ ‘MATNR’ ‘PLM物料编号(NEW)’ ‘’ ‘’ ‘’ ‘’ ‘X’ .
init_fieldcat pt_fieldcat ‘’ ‘MAKTX_N’ ‘PLM物料描述’ ‘’ ‘’ ‘’ ‘’ ‘’ .
init_fieldcat pt_fieldcat ‘’ ‘EKORG’ ‘采购组织’ ‘’ ‘’ ‘’ ‘’ ‘’ .
init_fieldcat pt_fieldcat ‘’ ‘WERKS’ ‘工厂’ ‘’ ‘’ ‘’ ‘’ ‘’ .
init_fieldcat pt_fieldcat ‘’ ‘ESOKZ’ ‘采购类型’ ‘’ ‘’ ‘’ ‘’ ‘’ .
init_fieldcat pt_fieldcat ‘’ ‘APLFZ’ ‘计划交货时间’ ‘’ ‘’ ‘’ ‘’ ‘’ .
init_fieldcat pt_fieldcat ‘’ ‘EKGRP’ ‘采购组’ ‘’ ‘’ ‘’ ‘’ ‘’ .
init_fieldcat pt_fieldcat ‘’ ‘NORBM’ ‘标准定单数量’ ‘’ ‘’ ‘’ ‘’ ‘’ .
init_fieldcat pt_fieldcat ‘’ ‘WEBRE’ ‘基于收货的发票验证’ ‘’ ‘’ ‘’ ‘’ ‘’ .
init_fieldcat pt_fieldcat ‘’ ‘MWSKZ’ ‘税码’ ‘’ ‘’ ‘’ ‘’ ‘’ .
init_fieldcat pt_fieldcat ‘’ ‘KBETR’ ‘含税价’ ‘’ ‘’ ‘’ ‘’ ‘’ .
init_fieldcat pt_fieldcat ‘’ ‘KONWA’ ‘币别’ ‘’ ‘’ ‘’ ‘’ ‘’ .
init_fieldcat pt_fieldcat ‘’ ‘KPEIN’ ‘价格单位’ ‘’ ‘’ ‘’ ‘’ ‘’ .
init_fieldcat pt_fieldcat ‘’ ‘DATAB’ ‘开始日期’ ‘’ ‘’ ‘’ ‘’ ‘’ .
init_fieldcat pt_fieldcat ‘’ ‘DATBI’ ‘结束日期’ ‘’ ‘’ ‘’ ‘’ ‘’ .
init_fieldcat pt_fieldcat ‘’ ‘KOSRT’ ‘暂估价标识’ ‘’ ‘’ ‘’ ‘’ ‘’ .
init_fieldcat pt_fieldcat ‘’ ‘ZJJ’ ‘净价(未乘基数)’ ‘’ ‘’ ‘’ ‘’ ‘’ .
ENDFORM.
&---------------------------------------------------------------------
*& Form FRM_GET_LAYOUT
&---------------------------------------------------------------------
-
text
----------------------------------------------------------------------
-
<--P_GW_ALV_LAYOUT text
----------------------------------------------------------------------
FORM frm_get_layout CHANGING pw_alv_layout TYPE lvc_s_layo.
pw_alv_layout-zebra = ‘X’.
pw_alv_layout-sel_mode = ‘A’.
ENDFORM.
"设置ALV Status
FORM set_alv_status USING rt_extab TYPE slis_t_extab.
SET PF-STATUS ‘STATUS’.
ENDFORM.
"按钮触发事件
FORM frm_user_command USING r_ucomm LIKE sy-ucomm
selfield TYPE slis_selfield.
selfield-refresh = ‘X’.
selfield-col_stable = ‘X’.
selfield-row_stable = ‘X’.
"修改alv中的数据,并保存到内表
CALL FUNCTION ‘GET_GLOBALS_FROM_SLVC_FULLSCR’
IMPORTING
e_grid = gv_grid.
CALL METHOD gv_grid->check_changed_data .
CASE r_ucomm.
WHEN ‘ALL’.
gs_alv-sel = ‘X’.
MODIFY gt_alv FROM gs_alv TRANSPORTING sel WHERE sel = ‘’ .
WHEN 'SAL'.
gs_alv-sel = ''.
MODIFY gt_alv FROM gs_alv TRANSPORTING sel WHERE sel = 'X'.
WHEN 'CHECK'.
CHECK lv_check NE 'X'.
SORT gt_alv BY msg DESCENDING sel DESCENDING.
READ TABLE gt_alv INTO gs_alv WITH KEY sel = 'X' msg = ''.
IF sy-subrc = 0.
PERFORM frm_bapi_creat USING ''.
lv_check = 'X'.
ELSE.
MESSAGE '请选择!'(035) TYPE 'E'.
ENDIF.
WHEN 'EXCU'.
IF lv_check = 'X'.
SORT gt_alv BY msg DESCENDING sel DESCENDING.
READ TABLE gt_alv INTO gs_alv WITH KEY sel = 'X' msg = '' .
IF sy-subrc = 0.
PERFORM frm_bapi_creat USING 'X'.
lv_check = ''.
ELSE.
MESSAGE '请选择!'(035) TYPE 'E'.
ENDIF.
ELSE.
MESSAGE '请先点击检查按钮,确认数据准确后再进行采购记录创建!'(033) TYPE 'S' DISPLAY LIKE 'E'.
ENDIF.
WHEN '&IC1'."* 获取当前alv所在行数据
IF selfield-fieldname = 'INFNR'. "判断双击是不是规定双击事件的字段
READ TABLE gt_alv INTO DATA(lss_alv) INDEX selfield-tabindex. "获取单双击的行,并读取对应的值
SET PARAMETER ID: 'LIF' FIELD lss_alv-lifnr. "对应值赋值给需要调用的屏幕id
SET PARAMETER ID: 'MAT' FIELD lss_alv-bismt. "对应值赋值给需要调用的屏幕id
SET PARAMETER ID: 'EKO' FIELD lss_alv-ekorg. "对应值赋值给需要调用的屏幕id
SET PARAMETER ID: 'WRK' FIELD lss_alv-werks. "对应值赋值给需要调用的屏幕id
SET PARAMETER ID: 'INF' FIELD lss_alv-infnr. "对应值赋值给需要调用的屏幕id
CALL TRANSACTION 'ME13' AND SKIP FIRST SCREEN. "调用程式并跳过第一个画面
ELSEIF selfield-fieldname = 'INFNR_N'. "判断双击是不是规定双击事件的字段
READ TABLE gt_alv INTO lss_alv INDEX selfield-tabindex. "获取单双击的行,并读取对应的值
SET PARAMETER ID: 'LIF' FIELD lss_alv-lifnr. "对应值赋值给需要调用的屏幕id
SET PARAMETER ID: 'MAT' FIELD lss_alv-matnr. "对应值赋值给需要调用的屏幕id
SET PARAMETER ID: 'EKO' FIELD lss_alv-ekorg. "对应值赋值给需要调用的屏幕id
SET PARAMETER ID: 'WRK' FIELD lss_alv-werks. "对应值赋值给需要调用的屏幕id
SET PARAMETER ID: 'INF' FIELD lss_alv-infnr_n. "对应值赋值给需要调用的屏幕id
CALL TRANSACTION 'ME13' AND SKIP FIRST SCREEN. "调用程式并跳过第一个画面
ENDIF.
ENDCASE.
CALL METHOD gv_grid->refresh_table_display.
ENDFORM.
&---------------------------------------------------------------------
*& Form FRM_BAPI_CREAT
&---------------------------------------------------------------------
-
text
----------------------------------------------------------------------
-
-->P_0923 text
----------------------------------------------------------------------
FORM frm_bapi_creat USING lv_type TYPE char01 .
IF p_job = ‘X’.
gs_alv-sel = ‘X’.
MODIFY gt_alv FROM gs_alv TRANSPORTING sel WHERE sel = ‘’ .
ENDIF.
LOOP AT gt_alv ASSIGNING FIELD-SYMBOL(<fs_alv>) WHERE sel = ‘X’.
IF lv_type = 'X'.
IF <fs_alv>-infnr_n IS INITIAL.
PERFORM frm_bcd_me11_all USING <fs_alv>."ME11创建基础视图和价格视图
ELSE.
IF <fs_alv>-esokz_x = ''.
PERFORM frm_bcd_me12 USING <fs_alv>."ME12价格视图
ELSE.
PERFORM frm_bcd_me11 USING <fs_alv>."ME11创建价格视图
ENDIF.
ENDIF.
IF <fs_alv>-light = icon_led_green.
PERFORM frm_ztmm315_log USING <fs_alv> '创建成功' ''."记录日志
ELSE.
PERFORM frm_ztmm315_log USING <fs_alv> '创建失败' <fs_alv>-msg."记录日志
ENDIF.
ELSE.
<fs_alv>-light = icon_led_green.
ENDIF.
ENDLOOP.
IF gt_ztmm315_log[] IS NOT INITIAL.
MODIFY ztmm315_log FROM TABLE gt_ztmm315_log.
COMMIT WORK AND WAIT.
ENDIF.
ENDFORM.
----------------------------------------------------------------------
-
Start new screen *
----------------------------------------------------------------------
FORM bdc_dynpro USING program dynpro.
CLEAR ls_bdcdata.
ls_bdcdata-program = program.
ls_bdcdata-dynpro = dynpro.
ls_bdcdata-dynbegin = ‘X’.
APPEND ls_bdcdata TO lt_bdcdata.
ENDFORM.
----------------------------------------------------------------------
-
Insert field *
----------------------------------------------------------------------
FORM bdc_field USING fnam fval.
- IF FVAL <> NODATA.
CLEAR ls_bdcdata.
ls_bdcdata-fnam = fnam.
ls_bdcdata-fval = fval.
CONDENSE ls_bdcdata-fval NO-GAPS.
APPEND ls_bdcdata TO lt_bdcdata. - ENDIF.
ENDFORM.
&---------------------------------------------------------------------
*& Form FRM_BCD_ME12
&--------------------------------------------------------------------- -
text
----------------------------------------------------------------------
FORM frm_bcd_me12 USING ls_alv LIKE gs_alv .
DATA:lv_kbetr TYPE char15.
DATA:lv_bdcmode TYPE c VALUE ‘N’,
lv_bdcupdate TYPE c VALUE ‘L’.
DATA:lv_int TYPE char10.
DATA:lv_fod TYPE char10.
"不同币别价格单位不同问题处理
lv_kbetr = ls_alv-kbetr.
CONDENSE lv_kbetr NO-GAPS.
SELECT SINGLE
currdec
INTO @DATA(lv_currdec)
FROM tcurx
WHERE currkey = @ls_alv-konwa.
IF sy-subrc = 0.
SPLIT lv_kbetr AT ‘.’ INTO lv_int lv_fod.
IF lv_currdec > 0.
lv_kbetr = lv_int && ‘.’&& lv_fod+(lv_currdec).
ELSE.
lv_kbetr = lv_int .
ENDIF.
ENDIF.
CONDENSE lv_kbetr NO-GAPS.
REFRESH lt_bdcdata.
REFRESH lt_msgtab.
PERFORM bdc_dynpro USING ‘SAPMM06I’ ‘0100’.
PERFORM bdc_field USING ‘BDC_CURSOR’ ‘EINA-LIFNR’.
PERFORM bdc_field USING ‘BDC_OKCODE’ ‘/00’.
PERFORM bdc_field USING ‘EINA-LIFNR’ ls_alv-lifnr.
PERFORM bdc_field USING ‘EINA-MATNR’ ls_alv-matnr.
PERFORM bdc_field USING ‘EINE-EKORG’ ls_alv-ekorg.
PERFORM bdc_field USING ‘EINE-WERKS’ ls_alv-werks.
IF ls_alv-esokz = ‘0’.
PERFORM bdc_field USING ‘RM06I-NORMB’ ‘X’.
ELSEIF ls_alv-esokz = ‘3’.
PERFORM bdc_field USING ‘RM06I-LOHNB’ ‘X’.
ENDIF.
PERFORM bdc_dynpro USING ‘SAPMM06I’ ‘0101’.
PERFORM bdc_field USING ‘BDC_CURSOR’ ‘EINA-MAHN1’.
PERFORM bdc_field USING ‘BDC_OKCODE’ ‘=KO’.
- PERFORM bdc_field USING ‘EINA-URZTP’ record-urztp_006.
- PERFORM bdc_field USING ‘EINA-URZLA’ record-urzla_007.
- PERFORM bdc_field USING ‘EINA-REGIO’ record-regio_008.
- PERFORM bdc_field USING ‘EINA-VERKF’ record-verkf_009.
- PERFORM bdc_field USING ‘EINA-TELF1’ record-telf1_010.
- PERFORM bdc_field USING ‘EINA-MEINS’ record-meins_011.
- PERFORM bdc_field USING ‘EINA-UMREZ’ record-umrez_012.
- PERFORM bdc_field USING ‘EINA-UMREN’ record-umren_013.
PERFORM bdc_dynpro USING ‘SAPLV14A’ ‘0102’.
PERFORM bdc_field USING ‘BDC_CURSOR’ ‘VAKE-DATAB(01)’.
PERFORM bdc_field USING ‘BDC_OKCODE’ ‘=NEWR’.
PERFORM bdc_dynpro USING ‘SAPMV13A’ ‘0201’.
PERFORM bdc_field USING ‘BDC_CURSOR’ ‘KONP-KBETR(01)’.
PERFORM bdc_field USING ‘BDC_OKCODE’ ‘=SICH’.
PERFORM bdc_field USING ‘RV13A-DATAB’ p_datbi.
PERFORM bdc_field USING ‘RV13A-DATBI’ ls_alv-datbi.
PERFORM bdc_field USING ‘KONP-KBETR(01)’ lv_kbetr.
PERFORM bdc_field USING ‘KONP-KPEIN(01)’ ls_alv-kpein.
CALL TRANSACTION ‘ME12’ " BDC调用的事务码
USING lt_bdcdata " BDC执行内表
MODE lv_bdcmode " BDC运行模式
MESSAGES INTO lt_msgtab " BDC返回信息表
UPDATE lv_bdcupdate. " 批导更新模式(A = ‘异步’,S = ‘同步’)
READ TABLE lt_msgtab WITH KEY msgtyp = ‘E’.
IF sy-subrc = 0.
MESSAGE ID lt_msgtab-msgid TYPE lt_msgtab-msgtyp NUMBER lt_msgtab-msgnr
WITH lt_msgtab-msgv1 lt_msgtab-msgv2 lt_msgtab-msgv3 lt_msgtab-msgv4 INTO ls_alv-msg.
ls_alv-light = icon_led_red.
ROLLBACK WORK.
ELSE.
ls_alv-light = icon_led_green.
COMMIT WORK AND WAIT.
ENDIF.
IF ls_alv-msg IS INITIAL.
ls_alv-msg = ‘S创建信息记录成功’.
ENDIF.
ENDFORM.
&---------------------------------------------------------------------
*& Form FRM_BCD_ME11
&---------------------------------------------------------------------
-
text
----------------------------------------------------------------------
FORM frm_bcd_me11 USING ls_alv LIKE gs_alv .
DATA:lv_kbetr TYPE char15.
DATA:lv_bdcmode TYPE c VALUE ‘N’,
lv_bdcupdate TYPE c VALUE ‘L’.
DATA:lv_int TYPE char10.
DATA:lv_fod TYPE char10.
lv_kbetr = ls_alv-kbetr.
CONDENSE lv_kbetr NO-GAPS.
SELECT SINGLE
currdec
INTO @DATA(lv_currdec)
FROM tcurx
WHERE currkey = @ls_alv-konwa.
IF sy-subrc = 0.
SPLIT lv_kbetr AT ‘.’ INTO lv_int lv_fod.
IF lv_currdec > 0.
lv_kbetr = lv_int && ‘.’&& lv_fod+(lv_currdec).
ELSE.
lv_kbetr = lv_int .
ENDIF.
ENDIF.
CONDENSE lv_kbetr NO-GAPS.
REFRESH lt_bdcdata.
REFRESH lt_msgtab.
PERFORM bdc_dynpro USING ‘SAPMM06I’ ‘0100’.
PERFORM bdc_field USING ‘BDC_CURSOR’ ‘EINE-WERKS’.
PERFORM bdc_field USING ‘BDC_OKCODE’ ‘/00’.
PERFORM bdc_field USING ‘EINA-LIFNR’ ls_alv-lifnr.
PERFORM bdc_field USING ‘EINA-MATNR’ ls_alv-matnr.
PERFORM bdc_field USING ‘EINE-EKORG’ ls_alv-ekorg.
PERFORM bdc_field USING ‘EINE-WERKS’ ls_alv-werks.
IF ls_alv-esokz = ‘0’.
PERFORM bdc_field USING ‘RM06I-NORMB’ ‘X’.
ELSEIF ls_alv-esokz = ‘3’.
PERFORM bdc_field USING ‘RM06I-LOHNB’ ‘X’.
ENDIF.
PERFORM bdc_dynpro USING ‘SAPMM06I’ ‘0101’.
PERFORM bdc_field USING ‘BDC_CURSOR’ ‘EINA-MAHN1’.
PERFORM bdc_field USING ‘BDC_OKCODE’ ‘=EINE’.
-
PERFORM bdc_field USING ‘EINA-URZTP’ record-urztp_006.
-
PERFORM bdc_field USING ‘EINA-URZLA’ record-urzla_007.
-
PERFORM bdc_field USING ‘EINA-REGIO’ record-regio_008.
-
PERFORM bdc_field USING ‘EINA-VERKF’ ls_alv-verkf.
-
PERFORM bdc_field USING ‘EINA-TELF1’ ls_alv-telf1.
-
PERFORM bdc_field USING ‘EINA-MEINS’ record-meins_011.
-
PERFORM bdc_field USING ‘EINA-UMREZ’ record-umrez_012.
-
PERFORM bdc_field USING ‘EINA-UMREN’ record-umren_013.
PERFORM bdc_dynpro USING ‘SAPMM06I’ ‘0102’.
PERFORM bdc_field USING ‘BDC_CURSOR’ ‘EINE-EKKOL’.
PERFORM bdc_field USING ‘BDC_OKCODE’ ‘=KO’.
PERFORM bdc_field USING ‘EINE-APLFZ’ ls_alv-aplfz.
- PERFORM bdc_field USING ‘EINE-EKGRP’* record-ekgrp_015.
- PERFORM bdc_field USING ‘EINE-WEBRE’* record-webre_016.
PERFORM bdc_field USING ‘EINE-MWSKZ’ ls_alv-mwskz.
- PERFORM bdc_field USING ‘EINE-IPRKZ’* record-iprkz_018.
PERFORM bdc_field USING ‘EINE-NETPR’ lv_kbetr.
PERFORM bdc_field USING ‘EINE-WAERS’ ls_alv-konwa.
PERFORM bdc_field USING ‘EINE-PEINH’ ls_alv-kpein.
-
PERFORM bdc_field USING ‘EINE-BPRME’ ‘PCS’.
-
PERFORM bdc_field USING ‘EINE-BPUMZ’ ‘1’.
-
PERFORM bdc_field USING ‘EINE-BPUMN’ ‘1’.
-
PERFORM bdc_field USING ‘EINE-EKKOL’ ls_alv-kosrt.
PERFORM bdc_dynpro USING ‘SAPMV13A’ ‘0201’.
PERFORM bdc_field USING ‘BDC_CURSOR’ ‘RV13A-DATAB’.
PERFORM bdc_field USING ‘BDC_OKCODE’ ‘=KDAT’.
PERFORM bdc_field USING ‘RV13A-DATAB’ p_datbi.
PERFORM bdc_field USING ‘RV13A-DATBI’ ls_alv-datbi.
PERFORM bdc_field USING ‘KONP-KBETR(01)’ lv_kbetr.
PERFORM bdc_field USING ‘KONP-KONWA(01)’ ls_alv-konwa.
PERFORM bdc_dynpro USING ‘SAPMV13A’ ‘0200’.
PERFORM bdc_field USING ‘BDC_CURSOR’ ‘KONH-KOSRT’.
PERFORM bdc_field USING ‘BDC_OKCODE’ ‘=SICH’.
PERFORM bdc_field USING ‘RV13A-DATAB’ p_datbi.
PERFORM bdc_field USING ‘RV13A-DATBI’ ls_alv-datbi.
PERFORM bdc_field USING ‘KONH-KOSRT’ ls_alv-kosrt.
CALL TRANSACTION ‘ME11’ " BDC调用的事务码
USING lt_bdcdata " BDC执行内表
MODE lv_bdcmode " BDC运行模式
MESSAGES INTO lt_msgtab " BDC返回信息表
UPDATE lv_bdcupdate. " 批导更新模式(A = ‘异步’,S = ‘同步’)
READ TABLE lt_msgtab WITH KEY msgtyp = ‘E’.
IF sy-subrc = 0.
MESSAGE ID lt_msgtab-msgid TYPE lt_msgtab-msgtyp NUMBER lt_msgtab-msgnr
WITH lt_msgtab-msgv1 lt_msgtab-msgv2 lt_msgtab-msgv3 lt_msgtab-msgv4 INTO ls_alv-msg.
ls_alv-light = icon_led_red.
ROLLBACK WORK.
ELSE.
ls_alv-light = icon_led_green.
COMMIT WORK AND WAIT.
ENDIF.
IF ls_alv-msg IS INITIAL.
ls_alv-msg = ‘S创建信息记录成功’.
ENDIF.
ENDFORM.
&---------------------------------------------------------------------
*& Form FRM_BCD_ME11_ALL
&---------------------------------------------------------------------
-
ME11创建基础视图和价格视图
----------------------------------------------------------------------
-
-->ls_alv text
----------------------------------------------------------------------
FORM frm_bcd_me11_all USING ls_alv LIKE gs_alv .
DATA:lv_kbetr TYPE char15.
DATA:lv_bdcmode TYPE c VALUE ‘N’,
lv_bdcupdate TYPE c VALUE ‘L’.
DATA:lv_int TYPE char10.
DATA:lv_fod TYPE char10.
lv_kbetr = ls_alv-kbetr.
CONDENSE lv_kbetr NO-GAPS.
SELECT SINGLE
currdec
INTO @DATA(lv_currdec)
FROM tcurx
WHERE currkey = @ls_alv-konwa.
IF sy-subrc = 0.
SPLIT lv_kbetr AT ‘.’ INTO lv_int lv_fod.
IF lv_currdec > 0.
lv_kbetr = lv_int && ‘.’&& lv_fod+(lv_currdec).
ELSE.
lv_kbetr = lv_int .
ENDIF.
ENDIF.
CONDENSE lv_kbetr NO-GAPS.
REFRESH lt_bdcdata.
REFRESH lt_msgtab.
PERFORM bdc_dynpro USING ‘SAPMM06I’ ‘0100’.
PERFORM bdc_field USING ‘BDC_CURSOR’ ‘EINA-LIFNR’.
PERFORM bdc_field USING ‘BDC_OKCODE’ ‘/00’.
PERFORM bdc_field USING ‘EINA-LIFNR’ ls_alv-lifnr.
PERFORM bdc_field USING ‘EINA-MATNR’ ls_alv-matnr.
PERFORM bdc_field USING ‘EINE-EKORG’ ls_alv-ekorg.
PERFORM bdc_field USING ‘EINE-WERKS’ ls_alv-werks.
IF ls_alv-esokz = ‘0’.
PERFORM bdc_field USING ‘RM06I-NORMB’ ‘X’.
ELSEIF ls_alv-esokz = ‘3’.
PERFORM bdc_field USING ‘RM06I-LOHNB’ ‘X’.
ENDIF.
PERFORM bdc_dynpro USING ‘SAPMM06I’ ‘0101’.
PERFORM bdc_field USING ‘BDC_CURSOR’ ‘EINA-URZTP’.
PERFORM bdc_field USING ‘BDC_OKCODE’ ‘=EINE’.
- PERFORM bdc_field USING ‘EINA-URZTP’* record-urztp_006.
- PERFORM bdc_field USING ‘EINA-URZLA’* record-urzla_007.
- PERFORM bdc_field USING ‘EINA-REGIO’* record-regio_008.
PERFORM bdc_field USING ‘EINA-VERKF’ ls_alv-verkf.
PERFORM bdc_field USING ‘EINA-TELF1’ ls_alv-telf1.
- PERFORM bdc_field USING ‘EINA-MEINS’* record-meins_011.
- PERFORM bdc_field USING ‘EINA-UMREZ’* record-umrez_012.
- PERFORM bdc_field USING ‘EINA-UMREN’* record-umren_013.
PERFORM bdc_dynpro USING ‘SAPMM06I’ ‘0102’.
PERFORM bdc_field USING ‘BDC_CURSOR’ ‘EINE-APLFZ’.
-
PERFORM bdc_field USING ‘BDC_OKCODE’ ‘=SICH’.
PERFORM bdc_field USING ‘BDC_OKCODE’ ‘=KO’.
PERFORM bdc_field USING ‘EINE-APLFZ’ ls_alv-aplfz. -
PERFORM bdc_field USING ‘EINE-EKGRP’* record-ekgrp_015.
-
PERFORM bdc_field USING ‘EINE-WEBRE’* record-webre_016.
PERFORM bdc_field USING ‘EINE-MWSKZ’ ls_alv-mwskz.
- PERFORM bdc_field USING ‘EINE-IPRKZ’* record-iprkz_018.
PERFORM bdc_field USING ‘EINE-NETPR’ lv_kbetr.
PERFORM bdc_field USING ‘EINE-WAERS’ ls_alv-konwa.
PERFORM bdc_field USING ‘EINE-PEINH’ ls_alv-kpein.
-
PERFORM bdc_field USING ‘EINE-BPRME’* record-bprme_022.
-
PERFORM bdc_field USING ‘EINE-BPUMZ’* record-bpumz_023.
-
PERFORM bdc_field USING ‘EINE-BPUMN’* record-bpumn_024.
-
PERFORM bdc_field USING ‘EINE-EKKOL’ ls_alv-kosrt.
PERFORM bdc_dynpro USING ‘SAPMV13A’ ‘0201’.
PERFORM bdc_field USING ‘BDC_CURSOR’ ‘KONP-KBETR(01)’.
PERFORM bdc_field USING ‘BDC_OKCODE’ ‘=KDAT’.
PERFORM bdc_field USING ‘RV13A-DATAB’ p_datbi.
PERFORM bdc_field USING ‘RV13A-DATBI’ ls_alv-datbi.
PERFORM bdc_field USING ‘KONP-KONWA(01)’ ls_alv-konwa.
PERFORM bdc_field USING ‘KONP-KBETR(01)’ lv_kbetr.
PERFORM bdc_dynpro USING ‘SAPMV13A’ ‘0200’.
PERFORM bdc_field USING ‘BDC_CURSOR’ ‘KONH-KOSRT’.
PERFORM bdc_field USING ‘BDC_OKCODE’ ‘=SICH’.
PERFORM bdc_field USING ‘RV13A-DATAB’ p_datbi.
PERFORM bdc_field USING ‘RV13A-DATBI’ ls_alv-datbi.
PERFORM bdc_field USING ‘KONH-KOSRT’ ls_alv-kosrt.
CALL TRANSACTION ‘ME11’ " BDC调用的事务码
USING lt_bdcdata " BDC执行内表
MODE lv_bdcmode " BDC运行模式
MESSAGES INTO lt_msgtab " BDC返回信息表
UPDATE lv_bdcupdate. " 批导更新模式(A = ‘异步’,S = ‘同步’)
READ TABLE lt_msgtab WITH KEY msgtyp = ‘E’.
IF sy-subrc = 0.
MESSAGE ID lt_msgtab-msgid TYPE lt_msgtab-msgtyp NUMBER lt_msgtab-msgnr
WITH lt_msgtab-msgv1 lt_msgtab-msgv2 lt_msgtab-msgv3 lt_msgtab-msgv4 INTO ls_alv-msg.
ls_alv-light = icon_led_red.
ROLLBACK WORK.
ELSE.
READ TABLE lt_msgtab WITH KEY msgtyp = 'S'
msgid = '06'
msgnr = '331'.
IF sy-subrc = 0.
LOOP AT gt_alv INTO DATA(lss_alv) WHERE matnr = ls_alv-matnr
AND lifnr = ls_alv-lifnr.
lss_alv-infnr_n = lt_msgtab-msgv1.
MODIFY gt_alv FROM lss_alv.
ENDLOOP.
ENDIF.
ls_alv-light = icon_led_green.
COMMIT WORK AND WAIT.
ENDIF.
IF ls_alv-msg IS INITIAL.
ls_alv-msg = ‘S创建信息记录成功’.
ENDIF.
ENDFORM.
&---------------------------------------------------------------------
*& Form FRM_ZTMM315_LOG
&---------------------------------------------------------------------
-
记录日志
----------------------------------------------------------------------
-
-->P_<FS_ALV> text
-
-->P_0575 text
-
-->P_0576 text
----------------------------------------------------------------------
FORM frm_ztmm315_log USING ls_alv LIKE gs_alv
p_ztype TYPE char20
p_msg TYPE char100
.
CLEAR gs_ztmm315_log.
MOVE-CORRESPONDING ls_alv TO gs_ztmm315_log.
gs_ztmm315_log-ztype = p_ztype.
gs_ztmm315_log-msg = p_msg.
APPEND gs_ztmm315_log TO gt_ztmm315_log.
ENDFORM.
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。 如若内容造成侵权/违法违规/事实不符,请联系我的编程经验分享网邮箱:veading@qq.com进行投诉反馈,一经查实,立即删除!