*&---------------------------------------------------------------------*
*& Report ZMMUPLD_RMDATIND
*&
*&---------------------------------------------------------------------*
*&
*& Report ZMMUPLD_RMDATIND
*&
*&---------------------------------------------------------------------*
*&
*&--------------------------------------------------------------------*
REPORT ZMMUPLD_RMDATIND NO STANDARD PAGE HEADING
LINE-SIZE 132
LINE-COUNT 65 MESSAGE-ID ZM..
* *&---------------------------------------------------------------------*
* *&
* *&
* *&---------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
* * Data declaration *
* *--------------------------------------------------------------------*
CONSTANTS: C_MAP LIKE MBEW-VPRSV VALUE 'V', "Moving average price
C_STNP LIKE MBEW-VPRSV VALUE 'S', "Standard price
C_LOGICALFILE LIKE FILENAME-FILEINTERN VALUE 'DHOOT_MM_UPLOAD'.
TABLES: MARA.
TYPES : BEGIN OF ty_upload1,
MATNR type MARA-MATNR ,
MBRSH type MARA-MBRSH ,
MTART type MARA-MTART ,
WERKS type MARC-WERKS ,
LGORT type MARD-LGORT ,
VKORG type BMM00-VKORG ,
VTWEG type BMM00-VTWEG ,
MAKTX type MAKT-MAKTX ,
MEINS type MARA-MEINS ,
MATKL type MARA-MATKL ,
SPART type MARA-SPART ,
BRGEW type MARA-BRGEW ,
GEWEI type MARA-GEWEI ,
NTGEW type MARA-NTGEW ,
EKGRP type MARC-EKGRP ,
DISGR type MARC-DISGR ,
DISMM type MARC-DISMM ,
DISPO type MARC-DISPO ,
DISLS type MARC-DISLS ,
BSTFE type MARC-BSTFE ,
MINBE type MARC-MINBE ,
BESKZ type MARC-BESKZ ,
RGEKZ type MARC-RGEKZ ,
WEBAZ type MARC-WEBAZ ,
FHORI type MARC-FHORI ,
PLIFZ type MARC-PLIFZ ,
EISBE type MARC-EISBE ,
MTVFP type MARC-MTVFP ,
SBDKZ type MARC-SBDKZ ,
LZEIH type MARC-LZEIH ,
MAXLZ type MARC-MAXLZ ,
MHDRZ type MARA-MHDRZ ,
IPRKZ type MARA-IPRKZ ,
MHDHB type MARA-MHDHB ,
PRCTR type MARC-PRCTR ,
BKLAS type MBEW-BKLAS ,
VPRSV type MBEW-VPRSV ,
VERPR type MBEW-VERPR ,
EKALR type MBEW-EKALR ,
HKMAT type MBEW-HKMAT ,
END OF ty_upload1.
DATA :it_upload1 TYPE TABLE OF ty_upload1.
DATA : wa_upload1 TYPE ty_upload1.
DATA: BEGIN OF IT_UPLOAD OCCURS 0,
MATNR type MARA-MATNR , "Material Number
MBRSH type MARA-MBRSH , "industry sector
MTART type MARA-MTART , "material type
WERKS type MARC-WERKS , "plant
LGORT type MARD-LGORT , "storage location
VKORG type BMM00-VKORG , "Sales Organization
VTWEG type BMM00-VTWEG , "Distribution Channel
MAKTX type MAKT-MAKTX , "material desc.
MEINS type MARA-MEINS , "base UOM
BISMT type MARA-BISMT , "old material no
EXTWG type MARA-EXTWG , "External Material Group
MATKL type MARA-MATKL , "material grp
SPART type MARA-SPART , "division
BRGEW type MARA-BRGEW , "gross weight
GEWEI type MARA-GEWEI , "weight unit
NTGEW type MARA-NTGEW , "net weight
MTPOS_MARA type MARA-MTPOS_MARA , "General item category group
VRKME type MVKE-VRKME , "Sales unit
DWERK type MVKE-DWERK , "Delivering Plant
VTEXT type TSKMT-VTEXT , "Description
AUMNG type MVKE-AUMNG , "Minimum order quantity in base unit of measure (BTCI)
LFMNG type MVKE-LFMNG , " Min. delivery quantity for delivery note processing (BTCI)
SCMNG type MVKE-SCMNG , "Delivery unit (BTCI)
SKTOF type MVKE-SKTOF , "Cash discount indicator
VERSG type MVKE-VERSG , "Material statistics group
KTGRM type MVKE-KTGRM , "Account assignment group for this material
MTPOS type MVKE-MTPOS , "Item category group from material master
*MTVFP type MARC-MTVFP , "availability check
TRAGR type MARA-TRAGR , "Transportation Group
LADGR type MARC-LADGR , "Loading Group
BSTME type MARA-BSTME , "Purchase Order Unit of Measure
EKGRP type MARC-EKGRP , "Purchasing group
EKWSL type MARA-EKWSL , "purchasing value key
DISGR type MARC-DISGR , "MRP Group
DISMM type MARC-DISMM , "MRP Type
DISPO type MARC-DISPO , "MRP Controller (Materials Planner)
DISLS type MARC-DISLS , "Lot size (materials planning)
BSTFE type MARC-BSTFE , "Fixed lot size (BTCI)
MINBE type MARC-MINBE , "Reorder point (BTCI)
BESKZ type MARC-BESKZ , "Procurement Type
SOBSL type MARC-SOBSL , "Special procurement type
RGEKZ type MARC-RGEKZ , "Indicator: Backflush
KZECH type MARC-KZECH , "Determination of batch entry in the production/process order
LGPRO type MARC-LGPRO , "Issue Storage Location
WEBAZ type MARC-WEBAZ , "Goods Receipt Processing Time in Days
FHORI type MARC-FHORI , "Scheduling Margin Key for Floats
PLIFZ type MARC-PLIFZ , "Planned Delivery Time in Days
EISBE type MARC-EISBE , "Safety Stock
STRGR type MARC-STRGR , "Planning strategy group
MTVFP type MARC-MTVFP , "Checking Group for Availability Check
ALTSL type MARC-ALTSL , "Method for Selecting Alternative Bills of Material
SBDKZ type MARC-SBDKZ , "Dependent requirements ind. for individual and coll. Reqmts
RAUBE type MARA-RAUBE , "Storage conditions
LZEIH type MARC-LZEIH , "Unit for maximum storage period
MAXLZ type MARC-MAXLZ , "Maximum storage period
MHDRZ type MARA-MHDRZ , "Minimum Remaining Shelf Life
IPRKZ type MARA-IPRKZ , "Period Indicator for Shelf Life Expiration Date
MHDHB type MARA-MHDHB , "Total shelf life
SERNP type MARC-SERNP , "Serial Number Profile
SERLV type MARA-SERLV , "Level of Explicitness for Serial Number
PRCTR type MARC-PRCTR , "Profit Center
BWTTY type MBEW-BWTTY , "Valuation Category
BKLAS type MBEW-BKLAS , "Valuation Class
VPRSV type MBEW-VPRSV , "Price Control Indicator
VERPR type MBEW-VERPR , "Moving Average Price/Periodic Unit Price
STPRS type MBEW-STPRS , "Standard price
EKALR type MBEW-EKALR , "Material Is Costed with Quantity Structure
HKMAT type MBEW-HKMAT , "Material-related origin
PLNNR type MARC-PLNNR , "Key for Task List Group
PLNTY type MARC-PLNTY , "Task List Type
END OF IT_UPLOAD.
DATA: BEGIN OF IT_ERROR OCCURS 0,
TABIX(10) TYPE N,
MATNR LIKE MARA-MATNR,
ERMSG(255) TYPE C,
END OF IT_ERROR.
DATA: V_FIELDTEXT(60) TYPE C,
V_FILENAME LIKE RLGRAP-FILENAME,
V_TABIX LIKE SY-TABIX.
DATA: W_BGR00 LIKE BGR00,
W_BMM00 LIKE BMM00,
W_BMMH1 LIKE BMMH1.
**----------------------------------------------------------------------*
* * Selection-Screen *
* *---------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-S01.
PARAMETERS: P_PCFILE LIKE RLGRAP-FILENAME OBLIGATORY,
P_TYPE LIKE RLGRAP-FILETYPE DEFAULT 'ASC',
P_TEST AS CHECKBOX DEFAULT 'X'.
SELECTION-SCREEN END OF BLOCK B1.
**----------------------------------------------------------------------*
* * At Selection-Screen *
* *---------------------------------------------------------------------*
AT SELECTION-SCREEN.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_PCFILE.
*BEGIN SYDK978748
DATA: L_FILE TYPE STRING,
T_FILES TYPE FILETABLE,
L_SUBRC TYPE I,
L_TITLE TYPE STRING VALUE 'File System for Pres. Server'.
L_file = '000000'.
L_FILE = P_PCFILE.
CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_OPEN_DIALOG
EXPORTING
WINDOW_TITLE = L_TITLE
DEFAULT_FILENAME = L_FILE
CHANGING
FILE_TABLE = T_FILES
RC = L_SUBRC
EXCEPTIONS
FILE_OPEN_DIALOG_FAILED = 1
CNTL_ERROR = 2
ERROR_NO_GUI = 3
OTHERS = 4.
READ TABLE T_FILES INDEX 1 INTO P_PCFILE.
*** CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
* ** EXPORTING
* * MASK = ',txt,.txt'
* ** STATIC = 'X'
* ** CHANGING
* ** FILE_NAME = P_PCFILE.
* *----------------------------------------------------------------------*
* * START OF SELECTION *
* *----------------------------------------------------------------------*
START-OF-SELECTION.
** upload file
PERFORM UPLOAD_PC_FILE.
** checking master data
PERFORM DATA_CHECKING.
** if actual run and if no mapping errors, upload the data
CHECK ( P_TEST IS INITIAL AND
IT_ERROR[] IS INITIAL ).
*** PERFORM UPLOAD_DATA.
*----------------------------------------------------------------------*
* END OF SELECTION *
*----------------------------------------------------------------------*
END-OF-SELECTION.
PERFORM PRINT_MAPPING_ERRORS.
PERFORM UPLOAD_DATA.
**&----------------------------------------------------------------------*
* *& Form UPLOAD_PC_FILE
* *&---------------------------------------------------------------------*
* * text
* *----------------------------------------------------------------------*
* * --> p1 text
* * <-- p2 text
* *----------------------------------------------------------------------*
FORM UPLOAD_PC_FILE.
DATA: IT_TEMP(4096) TYPE C OCCURS 0.
DATA:it_temp1 TYPE STANDARD TABLE OF alsmex_tabline.
DATA : wa_temp1 TYPE alsmex_tabline.
data: l_file type string.
DATA: L_SEPA TYPE C.
IF P_TYPE = 'DAT'.
L_SEPA = 'X'.
ELSE.
L_SEPA = ' '.
ENDIF.
* l_file = P_PCFILE.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
filename = p_pcfile
i_begin_col = 1
i_begin_row = 4
i_end_col = 256
i_end_row = 65536
TABLES
intern = it_temp1
* EXCEPTIONS
* INCONSISTENT_PARAMETERS = 1
* UPLOAD_OLE = 2
* OTHERS = 3
.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
sort it_temp1 by row col.
LOOP AT it_temp1 INTO wa_temp1.
CASE wa_temp1-col.
when '0001' . wa_upload1-MATNR = wa_temp1-value .
when '0002' . wa_upload1-MBRSH = wa_temp1-value .
when '0003' . wa_upload1-MTART = wa_temp1-value .
when '0004' . wa_upload1-WERKS = wa_temp1-value .
when '0005' . wa_upload1-LGORT = wa_temp1-value .
when '0006' . wa_upload1-VKORG = wa_temp1-value .
when '0007' . wa_upload1-VTWEG = wa_temp1-value .
when '0008' . wa_upload1-MAKTX = wa_temp1-value .
when '0009' . wa_upload1-MEINS = wa_temp1-value .
when '0010' . wa_upload1-MATKL = wa_temp1-value .
when '0011' . wa_upload1-SPART = wa_temp1-value .
when '0012' . wa_upload1-BRGEW = wa_temp1-value .
when '0013' . wa_upload1-GEWEI = wa_temp1-value .
when '0014' . wa_upload1-NTGEW = wa_temp1-value .
when '0015' . wa_upload1-EKGRP = wa_temp1-value .
when '0016' . wa_upload1-DISGR = wa_temp1-value .
when '0017' . wa_upload1-DISMM = wa_temp1-value .
when '0018' . wa_upload1-DISPO = wa_temp1-value .
when '0019' . wa_upload1-DISLS = wa_temp1-value .
when '0020' . wa_upload1-BSTFE = wa_temp1-value .
when '0021' . wa_upload1-MINBE = wa_temp1-value .
when '0022' . wa_upload1-BESKZ = wa_temp1-value .
when '0023' . wa_upload1-RGEKZ = wa_temp1-value .
when '0024' . wa_upload1-WEBAZ = wa_temp1-value .
when '0025' . wa_upload1-FHORI = wa_temp1-value .
when '0026' . wa_upload1-PLIFZ = wa_temp1-value .
when '0027' . wa_upload1-EISBE = wa_temp1-value .
when '0028' . wa_upload1-MTVFP = wa_temp1-value .
when '0029' . wa_upload1-SBDKZ = wa_temp1-value .
when '0030' . wa_upload1-LZEIH = wa_temp1-value .
when '0031' . wa_upload1-MAXLZ = wa_temp1-value .
when '0032' . wa_upload1-MHDRZ = wa_temp1-value .
when '0033' . wa_upload1-IPRKZ = wa_temp1-value .
when '0034 '. wa_upload1-MHDHB = wa_temp1-value .
when '0035 '. wa_upload1-PRCTR = wa_temp1-value .
when '0036' . wa_upload1-BKLAS = wa_temp1-value .
when '0037' . wa_upload1-VPRSV = wa_temp1-value .
when '0038' . wa_upload1-VERPR = wa_temp1-value .
when '0039' . wa_upload1-EKALR = wa_temp1-value .
when '0040' . wa_upload1-HKMAT = wa_temp1-value .
ENDCASE.
at end of row.
APPEND wa_upload1 TO it_upload1.
*** MOVE-CORRESPONDING wa_upload1 to it_upload.
move: wa_upload1-MATNR to it_upload-MATNR ,
wa_upload1-MBRSH to it_upload-MBRSH ,
wa_upload1-MTART to it_upload-MTART ,
wa_upload1-WERKS to it_upload-WERKS ,
wa_upload1-LGORT to it_upload-LGORT ,
wa_upload1-VKORG to it_upload-VKORG ,
wa_upload1-VTWEG to it_upload-VTWEG ,
wa_upload1-MAKTX to it_upload-MAKTX ,
wa_upload1-MEINS to it_upload-MEINS ,
wa_upload1-MATKL to it_upload-MATKL ,
wa_upload1-SPART to it_upload-SPART ,
wa_upload1-BRGEW to it_upload-BRGEW ,
wa_upload1-GEWEI to it_upload-GEWEI ,
wa_upload1-NTGEW to it_upload-NTGEW ,
wa_upload1-EKGRP to it_upload-EKGRP ,
wa_upload1-DISGR to it_upload-DISGR ,
wa_upload1-DISMM to it_upload-DISMM ,
wa_upload1-DISPO to it_upload-DISPO ,
wa_upload1-DISLS to it_upload-DISLS ,
wa_upload1-BSTFE to it_upload-BSTFE ,
wa_upload1-MINBE to it_upload-MINBE ,
wa_upload1-BESKZ to it_upload-BESKZ ,
wa_upload1-RGEKZ to it_upload-RGEKZ ,
wa_upload1-WEBAZ to it_upload-WEBAZ ,
wa_upload1-FHORI to it_upload-FHORI ,
wa_upload1-PLIFZ to it_upload-PLIFZ ,
wa_upload1-EISBE to it_upload-EISBE ,
wa_upload1-MTVFP to it_upload-MTVFP ,
wa_upload1-SBDKZ to it_upload-SBDKZ ,
wa_upload1-LZEIH to it_upload-LZEIH ,
wa_upload1-MAXLZ to it_upload-MAXLZ ,
wa_upload1-MHDRZ to it_upload-MHDRZ ,
wa_upload1-IPRKZ to it_upload-IPRKZ ,
wa_upload1-MHDHB to it_upload-MHDHB ,
wa_upload1-PRCTR to it_upload-PRCTR ,
wa_upload1-BKLAS to it_upload-BKLAS ,
wa_upload1-VPRSV to it_upload-VPRSV ,
wa_upload1-VERPR to it_upload-VERPR ,
wa_upload1-EKALR to it_upload-EKALR ,
wa_upload1-HKMAT to it_upload-HKMAT .
APPEND it_upload.
endat.
ENDLOOP.
**** CALL FUNCTION 'GUI_UPLOAD'
**** EXPORTING
**** filename = l_file
**** filetype = 'ASC'
**** has_field_separator = L_SEPA
****
**** TABLES
**** data_tab = IT_TEMP
**** EXCEPTIONS
**** file_open_error = 1
**** file_read_error = 2
**** no_batch = 3
**** gui_refuse_filetransfer = 4
**** invalid_type = 5
**** no_authority = 6
**** unknown_error = 7
**** bad_data_format = 8
**** header_not_allowed = 9
**** separator_not_allowed = 10
**** header_too_long = 11
**** unknown_dp_error = 12
**** access_denied = 13
**** dp_out_of_memory = 14
**** disk_full = 15
**** dp_timeout = 16
**** OTHERS = 17.
******
****** CALL FUNCTION 'WS_UPLOAD'
****** EXPORTING
****** FILENAME = P_PCFILE
****** FILETYPE = P_TYPE
****** TABLES
****** DATA_TAB = IT_TEMP
****** EXCEPTIONS
****** CONVERSION_ERROR = 1
****** INVALID_TABLE_WIDTH = 2
****** INVALID_TYPE = 3
****** NO_BATCH = 4
****** UNKNOWN_ERROR = 5
****** FILE_OPEN_ERROR = 6
****** FILE_READ_ERROR = 7
****** OTHERS = 8.
IF SY-SUBRC NE 0.
MESSAGE S318 WITH TEXT-E01 P_PCFILE.
ENDIF.
****
**** CALL FUNCTION 'TEXT_CONVERT_TEX_TO_SAP'
**** EXPORTING
**** I_FIELD_SEPERATOR = ','
***** I_LINE_HEADER =
**** I_TAB_RAW_DATA = IT_TEMP
***** I_FILENAME = p_pcfile
**** TABLES
**** I_TAB_CONVERTED_DATA = IT_UPLOAD
***** EXCEPTIONS
***** CONVERSION_FAILED = 1
***** OTHERS = 2
**** .
****
**** IF SY-SUBRC NE 0.
**** MESSAGE S318 WITH TEXT-E04 P_PCFILE.
**** ENDIF.
ENDFORM. " UPLOAD_PC_FILE
*&---------------------------------------------------------------------*
*& Form DATA_CHECKING
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM DATA_CHECKING.
LOOP AT IT_UPLOAD.
V_TABIX = SY-TABIX.
* perform check_mara.
PERFORM CHECK_T137.
PERFORM CHECK_T134.
PERFORM CHECK_T001W.
PERFORM CHECK_T001L.
PERFORM CHECK_T006.
PERFORM CHECK_T023.
PERFORM CHECK_TSPA.
PERFORM CHECK_T024.
PERFORM CHECK_T438M.
PERFORM CHECK_T438A.
PERFORM CHECK_T024D.
PERFORM CHECK_T439A.
PERFORM CHECK_T460A.
PERFORM CHECK_T436A.
PERFORM CHECK_TMVF.
PERFORM CHECK_T159C.
PERFORM CHECK_T149.
PERFORM CHECK_T025.
PERFORM CHECK_PRICE_CTRL.
ENDLOOP.
ENDFORM. " DATA_CHECKING
*&---------------------------------------------------------------------*
*& Form get_field_description
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_IT_UPLOAD_MATNR text
* <--P_V_FIELDTEXT text
*----------------------------------------------------------------------*
FORM GET_FIELD_DESCRIPTION USING VALUE(P_FIELDNAME)
CHANGING P_TEXT.
CLEAR P_TEXT.
CALL FUNCTION 'TB_DATAELEMENT_GET_TEXTS'
EXPORTING
NAME = P_FIELDNAME
IMPORTING
DESCRIPTION = P_TEXT
EXCEPTIONS
NOT_FOUND = 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. " get_field_description
*&---------------------------------------------------------------------*
*& Form check_t137
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM CHECK_T137.
TABLES: T137.
SELECT SINGLE * FROM T137 WHERE MBRSH = IT_UPLOAD-MBRSH.
IF SY-SUBRC <> 0.
PERFORM KEEP_DATA_ERROR USING 'MBRSH'
IT_UPLOAD-MBRSH
SPACE.
ENDIF.
ENDFORM. " check_t137
*&---------------------------------------------------------------------*
*& Form check_t134
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM CHECK_T134.
TABLES: T134.
SELECT SINGLE * FROM T134 WHERE MTART = IT_UPLOAD-MTART.
IF SY-SUBRC <> 0.
PERFORM KEEP_DATA_ERROR USING 'MTART'
IT_UPLOAD-MTART
SPACE.
ENDIF.
ENDFORM. " check_t134
*&---------------------------------------------------------------------*
*& Form keep_data_error
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_0349 text
* -->P_IT_UPLOAD_MATNR text
*----------------------------------------------------------------------*
FORM KEEP_DATA_ERROR USING VALUE(P_FIELDNAME)
P_FIELDVALUE
P_WERKS.
MOVE V_TABIX TO IT_ERROR-TABIX.
MOVE IT_UPLOAD-MATNR TO IT_ERROR-MATNR.
PERFORM GET_FIELD_DESCRIPTION USING P_FIELDNAME
CHANGING V_FIELDTEXT.
CONCATENATE TEXT-T01 V_FIELDTEXT ':' P_WERKS P_FIELDVALUE
INTO IT_ERROR-ERMSG SEPARATED BY SPACE.
APPEND IT_ERROR.
ENDFORM. " keep_data_error
*&---------------------------------------------------------------------*
*& Form check_t001w
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM CHECK_T001W.
TABLES: T001W.
SELECT SINGLE * FROM T001W WHERE WERKS = IT_UPLOAD-WERKS.
IF SY-SUBRC <> 0.
PERFORM KEEP_DATA_ERROR USING 'WERKS_D'
IT_UPLOAD-WERKS
SPACE.
ENDIF.
ENDFORM. " check_t001w
*&---------------------------------------------------------------------*
*& Form check_t001l
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM CHECK_T001L.
** Storage location
PERFORM CHECK_STOR_LOC USING 'LGORT_D'
IT_UPLOAD-LGORT.
** Issue Stor. location
IF NOT IT_UPLOAD-LGPRO IS INITIAL.
PERFORM CHECK_STOR_LOC USING 'LGPRO'
IT_UPLOAD-LGPRO.
ENDIF.
** Stor. loc for EP
* IF NOT IT_UPLOAD-LGFSB IS INITIAL.
* PERFORM CHECK_STOR_LOC USING 'LGFSB'
* IT_UPLOAD-LGFSB.
* ENDIF.
ENDFORM. " check_t001l
*&---------------------------------------------------------------------*
*& Form check_t006
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM CHECK_T006.
** Base UOM
PERFORM CHECK_UOM USING 'MEINS'
IT_UPLOAD-MEINS.
** Weight unit
IF NOT IT_UPLOAD-GEWEI IS INITIAL.
PERFORM CHECK_UOM USING 'GEWEI'
IT_UPLOAD-GEWEI.
ENDIF.
** Volume unit
* IF NOT IT_UPLOAD-VOLEH IS INITIAL.
* PERFORM CHECK_UOM USING 'VOLEH'
* IT_UPLOAD-VOLEH.
* ENDIF.
ENDFORM. " check_t006
*&---------------------------------------------------------------------*
*& Form check_UOM
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_0536 text
* -->P_IT_UPLOAD_MEINS text
*----------------------------------------------------------------------*
FORM CHECK_UOM USING VALUE(P_FIELDNAME)
P_FIELDVALUE.
TABLES: T006.
SELECT SINGLE * FROM T006 WHERE MSEHI = P_FIELDVALUE.
IF SY-SUBRC <> 0.
PERFORM KEEP_DATA_ERROR USING P_FIELDNAME
P_FIELDVALUE
SPACE.
ENDIF.
ENDFORM. " check_UOM
*&---------------------------------------------------------------------*
* *& Form check_t023
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM CHECK_T023.
TABLES: T023.
SELECT SINGLE * FROM T023 WHERE MATKL = IT_UPLOAD-MATKL.
IF SY-SUBRC <> 0.
PERFORM KEEP_DATA_ERROR USING 'MATKL'
IT_UPLOAD-MATKL
SPACE.
ENDIF.
ENDFORM. " check_t023
*&---------------------------------------------------------------------*
*& Form check_tspa
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* * --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM CHECK_TSPA.
TABLES: TSPA.
CHECK NOT IT_UPLOAD-SPART IS INITIAL.
SELECT SINGLE * FROM TSPA WHERE SPART = IT_UPLOAD-SPART.
IF SY-SUBRC <> 0.
PERFORM KEEP_DATA_ERROR USING 'SPART'
IT_UPLOAD-SPART
SPACE.
ENDIF.
ENDFORM. " check_tspa
*&---------------------------------------------------------------------*
*& Form check_t024
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM CHECK_T024.
TABLES: T024.
SELECT SINGLE * FROM T024 WHERE EKGRP = IT_UPLOAD-EKGRP.
IF SY-SUBRC <> 0.
PERFORM KEEP_DATA_ERROR USING 'EKGRP'
IT_UPLOAD-EKGRP
SPACE.
ENDIF.
ENDFORM. " check_t024
*&---------------------------------------------------------------------*
*& Form check_t438m
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM CHECK_T438M.
TABLES: T438M.
CHECK NOT IT_UPLOAD-DISGR IS INITIAL.
SELECT SINGLE * FROM T438M WHERE WERKS = IT_UPLOAD-WERKS
AND MTART = IT_UPLOAD-DISGR.
IF SY-SUBRC <> 0.
PERFORM KEEP_DATA_ERROR USING 'DISGR'
IT_UPLOAD-DISGR
IT_UPLOAD-WERKS.
ENDIF.
ENDFORM. " check_t438m
*&---------------------------------------------------------------------*
*& Form check_t438a
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM CHECK_T438A.
TABLES: T438A.
SELECT SINGLE * FROM T438A WHERE DISMM = IT_UPLOAD-DISMM.
IF SY-SUBRC <> 0.
PERFORM KEEP_DATA_ERROR USING 'DISMM'
IT_UPLOAD-DISMM
SPACE.
ENDIF.
ENDFORM. " check_t438a
*&---------------------------------------------------------------------*
*& Form check_t024d
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM CHECK_T024D.
TABLES: T024D.
SELECT SINGLE * FROM T024D WHERE WERKS = IT_UPLOAD-WERKS
AND DISPO = IT_UPLOAD-DISPO.
IF SY-SUBRC <> 0.
PERFORM KEEP_DATA_ERROR USING 'DISPO'
IT_UPLOAD-DISPO
IT_UPLOAD-WERKS.
ENDIF.
ENDFORM. " check_t024d
*&---------------------------------------------------------------------*
*& Form check_t460a
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM CHECK_T460A.
TABLES: T460A.
CHECK NOT IT_UPLOAD-SOBSL IS INITIAL.
SELECT SINGLE * FROM T460A WHERE WERKS = IT_UPLOAD-WERKS
AND SOBSL = IT_UPLOAD-SOBSL.
IF SY-SUBRC <> 0.
PERFORM KEEP_DATA_ERROR USING 'SOBSL'
IT_UPLOAD-SOBSL
IT_UPLOAD-WERKS.
ENDIF.
ENDFORM. " check_t460a
*&---------------------------------------------------------------------*
*& Form check_stor_loc
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_T001L text
*----------------------------------------------------------------------*
FORM CHECK_STOR_LOC USING VALUE(P_FIELDNAME)
P_FIELDVALUE.
TABLES: T001L.
SELECT SINGLE * FROM T001L WHERE WERKS = IT_UPLOAD-WERKS
AND LGORT = P_FIELDVALUE.
IF SY-SUBRC <> 0.
PERFORM KEEP_DATA_ERROR USING P_FIELDNAME
P_FIELDVALUE
IT_UPLOAD-WERKS.
ENDIF.
ENDFORM. " check_stor_loc
*&---------------------------------------------------------------------*
*& Form check_t436a
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM CHECK_T436A.
TABLES: T436A.
SELECT SINGLE * FROM T436A WHERE WERKS = IT_UPLOAD-WERKS
AND FHORI = IT_UPLOAD-FHORI.
IF SY-SUBRC <> 0.
PERFORM KEEP_DATA_ERROR USING 'FHORI'
IT_UPLOAD-FHORI
IT_UPLOAD-WERKS.
ENDIF.
ENDFORM. " check_t436a
*&---------------------------------------------------------------------*
*& Form check_tmvf
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM CHECK_TMVF.
TABLES: TMVF.
SELECT SINGLE * FROM TMVF WHERE MTVFP = IT_UPLOAD-MTVFP.
IF SY-SUBRC <> 0.
PERFORM KEEP_DATA_ERROR USING 'MTVFP'
IT_UPLOAD-MTVFP
SPACE.
ENDIF.
ENDFORM. " check_tmvf
*&---------------------------------------------------------------------*
*& Form check_t159c
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM CHECK_T159C.
TABLES: T159C.
* CHECK NOT IT_UPLOAD-ABCIN IS INITIAL.
* SELECT SINGLE * FROM T159C WHERE WERKS = IT_UPLOAD-WERKS
* AND ABCIN = IT_UPLOAD-ABCIN.
* IF SY-SUBRC <> 0.
* PERFORM KEEP_DATA_ERROR USING 'ABCIN'
* IT_UPLOAD-ABCIN
* IT_UPLOAD-WERKS.
* ENDIF.
ENDFORM. " check_t159c
*&---------------------------------------------------------------------*
*& Form check_t149
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM CHECK_T149.
TABLES: T149.
CHECK NOT IT_UPLOAD-BWTTY IS INITIAL.
SELECT SINGLE * FROM T149 WHERE BWKEY = IT_UPLOAD-WERKS
AND BWTTY = IT_UPLOAD-BWTTY.
IF SY-SUBRC <> 0.
PERFORM KEEP_DATA_ERROR USING 'BWTTY_D'
IT_UPLOAD-BWTTY
IT_UPLOAD-WERKS.
ENDIF.
ENDFORM. " check_t149
*&---------------------------------------------------------------------*
*& Form check_t025
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM CHECK_T025.
TABLES: T025.
SELECT SINGLE * FROM T025 WHERE BKLAS = IT_UPLOAD-BKLAS.
IF SY-SUBRC <> 0.
PERFORM KEEP_DATA_ERROR USING 'BKLAS'
IT_UPLOAD-BKLAS
SPACE.
ENDIF.
ENDFORM. " check_t025
*&---------------------------------------------------------------------*
*& Form check_price_ctrl
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM CHECK_PRICE_CTRL.
IF ( IT_UPLOAD-VPRSV <> C_MAP AND
IT_UPLOAD-VPRSV <> C_STNP ).
PERFORM KEEP_DATA_ERROR USING 'VPRSV'
IT_UPLOAD-VPRSV
SPACE.
ENDIF.
ENDFORM. " check_price_ctrl
*&---------------------------------------------------------------------*
*& Form upload_data
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM UPLOAD_DATA.
** open file in UNIX for output
PERFORM OPEN_UNIX_FILE.
** header record
W_BGR00-STYPE = '0'.
W_BGR00-GROUP = 'MATERIAL_MASTER_UPLOAD'.
W_BGR00-MANDT = SY-MANDT.
W_BGR00-USNAM = SY-UNAME.
TRANSFER W_BGR00 TO V_FILENAME.
** load data into the direct input structures
** in the UNIX file
LOOP AT IT_UPLOAD.
W_BMM00-STYPE = '1'.
W_BMM00-TCODE = 'MM01'.
W_BMM00-XEIK1 = 'X'.
W_BMM00-XEIE1 = 'X'.
W_BMM00-XEID1 = 'X'.
W_BMM00-XEID2 = 'X'.
W_BMM00-XEID3 = 'X'.
W_BMM00-XEIL1 = 'X'.
W_BMM00-XEIB1 = 'X'.
SELECT SINGLE * FROM MARA WHERE MATNR EQ IT_UPLOAD-MATNR.
IF SY-SUBRC EQ 0.
CLEAR W_BMM00-XEIK1.
ENDIF.
** End of addition
MOVE-CORRESPONDING IT_UPLOAD TO W_BMM00.
TRANSFER W_BMM00 TO V_FILENAME.
W_BMMH1-STYPE = '2'.
MOVE-CORRESPONDING IT_UPLOAD TO W_BMMH1.
IF IT_UPLOAD-VPRSV = 'S'.
CLEAR W_BMMH1-VERPR.
MOVE IT_UPLOAD-VERPR TO W_BMMH1-STPRS.
ENDIF.
TRANSFER W_BMMH1 TO V_FILENAME.
CLEAR : W_BMM00, W_BMMH1.
ENDLOOP.
** call direct input program to create the materials
** from the UNIX file
SUBMIT RMDATIND AND RETURN
WITH LDS_NAME = C_LOGICALFILE
WITH SPERR = 'E'.
ENDFORM. " upload_data
*&---------------------------------------------------------------------*
*& Form open_unix_file
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM OPEN_UNIX_FILE.
CALL FUNCTION 'FILE_GET_NAME'
EXPORTING
LOGICAL_FILENAME = C_LOGICALFILE
IMPORTING
FILE_NAME = V_FILENAME
EXCEPTIONS
FILE_NOT_FOUND = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
MESSAGE E318 WITH TEXT-E02 C_LOGICALFILE.
ELSE.
* * OPEN DATASET V_FILENAME FOR OUTPUT IN TEXT MODE.
OPEN DATASET V_FILENAME FOR OUTPUT IN LEGACY TEXT MODE.
IF SY-SUBRC EQ 0.
* * delete existing file and create new one
DELETE DATASET V_FILENAME.
* * OPEN DATASET V_FILENAME FOR OUTPUT IN TEXT MODE.
OPEN DATASET V_FILENAME FOR OUTPUT IN LEGACY TEXT MODE.
ENDIF.
ENDIF.
ENDFORM. " open_unix_file
*&---------------------------------------------------------------------*
*& Form print_mapping_errors
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM PRINT_MAPPING_ERRORS.
DATA: V_TABIX LIKE IT_ERROR-TABIX.
IF IT_ERROR[] IS INITIAL AND P_TEST = 'X'.
MESSAGE S105 WITH TEXT-S01.
ENDIF.
CHECK NOT IT_ERROR[] IS INITIAL.
WRITE: / TEXT-H01.
ULINE.
LOOP AT IT_ERROR.
IF V_TABIX <> IT_ERROR-TABIX.
V_TABIX = IT_ERROR-TABIX.
WRITE: / TEXT-R01 INTENSIFIED OFF,
IT_ERROR-TABIX INTENSIFIED ON,
TEXT-R02 INTENSIFIED OFF,
IT_ERROR-MATNR INTENSIFIED ON.
ELSE.
CONTINUE.
ENDIF.
FORMAT COLOR COL_NEGATIVE INTENSIFIED OFF.
LOOP AT IT_ERROR WHERE TABIX = V_TABIX.
WRITE: /12 IT_ERROR-ERMSG.
ENDLOOP.
FORMAT COLOR OFF.
ENDLOOP.
ENDFORM. " print_mapping_errors
*&---------------------------------------------------------------------*
*& Form check_t439a
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* * --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM CHECK_T439A.
TABLES: T439A.
SELECT SINGLE * FROM T439A WHERE DISLS = IT_UPLOAD-DISLS.
IF SY-SUBRC <> 0.
PERFORM KEEP_DATA_ERROR USING 'DISLS'
IT_UPLOAD-DISLS
SPACE.
ENDIF.
ENDFORM. " check_t439a
* *&---------------------------------------------------------------------*
* *& Form check_mara
* *&---------------------------------------------------------------------*
* * text
* *----------------------------------------------------------------------*
* * --> p1 text
* * <-- p2 text
* *----------------------------------------------------------------------*
FORM CHECK_MARA.
* TABLES: MARA.
SELECT SINGLE * FROM MARA WHERE MATNR = IT_UPLOAD-MATNR.
IF SY-SUBRC = 0.
MOVE V_TABIX TO IT_ERROR-TABIX.
MOVE IT_UPLOAD-MATNR TO IT_ERROR-MATNR.
CONCATENATE TEXT-T02 IT_UPLOAD-MATNR TEXT-T03
INTO IT_ERROR-ERMSG SEPARATED BY SPACE.
APPEND IT_ERROR.
ENDIF.
ENDFORM. " check_mara
*Selection texts
**----------------------------------------------------------
** P_PCFILE Presentation Server File
* * P_TEST Test
* * P_TYPE File Type
*
**Messages
**----------------------------------------------------------
* *
** Message class: ZM
* *105
**318
*
*--------------------------------------------------------------------------------
REPORT ZMMUPLD_RMDATIND NO STANDARD PAGE HEADING
LINE-SIZE 132
LINE-COUNT 65 MESSAGE-ID ZM..
* *&---------------------------------------------------------------------*
* *&
* *&
* *&---------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
* * Data declaration *
* *--------------------------------------------------------------------*
CONSTANTS: C_MAP LIKE MBEW-VPRSV VALUE 'V', "Moving average price
C_STNP LIKE MBEW-VPRSV VALUE 'S', "Standard price
C_LOGICALFILE LIKE FILENAME-FILEINTERN VALUE 'DHOOT_MM_UPLOAD'.
TABLES: MARA.
TYPES : BEGIN OF ty_upload1,
MATNR type MARA-MATNR ,
MBRSH type MARA-MBRSH ,
MTART type MARA-MTART ,
WERKS type MARC-WERKS ,
LGORT type MARD-LGORT ,
VKORG type BMM00-VKORG ,
VTWEG type BMM00-VTWEG ,
MAKTX type MAKT-MAKTX ,
MEINS type MARA-MEINS ,
MATKL type MARA-MATKL ,
SPART type MARA-SPART ,
BRGEW type MARA-BRGEW ,
GEWEI type MARA-GEWEI ,
NTGEW type MARA-NTGEW ,
EKGRP type MARC-EKGRP ,
DISGR type MARC-DISGR ,
DISMM type MARC-DISMM ,
DISPO type MARC-DISPO ,
DISLS type MARC-DISLS ,
BSTFE type MARC-BSTFE ,
MINBE type MARC-MINBE ,
BESKZ type MARC-BESKZ ,
RGEKZ type MARC-RGEKZ ,
WEBAZ type MARC-WEBAZ ,
FHORI type MARC-FHORI ,
PLIFZ type MARC-PLIFZ ,
EISBE type MARC-EISBE ,
MTVFP type MARC-MTVFP ,
SBDKZ type MARC-SBDKZ ,
LZEIH type MARC-LZEIH ,
MAXLZ type MARC-MAXLZ ,
MHDRZ type MARA-MHDRZ ,
IPRKZ type MARA-IPRKZ ,
MHDHB type MARA-MHDHB ,
PRCTR type MARC-PRCTR ,
BKLAS type MBEW-BKLAS ,
VPRSV type MBEW-VPRSV ,
VERPR type MBEW-VERPR ,
EKALR type MBEW-EKALR ,
HKMAT type MBEW-HKMAT ,
END OF ty_upload1.
DATA :it_upload1 TYPE TABLE OF ty_upload1.
DATA : wa_upload1 TYPE ty_upload1.
DATA: BEGIN OF IT_UPLOAD OCCURS 0,
MATNR type MARA-MATNR , "Material Number
MBRSH type MARA-MBRSH , "industry sector
MTART type MARA-MTART , "material type
WERKS type MARC-WERKS , "plant
LGORT type MARD-LGORT , "storage location
VKORG type BMM00-VKORG , "Sales Organization
VTWEG type BMM00-VTWEG , "Distribution Channel
MAKTX type MAKT-MAKTX , "material desc.
MEINS type MARA-MEINS , "base UOM
BISMT type MARA-BISMT , "old material no
EXTWG type MARA-EXTWG , "External Material Group
MATKL type MARA-MATKL , "material grp
SPART type MARA-SPART , "division
BRGEW type MARA-BRGEW , "gross weight
GEWEI type MARA-GEWEI , "weight unit
NTGEW type MARA-NTGEW , "net weight
MTPOS_MARA type MARA-MTPOS_MARA , "General item category group
VRKME type MVKE-VRKME , "Sales unit
DWERK type MVKE-DWERK , "Delivering Plant
VTEXT type TSKMT-VTEXT , "Description
AUMNG type MVKE-AUMNG , "Minimum order quantity in base unit of measure (BTCI)
LFMNG type MVKE-LFMNG , " Min. delivery quantity for delivery note processing (BTCI)
SCMNG type MVKE-SCMNG , "Delivery unit (BTCI)
SKTOF type MVKE-SKTOF , "Cash discount indicator
VERSG type MVKE-VERSG , "Material statistics group
KTGRM type MVKE-KTGRM , "Account assignment group for this material
MTPOS type MVKE-MTPOS , "Item category group from material master
*MTVFP type MARC-MTVFP , "availability check
TRAGR type MARA-TRAGR , "Transportation Group
LADGR type MARC-LADGR , "Loading Group
BSTME type MARA-BSTME , "Purchase Order Unit of Measure
EKGRP type MARC-EKGRP , "Purchasing group
EKWSL type MARA-EKWSL , "purchasing value key
DISGR type MARC-DISGR , "MRP Group
DISMM type MARC-DISMM , "MRP Type
DISPO type MARC-DISPO , "MRP Controller (Materials Planner)
DISLS type MARC-DISLS , "Lot size (materials planning)
BSTFE type MARC-BSTFE , "Fixed lot size (BTCI)
MINBE type MARC-MINBE , "Reorder point (BTCI)
BESKZ type MARC-BESKZ , "Procurement Type
SOBSL type MARC-SOBSL , "Special procurement type
RGEKZ type MARC-RGEKZ , "Indicator: Backflush
KZECH type MARC-KZECH , "Determination of batch entry in the production/process order
LGPRO type MARC-LGPRO , "Issue Storage Location
WEBAZ type MARC-WEBAZ , "Goods Receipt Processing Time in Days
FHORI type MARC-FHORI , "Scheduling Margin Key for Floats
PLIFZ type MARC-PLIFZ , "Planned Delivery Time in Days
EISBE type MARC-EISBE , "Safety Stock
STRGR type MARC-STRGR , "Planning strategy group
MTVFP type MARC-MTVFP , "Checking Group for Availability Check
ALTSL type MARC-ALTSL , "Method for Selecting Alternative Bills of Material
SBDKZ type MARC-SBDKZ , "Dependent requirements ind. for individual and coll. Reqmts
RAUBE type MARA-RAUBE , "Storage conditions
LZEIH type MARC-LZEIH , "Unit for maximum storage period
MAXLZ type MARC-MAXLZ , "Maximum storage period
MHDRZ type MARA-MHDRZ , "Minimum Remaining Shelf Life
IPRKZ type MARA-IPRKZ , "Period Indicator for Shelf Life Expiration Date
MHDHB type MARA-MHDHB , "Total shelf life
SERNP type MARC-SERNP , "Serial Number Profile
SERLV type MARA-SERLV , "Level of Explicitness for Serial Number
PRCTR type MARC-PRCTR , "Profit Center
BWTTY type MBEW-BWTTY , "Valuation Category
BKLAS type MBEW-BKLAS , "Valuation Class
VPRSV type MBEW-VPRSV , "Price Control Indicator
VERPR type MBEW-VERPR , "Moving Average Price/Periodic Unit Price
STPRS type MBEW-STPRS , "Standard price
EKALR type MBEW-EKALR , "Material Is Costed with Quantity Structure
HKMAT type MBEW-HKMAT , "Material-related origin
PLNNR type MARC-PLNNR , "Key for Task List Group
PLNTY type MARC-PLNTY , "Task List Type
END OF IT_UPLOAD.
DATA: BEGIN OF IT_ERROR OCCURS 0,
TABIX(10) TYPE N,
MATNR LIKE MARA-MATNR,
ERMSG(255) TYPE C,
END OF IT_ERROR.
DATA: V_FIELDTEXT(60) TYPE C,
V_FILENAME LIKE RLGRAP-FILENAME,
V_TABIX LIKE SY-TABIX.
DATA: W_BGR00 LIKE BGR00,
W_BMM00 LIKE BMM00,
W_BMMH1 LIKE BMMH1.
**----------------------------------------------------------------------*
* * Selection-Screen *
* *---------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-S01.
PARAMETERS: P_PCFILE LIKE RLGRAP-FILENAME OBLIGATORY,
P_TYPE LIKE RLGRAP-FILETYPE DEFAULT 'ASC',
P_TEST AS CHECKBOX DEFAULT 'X'.
SELECTION-SCREEN END OF BLOCK B1.
**----------------------------------------------------------------------*
* * At Selection-Screen *
* *---------------------------------------------------------------------*
AT SELECTION-SCREEN.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_PCFILE.
*BEGIN SYDK978748
DATA: L_FILE TYPE STRING,
T_FILES TYPE FILETABLE,
L_SUBRC TYPE I,
L_TITLE TYPE STRING VALUE 'File System for Pres. Server'.
L_file = '000000'.
L_FILE = P_PCFILE.
CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_OPEN_DIALOG
EXPORTING
WINDOW_TITLE = L_TITLE
DEFAULT_FILENAME = L_FILE
CHANGING
FILE_TABLE = T_FILES
RC = L_SUBRC
EXCEPTIONS
FILE_OPEN_DIALOG_FAILED = 1
CNTL_ERROR = 2
ERROR_NO_GUI = 3
OTHERS = 4.
READ TABLE T_FILES INDEX 1 INTO P_PCFILE.
*** CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
* ** EXPORTING
* * MASK = ',txt,.txt'
* ** STATIC = 'X'
* ** CHANGING
* ** FILE_NAME = P_PCFILE.
* *----------------------------------------------------------------------*
* * START OF SELECTION *
* *----------------------------------------------------------------------*
START-OF-SELECTION.
** upload file
PERFORM UPLOAD_PC_FILE.
** checking master data
PERFORM DATA_CHECKING.
** if actual run and if no mapping errors, upload the data
CHECK ( P_TEST IS INITIAL AND
IT_ERROR[] IS INITIAL ).
*** PERFORM UPLOAD_DATA.
*----------------------------------------------------------------------*
* END OF SELECTION *
*----------------------------------------------------------------------*
END-OF-SELECTION.
PERFORM PRINT_MAPPING_ERRORS.
PERFORM UPLOAD_DATA.
**&----------------------------------------------------------------------*
* *& Form UPLOAD_PC_FILE
* *&---------------------------------------------------------------------*
* * text
* *----------------------------------------------------------------------*
* * --> p1 text
* * <-- p2 text
* *----------------------------------------------------------------------*
FORM UPLOAD_PC_FILE.
DATA: IT_TEMP(4096) TYPE C OCCURS 0.
DATA:it_temp1 TYPE STANDARD TABLE OF alsmex_tabline.
DATA : wa_temp1 TYPE alsmex_tabline.
data: l_file type string.
DATA: L_SEPA TYPE C.
IF P_TYPE = 'DAT'.
L_SEPA = 'X'.
ELSE.
L_SEPA = ' '.
ENDIF.
* l_file = P_PCFILE.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
filename = p_pcfile
i_begin_col = 1
i_begin_row = 4
i_end_col = 256
i_end_row = 65536
TABLES
intern = it_temp1
* EXCEPTIONS
* INCONSISTENT_PARAMETERS = 1
* UPLOAD_OLE = 2
* OTHERS = 3
.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
sort it_temp1 by row col.
LOOP AT it_temp1 INTO wa_temp1.
CASE wa_temp1-col.
when '0001' . wa_upload1-MATNR = wa_temp1-value .
when '0002' . wa_upload1-MBRSH = wa_temp1-value .
when '0003' . wa_upload1-MTART = wa_temp1-value .
when '0004' . wa_upload1-WERKS = wa_temp1-value .
when '0005' . wa_upload1-LGORT = wa_temp1-value .
when '0006' . wa_upload1-VKORG = wa_temp1-value .
when '0007' . wa_upload1-VTWEG = wa_temp1-value .
when '0008' . wa_upload1-MAKTX = wa_temp1-value .
when '0009' . wa_upload1-MEINS = wa_temp1-value .
when '0010' . wa_upload1-MATKL = wa_temp1-value .
when '0011' . wa_upload1-SPART = wa_temp1-value .
when '0012' . wa_upload1-BRGEW = wa_temp1-value .
when '0013' . wa_upload1-GEWEI = wa_temp1-value .
when '0014' . wa_upload1-NTGEW = wa_temp1-value .
when '0015' . wa_upload1-EKGRP = wa_temp1-value .
when '0016' . wa_upload1-DISGR = wa_temp1-value .
when '0017' . wa_upload1-DISMM = wa_temp1-value .
when '0018' . wa_upload1-DISPO = wa_temp1-value .
when '0019' . wa_upload1-DISLS = wa_temp1-value .
when '0020' . wa_upload1-BSTFE = wa_temp1-value .
when '0021' . wa_upload1-MINBE = wa_temp1-value .
when '0022' . wa_upload1-BESKZ = wa_temp1-value .
when '0023' . wa_upload1-RGEKZ = wa_temp1-value .
when '0024' . wa_upload1-WEBAZ = wa_temp1-value .
when '0025' . wa_upload1-FHORI = wa_temp1-value .
when '0026' . wa_upload1-PLIFZ = wa_temp1-value .
when '0027' . wa_upload1-EISBE = wa_temp1-value .
when '0028' . wa_upload1-MTVFP = wa_temp1-value .
when '0029' . wa_upload1-SBDKZ = wa_temp1-value .
when '0030' . wa_upload1-LZEIH = wa_temp1-value .
when '0031' . wa_upload1-MAXLZ = wa_temp1-value .
when '0032' . wa_upload1-MHDRZ = wa_temp1-value .
when '0033' . wa_upload1-IPRKZ = wa_temp1-value .
when '0034 '. wa_upload1-MHDHB = wa_temp1-value .
when '0035 '. wa_upload1-PRCTR = wa_temp1-value .
when '0036' . wa_upload1-BKLAS = wa_temp1-value .
when '0037' . wa_upload1-VPRSV = wa_temp1-value .
when '0038' . wa_upload1-VERPR = wa_temp1-value .
when '0039' . wa_upload1-EKALR = wa_temp1-value .
when '0040' . wa_upload1-HKMAT = wa_temp1-value .
ENDCASE.
at end of row.
APPEND wa_upload1 TO it_upload1.
*** MOVE-CORRESPONDING wa_upload1 to it_upload.
move: wa_upload1-MATNR to it_upload-MATNR ,
wa_upload1-MBRSH to it_upload-MBRSH ,
wa_upload1-MTART to it_upload-MTART ,
wa_upload1-WERKS to it_upload-WERKS ,
wa_upload1-LGORT to it_upload-LGORT ,
wa_upload1-VKORG to it_upload-VKORG ,
wa_upload1-VTWEG to it_upload-VTWEG ,
wa_upload1-MAKTX to it_upload-MAKTX ,
wa_upload1-MEINS to it_upload-MEINS ,
wa_upload1-MATKL to it_upload-MATKL ,
wa_upload1-SPART to it_upload-SPART ,
wa_upload1-BRGEW to it_upload-BRGEW ,
wa_upload1-GEWEI to it_upload-GEWEI ,
wa_upload1-NTGEW to it_upload-NTGEW ,
wa_upload1-EKGRP to it_upload-EKGRP ,
wa_upload1-DISGR to it_upload-DISGR ,
wa_upload1-DISMM to it_upload-DISMM ,
wa_upload1-DISPO to it_upload-DISPO ,
wa_upload1-DISLS to it_upload-DISLS ,
wa_upload1-BSTFE to it_upload-BSTFE ,
wa_upload1-MINBE to it_upload-MINBE ,
wa_upload1-BESKZ to it_upload-BESKZ ,
wa_upload1-RGEKZ to it_upload-RGEKZ ,
wa_upload1-WEBAZ to it_upload-WEBAZ ,
wa_upload1-FHORI to it_upload-FHORI ,
wa_upload1-PLIFZ to it_upload-PLIFZ ,
wa_upload1-EISBE to it_upload-EISBE ,
wa_upload1-MTVFP to it_upload-MTVFP ,
wa_upload1-SBDKZ to it_upload-SBDKZ ,
wa_upload1-LZEIH to it_upload-LZEIH ,
wa_upload1-MAXLZ to it_upload-MAXLZ ,
wa_upload1-MHDRZ to it_upload-MHDRZ ,
wa_upload1-IPRKZ to it_upload-IPRKZ ,
wa_upload1-MHDHB to it_upload-MHDHB ,
wa_upload1-PRCTR to it_upload-PRCTR ,
wa_upload1-BKLAS to it_upload-BKLAS ,
wa_upload1-VPRSV to it_upload-VPRSV ,
wa_upload1-VERPR to it_upload-VERPR ,
wa_upload1-EKALR to it_upload-EKALR ,
wa_upload1-HKMAT to it_upload-HKMAT .
APPEND it_upload.
endat.
ENDLOOP.
**** CALL FUNCTION 'GUI_UPLOAD'
**** EXPORTING
**** filename = l_file
**** filetype = 'ASC'
**** has_field_separator = L_SEPA
****
**** TABLES
**** data_tab = IT_TEMP
**** EXCEPTIONS
**** file_open_error = 1
**** file_read_error = 2
**** no_batch = 3
**** gui_refuse_filetransfer = 4
**** invalid_type = 5
**** no_authority = 6
**** unknown_error = 7
**** bad_data_format = 8
**** header_not_allowed = 9
**** separator_not_allowed = 10
**** header_too_long = 11
**** unknown_dp_error = 12
**** access_denied = 13
**** dp_out_of_memory = 14
**** disk_full = 15
**** dp_timeout = 16
**** OTHERS = 17.
******
****** CALL FUNCTION 'WS_UPLOAD'
****** EXPORTING
****** FILENAME = P_PCFILE
****** FILETYPE = P_TYPE
****** TABLES
****** DATA_TAB = IT_TEMP
****** EXCEPTIONS
****** CONVERSION_ERROR = 1
****** INVALID_TABLE_WIDTH = 2
****** INVALID_TYPE = 3
****** NO_BATCH = 4
****** UNKNOWN_ERROR = 5
****** FILE_OPEN_ERROR = 6
****** FILE_READ_ERROR = 7
****** OTHERS = 8.
IF SY-SUBRC NE 0.
MESSAGE S318 WITH TEXT-E01 P_PCFILE.
ENDIF.
****
**** CALL FUNCTION 'TEXT_CONVERT_TEX_TO_SAP'
**** EXPORTING
**** I_FIELD_SEPERATOR = ','
***** I_LINE_HEADER =
**** I_TAB_RAW_DATA = IT_TEMP
***** I_FILENAME = p_pcfile
**** TABLES
**** I_TAB_CONVERTED_DATA = IT_UPLOAD
***** EXCEPTIONS
***** CONVERSION_FAILED = 1
***** OTHERS = 2
**** .
****
**** IF SY-SUBRC NE 0.
**** MESSAGE S318 WITH TEXT-E04 P_PCFILE.
**** ENDIF.
ENDFORM. " UPLOAD_PC_FILE
*&---------------------------------------------------------------------*
*& Form DATA_CHECKING
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM DATA_CHECKING.
LOOP AT IT_UPLOAD.
V_TABIX = SY-TABIX.
* perform check_mara.
PERFORM CHECK_T137.
PERFORM CHECK_T134.
PERFORM CHECK_T001W.
PERFORM CHECK_T001L.
PERFORM CHECK_T006.
PERFORM CHECK_T023.
PERFORM CHECK_TSPA.
PERFORM CHECK_T024.
PERFORM CHECK_T438M.
PERFORM CHECK_T438A.
PERFORM CHECK_T024D.
PERFORM CHECK_T439A.
PERFORM CHECK_T460A.
PERFORM CHECK_T436A.
PERFORM CHECK_TMVF.
PERFORM CHECK_T159C.
PERFORM CHECK_T149.
PERFORM CHECK_T025.
PERFORM CHECK_PRICE_CTRL.
ENDLOOP.
ENDFORM. " DATA_CHECKING
*&---------------------------------------------------------------------*
*& Form get_field_description
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_IT_UPLOAD_MATNR text
* <--P_V_FIELDTEXT text
*----------------------------------------------------------------------*
FORM GET_FIELD_DESCRIPTION USING VALUE(P_FIELDNAME)
CHANGING P_TEXT.
CLEAR P_TEXT.
CALL FUNCTION 'TB_DATAELEMENT_GET_TEXTS'
EXPORTING
NAME = P_FIELDNAME
IMPORTING
DESCRIPTION = P_TEXT
EXCEPTIONS
NOT_FOUND = 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. " get_field_description
*&---------------------------------------------------------------------*
*& Form check_t137
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM CHECK_T137.
TABLES: T137.
SELECT SINGLE * FROM T137 WHERE MBRSH = IT_UPLOAD-MBRSH.
IF SY-SUBRC <> 0.
PERFORM KEEP_DATA_ERROR USING 'MBRSH'
IT_UPLOAD-MBRSH
SPACE.
ENDIF.
ENDFORM. " check_t137
*&---------------------------------------------------------------------*
*& Form check_t134
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM CHECK_T134.
TABLES: T134.
SELECT SINGLE * FROM T134 WHERE MTART = IT_UPLOAD-MTART.
IF SY-SUBRC <> 0.
PERFORM KEEP_DATA_ERROR USING 'MTART'
IT_UPLOAD-MTART
SPACE.
ENDIF.
ENDFORM. " check_t134
*&---------------------------------------------------------------------*
*& Form keep_data_error
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_0349 text
* -->P_IT_UPLOAD_MATNR text
*----------------------------------------------------------------------*
FORM KEEP_DATA_ERROR USING VALUE(P_FIELDNAME)
P_FIELDVALUE
P_WERKS.
MOVE V_TABIX TO IT_ERROR-TABIX.
MOVE IT_UPLOAD-MATNR TO IT_ERROR-MATNR.
PERFORM GET_FIELD_DESCRIPTION USING P_FIELDNAME
CHANGING V_FIELDTEXT.
CONCATENATE TEXT-T01 V_FIELDTEXT ':' P_WERKS P_FIELDVALUE
INTO IT_ERROR-ERMSG SEPARATED BY SPACE.
APPEND IT_ERROR.
ENDFORM. " keep_data_error
*&---------------------------------------------------------------------*
*& Form check_t001w
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM CHECK_T001W.
TABLES: T001W.
SELECT SINGLE * FROM T001W WHERE WERKS = IT_UPLOAD-WERKS.
IF SY-SUBRC <> 0.
PERFORM KEEP_DATA_ERROR USING 'WERKS_D'
IT_UPLOAD-WERKS
SPACE.
ENDIF.
ENDFORM. " check_t001w
*&---------------------------------------------------------------------*
*& Form check_t001l
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM CHECK_T001L.
** Storage location
PERFORM CHECK_STOR_LOC USING 'LGORT_D'
IT_UPLOAD-LGORT.
** Issue Stor. location
IF NOT IT_UPLOAD-LGPRO IS INITIAL.
PERFORM CHECK_STOR_LOC USING 'LGPRO'
IT_UPLOAD-LGPRO.
ENDIF.
** Stor. loc for EP
* IF NOT IT_UPLOAD-LGFSB IS INITIAL.
* PERFORM CHECK_STOR_LOC USING 'LGFSB'
* IT_UPLOAD-LGFSB.
* ENDIF.
ENDFORM. " check_t001l
*&---------------------------------------------------------------------*
*& Form check_t006
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM CHECK_T006.
** Base UOM
PERFORM CHECK_UOM USING 'MEINS'
IT_UPLOAD-MEINS.
** Weight unit
IF NOT IT_UPLOAD-GEWEI IS INITIAL.
PERFORM CHECK_UOM USING 'GEWEI'
IT_UPLOAD-GEWEI.
ENDIF.
** Volume unit
* IF NOT IT_UPLOAD-VOLEH IS INITIAL.
* PERFORM CHECK_UOM USING 'VOLEH'
* IT_UPLOAD-VOLEH.
* ENDIF.
ENDFORM. " check_t006
*&---------------------------------------------------------------------*
*& Form check_UOM
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_0536 text
* -->P_IT_UPLOAD_MEINS text
*----------------------------------------------------------------------*
FORM CHECK_UOM USING VALUE(P_FIELDNAME)
P_FIELDVALUE.
TABLES: T006.
SELECT SINGLE * FROM T006 WHERE MSEHI = P_FIELDVALUE.
IF SY-SUBRC <> 0.
PERFORM KEEP_DATA_ERROR USING P_FIELDNAME
P_FIELDVALUE
SPACE.
ENDIF.
ENDFORM. " check_UOM
*&---------------------------------------------------------------------*
* *& Form check_t023
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM CHECK_T023.
TABLES: T023.
SELECT SINGLE * FROM T023 WHERE MATKL = IT_UPLOAD-MATKL.
IF SY-SUBRC <> 0.
PERFORM KEEP_DATA_ERROR USING 'MATKL'
IT_UPLOAD-MATKL
SPACE.
ENDIF.
ENDFORM. " check_t023
*&---------------------------------------------------------------------*
*& Form check_tspa
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* * --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM CHECK_TSPA.
TABLES: TSPA.
CHECK NOT IT_UPLOAD-SPART IS INITIAL.
SELECT SINGLE * FROM TSPA WHERE SPART = IT_UPLOAD-SPART.
IF SY-SUBRC <> 0.
PERFORM KEEP_DATA_ERROR USING 'SPART'
IT_UPLOAD-SPART
SPACE.
ENDIF.
ENDFORM. " check_tspa
*&---------------------------------------------------------------------*
*& Form check_t024
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM CHECK_T024.
TABLES: T024.
SELECT SINGLE * FROM T024 WHERE EKGRP = IT_UPLOAD-EKGRP.
IF SY-SUBRC <> 0.
PERFORM KEEP_DATA_ERROR USING 'EKGRP'
IT_UPLOAD-EKGRP
SPACE.
ENDIF.
ENDFORM. " check_t024
*&---------------------------------------------------------------------*
*& Form check_t438m
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM CHECK_T438M.
TABLES: T438M.
CHECK NOT IT_UPLOAD-DISGR IS INITIAL.
SELECT SINGLE * FROM T438M WHERE WERKS = IT_UPLOAD-WERKS
AND MTART = IT_UPLOAD-DISGR.
IF SY-SUBRC <> 0.
PERFORM KEEP_DATA_ERROR USING 'DISGR'
IT_UPLOAD-DISGR
IT_UPLOAD-WERKS.
ENDIF.
ENDFORM. " check_t438m
*&---------------------------------------------------------------------*
*& Form check_t438a
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM CHECK_T438A.
TABLES: T438A.
SELECT SINGLE * FROM T438A WHERE DISMM = IT_UPLOAD-DISMM.
IF SY-SUBRC <> 0.
PERFORM KEEP_DATA_ERROR USING 'DISMM'
IT_UPLOAD-DISMM
SPACE.
ENDIF.
ENDFORM. " check_t438a
*&---------------------------------------------------------------------*
*& Form check_t024d
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM CHECK_T024D.
TABLES: T024D.
SELECT SINGLE * FROM T024D WHERE WERKS = IT_UPLOAD-WERKS
AND DISPO = IT_UPLOAD-DISPO.
IF SY-SUBRC <> 0.
PERFORM KEEP_DATA_ERROR USING 'DISPO'
IT_UPLOAD-DISPO
IT_UPLOAD-WERKS.
ENDIF.
ENDFORM. " check_t024d
*&---------------------------------------------------------------------*
*& Form check_t460a
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM CHECK_T460A.
TABLES: T460A.
CHECK NOT IT_UPLOAD-SOBSL IS INITIAL.
SELECT SINGLE * FROM T460A WHERE WERKS = IT_UPLOAD-WERKS
AND SOBSL = IT_UPLOAD-SOBSL.
IF SY-SUBRC <> 0.
PERFORM KEEP_DATA_ERROR USING 'SOBSL'
IT_UPLOAD-SOBSL
IT_UPLOAD-WERKS.
ENDIF.
ENDFORM. " check_t460a
*&---------------------------------------------------------------------*
*& Form check_stor_loc
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_T001L text
*----------------------------------------------------------------------*
FORM CHECK_STOR_LOC USING VALUE(P_FIELDNAME)
P_FIELDVALUE.
TABLES: T001L.
SELECT SINGLE * FROM T001L WHERE WERKS = IT_UPLOAD-WERKS
AND LGORT = P_FIELDVALUE.
IF SY-SUBRC <> 0.
PERFORM KEEP_DATA_ERROR USING P_FIELDNAME
P_FIELDVALUE
IT_UPLOAD-WERKS.
ENDIF.
ENDFORM. " check_stor_loc
*&---------------------------------------------------------------------*
*& Form check_t436a
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM CHECK_T436A.
TABLES: T436A.
SELECT SINGLE * FROM T436A WHERE WERKS = IT_UPLOAD-WERKS
AND FHORI = IT_UPLOAD-FHORI.
IF SY-SUBRC <> 0.
PERFORM KEEP_DATA_ERROR USING 'FHORI'
IT_UPLOAD-FHORI
IT_UPLOAD-WERKS.
ENDIF.
ENDFORM. " check_t436a
*&---------------------------------------------------------------------*
*& Form check_tmvf
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM CHECK_TMVF.
TABLES: TMVF.
SELECT SINGLE * FROM TMVF WHERE MTVFP = IT_UPLOAD-MTVFP.
IF SY-SUBRC <> 0.
PERFORM KEEP_DATA_ERROR USING 'MTVFP'
IT_UPLOAD-MTVFP
SPACE.
ENDIF.
ENDFORM. " check_tmvf
*&---------------------------------------------------------------------*
*& Form check_t159c
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM CHECK_T159C.
TABLES: T159C.
* CHECK NOT IT_UPLOAD-ABCIN IS INITIAL.
* SELECT SINGLE * FROM T159C WHERE WERKS = IT_UPLOAD-WERKS
* AND ABCIN = IT_UPLOAD-ABCIN.
* IF SY-SUBRC <> 0.
* PERFORM KEEP_DATA_ERROR USING 'ABCIN'
* IT_UPLOAD-ABCIN
* IT_UPLOAD-WERKS.
* ENDIF.
ENDFORM. " check_t159c
*&---------------------------------------------------------------------*
*& Form check_t149
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM CHECK_T149.
TABLES: T149.
CHECK NOT IT_UPLOAD-BWTTY IS INITIAL.
SELECT SINGLE * FROM T149 WHERE BWKEY = IT_UPLOAD-WERKS
AND BWTTY = IT_UPLOAD-BWTTY.
IF SY-SUBRC <> 0.
PERFORM KEEP_DATA_ERROR USING 'BWTTY_D'
IT_UPLOAD-BWTTY
IT_UPLOAD-WERKS.
ENDIF.
ENDFORM. " check_t149
*&---------------------------------------------------------------------*
*& Form check_t025
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM CHECK_T025.
TABLES: T025.
SELECT SINGLE * FROM T025 WHERE BKLAS = IT_UPLOAD-BKLAS.
IF SY-SUBRC <> 0.
PERFORM KEEP_DATA_ERROR USING 'BKLAS'
IT_UPLOAD-BKLAS
SPACE.
ENDIF.
ENDFORM. " check_t025
*&---------------------------------------------------------------------*
*& Form check_price_ctrl
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM CHECK_PRICE_CTRL.
IF ( IT_UPLOAD-VPRSV <> C_MAP AND
IT_UPLOAD-VPRSV <> C_STNP ).
PERFORM KEEP_DATA_ERROR USING 'VPRSV'
IT_UPLOAD-VPRSV
SPACE.
ENDIF.
ENDFORM. " check_price_ctrl
*&---------------------------------------------------------------------*
*& Form upload_data
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM UPLOAD_DATA.
** open file in UNIX for output
PERFORM OPEN_UNIX_FILE.
** header record
W_BGR00-STYPE = '0'.
W_BGR00-GROUP = 'MATERIAL_MASTER_UPLOAD'.
W_BGR00-MANDT = SY-MANDT.
W_BGR00-USNAM = SY-UNAME.
TRANSFER W_BGR00 TO V_FILENAME.
** load data into the direct input structures
** in the UNIX file
LOOP AT IT_UPLOAD.
W_BMM00-STYPE = '1'.
W_BMM00-TCODE = 'MM01'.
W_BMM00-XEIK1 = 'X'.
W_BMM00-XEIE1 = 'X'.
W_BMM00-XEID1 = 'X'.
W_BMM00-XEID2 = 'X'.
W_BMM00-XEID3 = 'X'.
W_BMM00-XEIL1 = 'X'.
W_BMM00-XEIB1 = 'X'.
SELECT SINGLE * FROM MARA WHERE MATNR EQ IT_UPLOAD-MATNR.
IF SY-SUBRC EQ 0.
CLEAR W_BMM00-XEIK1.
ENDIF.
** End of addition
MOVE-CORRESPONDING IT_UPLOAD TO W_BMM00.
TRANSFER W_BMM00 TO V_FILENAME.
W_BMMH1-STYPE = '2'.
MOVE-CORRESPONDING IT_UPLOAD TO W_BMMH1.
IF IT_UPLOAD-VPRSV = 'S'.
CLEAR W_BMMH1-VERPR.
MOVE IT_UPLOAD-VERPR TO W_BMMH1-STPRS.
ENDIF.
TRANSFER W_BMMH1 TO V_FILENAME.
CLEAR : W_BMM00, W_BMMH1.
ENDLOOP.
** call direct input program to create the materials
** from the UNIX file
SUBMIT RMDATIND AND RETURN
WITH LDS_NAME = C_LOGICALFILE
WITH SPERR = 'E'.
ENDFORM. " upload_data
*&---------------------------------------------------------------------*
*& Form open_unix_file
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM OPEN_UNIX_FILE.
CALL FUNCTION 'FILE_GET_NAME'
EXPORTING
LOGICAL_FILENAME = C_LOGICALFILE
IMPORTING
FILE_NAME = V_FILENAME
EXCEPTIONS
FILE_NOT_FOUND = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
MESSAGE E318 WITH TEXT-E02 C_LOGICALFILE.
ELSE.
* * OPEN DATASET V_FILENAME FOR OUTPUT IN TEXT MODE.
OPEN DATASET V_FILENAME FOR OUTPUT IN LEGACY TEXT MODE.
IF SY-SUBRC EQ 0.
* * delete existing file and create new one
DELETE DATASET V_FILENAME.
* * OPEN DATASET V_FILENAME FOR OUTPUT IN TEXT MODE.
OPEN DATASET V_FILENAME FOR OUTPUT IN LEGACY TEXT MODE.
ENDIF.
ENDIF.
ENDFORM. " open_unix_file
*&---------------------------------------------------------------------*
*& Form print_mapping_errors
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM PRINT_MAPPING_ERRORS.
DATA: V_TABIX LIKE IT_ERROR-TABIX.
IF IT_ERROR[] IS INITIAL AND P_TEST = 'X'.
MESSAGE S105 WITH TEXT-S01.
ENDIF.
CHECK NOT IT_ERROR[] IS INITIAL.
WRITE: / TEXT-H01.
ULINE.
LOOP AT IT_ERROR.
IF V_TABIX <> IT_ERROR-TABIX.
V_TABIX = IT_ERROR-TABIX.
WRITE: / TEXT-R01 INTENSIFIED OFF,
IT_ERROR-TABIX INTENSIFIED ON,
TEXT-R02 INTENSIFIED OFF,
IT_ERROR-MATNR INTENSIFIED ON.
ELSE.
CONTINUE.
ENDIF.
FORMAT COLOR COL_NEGATIVE INTENSIFIED OFF.
LOOP AT IT_ERROR WHERE TABIX = V_TABIX.
WRITE: /12 IT_ERROR-ERMSG.
ENDLOOP.
FORMAT COLOR OFF.
ENDLOOP.
ENDFORM. " print_mapping_errors
*&---------------------------------------------------------------------*
*& Form check_t439a
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* * --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM CHECK_T439A.
TABLES: T439A.
SELECT SINGLE * FROM T439A WHERE DISLS = IT_UPLOAD-DISLS.
IF SY-SUBRC <> 0.
PERFORM KEEP_DATA_ERROR USING 'DISLS'
IT_UPLOAD-DISLS
SPACE.
ENDIF.
ENDFORM. " check_t439a
* *&---------------------------------------------------------------------*
* *& Form check_mara
* *&---------------------------------------------------------------------*
* * text
* *----------------------------------------------------------------------*
* * --> p1 text
* * <-- p2 text
* *----------------------------------------------------------------------*
FORM CHECK_MARA.
* TABLES: MARA.
SELECT SINGLE * FROM MARA WHERE MATNR = IT_UPLOAD-MATNR.
IF SY-SUBRC = 0.
MOVE V_TABIX TO IT_ERROR-TABIX.
MOVE IT_UPLOAD-MATNR TO IT_ERROR-MATNR.
CONCATENATE TEXT-T02 IT_UPLOAD-MATNR TEXT-T03
INTO IT_ERROR-ERMSG SEPARATED BY SPACE.
APPEND IT_ERROR.
ENDIF.
ENDFORM. " check_mara
*Selection texts
**----------------------------------------------------------
** P_PCFILE Presentation Server File
* * P_TEST Test
* * P_TYPE File Type
*
**Messages
**----------------------------------------------------------
* *
** Message class: ZM
* *105
**318
*
*--------------------------------------------------------------------------------
No comments:
Post a Comment