Application Development and Automation 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: 
Read only

Execl upload using BDC for item data

Former Member
0 Likes
368

Hi All,

I am doing Excel file Upload using BDC.I am using the function module

'ALSM_EXCEL_TO_INTERNAL_TABLE' to get the data into the internal table.In my excel file the header wil be first and then all the items will be strored.How to upload item data of excel sheet into BDC.

Can anybody please give answer to my question.

Thanks,

Swapna.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
343

Upload code:


DATA: G_XLDATA LIKE ALSMEX_TABLINE OCCURS 0 WITH HEADER LINE.
  DATA: L_FILE LIKE RLGRAP-FILENAME.
  L_FILE = P_FILE.
  CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
    EXPORTING
      FILENAME                = L_FILE
      I_BEGIN_COL             = 1
      I_BEGIN_ROW             = 1
      I_END_COL               = 100
      I_END_ROW               = 9999
    TABLES
      INTERN                  = G_XLDATA
    EXCEPTIONS
      INCONSISTENT_PARAMETERS = 1
      UPLOAD_OLE              = 2
      OTHERS                  = 3.

You should convert the data in G_XLDATA internal table to your nessesary row type itab.

Assume that the ITAB is the itab, using following code:



DATA: BEGIN OF BDCDATA OCCURS 0.
        INCLUDE STRUCTURE BDCDATA.
DATA: END OF BDCDATA.

    PERFORM bdc_dynpro USING 'SAPMV13A' '0100'.
    PERFORM bdc_field  USING 'BDC_OKCODE' '=ANTA'.
    PERFORM bdc_field  USING 'RV13A-KSCHL' ITAB-FIELD1.
u2026u2026


*&---------------------------------------------------------------------*
*&      Form  bdc_dynpro
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->PROGRAM    text
*      -->DYNPRO     text
*----------------------------------------------------------------------*
FORM BDC_DYNPRO USING PROGRAM DYNPRO.
  CLEAR BDCDATA.
  BDCDATA-PROGRAM  = PROGRAM.
  BDCDATA-DYNPRO   = DYNPRO.
  BDCDATA-DYNBEGIN = 'X'.
  APPEND BDCDATA.
ENDFORM.                    "bdc_dynpro
*&---------------------------------------------------------------------*
*&      Form  bdc_field
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->FNAM       text
*      -->FVAL       text
*----------------------------------------------------------------------*
FORM BDC_FIELD USING FNAM FVAL.
  CLEAR BDCDATA.
  BDCDATA-FNAM = FNAM.
  BDCDATA-FVAL = FVAL.
  APPEND BDCDATA.
ENDFORM.                    "bdc_field
    

1 REPLY 1
Read only

Former Member
0 Likes
344

Upload code:


DATA: G_XLDATA LIKE ALSMEX_TABLINE OCCURS 0 WITH HEADER LINE.
  DATA: L_FILE LIKE RLGRAP-FILENAME.
  L_FILE = P_FILE.
  CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
    EXPORTING
      FILENAME                = L_FILE
      I_BEGIN_COL             = 1
      I_BEGIN_ROW             = 1
      I_END_COL               = 100
      I_END_ROW               = 9999
    TABLES
      INTERN                  = G_XLDATA
    EXCEPTIONS
      INCONSISTENT_PARAMETERS = 1
      UPLOAD_OLE              = 2
      OTHERS                  = 3.

You should convert the data in G_XLDATA internal table to your nessesary row type itab.

Assume that the ITAB is the itab, using following code:



DATA: BEGIN OF BDCDATA OCCURS 0.
        INCLUDE STRUCTURE BDCDATA.
DATA: END OF BDCDATA.

    PERFORM bdc_dynpro USING 'SAPMV13A' '0100'.
    PERFORM bdc_field  USING 'BDC_OKCODE' '=ANTA'.
    PERFORM bdc_field  USING 'RV13A-KSCHL' ITAB-FIELD1.
u2026u2026


*&---------------------------------------------------------------------*
*&      Form  bdc_dynpro
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->PROGRAM    text
*      -->DYNPRO     text
*----------------------------------------------------------------------*
FORM BDC_DYNPRO USING PROGRAM DYNPRO.
  CLEAR BDCDATA.
  BDCDATA-PROGRAM  = PROGRAM.
  BDCDATA-DYNPRO   = DYNPRO.
  BDCDATA-DYNBEGIN = 'X'.
  APPEND BDCDATA.
ENDFORM.                    "bdc_dynpro
*&---------------------------------------------------------------------*
*&      Form  bdc_field
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->FNAM       text
*      -->FVAL       text
*----------------------------------------------------------------------*
FORM BDC_FIELD USING FNAM FVAL.
  CLEAR BDCDATA.
  BDCDATA-FNAM = FNAM.
  BDCDATA-FVAL = FVAL.
  APPEND BDCDATA.
ENDFORM.                    "bdc_field