ME11/ME12拷贝采购信息记录

news2024/11/24 21:06:00

注意点:
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.

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1366704.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

软件测试|Linux基础教程:cp命令详解,复制文件或目录

简介 在Linux系统中&#xff0c;cp命令是一个非常常用且强大的命令&#xff0c;用于复制文件和目录。cp命令允许我们在不同目录之间复制文件或目录&#xff0c;并可以根据需求对文件复制的行为进行调整。在本文中&#xff0c;我们将详细解释cp命令的用法以及一些常见的选项。 …

spark的任务提交方式及流程

本地模式 local 测试用,不多赘述 分布式模式 standalone standalone集群是spark 自带的一个资源调度集群&#xff0c;分为两个角色&#xff0c;master/worker&#xff0c;master负责接收任务请求、资源调度&#xff08;监听端口7077&#xff09;&#xff0c;worker负责运行exec…

深入了解鸿鹄工程项目管理系统源码:功能清单与项目模块的深度解析

工程项目管理软件是现代项目管理中不可或缺的工具&#xff0c;它能够帮助项目团队更高效地组织和协调工作。本文将介绍一款功能强大的工程项目管理软件&#xff0c;该软件采用先进的Vue、Uniapp、Layui等技术框架&#xff0c;涵盖了项目策划决策、规划设计、施工建设到竣工交付…

Java如何拷贝数据?

Java如何拷贝数据&#xff1f; 在 Java 中&#xff0c;数组和集合的深拷贝与浅拷贝的概念与复制对象的引用和内容相关。深拷贝是创建一个新对象&#xff0c;并递归地复制其所有内容&#xff0c;而浅拷贝则只是复制对象的引用。 数组的深拷贝与浅拷贝&#xff1a; 1. 深拷贝数…

金和OA C6 HomeService.asmx SQL注入漏洞复现

0x01 产品简介 金和网络是专业信息化服务商,为城市监管部门提供了互联网+监管解决方案,为企事业单位提供组织协同OA系统开发平台,电子政务一体化平台,智慧电商平台等服务。 0x02 漏洞概述 金和OA C6 HomeService.asmx接口处存在SQL注入漏洞,攻击者除了可以利用 SQL 注入漏洞…

量子革命的基础:激光冷却史(下)

本文是《激光冷却史》系列的最后一部分。 在20世纪的最后20年里&#xff0c;原子物理学家屡次打破宇宙中最冷温度的记录。这些成就有赖于一些进步&#xff0c;包括激光冷却&#xff08;《激光冷却史&#xff08;上&#xff09;》&#xff09;、磁光阱和西西弗斯冷却等技术&…

DES算法(Python实现)

一、具体描述 基于计算机高级语言&#xff08;如C语言&#xff09;实现DES算法 二、名词术语与相关知识 DES算法 DES&#xff08;Data Encryption Standard&#xff09;是一种对称加密算法&#xff0c;被广泛应用于数据加密领域。它使用64位密钥和64位明文&#xff0c;通过…

西门子WinCC的C脚本——对象的事件任务

1、 全局脚本编辑器&#xff1b; 2、 对象的属性任务&#xff1b; 3、 对象的事件任务。 本文探讨一下用C脚本来实现对象的事件任务。 一、例程说明引文&#xff1a;博途工控人平时在哪里技术交流博途工控人社群 如图1所示&#xff0c;为本例程的运行画面。本例程实现以下…

大数据 Hive - 实现SQL执行

文章目录 MapReduce实现SQL的原理Hive的架构Hive如何实现join操作小结 MapReduce的出现大大简化了大数据编程的难度&#xff0c;使得大数据计算不再是高不可攀的技术圣殿&#xff0c;普通工程师也能使用MapReduce开发大数据程序。 但是对于经常需要进行大数据计算的人&#xff…

没经验没资金,适合穷人创业项目的低成本生意

什么人可以赚到钱呢&#xff1f;不管你怎么都赚不到&#xff0c;那归根结底是因为你身边没有明白人。像我们普通人一没经验二没资金三没人脉&#xff0c;该如何创业呢&#xff1f; 第一点&#xff0c;如果你不知道干什么&#xff0c;就做黄牛&#xff0c;只当渠道&#xff0c;只…

Web前端篇——ElementUI之el-scrollbar + el-backtop + el-timeline实现时间轴触底刷新和一键返回页面顶部

ElementUI之el-scrollbar el-backtop el-timeline实现时间轴触底刷新和一键返回页面顶部。 背景&#xff1a;ElementUI的版本&#xff08;vue.global.js 3.2.36&#xff0c; index.css 2.4.4&#xff0c; index.full.js 2.4.4&#xff09; 废话不多说&#xff0c;先看动…

猫头虎分享已解决Bug || Error: ImagePullBackOff (K8s)

博主猫头虎的技术世界 &#x1f31f; 欢迎来到猫头虎的博客 — 探索技术的无限可能&#xff01; 专栏链接&#xff1a; &#x1f517; 精选专栏&#xff1a; 《面试题大全》 — 面试准备的宝典&#xff01;《IDEA开发秘籍》 — 提升你的IDEA技能&#xff01;《100天精通Golang》…

(二)Explain使用与详解

explain中的列 sql语句: EXPLAIN SELECT * from user WHERE userId=1340; 执行结果: 1. id列 id列的编号是 select 的序列号,有几个 select 就有几个id,并且id的顺序是按 select 出现的顺序增长的。 id列越大执行优先级越高,id相同则从上往下执行,id为NULL最后执行…

python股票分析挖掘预测技术指标知识之蜡烛图指标(6)

本人股市多年的老韭菜&#xff0c;各种股票分析书籍&#xff0c;技术指标书籍阅历无数&#xff0c;萌发想法&#xff0c;何不自己开发个股票预测分析软件&#xff0c;选择python因为够强大&#xff0c;它提供了很多高效便捷的数据分析工具包。 我们已经初步的接触与学习其中数…

7.27 SpringBoot项目实战 之 整合Swagger

文章目录 前言一、Maven依赖二、编写Swagger配置类三、编写接口配置3.1 控制器Controller 配置描述3.2 接口API 配置描述3.3 参数配置描述3.4 忽略API四、全局参数配置五、启用增强功能六、调试前言 在我们实现了那么多API以后,进入前后端联调阶段,需要给前端同学提供接口文…

软件测试|Python中的变量与关键字详解

简介 在Python编程中&#xff0c;变量和关键字是非常重要的概念。它们是构建和控制程序的基本要素。本文将深入介绍Python中的变量和关键字&#xff0c;包括它们的定义、使用方法以及一些常见注意事项。 变量 变量的定义 变量是用于存储数据值的名称。在Python中&#xff0…

java每日一题——输出9x9乘法表(答案及编程思路)

前言&#xff1a; 打好基础&#xff0c;daydayup! 题目&#xff1a;输出下图9x9乘法表 编程思路&#xff1a;java只能输出行&#xff0c;不能输出列&#xff0c;所以考虑好每一行输出的内容即可 public class demo {public static void main(String[] args) {for (int i 1; i…

静态网页设计——清雅古筝网(HTML+CSS+JavaScript)

前言 声明&#xff1a;该文章只是做技术分享&#xff0c;若侵权请联系我删除。&#xff01;&#xff01; 感谢大佬的视频&#xff1a; https://www.bilibili.com/video/BV1T64y1K7Zn/?vd_source5f425e0074a7f92921f53ab87712357b 使用技术&#xff1a;HTMLCSSJS&#xff08;…

物理机与vm文件共享与传输的设置方法

今天跟各位小伙伴&#xff0c;分享一下物理机与vm虚拟机文件共享与传输的设置方法&#xff0c;以供大家参考&#xff01; 一、物理机与虚拟机文件共享设置方法 第一步&#xff1a;先关闭虚拟机&#xff08;客户机&#xff09; 第二步&#xff1a;选择编辑虚拟机设置 第三步&am…

Java研学-Servlet3.0文件上传下载

一 文件上传 1 介绍 用户选择本地文件资源保存到服务器上&#xff0c;Servlet需要将二进制数据以文件保存到服务器磁盘中&#xff0c;再将磁盘路径保存到数据库中 2 项目搭建 创建web项目&#xff0c;并添加对应jar包(JSTL) 3 API HttpServletRequest 方法–从请求中解析上…