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.

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

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

C语言—数据类型

变量和基本数据类型 变量类型的概念 变量是在程序中可以发生变化的量&#xff0c;变量是有类型的&#xff0c;变量的类型决定了变量存储空间的大小以及如何解释存储的位模式。 1字节&#xff08;Byte&#xff09;8位&#xff08;bit&#xff09; 定义格式 存储类型 数据…

基于Java+Springboot+Mybatis+Vue+微信小程序的轿车改装设计方案

微信小程序的轿车改装设计方案,用户可以自行在小程序中查看某型号轿车的零件&#xff0c;可以查看相关的汽车资源。 一、API1.1 SpringBoot框架搭建1.2 数据库设计1.3 实体映射创建Mapper1.4 接口封装1.5 常用字段类型 二、小程序2.1 项目创建2.2 首页2.3 产品中心页 三、管理端…

[C#]winform利用seetaface6实现C#人脸检测活体检测口罩检测年龄预测性别判断眼睛状态检测

【官方框架地址】 https://github.com/ViewFaceCore/ViewFaceCore 【算法介绍】 SeetaFace6是由中国科技公司自主研发的一款人脸识别技术&#xff0c;它基于深度学习算法&#xff0c;能够快速、准确地识别出人脸&#xff0c;并且支持多种应用场景&#xff0c;如门禁系统、移动…

通过Kuboard部署Nginx服务并映射挂载NFS服务器

这里写目录标题 一、项目概述二、环境三、样式nginx运行页面nginx挂载存储页面nginx服务service页面index代理网页 四、部署流程集群导入NFS服务器搭建新建nginx工作负载配置拷贝配置信息到NFS 五、总结 一、项目概述 使用Kuboard图形化页面部署Nginx工作负载&#xff0c;代理…

FineBI实战项目一(8):每天每小时订单笔数

1 明确数据分析目标 统计每个小时产生的订单个数 2 创建用于保存数据分析结果的表 create table app_hour_orders(id int primary key auto_increment,daystr varchar(20),hourstr varchar(20),cnt int ); 3 编写SQL语句进行数据分析 selectsubstring(createTime,1,10) as …

SpringBoot pom.xml文件标签含义

Pom文件 基本构成 通过最简单的一个SpringBoot项目的 Pom文件来了解一下Pom文件的基本构成 <?xml version"1.0" encoding"UTF-8"?> <project xmlns"http://maven.apache.org/POM/4.0.0" xmlns:xsi"http://www.w3.org/2001/XML…

Failed to create CUDAExecutionProvider 使用onnxruntime-gpu未成功调用gpu

最近在使用GPU对onnx模型进行加速过程中&#xff08;仅针对N卡&#xff0c;毕竟也没有别的显卡了。。&#xff09;&#xff0c;遇到了点问题&#xff1a;就是明明在安装了合适版本的显卡驱动和CUDA后&#xff0c;onnx还是不能够成功调用GPU&#xff0c;并且还出现了先导入torch…

专属定制适合个人的知识付费平台,打造个性化品牌与自主管理体验

明理信息科技知识付费saas租户平台 在当今数字化时代&#xff0c;知识付费平台已经成为人们获取专业知识、提升自身素质的重要渠道。然而&#xff0c;公共知识付费平台虽然内容丰富&#xff0c;但难以满足个人或企业个性化的需求和品牌打造。因此&#xff0c;我们提出了专属定…

代码随想录算法训练营day6|242.有效的字母异位词、349.两个数组的交集、202.快乐数

哈希表理论基础 建议&#xff1a;大家要了解哈希表的内部实现原理&#xff0c;哈希函数&#xff0c;哈希碰撞&#xff0c;以及常见哈希表的区别&#xff0c;数组&#xff0c;set 和map。 什么时候想到用哈希法&#xff0c;当我们遇到了要快速判断一个元素是否出现集合里的时…

大图切片预览

文章目录 前言处理流程完整代码前端预览 前言 最近有需求&#xff0c;前端要预览百兆以上的大图&#xff0c;这直接访问应该就不太行了&#xff0c;系统打开都在加载好一会儿&#xff0c;刚好从事的又是 gis 行业&#xff0c;于是打算用类似加载地图的方式来切片加载大图。这里…

视频做成二维码查看?多格式视频二维码生成器的使用方法

现在音视频是工作和生活中经常需要使用的一种内容表现形式&#xff0c;很多人都通过这种方式来查看视频内容&#xff0c;比如产品介绍、使用说明、安装教程等。通过一个二维码就可以来承载视频内容&#xff0c;与传统的方式相比拥有更快的内容传播速度&#xff0c;简化用户获取…

04.SpringCloud网关-gateway

1.Gateway服务网关 Spring Cloud Gateway 是 Spring Cloud 的一个全新项目&#xff0c;该项目是基于 Spring 5.0&#xff0c;Spring Boot 2.0 和 Project Reactor 等响应式编程和事件流技术开发的网关&#xff0c;它旨在为微服务架构提供一种简单有效的统一的 API 路由管理方式…

Stm32cube keil5配置串口printf 蓝牙打印不出来

1.检查cube里面波特率是否与AT蓝牙设置一致 2.keil里面设置是否打开Use MicroLIB 3、stm32cube是否开启串口中断 4.检测线路是否接触不良&#xff0c;读写线插反等。

这一次技术学习分享,超过苦读30本书

同学们&#xff0c;做个问卷调查&#xff0c;你参加了这次由腾讯云主办的第四期“云梯计划”了不&#xff1f; “云梯计划”已连续举办三年&#xff0c;免费为超过1万名大学生提供了腾讯云认证培训和考试名额&#xff0c;帮助其提升就业竞争力。 想要得到免费的系统性、实战性…

SpringBoot集成 Websocket 实现服务与客户端进行消息发送和接收

介绍 WebSocket是一种在单个TCP连接上进行全双工通信的协议。WebSocket使得客户端和服务器之间的数据交换变得更加简单,允许服务端主动向客户端推送数据。 效果 客户端效果 服务端日志 pom依赖 <!-- websocket --> <dependency><groupId>org.springfram…

APM32F035有感矢量控制方案

一、先来几句废话 首先这两年公司越来越多的开始使用国产的MCU&#xff0c;用过GD32、AT32、APM32等等&#xff0c;目前稳定使用的是APM32,包括身边朋友工作室&#xff0c;也开始从TI、STM、NXP换成APM32。上个月有幸拿到APM32F035电路控制板&#xff0c;非常感谢面包板社区提供…

Pytest自动化测试框架

1、pytest简介 pytest是Python的一种单元测试框架&#xff0c;与python自带的unittest测试框架类似&#xff0c;但是比unittest框架使用起来更简洁&#xff0c;效率更高。 执行测试过程中可以将某些测试跳过&#xff0c;或者对某些预期失败的case标记成失败能够支持简单的单元…

服务器网卡介绍

本篇文章对服务器网卡进行基础介绍&#xff0c;包括基本概念、网卡厂商及网卡绑定策略等。 1、基本概念 服务器网卡&#xff08;Network Interface Card&#xff09;是一种用于连接服务器与网络之间的硬件设备。它允许服务器通过网络与其他设备进行通信&#xff0c;包括传输数…

九州金榜孩子厌学原因及解决方法

厌学是根据不同类型孩子&#xff0c;表现也有差异&#xff0c;但是者都会对成绩产生很大的影响。那么作为家长&#xff0c;我们应该怎么面对不同类型孩子的厌学&#xff0c;又该怎么样去解决呢&#xff0c;我们要如何让孩子重拾学习的信心呢&#xff1f;下面&#xff0c;我们从…

如何查看崩溃日志

​ 目录 描述 思路 查看ipa包崩溃日志 简单查看手机崩溃信息几种方式 方式1:手机设置查看崩溃日志 方式2: Xocde工具 方式3: 第三方软件克魔助手 环境配置 实时日志 奔溃日志分析 方式四&#xff1a;控制台资源库 线上崩溃日志 线上监听crash的几种方式 方式1: 三…