Registration

Dear SAP Community Member,
In order to fully benefit from what the SAP Community has to offer, please register at:
http://scn.sap.com
Thank you,
The SAP Community team.
Skip to end of metadata
Go to start of metadata

Description: Material Master Upload Program
--------------------------------------------------------------------------------

*&---------------------------------------------------------------------*
*& Report  ZMATMASTERUPL
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT ZMATMASTERUPL  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 'ZMATERIAL'.

TABLES: MARA. 

DATA: BEGIN OF IT_UPLOAD OCCURS 0,
        MATNR LIKE MARA-MATNR,   "material no
        MBRSH LIKE MARA-MBRSH,   "industry sector
        MTART LIKE MARA-MTART,   "material type
        WERKS LIKE MARC-WERKS,   "plant
        LGORT LIKE MARD-LGORT,   "storage location
        MAKTX LIKE MAKT-MAKTX,   "material desc.
        MEINS LIKE MARA-MEINS,   "base UOM
        MATKL LIKE MARA-MATKL,   "material grp
        BISMT LIKE MARA-BISMT,   "old material no
        SPART LIKE MARA-SPART,   "division
        BRGEW LIKE MARA-BRGEW,   "gross weight
        NTGEW LIKE MARA-NTGEW,   "net weight
        GEWEI LIKE MARA-GEWEI,   "weight unit
        VOLUM LIKE MARA-VOLUM,   "volume
        VOLEH LIKE MARA-VOLEH,   "volume unit
        EKGRP LIKE MARC-EKGRP,   "purchasing grp
        XCHPF LIKE MARA-XCHPF,   "batch mgmt
        EKWSL LIKE MARA-EKWSL,   "purchasing value key
        WEBAZ LIKE MARC-WEBAZ,   "GR processing time
        DISGR LIKE MARC-DISGR,   "MRP group
        DISMM LIKE MARC-DISMM,   "MRP type
        DISPO LIKE MARC-DISPO,   "MRP controller
        MINBE LIKE MARC-MINBE,   "reorder point
        DISLS LIKE MARC-DISLS,   "lot size
        BSTRF LIKE MARC-BSTRF,   "rounding value
        SOBSL LIKE MARC-SOBSL,   "special procurement
        LGPRO LIKE MARC-LGPRO,   "issue stor. loc
        LGFSB LIKE MARC-LGFSB,   "stoc. loc for EP
        PLIFZ LIKE MARC-PLIFZ,   "planned delivery time
        FHORI LIKE MARC-FHORI,   "scheduling margin key
        EISBE LIKE MARC-EISBE,   "safety stock
        PERKZ LIKE MARC-PERKZ,   "period indicator
        MTVFP LIKE MARC-MTVFP,   "availability check
        LGPBE LIKE MARD-LGPBE,   "storage bin
        ABCIN LIKE MARC-ABCIN,   "CC physical inventory ind
        BWTTY LIKE MBEW-BWTTY,   "valuation category
        BKLAS LIKE MBEW-BKLAS,   "valuation class
        BWTAR LIKE MBEW-BWTAR,   "valuation type
        VPRSV LIKE MBEW-VPRSV,   "price control
        VERPR LIKE MBEW-VERPR,   "price (MAP/Standard)
     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 = 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.
*END SYDK978748
*----------------------------------------------------------------------*
* 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.

*&---------------------------------------------------------------------*
*&      Form  UPLOAD_PC_FILE
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM UPLOAD_PC_FILE.

  DATA: IT_TEMP(4096) TYPE C OCCURS 0.
*BEGIN SYDK978748

  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 'GUI_UPLOAD'
    EXPORTING
      filename                = l_file
      filetype                = 'ASC'
      has_field_separator     = L_SEPA
*

Unknown macro: { SYDK981609 - insert   DAT_MODE                      = 'X'\*}

SYDK981609
    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.
*END SYDK978748

  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.
*BEGIN SYDK978748
*    OPEN DATASET V_FILENAME FOR OUTPUT IN TEXT MODE.
    OPEN DATASET V_FILENAME FOR OUTPUT IN LEGACY TEXT MODE.
*END SYDK978748

    IF SY-SUBRC EQ 0.
* delete existing file and create new one
      DELETE DATASET V_FILENAME.
*BEGIN SYDK978748
*      OPEN DATASET V_FILENAME FOR OUTPUT IN TEXT MODE.
      OPEN DATASET V_FILENAME FOR OUTPUT IN LEGACY TEXT MODE.
*END ASYDK978748
    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 labels