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

bdc output

0 Likes
1,893
this report output 21 details should be uploaded from excel to sap.1 record  uploading remaining records are not uploading.please check the program,please correct it and give it.

report ZMM01
       no standard page heading line-size 255.

TYPES : BEGIN OF rec_type,
        MATNR TYPE RMMG1-MATNR,
        MBRSH TYPE RMMG1-MBRSH,
        MTART TYPE RMMG1-MTART,
        MAKTX TYPE MAKT-MAKTX,
        MEINS TYPE MARA-MEINS,
        END OF rec_type.

DATA : it_mat TYPE TABLE OF rec_type,
        wa_mat TYPE rec_type.

DATA IT_EXCEL TYPE TABLE OF ALSMEX_TABLINE WITH HEADER LINE.

DATA IT_BDCDATA TYPE TABLE OF BDCDATA WITH HEADER LINE.

PARAMETERS P_FILE TYPE IBIPPARMS-PATH.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.


PERFORM BROWSE_FILE.
START-OF-SELECTION.
PERFORM UPLOAD_EXCEL_FILE.
PERFORM CONVERT_IT_EXCEL_TO_IT_MAT.
PERFORM VALIDATE_DATA.

*&---------------------------------------------------------------------*
*&      Form  BROWSE_FILE
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
form BROWSE_FILE .
CALL FUNCTION 'F4_FILENAME'
 EXPORTING
   PROGRAM_NAME        = SYST-CPROG
   DYNPRO_NUMBER       = SYST-DYNNR
*   FIELD_NAME          = ' '
 IMPORTING
   FILE_NAME           = P_FILE
          .

endform.                    " BROWSE_FILE
*&---------------------------------------------------------------------*
*&      Form  UPLOAD_EXCEL_FILE
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
form UPLOAD_EXCEL_FILE.

CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
  EXPORTING
    filename                      = P_FILE
    i_begin_col                   = 2
    i_begin_row                   = 2
    i_end_col                     = 13
    i_end_row                     = 100
  TABLES
    intern                        = IT_EXCEL
 EXCEPTIONS
   INCONSISTENT_PARAMETERS       = 1
   UPLOAD_OLE                    = 2
   OTHERS                        = 3.
endform.                    " UPLOAD_EXCEL_FILE
*&---------------------------------------------------------------------*
*&      Form  CONVERT_IT_EXCEL_TO_IT_MAT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
form CONVERT_IT_EXCEL_TO_IT_MAT .

LOOP AT IT_EXCEL.
CASE IT_EXCEL-COL.

WHEN 1.
wa_MAT-MATNR  = IT_EXCEL-VALUE.

WHEN 2.
wa_MAT-MBRSH =  IT_EXCEL-VALUE.

WHEN 3.
wa_MAT-MTART =  IT_EXCEL-VALUE.

WHEN 4.
wa_MAT-MAKTX = IT_EXCEL-VALUE.

WHEN 5.
wa_MAT-MEINS = IT_EXCEL-VALUE.
APPEND wa_MAT to it_mat.
CLEAR: wa_MAT.
ENDCASE.
ENDLOOP.
*
*
endform.                    " CONVERT_IT_EXCEL_TO_IT_MAT
*&---------------------------------------------------------------------*
*&      Form  VALIDATE_DATA
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
form VALIDATE_DATA .

LOOP AT IT_MAT INTO wa_mat.

perform bdc_dynpro      using 'SAPLMGMM' '0060'.
perform bdc_field       using 'BDC_CURSOR'
                              'RMMG1-MTART'.
perform bdc_field       using 'BDC_OKCODE'
                              '=ENTR'.
perform bdc_field       using 'RMMG1-MATNR'
                               wa_MAT-MATNR.
perform bdc_field       using 'RMMG1-MBRSH'
                               wa_MAT-MBRSH.
perform bdc_field       using 'RMMG1-MTART'
                               wa_MAT-MTART.
perform bdc_dynpro      using 'SAPLMGMM' '4000'.
perform bdc_field       using 'BDC_OKCODE'
                              '/00'.
perform bdc_field       using 'MAKT-MAKTX'
                               wa_MAT-MAKTX.
perform bdc_field       using 'BDC_CURSOR'
                              'MARA-MEINS'.
perform bdc_field       using 'MARA-MEINS'
                               wa_MAT-MEINS.
perform bdc_dynpro      using 'SAPLSPO1' '0300'.
perform bdc_field       using 'BDC_OKCODE'
                              '=YES'.

CALL TRANSACTION 'MM01' USING IT_BDCDATA  MODE 'A' .


ENDLOOP.
*IF SY-SUBRC = 0.
MESSAGE  'RECORDS ARE TRANSFERED SUCCESSFULLY'  TYPE 'S'.
*ENDIF.
endform.                    " VALIDATE_DATA
*&---------------------------------------------------------------------*
*&      Form  BDC_DYNPRO
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_0207   text
*      -->P_0208   text
*----------------------------------------------------------------------*
form BDC_DYNPRO  using prgm SCRN.

IT_BDCDATA-PROGRAM = PRGM.
IT_BDCDATA-DYNPRO = SCRN.
IT_BDCDATA-DYNBEGIN = 'X'.
APPEND IT_BDCDATA.
 CLEAR IT_BDCDATA.
endform.                    " BDC_DYNPRO
*&---------------------------------------------------------------------*
*&      Form  BDC_FIELD
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_0212   text
*      -->P_0213   text
*----------------------------------------------------------------------*
form BDC_FIELD  using  FNAME FVALUE.
IT_BDCDATA-FNAM = FNAME.
IT_BDCDATA-FVAL = FVALUE.
APPEND IT_BDCDATA.
CLEAR IT_BDCDATA.
endform.                    " BDC_FIELD
5 REPLIES 5
Read only

Sandra_Rossi
Active Contributor
0 Likes
1,829

Moderator alerted: "ask a question" should not be used to continue the original question. You should learn to use "edit the question" or "comment" instead.

Read only

Sandra_Rossi
Active Contributor
0 Likes
1,829

And please select your code and press the "CODE" button to make it correctly colorized/indented, so that it's easier for us to analyze it. Thank you.

Read only

ThangaPrakash
Active Contributor
0 Likes
1,829

Hi alagu123

I did a BDC recording in my system and I could achieve it, it creates multiple material based on my excel data. PFA text file zmm01.txt

Read only

0 Likes
1,829

can you please give your program for clarity.

Read only

KatiNonhebel
Advisor
Advisor
0 Likes
1,829

DUPLICATION OF https://answers.sap.com/questions/13317408/bdc-record-not-uploading-directly-from-excel-while.html
Welcome to SAP Community! I saw that you posted this question multiple times. To avoid duplicates, I will remove all duplicates, including this question. Here is the link to the same published question: (https://answers.sap.com/questions/13317408/bdc-record-not-uploading-directly-from-excel-while.html) Let’s give community members some time to be able to help you finding the correct answer to your question. If you need further assistance feel free to reach out to moderators@sap.com