BDC
DATA: bdcdata LIKE bdcdata OCCURS 0 WITH HEADER LINE.
DATA: messtab LIKE bdcmsgcoll OCCURS 0 WITH HEADER LINE,
w_messtab TYPE bdcmsgcoll.
data: g_message TYPE balmsgtxtp.
data: w_RETURN type BAPIRET2.
CLEAR t_return.
FREE messtab.
CLEAR messtab.
FREE bdcdata.
CLEAR bdcdata.
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'
i_lifnr. "
PERFORM bdc_field USING 'EINA-MATNR'
i_matnr. "
PERFORM bdc_field USING 'EINE-EKORG'
'1090'.
PERFORM bdc_field USING 'EINE-WERKS'
'1080'.
PERFORM bdc_field USING 'RM06I-NORMB'
'X'.
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-URZLA'
* 'CN'.
PERFORM bdc_field USING 'EINA-MEINS'
* 'PC'.
I_KMEIN.
PERFORM bdc_field USING 'EINA-UMREZ'
'1'.
PERFORM bdc_field USING 'EINA-UMREN'
'1'.
PERFORM bdc_field USING 'EINA-VABME' "激活单位
'1'.
PERFORM bdc_dynpro USING 'SAPMM06I' '0102'.
PERFORM bdc_field USING 'BDC_CURSOR'
'EINE-NETPR'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=KO'.
PERFORM bdc_field USING 'EINE-NORBM'
'10'. "
PERFORM bdc_field USING 'EINE-APLFZ'
'10'.
PERFORM bdc_field USING 'EINE-EKGRP'
'101'.
PERFORM bdc_field USING 'EINE-WEBRE'
'X'.
PERFORM bdc_field USING 'EINE-MWSKZ'
'P0'.
PERFORM bdc_field USING 'EINE-IPRKZ'
'D'.
PERFORM bdc_field USING 'EINE-NETPR'
'1.00'.
PERFORM bdc_field USING 'EINE-WAERS'
'USD'.
PERFORM bdc_field USING 'EINE-PEINH'
'1'.
PERFORM bdc_field USING 'EINE-BPRME'
'PC'.
PERFORM bdc_field USING 'EINE-BPUMZ'
'1'.
PERFORM bdc_field USING 'EINE-BPUMN'
'1'.
PERFORM bdc_dynpro USING 'SAPMV13A' '0201'.
PERFORM bdc_field USING 'BDC_CURSOR'
'RV13A-DATBI'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=SICH'.
PERFORM bdc_field USING 'RV13A-DATAB'
'20111111'.
PERFORM bdc_field USING 'RV13A-DATBI'
'20111111'.
CALL TRANSACTION 'ME11' USING bdcdata MODE i_ptype MESSAGES INTO
messtab.
WAIT UP TO 1 SECONDS.
LOOP AT messtab INTO w_messtab WHERE msgtyp = 'E'
OR msgtyp = 'A' OR msgtyp = 'S'.
PERFORM get_message USING w_messtab
CHANGING g_message .
w_return-TYPE = w_messtab-msgtyp.
w_return-MESSAGE = g_message.
append w_return to t_return.
clear w_return.
clear g_message.
ENDLOOP.
*----------------------------------------------------------------------*
***INCLUDE LZMM25F01 .
*----------------------------------------------------------------------*
*-------------------------------------------------------------------*
* Start new screen
*
*-------------------------------------------------------------------*
FORM bdc_dynpro USING program dynpro.
CLEAR bdcdata.
bdcdata-program = program.
bdcdata-dynpro = dynpro.
bdcdata-dynbegin = 'X'.
APPEND bdcdata.
ENDFORM. "bdc_dynpro
*-------------------------------------------------------------------*
* Insert field
*
*-------------------------------------------------------------------*
FORM bdc_field USING fnam fval.
CLEAR bdcdata.
bdcdata-fnam = fnam.
bdcdata-fval = fval.
APPEND bdcdata.
ENDFORM. "bdc_field
*&---------------------------------------------------------------------*
*& Form GET_MESSAGE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_WA_BDC_MESSAGE text
* <--P_WA_MESSAGE_MSG_TXT text
*----------------------------------------------------------------------*
FORM get_message USING lw_message TYPE bdcmsgcoll
CHANGING g_message TYPE balmsgtxtp.
clear g_message.
CALL FUNCTION 'MESSAGE_TEXT_BUILD'
EXPORTING
msgid = lw_message-msgid
msgnr = lw_message-msgnr
msgv1 = lw_message-msgv1
msgv2 = lw_message-msgv2
msgv3 = lw_message-msgv3
msgv4 = lw_message-msgv4
IMPORTING
message_text_output = g_message.
endform. " GET_MESSAGE