vk11写入ZWX2的价格
SAP
SPAN {
font-family: “Courier New”;
font-size: 10pt;
color: #000000;
background: #FFFFFF;
}
.L0S31 {
font-style: italic;
color: #808080;
}
.L0S32 {
color: #3399FF;
}
.L0S33 {
color: #4DA619;
}
.L0S52 {
color: #0000FF;
}
.L0S55 {
color: #800080;
}
.L0S70 {
color: #808080;
}
FUNCTION ZBAPI_ZWX2.
*"----------------------------------------------------------------------
"“本地接口:
*” EXPORTING
" VALUE(E_MSGTY) TYPE SY-MSGTY
" VALUE(E_MESSAGE) TYPE CHAR250
" TABLES
" TAB_KONP STRUCTURE ZBAPI_ZWX2
"----------------------------------------------------------------------
日期转换成与SU01相同的格式
DEFINE mcr_date_external.
IF &1 IS NOT INITIAL.
CALL FUNCTION ‘CONVERT_DATE_TO_EXTERNAL’
EXPORTING
date_internal = &1
IMPORTING
date_external = &2
EXCEPTIONS
date_internal_is_invalid = 1.
ENDIF.
END-OF-DEFINITION.
DEFINE mcr_check_data.
if &1 is INITIAL.
if TAB_KONP-message is INITIAL.
TAB_KONP-message = &2.
else.
CONCATENATE TAB_KONP-message &2 INTO TAB_KONP-message SEPARATED BY ‘/’.
endif.
CONDENSE TAB_KONP-message NO-GAPS.
endif.
END-OF-DEFINITION.
DATA:lv_datab(10) TYPE c,
lv_datbi(10) TYPE c.
DATA:lv_kbetr(12) TYPE c.
DATA:lv_mode(1) TYPE c VALUE ‘N’,
lv_msg TYPE string.
DATA:lv_datum LIKE sy-datum,
lv_uzeit LIKE sy-uzeit.
DATA:lt_ztmst013 LIKE TABLE OF ztmst013,
ls_ztmst013 LIKE ztmst013.
DATA:lv_error(10) TYPE c VALUE ‘0’,
lv_success(10) TYPE c VALUE ‘0’.
lv_datum = sy-datum.
lv_uzeit = sy-uzeit.
LOOP AT tab_konp.
mcr_check_data:tab_konp-matnr '物料号为空',
tab_konp-kschl '条件类型为空',
tab_konp-kbetr '价格为空',
tab_konp-konwa '单位为空',
tab_konp-datab '有效日期从为空',
tab_konp-datbi '有效日期到为空'.
IF tab_konp-kschl EQ 'ZWX2'.
mcr_check_data:tab_konp-kunnr '客户为空'.
ENDIF.
IF tab_konp-kschl NE 'ZWX2' .
CONCATENATE tab_konp-message '条件类型只能为ZWX2' INTO tab_konp-message SEPARATED BY '/'.
CONDENSE tab_konp-message NO-GAPS.
SHIFT tab_konp-message LEFT DELETING LEADING '/'.
ENDIF.
IF tab_konp-message IS INITIAL.
PERFORM frm_bdc_dynpro USING 'SAPMV13A' '0100'.
PERFORM frm_bdc_field USING 'BDC_OKCODE' '/00'.
PERFORM frm_bdc_field USING 'RV13A-KSCHL' tab_konp-kschl.
***转换日期为外部格式
CLEAR:lv_datab,lv_datbi.
mcr_date_external: tab_konp-datab lv_datab,
tab_konp-datbi lv_datbi.
lv_kbetr = tab_konp-kbetr.
PERFORM frm_bdc_dynpro USING 'SAPLV14A' '0100'.
PERFORM frm_bdc_field USING 'BDC_OKCODE' '=WEIT'.
PERFORM frm_bdc_field USING 'RV130-SELKZ(01)' 'X'.
PERFORM frm_bdc_dynpro USING 'SAPMV13A' '1005'.
PERFORM frm_bdc_field USING 'BDC_OKCODE' '=SICH'.
PERFORM frm_bdc_field USING 'KOMG-VKORG' tab_konp-vkorg.
PERFORM frm_bdc_field USING 'KOMG-VTWEG' tab_konp-vtweg.
PERFORM frm_bdc_field USING 'KOMG-KUNNR' tab_konp-kunnr.
PERFORM frm_bdc_field USING 'KOMG-MATNR(01)' tab_konp-matnr .
PERFORM frm_bdc_field USING 'KONP-KBETR(01)' lv_kbetr .
PERFORM frm_bdc_field USING 'KONP-KONWA(01)' tab_konp-konwa.
PERFORM frm_bdc_field USING 'RV13A-DATAB(01)' lv_datab.
PERFORM frm_bdc_field USING 'RV13A-DATBI(01)' lv_datbi.
CALL TRANSACTION 'VK11' USING bdcdata_itab MODE lv_mode UPDATE 'S' MESSAGES INTO messtab.
LOOP AT messtab WHERE msgtyp = 'E' OR msgtyp = 'A'.
EXIT.
ENDLOOP.
IF sy-subrc = 0.
LOOP AT messtab WHERE msgtyp = 'E' OR msgtyp = 'A'.
CLEAR lv_msg.
CALL FUNCTION 'MESSAGE_TEXT_BUILD'
EXPORTING
msgid = messtab-msgid
msgnr = messtab-msgnr
msgv1 = messtab-msgv1
msgv2 = messtab-msgv2
msgv3 = messtab-msgv3
msgv4 = messtab-msgv4
IMPORTING
message_text_output = lv_msg.
IF tab_konp-message IS INITIAL.
tab_konp-message = lv_msg.
ELSE.
CONCATENATE tab_konp-message lv_msg INTO tab_konp-message.
ENDIF.
ENDLOOP.
tab_konp-msgty = 'E'.
ADD 1 TO lv_error.
ELSE.
tab_konp-msgty = 'S'.
tab_konp-message = '成功'.
ADD 1 TO lv_success.
ENDIF.
ELSE.
tab_konp-msgty = 'E'.
ADD 1 TO lv_error.
ENDIF.
MODIFY tab_konp.
***记录日志信息
MOVE-CORRESPONDING tab_konp TO ls_ztmst013.
ls_ztmst013-erdat = lv_datum.
ls_ztmst013-ertim = lv_uzeit.
APPEND ls_ztmst013 TO lt_ztmst013.
CLEAR:ls_ztmst013.
REFRESH:bdcdata_itab,messtab.
ENDLOOP.
IF lt_ztmst013[] IS NOT INITIAL.
MODIFY ztmst013 FROM TABLE lt_ztmst013.
COMMIT WORK AND WAIT.
ENDIF.
e_msgty = ‘S’.
CONDENSE:lv_success ,lv_error NO-GAPS.
CONCATENATE ‘处理完成,成功条数:’ lv_success ‘失败条数:’ lv_error INTO e_message.
CONDENSE e_message NO-GAPS.
ENDFUNCTION.
推荐阅读