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 help for direct input

Former Member
0 Kudos

Hi,

Can someone step me through the process of uploading data from an excel spreadsheet using LSMW with DIRECT INPUT. I have reviewed several documents online in this regard but they all seem to talk about LSMW with a Batch input using recordings. I have the following questions:

1. Does one need to record the transactions for Direct input as well? I am confused. I thought direct input lets you upload data directly from an excel file.

2. How do you maintain source structure relationship?

Is it the case that each time you upload data the header information should be assigned to BGR00 or BI00?

3. I was trying to upload data into KNVV however I was not able to find the VKORG field in BKNVV. How do I find this field?

Please help !!!! Thanks for your time.

4 REPLIES 4

Former Member
0 Kudos

Hi Sona,

u dont need to Record the transaction while using Direct input. In Maintain Object Attributes, u need to click the first radiobutton ( Standard Direct Input), then using F4 select the object which u need to upload..( Note: only certain uploads are possible using Direct Method in SAP, u can chk this using F4 in the object).

After that method and program comes automaticaly wen u click F4 there....

For maintaining structure relationship, u need to c the fields in the target structure and chk if u want to fill them...accordingly u can relate.

Hope it helps.

Regards,

Bikash

to find out the uploads possible using direct input, in Object, press F4, u ll get the list.. regarding ur field not appearing, cud u tell me wat is it that u r uploading??

Message was edited by: Bikash Agarwal

0 Kudos

Hi Bikash,

Thanks for your response you said the following

" ( Note: only certain uploads are possible using Direct Method in SAP, u can chk this using F4 in the object). "

Can you elaborate on what uploads are possible by using Direct method. Also what uploads are not possible. Also when I was doing the mapping I couldnt fiid vkorg in KNVV.Do you know why that is the case?

Thanks,

0 Kudos

Hi!

Customer creation is possible with RFBIDE00. If you don't find a object with F4 - then that's one without direct input / batch input. You can still look for a IDOC/BAPI in this case, or just record something yourself.

To your missing VKORG: when you maintained the first customer sales view, you have to push 'SAVE'. This ends the first transaction, additional sales views have to be created seperate. Because of this VKORG is only defined on header level (in bkn00).

Regards,

Christian

former_member188685
Active Contributor
0 Kudos

Hi Sona,

1. you don't need any recording for Direct Input.

2. Header info always BGR00, but based on your fields,

like bank data, account data, some thing like ..

you need to select the fields...

3. check in other structures for VKORG.

here i just imitated LSMW direct input method just check this..

*&---------------------------------------------------------------------*
*& 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

Regards

vijay