*&---------------------------------------------------------------------*
*& 更改物料的MRP区域数据
*&---------------------------------------------------------------------*
REPORT ZMM025 NO STANDARD PAGE HEADING .
DATA: S_MDMA LIKE MDMA,
S_DPOP LIKE DPOP,
S_SELFIELDS LIKE SDIBE_MASSFIELDS,
RETURN LIKE BAPIRETURN1 .
DATA:HAD .
DATA: BEGIN OF ITAB OCCURS 0 ,
MATNR LIKE MARA-MATNR ,
WERKS LIKE MARC-WERKS ,
BERID LIKE MDMA-BERID ,
DISPO LIKE MDMA-DISPO ,
LGPRO LIKE MDMA-LGPRO ,
LGFSB LIKE MDMA-LGFSB ,
END OF ITAB.
DATA: FILENAME TYPE STRING ,
LF_RC TYPE C .
PARAMETERS:OPENFILE LIKE IBIPPARMS-PATH OBLIGATORY DEFAULT 'c:\ZMM025.txt' .
AT SELECTION-SCREEN ON VALUE-REQUEST FOR OPENFILE .
CALL FUNCTION 'F4_FILENAME'
EXPORTING
PROGRAM_NAME = SYST-CPROG
DYNPRO_NUMBER = SYST-DYNNR
FIELD_NAME = ' '
IMPORTING
FILE_NAME = OPENFILE.
AT SELECTION-SCREEN .
FILENAME = OPENFILE.
CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_EXIST
EXPORTING
FILE = FILENAME
RECEIVING
RESULT = LF_RC
EXCEPTIONS
CNTL_ERROR = 1
ERROR_NO_GUI = 2
WRONG_PARAMETER = 3
NOT_SUPPORTED_BY_GUI = 4
OTHERS = 5.
IF LF_RC <> 'X'.
MESSAGE E000(OO) WITH '文件不存在'.
ENDIF.
START-OF-SELECTION.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = FILENAME
FILETYPE = 'DAT'
TABLES
DATA_TAB = ITAB.
* itab-matnr = '001100000000000385'.
* itab-werks = '1010'.
* itab-berid = '1010CG'.
* itab-dispo = '102'.
* itab-lgpro = '1040'.
* itab-lgfsb = '1040'.
* APPEND itab.
LOOP AT ITAB WHERE MATNR = '' OR WERKS = '' OR BERID = ''.
IF HAD <> 'X'.
WRITE : '下列物料信息不全:'.
HAD = 'X'.
ENDIF.
WRITE : / ITAB-MATNR ,ITAB-WERKS ,ITAB-BERID .
ENDLOOP.
ULINE.
LOOP AT ITAB WHERE MATNR <> '' AND WERKS <> '' AND BERID <> ''.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = ITAB-MATNR
IMPORTING
OUTPUT = ITAB-MATNR.
CLEAR S_MDMA.
MOVE-CORRESPONDING ITAB TO S_MDMA .
CLEAR S_SELFIELDS.
IF ITAB-DISPO <> ''.
S_SELFIELDS-XDISPO = 'X'.
ENDIF.
IF ITAB-LGFSB <> ''.
S_SELFIELDS-XLGFSB = 'X'.
ENDIF.
IF ITAB-LGPRO <> ''.
S_SELFIELDS-XLGPRO = 'X'.
ENDIF.
CALL FUNCTION 'MD_MRP_LEVEL_CHANGE_DATA'
EXPORTING
I_MATNR = ITAB-MATNR
I_WERK = ITAB-WERKS
I_MRP_AREA = ITAB-BERID
I_BERTY = '02'
I_SELFIELDS = S_SELFIELDS
I_MDMA = S_MDMA
I_DPOP = S_DPOP
IMPORTING
E_ERROR_RETURN = RETURN.
IF NOT RETURN IS INITIAL .
WRITE : / ITAB-MATNR ,ITAB-WERKS ,ITAB-BERID .
PERFORM WRITE_WA USING RETURN 'XXXX' '' '' .
ELSE.
WRITE : / ITAB-MATNR,ITAB-WERKS ,ITAB-BERID ,'成功更改!'.
ENDIF.
CLEAR RETURN.
ENDLOOP.
*---------------------------------------------------------------------*
* FORM write_wa *
*---------------------------------------------------------------------*
FORM WRITE_WA USING WA FIELDMASK NEWLINE ALLLEN.
DATA: STR TYPE STRING ,
STR_IDX TYPE STRING ,
F_INDEX TYPE I ,
F_LEN TYPE I .
FIELD-SYMBOLS: .
F_LEN = STRLEN( FIELDMASK ).
IF NEWLINE = 'X'. WRITE / ''.ENDIF.
* POSITION 1 .
DO .
ASSIGN COMPONENT SY-INDEX OF STRUCTURE WA TO .
IF SY-SUBRC <> 0 OR SY-INDEX > F_LEN.
EXIT.
ELSE.
STR_IDX = SY-INDEX .
CONDENSE STR_IDX.
F_INDEX = SY-INDEX - 1.
IF FIELDMASK+F_INDEX(1) = 'X'.
IF ALLLEN = ''.
STR = .
WRITE STR.
ELSE.
WRITE .
ENDIF.
ENDIF.
ENDIF.
ENDDO.
ENDFORM. "write_wa
阅读(939) | 评论(0) | 转发(1) |