0% found this document useful (0 votes)
85 views3 pages

ZBDC Call Transaction

This document contains code for an ABAP report that imports data from an Excel file into transaction MM01 using BDC calls. It defines a data structure to hold the imported data, calls a function to convert the Excel file to a table, then loops through the table performing BDC calls to populate fields and navigate screens in MM01 to create material master records for each row of data.

Uploaded by

amaya100100
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
85 views3 pages

ZBDC Call Transaction

This document contains code for an ABAP report that imports data from an Excel file into transaction MM01 using BDC calls. It defines a data structure to hold the imported data, calls a function to convert the Excel file to a table, then loops through the table performing BDC calls to populate fields and navigate screens in MM01 to create material master records for each row of data.

Uploaded by

amaya100100
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

report ZBDC_CALL_TRANSACTION

no standard page heading line-size 255.


TYPES : BEGIN OF TY_MARA,
MBRSH TYPE MARA-MBRSH,
MEINS TYPE MARA-MEINS,
MATKL TYPE MARA-MATKL,
END OF TY_MARA.
DATA :

IT_TAB TYPE TABLE OF TY_MARA WITH HEADER LINE,


IT_BDCDATA TYPE TABLE OF BDCDATA WITH HEADER LINE,
TEXT(4096) TYPE C OCCURS 0.

SELECTION-SCREEN : BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.


PARAMETERS : P_FILE TYPE RLGRAP-FILENAME.
SELECTION-SCREEN : END OF BLOCK B1.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
PROGRAM_NAME
= SYST-CPROG
*
DYNPRO_NUMBER
= SYST-DYNNR
*
FIELD_NAME
= ' '
IMPORTING
FILE_NAME
= P_FILE.
*include bdcrecx1.
START-OF-SELECTION.

CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'


EXPORTING
* I_FIELD_SEPERATOR
=
* I_LINE_HEADER
=
I_TAB_RAW_DATA
= TEXT[]
I_FILENAME
= P_FILE
TABLES
I_TAB_CONVERTED_DATA
= IT_TAB[]
EXCEPTIONS
CONVERSION_FAILED
= 1
OTHERS
= 2
.
**CALL FUNCTION 'TEXT_CONVERT_TXT_TO_SAP'
** EXPORTING
*** I_FIELD_SEPERATOR
= ';'
*** I_LINE_HEADER
=
**
I_TAB_RAW_DATA
= TEXT[]
** I_FILENAME
= P_FILE
** TABLES
**
I_TAB_CONVERTED_DATA
= IT_TAB[]
** EXCEPTIONS

** CONVERSION_FAILED
= 1
** OTHERS
= 2
**
.
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.

*perform open_group.
LOOP AT IT_TAB.
perform bdc_dynpro
perform bdc_field
perform bdc_field
perform bdc_field
perform bdc_field
perform bdc_dynpro
perform bdc_field
perform bdc_field
perform bdc_field
perform bdc_field
perform bdc_dynpro
perform bdc_field
perform bdc_field
perform bdc_field
perform bdc_field
perform bdc_field
perform bdc_field
perform bdc_dynpro
perform bdc_field
perform bdc_field
perform bdc_field
perform bdc_dynpro
perform bdc_field
perform bdc_field

using 'SAPLMGMM' '0060'.


using 'BDC_CURSOR'
'RMMG1-MTART'.
using 'BDC_OKCODE'
'=ENTR'.
using 'RMMG1-MBRSH'
IT_TAB-MBRSH."'M'.
using 'RMMG1-MTART'
'ZROH'.
using 'SAPLMGMM' '0070'.
using 'BDC_CURSOR'
'MSICHTAUSW-DYTXT(02)'.
using 'BDC_OKCODE'
'=ENTR'.
using 'MSICHTAUSW-KZSEL(01)'
'X'.
using 'MSICHTAUSW-KZSEL(02)'
'X'.
using 'SAPLMGMM' '4004'.
using 'BDC_OKCODE'
'=SP02'.
using 'MAKT-MAKTX'
'material'.
using 'BDC_CURSOR'
'MARA-MATKL'.
using 'MARA-MEINS'
IT_TAB-MEINS. "'EA'.
using 'MARA-MATKL'
IT_TAB-MATKL."'001'.
using 'MARA-MTPOS_MARA'
'NORM'.
using 'SAPLMGMM' '4004'.
using 'BDC_OKCODE'
'=ZU01'.
using 'BDC_CURSOR'
'MAKT-MAKTX'.
using 'MAKT-MAKTX'
'material'.
using 'SAPLMGMM' '4300'.
using 'BDC_OKCODE'
'=MAIN'.
using 'BDC_CURSOR'
'RMMG1-MATNR'.

perform bdc_dynpro
perform bdc_field

using 'SAPLMGMM' '4004'.


using 'BDC_OKCODE'
'=BU'.
perform bdc_field
using 'BDC_CURSOR'
'MAKT-MAKTX'.
perform bdc_field
using 'MAKT-MAKTX'
'material'.
*perform bdc_transaction using 'MM01'.
*perform close_group.
CALL TRANSACTION 'MM01' USING IT_BDCDATA
MODE 'A'.
ENDLOOP.
*----------------------------------------------------------------------*
*
Start new screen
*
*----------------------------------------------------------------------*
FORM BDC_DYNPRO USING PROGRAM DYNPRO.
CLEAR IT_BDCDATA.
IT_BDCDATA-PROGRAM = PROGRAM.
IT_BDCDATA-DYNPRO = DYNPRO.
IT_BDCDATA-DYNBEGIN = 'X'.
APPEND IT_BDCDATA.
ENDFORM.
*----------------------------------------------------------------------*
*
Insert field
*
*----------------------------------------------------------------------*
FORM BDC_FIELD USING FNAM FVAL.
* IF FVAL <> NODATA.
CLEAR IT_BDCDATA.
IT_BDCDATA-FNAM = FNAM.
IT_BDCDATA-FVAL = FVAL.
APPEND IT_BDCDATA.
* ENDIF.
ENDFORM.

You might also like