Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

LSMW - problem with step nine- import data

Former Member
0 Kudos

Hi all,

I am trying to update materila master data using lsmw technique. The fields i am trying to update are matnr,mbrsh,mtart,maktx,meins and mtpos_mara. I am also selecting basic data 1 view. I have performed all the steps untill assign files. When I try to perform ninth step like import data I get an short dump .these are the short dumo details.

Runtime errors DATASET_SEEK_ERROR

Exception CX_SY_FUILE_POSITION

Positioning error in file <filename>.

Can anyone please me with this.

Regards,

Vijay.

1 ACCEPTED SOLUTION

former_member188685
Active Contributor
0 Kudos

Hi Vijay,

1. first check the Field mapping

2. and add T-code MM01.(assign T-code)

3. generate.

and still you are facing the same problem then the problem will be some thing else....

we developed direct input method program if you want you can check or just use bapi_material_savedata.

using bapi..

REPORT Z_NEW_PROGRAM .


**********************************************************************
*                STRUCTURE  DECLARATIONS                             *
**********************************************************************

TABLES: BAPIMATHEAD,  "Headerdata
        BAPI_MARA,    "Clientdata
        BAPI_MARAX,   "Clientdatax
        BAPI_MARC,    "Plantdata
        BAPI_MARCX,   "Plantdatax
        BAPI_MAKT,    "Material description
        BAPIRET2.     "Return messages

DATA:V_FILE TYPE STRING.


DATA:
  BEGIN OF LSMW_MATERIAL_MASTER,
    MATNR(018) TYPE C,  "Material number
    MTART(004) TYPE C,  "Material type
    MBRSH(001) TYPE C,  "Industry sector
    WERKS(004) TYPE C,  "Plant
    MAKTX(040) TYPE C,  "Material description
    DISMM(002) TYPE C,  "Extra Field Added In the Program as itsrequired
    MEINS(003) TYPE C,  "Base unit of measure
    MATKL(009) TYPE C,  "Material group
    SPART(002) TYPE C,  "Division
    LABOR(003) TYPE C,  "Lab/office
    PRDHA(018) TYPE C,  "Product hierarchy
    MSTAE(002) TYPE C,  "X-plant matl status
    MTPOS_MARA(004) TYPE C,  "Gen item cat group
    BRGEW(017) TYPE C,  "Gross weight
    GEWEI(003) TYPE C,  "Weight unit
    NTGEW(017) TYPE C,  "Net weight
    GROES(032) TYPE C,  "Size/Dimensions
    MAGRV(004) TYPE C,  "Matl grp pack matls
    BISMT(018) TYPE C,  "Old material number
    WRKST(048) TYPE C,  "Basic material
    PROFL(003) TYPE C,  "DG indicator profile
    KZUMW(001) TYPE C,  "Environmentally rlvt
    BSTME(003) TYPE C,  "Order unit
    VABME(001) TYPE C,
    EKGRP(003) TYPE C,  "Purchasing group
    XCHPF(001) TYPE C,  "Batch management
    EKWSL(004) TYPE C,  "Purchasing key value
    WEBAZ(003) TYPE C,  "GR processing time
    MFRPN(040) TYPE C,  "Manufacturer part number
    MFRNR(010) TYPE C,  "Manufacturer number
    VPRSV(001) TYPE C,  "Price control indicator
    STPRS(015) TYPE C,  "Standard price
    BWPRH(014) TYPE C,  "Commercial price1
    BKLAS(004) TYPE C,  "Valuation class
  END OF LSMW_MATERIAL_MASTER.


**********************************************************************
*                INTERNAL TABLE DECLARATIONS                         *
**********************************************************************

*to store the input data
DATA:
  BEGIN OF it_matmaster OCCURS 0.
        INCLUDE STRUCTURE LSMW_MATERIAL_MASTER.

DATA:
  END OF it_matmaster.

*for material description
DATA:BEGIN OF IT_MATERIALDESC OCCURS 0.
     INCLUDE STRUCTURE BAPI_MAKT .
DATA:END OF IT_MATERIALDESC.

*to return messages
DATA:BEGIN OF IT_RETURN OCCURS 0.
     INCLUDE STRUCTURE BAPIRET2.
DATA:END OF IT_RETURN.

************************************************************************
*  SELECTION SCREEN
************************************************************************
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-002.

PARAMETERS:P_FILE LIKE RLGRAP-FILENAME OBLIGATORY.
SELECTION-SCREEN END OF BLOCK B1 .

************************************************************************
* AT SELECTION SCREEN
************************************************************************
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
  CALL FUNCTION 'F4_FILENAME'
    EXPORTING
      PROGRAM_NAME  = SYST-CPROG
      DYNPRO_NUMBER = SYST-DYNNR
      FIELD_NAME    = 'P_FILE'
    IMPORTING
      FILE_NAME     = P_FILE.



**********************************************************************
*                TO UPLOAD THE DATA                                  *
**********************************************************************

START-OF-SELECTION.
V_FILE = P_FILE.
CALL FUNCTION 'GUI_UPLOAD'
  EXPORTING
    filename                      = V_FILE
   FILETYPE                      = 'ASC'
   HAS_FIELD_SEPARATOR           = 'X'
*   HEADER_LENGTH                 = 0
*   READ_BY_LINE                  = 'X'
*   DAT_MODE                      = ' '
* IMPORTING
*   FILELENGTH                    =
*   HEADER                        =
  tables
    data_tab                      =  IT_MATMASTER
 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
          .
IF sy-subrc <> 0.
 MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

**********************************************************************
*                DATA POPULATIONS                                    *
**********************************************************************


LOOP AT  IT_MATMASTER.
  BAPIMATHEAD-MATERIAL = IT_MATMASTER-MATNR.
  BAPIMATHEAD-IND_SECTOR = IT_MATMASTER-Mbrsh.
  BAPIMATHEAD-MATL_TYPE = IT_MATMASTER-Mtart.
  BAPIMATHEAD-BASIC_VIEW = 'X'.
  BAPIMATHEAD-PURCHASE_VIEW = 'X'.
  BAPIMATHEAD-ACCOUNT_VIEW = 'X'.
  BAPI_MARA-MATL_GROUP = IT_MATMASTER-MATKL.
  BAPI_MARA-OLD_MAT_NO = IT_MATMASTER-BISMT.
  BAPI_MARA-BASE_UOM = IT_MATMASTER-MEINS.
  BAPI_MARA-BASIC_MATL = IT_MATMASTER-WRKST.
  BAPI_MARA-MFR_NO = IT_MATMASTER-MFRNR.
  BAPI_MARAX-MATL_GROUP = 'X'.
  BAPI_MARAX-OLD_MAT_NO = 'X'.
  BAPI_MARAX-BASE_UOM = 'X'.
  BAPI_MARAX-BASIC_MATL = 'X'.
  BAPI_MARAX-MFR_NO = 'X'.
  BAPI_MARC-PLANT = IT_MATMASTER-WERKS.
  BAPI_MARC-PUR_GROUP = IT_MATMASTER-EKGRP.
  BAPI_MARCX-PLANT = IT_MATMASTER-WERKS.
  BAPI_MARCX-PUR_GROUP = 'X'.
  IT_MATERIALDESC-LANGU = 'EN'.
  IT_MATERIALDESC-MATL_DESC = IT_MATMASTER-MAKTX.
  append IT_materialdesc.
  CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'
    EXPORTING
      headdata                   = BAPIMATHEAD
      CLIENTDATA                 = BAPI_MARA
      CLIENTDATAX                = BAPI_MARAx
     PLANTDATA                  = BAPI_MARc
     PLANTDATAX                 = BAPI_MARcx
*     FORECASTPARAMETERS         =
*     FORECASTPARAMETERSX        =
*     PLANNINGDATA               =
*     PLANNINGDATAX              =
*     STORAGELOCATIONDATA        =
*     STORAGELOCATIONDATAX       =
*     VALUATIONDATA              =
*     VALUATIONDATAX             =
*     WAREHOUSENUMBERDATA        =
*     WAREHOUSENUMBERDATAX       =
*     SALESDATA                  =
*     SALESDATAX                 =
*     STORAGETYPEDATA            =
*     STORAGETYPEDATAX           =
*     FLAG_ONLINE                = ' '
*     FLAG_CAD_CALL              = ' '
   IMPORTING
     RETURN                     = IT_RETURN
   TABLES
     MATERIALDESCRIPTION        = IT_MATERIALDESC
*     UNITSOFMEASURE             =
*     UNITSOFMEASUREX            =
*     INTERNATIONALARTNOS        =
*     MATERIALLONGTEXT           =
*     TAXCLASSIFICATIONS         =
*     RETURNMESSAGES             =
*     PRTDATA                    =
*     PRTDATAX                   =
*     EXTENSIONIN                =
*     EXTENSIONINX               =
            .

 WRITE:/    IT_RETURN-TYPE,
        2   IT_RETURN-ID,
        22  IT_RETURN-NUMBER,
        25  IT_RETURN-MESSAGE.
*            IT_RETURN-LOG_NO,
*            IT_RETURN-LOG_MSG_NO,
*            IT_RETURN-MESSAGE_V1,
*            IT_RETURN-MESSAGE_V2,
*            IT_RETURN-MESSAGE_V3,
*            IT_RETURN-MESSAGE_V4,
*            IT_RETURN-PARAMETER,
*            IT_RETURN-ROW,
*            IT_RETURN-FIELD,
*            IT_RETURN-SYSTEM.

ENDLOOP.

6 REPLIES 6

Former Member
0 Kudos

Hi all,

I have posted a query regarding LSMW. Guys If you can help me please post a reply message.

Regards,

Vijay.

0 Kudos

U might get some info in the SAP Note 658979.

42795 is related to the same error.

Former Member
0 Kudos

Can u post one row of sample data what u are exactly importing.

Thanks

eswar

0 Kudos

Hi,

123-345 C VKHM X DATA g

this is the data i am trying to post.This is the only row I have in my input file.

Regards,

Vijay.

0 Kudos

hi,

direct input method...

*&---------------------------------------------------------------------*
*& Report  Z__DIRECT__MAT___CREAT                                      *
*&                                                                     *
*&---------------------------------------------------------------------*
*&                                                                     *
*&                                                                     *
*&---------------------------------------------------------------------*

REPORT  Z__DIRECT__MAT___CREAT                  .

INCLUDE Z_INCLUDE_MAT_CREAT.


************************************************************************
*  SELECTION SCREEN
************************************************************************
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-002.

PARAMETERS:P_FILE LIKE RLGRAP-FILENAME OBLIGATORY.
SELECTION-SCREEN END OF BLOCK B1 .

************************************************************************
* AT SELECTION SCREEN
************************************************************************
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.

  CALL FUNCTION 'F4_FILENAME'
    EXPORTING
      PROGRAM_NAME  = SYST-CPROG
      DYNPRO_NUMBER = SYST-DYNNR
      FIELD_NAME    = 'P_FILE'
    IMPORTING
      FILE_NAME     = P_FILE.


****************************************************
*START-OF-SELECTION
****************************************************
START-OF-SELECTION.

****************************************************
*Perform to upload the data from Presentation Server
****************************************************
  V_FILE = P_FILE.
  PERFORM UPLOAD_DATA.
*****************************************************
*Transfer the Data to the structure BGR00 BMMH1 BMM00
*****************************************************

  PERFORM CONVERT_0000.                                     " BGR00

  PERFORM POPULATE_DATA CHANGING BMM00.

  PERFORM POPULATE_DATA CHANGING BMMH1.
**Looping the flat file data and updating the structures BMM00 & BMMH1
  LOOP AT MATERIAL_MASTER.
*Writing the Data to the Application Server in a proper Format
    OPEN DATASET C_ZTEST FOR APPENDING IN  TEXT MODE ENCODING
    DEFAULT.
****************************************************
*Transfer the Data to the structure BMM00
****************************************************
    PERFORM CONVERT_0002.                                   " BMM00
****************************************************
*Transfer the Data to the structure BMMh1
****************************************************

    PERFORM CONVERT_0003.                                   " BMMH1
**Closing the dataset after transfering the data
    CLOSE DATASET  C_ZTEST.
  ENDLOOP.     "Endloop of MATERIAL_MASTER

****************************************************
*END-OF-SELECTION
****************************************************
END-OF-SELECTION.

**Calling the Direct Input Program to Create the material
  SUBMIT RMDATIND WITH %%%_R_P = C_X
                    WITH %%%_PHY = C_ZTEST
                    WITH SPERR = C_N.
*&---------------------------------------------------------------------*
*&  Include           Z_INCLUDE_MAT_CREAT                              *
*&---------------------------------------------------------------------*

**Tables Used To Create the Material
TABLES:
  BGR00,
  BMM00,
  BMMH1.

DATA:C_ZTEST(60) type c,
     C_X TYPE C,
     C_N TYPE C,
     V_file type string.

C_ZTEST = 'Ztest.lsmw.conv'(001).
C_X = 'X'(003).
C_N = 'N'(004).

**FILED SYMBOLS
FIELD-SYMBOLS: <F> .

**Structure to Hold the Flat File
data:
  begin of LSMW_MATERIAL_MASTER,
    MATNR(018) type C,  "Material number
    MTART(004) type C,  "Material type
    MBRSH(001) type C,  "Industry sector
    WERKS(004) type C,  "Plant
    MAKTX(040) type C,  "Material description
    DISMM(002) type C,  "Extra Field Added In the Program as it is required
    MEINS(003) type C,  "Base unit of measure
    MATKL(009) type C,  "Material group
    SPART(002) type C,  "Division
    LABOR(003) type C,  "Lab/office
    PRDHA(018) type C,  "Product hierarchy
    MSTAE(002) type C,  "X-plant matl status
    MTPOS_MARA(004) type C,  "Gen item cat group
    BRGEW(017) type C,  "Gross weight
    GEWEI(003) type C,  "Weight unit
    NTGEW(017) type C,  "Net weight
    GROES(032) type C,  "Size/Dimensions
    MAGRV(004) type C,  "Matl grp pack matls
    BISMT(018) type C,  "Old material number
    WRKST(048) type C,  "Basic material
    PROFL(003) type C,  "DG indicator profile
    KZUMW(001) type C,  "Environmentally rlvt
    BSTME(003) type C,  "Order unit
    VABME(001) type C,
    EKGRP(003) type C,  "Purchasing group
    XCHPF(001) type C,  "Batch management
    EKWSL(004) type C,  "Purchasing key value
    WEBAZ(003) type C,  "GR processing time
    MFRPN(040) type C,  "Manufacturer part number
    MFRNR(010) type C,  "Manufacturer number
    VPRSV(001) type C,  "Price control indicator
    STPRS(015) type C,  "Standard price
    BWPRH(014) type C,  "Commercial price1
  end of LSMW_MATERIAL_MASTER.

**InternalTable to HOld the Flat File Data
DATA:
  BEGIN OF MATERIAL_MASTER OCCURS 0.
        INCLUDE STRUCTURE LSMW_MATERIAL_MASTER.

DATA:
  END OF MATERIAL_MASTER.




*&--------------------------------------------------------------------*
*&      Form  upload_data From Presentation Server
*&--------------------------------------------------------------------*

FORM UPLOAD_DATA.
  CALL FUNCTION 'GUI_UPLOAD'
    EXPORTING
      FILENAME                      = V_FILE
     FILETYPE                      = 'ASC'
     HAS_FIELD_SEPARATOR           = 'X'
*     HEADER_LENGTH                 = 0
*     READ_BY_LINE                  = 'X'
*     DAT_MODE                      = ' '
*     CODEPAGE                      = ' '
*     IGNORE_CERR                   = ABAP_TRUE
*     REPLACEMENT                   = '#'
*   IMPORTING
*     FILELENGTH                    =
*     HEADER                        =
    TABLES
      DATA_TAB                      = MATERIAL_MASTER
   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
            .
  IF SY-SUBRC = 0.
    DELETE MATERIAL_MASTER INDEX 1.
  ENDIF.


ENDFORM.                    "upload_data

*&--------------------------------------------------------------------*
*&    Updating the BGR00 Structure
*&--------------------------------------------------------------------*

FORM CONVERT_0000.                                          " BGR00

**Opening the Data Set to write the data to Application Server
  OPEN DATASET C_ZTEST FOR OUTPUT IN  TEXT MODE ENCODING DEFAULT
  .

 MOVE: '0' TO BGR00-STYPE,
         'ZTEST' TO BGR00-GROUP,
         SY-MANDT TO BGR00-MANDT,
         SY-UNAME TO BGR00-USNAM,
         'X' TO BGR00-XKEEP,
         '/' TO BGR00-NODATA.
*Transefering the Data To the Application Server File
  TRANSFER BGR00 TO C_ZTEST.
*Closing the Dataset after Transfer
  CLOSE DATASET C_ZTEST.


ENDFORM.                    "convert_0001



*&--------------------------------------------------------------------*
*&     Updating BMM00 Structure
*&--------------------------------------------------------------------*

FORM CONVERT_0002.                                          " BMM00

* --- BMM00-STYPE
  BMM00-STYPE = '1'.

* --- BMM00-TCODE
  BMM00-TCODE = 'MM01'.

* --- BMM00-MATNR
  IF NOT MATERIAL_MASTER-MATNR IS INITIAL.
    BMM00-MATNR = MATERIAL_MASTER-MATNR.
  ELSE.
    BMM00-MATNR = '/'.
  ENDIF.
* --- BMM00-MBRSH
  IF NOT MATERIAL_MASTER-MBRSH IS INITIAL.
    BMM00-MBRSH = MATERIAL_MASTER-MBRSH.
  ELSE.
    BMM00-MBRSH = '/'.
  ENDIF.

* --- BMM00-MTART
  IF NOT MATERIAL_MASTER-MTART IS INITIAL.
    BMM00-MTART = MATERIAL_MASTER-MTART.
  ELSE.
    BMM00-MTART = '/'.
  ENDIF.


* --- BMM00-WERKS
  IF NOT MATERIAL_MASTER-WERKS IS INITIAL.
    BMM00-WERKS = MATERIAL_MASTER-WERKS.
  ELSE.
    BMM00-WERKS = '/'.
  ENDIF.


  BMM00-XEIB1 = 'X'.  " BMM00-xeib1 = '/'.

  BMM00-XEIE1 = 'X'.  " BMM00-xeie1 = '/'.

  BMM00-XEIK1 = 'X'.  " BMM00-xeik1 = '/'.

**Transfer the data to the Application Server File
  TRANSFER BMM00 TO C_ZTEST.

ENDFORM.                    "convert_0002

*&--------------------------------------------------------------------*
*&      UPdating BMMH1 Structure
*&--------------------------------------------------------------------*

FORM CONVERT_0003.                                          " BMMH1


* --- BMMH1-STYPE
  BMMH1-STYPE = '2'.

* --- BMMH1-MEINS
  IF NOT MATERIAL_MASTER-MEINS IS INITIAL.
    BMMH1-MEINS = MATERIAL_MASTER-MEINS.
  ELSE.
    BMMH1-MEINS = '/'.
  ENDIF.


* --- BMMH1-MAKTX
  IF NOT MATERIAL_MASTER-MAKTX IS INITIAL.
    BMMH1-MAKTX = MATERIAL_MASTER-MAKTX.
  ELSE.
    BMMH1-MAKTX = '/'.
  ENDIF.


* --- BMMH1-MATKL
  IF NOT MATERIAL_MASTER-MATKL IS INITIAL.
    BMMH1-MATKL = MATERIAL_MASTER-MATKL.
  ELSE.
    BMMH1-MATKL = '/'.
  ENDIF.


* --- BMMH1-BISMT
  IF NOT MATERIAL_MASTER-BISMT IS INITIAL.
    BMMH1-BISMT = MATERIAL_MASTER-BISMT.
  ELSE.
    BMMH1-BISMT = '/'.
  ENDIF.

* --- BMMH1-LABOR
  IF NOT MATERIAL_MASTER-LABOR IS INITIAL.
    BMMH1-LABOR = MATERIAL_MASTER-LABOR.
  ELSE.
    BMMH1-LABOR = '/'.
  ENDIF.



* --- BMMH1-WRKST
  IF NOT MATERIAL_MASTER-WRKST IS INITIAL.
    BMMH1-WRKST = MATERIAL_MASTER-WRKST.
  ELSE.
    BMMH1-WRKST = '/'.
  ENDIF.


* --- BMMH1-BRGEW
  IF NOT MATERIAL_MASTER-BRGEW IS INITIAL.
    BMMH1-BRGEW = MATERIAL_MASTER-BRGEW.
  ELSE.
    BMMH1-BRGEW = '/'.
  ENDIF.


* --- BMMH1-NTGEW
  IF NOT MATERIAL_MASTER-NTGEW IS INITIAL.
    BMMH1-NTGEW = MATERIAL_MASTER-NTGEW.
  ELSE.
    BMMH1-NTGEW = '/'.
  ENDIF.


* --- BMMH1-GEWEI
  IF NOT MATERIAL_MASTER-GEWEI IS INITIAL.
    BMMH1-GEWEI = MATERIAL_MASTER-GEWEI.
  ELSE.
    BMMH1-GEWEI = '/'.
  ENDIF.



* --- BMMH1-GROES
  IF NOT MATERIAL_MASTER-GROES IS INITIAL.
    BMMH1-GROES = MATERIAL_MASTER-GROES.
  ELSE.
    BMMH1-GROES = '/'.
  ENDIF.


* --- BMMH1-SPART
  IF NOT MATERIAL_MASTER-SPART IS INITIAL.
    BMMH1-SPART = MATERIAL_MASTER-SPART.
  ELSE.
    BMMH1-SPART = '/'.
  ENDIF.




* --- BMMH1-BSTME
  IF NOT MATERIAL_MASTER-BSTME IS INITIAL.
    BMMH1-BSTME = MATERIAL_MASTER-BSTME.
  ELSE.
    BMMH1-BSTME = '/'.
  ENDIF.


* --- BMMH1-EKWSL
  IF NOT MATERIAL_MASTER-EKWSL IS INITIAL.
    BMMH1-EKWSL = MATERIAL_MASTER-EKWSL.
  ELSE.
    BMMH1-EKWSL = '/'.
  ENDIF.


* --- BMMH1-EKGRP
  IF NOT MATERIAL_MASTER-EKGRP IS INITIAL.
    BMMH1-EKGRP = MATERIAL_MASTER-EKGRP.
  ELSE.
    BMMH1-EKGRP = '/'.
  ENDIF.


* --- BMMH1-XCHPF
  IF NOT MATERIAL_MASTER-XCHPF IS INITIAL.
    BMMH1-XCHPF = MATERIAL_MASTER-XCHPF.
  ELSE.
    BMMH1-XCHPF = '/'.
  ENDIF.


* --- BMMH1-WEBAZ
  IF NOT MATERIAL_MASTER-WEBAZ IS INITIAL.
    BMMH1-WEBAZ = MATERIAL_MASTER-WEBAZ.
  ELSE.
    BMMH1-WEBAZ = '/'.
  ENDIF.


  IF NOT MATERIAL_MASTER-DISMM IS INITIAL.
    BMMH1-DISMM = MATERIAL_MASTER-DISMM.
  ELSE.
    BMMH1-DISMM = '/'.
  ENDIF.



* --- BMMH1-VPRSV
  IF NOT MATERIAL_MASTER-VPRSV IS INITIAL.
    BMMH1-VPRSV = MATERIAL_MASTER-VPRSV.
  ELSE.
    BMMH1-VPRSV = '/'.
  ENDIF.

  BMMH1-VERPR = '/'.
* --- BMMH1-STPRS
  IF NOT MATERIAL_MASTER-STPRS IS INITIAL.
    BMMH1-STPRS = MATERIAL_MASTER-STPRS.
  ELSE.
    BMMH1-STPRS = '/'.
  ENDIF.

* --- BMMH1-BWPRH
  IF NOT MATERIAL_MASTER-BWPRH IS INITIAL.
    BMMH1-BWPRH = MATERIAL_MASTER-BWPRH.
  ELSE.
    BMMH1-BWPRH = '/'.
  ENDIF.


* --- BMMH1-PRDHA
  IF NOT MATERIAL_MASTER-PRDHA IS INITIAL.
    BMMH1-PRDHA = MATERIAL_MASTER-PRDHA.
  ELSE.
    BMMH1-PRDHA = '/'.
  ENDIF.


* --- BMMH1-VABME
  IF NOT MATERIAL_MASTER-VABME IS INITIAL.
    BMMH1-VABME = MATERIAL_MASTER-VABME.
  ELSE.
    BMMH1-VABME = '/'.
  ENDIF.


* --- BMMH1-MAGRV
  IF NOT MATERIAL_MASTER-MAGRV IS INITIAL.
    BMMH1-MAGRV = MATERIAL_MASTER-MAGRV.
  ELSE.
    BMMH1-MAGRV = '/'.
  ENDIF.


* --- BMMH1-KZUMW
  IF NOT MATERIAL_MASTER-KZUMW IS INITIAL.
    BMMH1-KZUMW = MATERIAL_MASTER-KZUMW.
  ELSE.
    BMMH1-KZUMW = '/'.
  ENDIF.


* --- BMMH1-MFRNR
  IF NOT MATERIAL_MASTER-MFRNR IS INITIAL.
    BMMH1-MFRNR = MATERIAL_MASTER-MFRNR.
  ELSE.
    BMMH1-MFRNR = '/'.
  ENDIF.


* --- BMMH1-MFRPN
  IF NOT MATERIAL_MASTER-MFRPN IS INITIAL.
    BMMH1-MFRPN = MATERIAL_MASTER-MFRPN.
  ELSE.
    BMMH1-MFRPN = '/'.
  ENDIF.

  BMMH1-MPROF = '/'.
* --- BMMH1-MSTAE
  IF NOT MATERIAL_MASTER-MSTAE IS INITIAL.
    BMMH1-MSTAE = MATERIAL_MASTER-MSTAE.
  ELSE.
    BMMH1-MSTAE = '/'.
  ENDIF.


* --- BMMH1-PROFL
  IF NOT MATERIAL_MASTER-PROFL IS INITIAL.
    BMMH1-PROFL = MATERIAL_MASTER-PROFL.
  ELSE.
    BMMH1-PROFL = '/'.
  ENDIF.


* --- BMMH1-MTPOS_MARA
  IF NOT MATERIAL_MASTER-MTPOS_MARA IS INITIAL.
    BMMH1-MTPOS_MARA = MATERIAL_MASTER-MTPOS_MARA.
  ELSE.
    BMMH1-MTPOS_MARA = '/'.
  ENDIF.


**Transfer the Data to Application Server File
TRANSFER BMMH1 TO C_ZTEST.


ENDFORM.                    "convert_0003

*&---------------------------------------------------------------------*
*&      Form  POPULATE_DATA
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      <--P_BLF text
*----------------------------------------------------------------------*
FORM POPULATE_DATA  CHANGING P_BLF.
  DATA: L_NUM TYPE I.
  DO.
    L_NUM = L_NUM + 1.
    ASSIGN COMPONENT L_NUM OF STRUCTURE P_BLF TO <F>.
    IF SY-SUBRC <> 0.
      EXIT.
    ENDIF.
    MOVE BGR00-NODATA TO <F>.
  ENDDO.

ENDFORM.                    " POPULATE_DATA

former_member188685
Active Contributor
0 Kudos

Hi Vijay,

1. first check the Field mapping

2. and add T-code MM01.(assign T-code)

3. generate.

and still you are facing the same problem then the problem will be some thing else....

we developed direct input method program if you want you can check or just use bapi_material_savedata.

using bapi..

REPORT Z_NEW_PROGRAM .


**********************************************************************
*                STRUCTURE  DECLARATIONS                             *
**********************************************************************

TABLES: BAPIMATHEAD,  "Headerdata
        BAPI_MARA,    "Clientdata
        BAPI_MARAX,   "Clientdatax
        BAPI_MARC,    "Plantdata
        BAPI_MARCX,   "Plantdatax
        BAPI_MAKT,    "Material description
        BAPIRET2.     "Return messages

DATA:V_FILE TYPE STRING.


DATA:
  BEGIN OF LSMW_MATERIAL_MASTER,
    MATNR(018) TYPE C,  "Material number
    MTART(004) TYPE C,  "Material type
    MBRSH(001) TYPE C,  "Industry sector
    WERKS(004) TYPE C,  "Plant
    MAKTX(040) TYPE C,  "Material description
    DISMM(002) TYPE C,  "Extra Field Added In the Program as itsrequired
    MEINS(003) TYPE C,  "Base unit of measure
    MATKL(009) TYPE C,  "Material group
    SPART(002) TYPE C,  "Division
    LABOR(003) TYPE C,  "Lab/office
    PRDHA(018) TYPE C,  "Product hierarchy
    MSTAE(002) TYPE C,  "X-plant matl status
    MTPOS_MARA(004) TYPE C,  "Gen item cat group
    BRGEW(017) TYPE C,  "Gross weight
    GEWEI(003) TYPE C,  "Weight unit
    NTGEW(017) TYPE C,  "Net weight
    GROES(032) TYPE C,  "Size/Dimensions
    MAGRV(004) TYPE C,  "Matl grp pack matls
    BISMT(018) TYPE C,  "Old material number
    WRKST(048) TYPE C,  "Basic material
    PROFL(003) TYPE C,  "DG indicator profile
    KZUMW(001) TYPE C,  "Environmentally rlvt
    BSTME(003) TYPE C,  "Order unit
    VABME(001) TYPE C,
    EKGRP(003) TYPE C,  "Purchasing group
    XCHPF(001) TYPE C,  "Batch management
    EKWSL(004) TYPE C,  "Purchasing key value
    WEBAZ(003) TYPE C,  "GR processing time
    MFRPN(040) TYPE C,  "Manufacturer part number
    MFRNR(010) TYPE C,  "Manufacturer number
    VPRSV(001) TYPE C,  "Price control indicator
    STPRS(015) TYPE C,  "Standard price
    BWPRH(014) TYPE C,  "Commercial price1
    BKLAS(004) TYPE C,  "Valuation class
  END OF LSMW_MATERIAL_MASTER.


**********************************************************************
*                INTERNAL TABLE DECLARATIONS                         *
**********************************************************************

*to store the input data
DATA:
  BEGIN OF it_matmaster OCCURS 0.
        INCLUDE STRUCTURE LSMW_MATERIAL_MASTER.

DATA:
  END OF it_matmaster.

*for material description
DATA:BEGIN OF IT_MATERIALDESC OCCURS 0.
     INCLUDE STRUCTURE BAPI_MAKT .
DATA:END OF IT_MATERIALDESC.

*to return messages
DATA:BEGIN OF IT_RETURN OCCURS 0.
     INCLUDE STRUCTURE BAPIRET2.
DATA:END OF IT_RETURN.

************************************************************************
*  SELECTION SCREEN
************************************************************************
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-002.

PARAMETERS:P_FILE LIKE RLGRAP-FILENAME OBLIGATORY.
SELECTION-SCREEN END OF BLOCK B1 .

************************************************************************
* AT SELECTION SCREEN
************************************************************************
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
  CALL FUNCTION 'F4_FILENAME'
    EXPORTING
      PROGRAM_NAME  = SYST-CPROG
      DYNPRO_NUMBER = SYST-DYNNR
      FIELD_NAME    = 'P_FILE'
    IMPORTING
      FILE_NAME     = P_FILE.



**********************************************************************
*                TO UPLOAD THE DATA                                  *
**********************************************************************

START-OF-SELECTION.
V_FILE = P_FILE.
CALL FUNCTION 'GUI_UPLOAD'
  EXPORTING
    filename                      = V_FILE
   FILETYPE                      = 'ASC'
   HAS_FIELD_SEPARATOR           = 'X'
*   HEADER_LENGTH                 = 0
*   READ_BY_LINE                  = 'X'
*   DAT_MODE                      = ' '
* IMPORTING
*   FILELENGTH                    =
*   HEADER                        =
  tables
    data_tab                      =  IT_MATMASTER
 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
          .
IF sy-subrc <> 0.
 MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

**********************************************************************
*                DATA POPULATIONS                                    *
**********************************************************************


LOOP AT  IT_MATMASTER.
  BAPIMATHEAD-MATERIAL = IT_MATMASTER-MATNR.
  BAPIMATHEAD-IND_SECTOR = IT_MATMASTER-Mbrsh.
  BAPIMATHEAD-MATL_TYPE = IT_MATMASTER-Mtart.
  BAPIMATHEAD-BASIC_VIEW = 'X'.
  BAPIMATHEAD-PURCHASE_VIEW = 'X'.
  BAPIMATHEAD-ACCOUNT_VIEW = 'X'.
  BAPI_MARA-MATL_GROUP = IT_MATMASTER-MATKL.
  BAPI_MARA-OLD_MAT_NO = IT_MATMASTER-BISMT.
  BAPI_MARA-BASE_UOM = IT_MATMASTER-MEINS.
  BAPI_MARA-BASIC_MATL = IT_MATMASTER-WRKST.
  BAPI_MARA-MFR_NO = IT_MATMASTER-MFRNR.
  BAPI_MARAX-MATL_GROUP = 'X'.
  BAPI_MARAX-OLD_MAT_NO = 'X'.
  BAPI_MARAX-BASE_UOM = 'X'.
  BAPI_MARAX-BASIC_MATL = 'X'.
  BAPI_MARAX-MFR_NO = 'X'.
  BAPI_MARC-PLANT = IT_MATMASTER-WERKS.
  BAPI_MARC-PUR_GROUP = IT_MATMASTER-EKGRP.
  BAPI_MARCX-PLANT = IT_MATMASTER-WERKS.
  BAPI_MARCX-PUR_GROUP = 'X'.
  IT_MATERIALDESC-LANGU = 'EN'.
  IT_MATERIALDESC-MATL_DESC = IT_MATMASTER-MAKTX.
  append IT_materialdesc.
  CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'
    EXPORTING
      headdata                   = BAPIMATHEAD
      CLIENTDATA                 = BAPI_MARA
      CLIENTDATAX                = BAPI_MARAx
     PLANTDATA                  = BAPI_MARc
     PLANTDATAX                 = BAPI_MARcx
*     FORECASTPARAMETERS         =
*     FORECASTPARAMETERSX        =
*     PLANNINGDATA               =
*     PLANNINGDATAX              =
*     STORAGELOCATIONDATA        =
*     STORAGELOCATIONDATAX       =
*     VALUATIONDATA              =
*     VALUATIONDATAX             =
*     WAREHOUSENUMBERDATA        =
*     WAREHOUSENUMBERDATAX       =
*     SALESDATA                  =
*     SALESDATAX                 =
*     STORAGETYPEDATA            =
*     STORAGETYPEDATAX           =
*     FLAG_ONLINE                = ' '
*     FLAG_CAD_CALL              = ' '
   IMPORTING
     RETURN                     = IT_RETURN
   TABLES
     MATERIALDESCRIPTION        = IT_MATERIALDESC
*     UNITSOFMEASURE             =
*     UNITSOFMEASUREX            =
*     INTERNATIONALARTNOS        =
*     MATERIALLONGTEXT           =
*     TAXCLASSIFICATIONS         =
*     RETURNMESSAGES             =
*     PRTDATA                    =
*     PRTDATAX                   =
*     EXTENSIONIN                =
*     EXTENSIONINX               =
            .

 WRITE:/    IT_RETURN-TYPE,
        2   IT_RETURN-ID,
        22  IT_RETURN-NUMBER,
        25  IT_RETURN-MESSAGE.
*            IT_RETURN-LOG_NO,
*            IT_RETURN-LOG_MSG_NO,
*            IT_RETURN-MESSAGE_V1,
*            IT_RETURN-MESSAGE_V2,
*            IT_RETURN-MESSAGE_V3,
*            IT_RETURN-MESSAGE_V4,
*            IT_RETURN-PARAMETER,
*            IT_RETURN-ROW,
*            IT_RETURN-FIELD,
*            IT_RETURN-SYSTEM.

ENDLOOP.