Bdc for mm01 transaction

Hi friends,
    I have to upload data using mm01 transaction.
    My program has to select respective views according to material type.
    Can anybody help me.
Thanks and regards,
Pavani.

Hi,
You will save lot of time & energy if you opt to use BAPI_MATERIAL_SAVEDATA. Have a look @the sample code. Please note Do not allocate any points as this code doesn't belong to me, however I have tested it & it works fine.
TABLES bapi_MVKEx.
* FLAGS
DATA: F_STOP. " Flag used to stop processing
* DATA DECLARATIONS
DATA : V_EMPTY TYPE I, " No. of empty records
       V_TOTAL TYPE I. " Total no. of records.
* STRUCTURES & INTERNAL TABLES
*--- BAPI structures
DATA: BAPI_HEAD LIKE BAPIMATHEAD, " Header Segment with Control
                                  "Information
BAPI_MAKT LIKE BAPI_MAKT, " Material Description
BAPI_MARA1 LIKE BAPI_MARA, " Client Data
BAPI_MARAX LIKE BAPI_MARAX, " Checkbox Structure for BAPI_MARA
BAPI_MARC1 LIKE BAPI_MARC, " Plant View
BAPI_MARCX LIKE BAPI_MARCX, " Checkbox Structure for BAPI_MARC
BAPI_MBEW1 LIKE BAPI_MBEW, " Accounting View
BAPI_MBEWX LIKE BAPI_MBEWX, " Checkbox Structure for BAPI_MBEW
BAPI_MVKE1 LIKE BAPI_MVKE, "Sales Data
BAPI_RETURN LIKE BAPIRET2. " Return Parameter
DATA: return     LIKE bapiret2 OCCURS 0 WITH HEADER LINE.
*--- Internal table to hold excel file data
DATA: IT_INTERN TYPE ALSMEX_TABLINE OCCURS 0 WITH HEADER LINE.
*--- Internal table to hold Matetrial descriptions
DATA: BEGIN OF IT_MAKT OCCURS 100.
INCLUDE STRUCTURE BAPI_MAKT.
DATA: END OF IT_MAKT.
*--- Internal to hold the records in the text file
DATA : BEGIN OF IT_DATA OCCURS 100,
WERKS(4), " Plant
MTART(4), " Material type
MATNR(18), " Material number
MATKL(9) , " Material group
MBRSH(1), " Industry sector
MEINS(3), " Base unit of measure
GEWEI(3), " Weight Unit
SPART(2), " Division
EKGRP(3), " Purchasing group
VPRSV(1), " Price control indicator
STPRS(12), " Standard price
PEINH(3), " Price unit
SPRAS(2), " Language key
MAKTX(40), " Material description
MTPOS_MARA(4), "Item Category Group
vkorg(4), "Sales Org
vtweg(2), "Dist channel
Prdha(18), "Prod Hierarchy
ladgr(4), " Loading Group
prctr(10), "Profit Centr
xchpf(1), "Batch Mgmt
kondm(2), "Material Pricing Grp
ktgrm(2), "Account Assignment Grp
mvgr1(4),
mvgr2(4),
mvgr3(4),
versg(1), "Material Statistics Grp
* Added fields not part of the layout
sapmatnr(18),
END OF IT_DATA.
* SELECTION SCREEN. *
SELECTION-SCREEN BEGIN OF BLOCK SCR1 WITH FRAME TITLE TEXT-111.
PARAMETER : P_FILE TYPE RLGRAP-FILENAME OBLIGATORY DEFAULT " Input File
'H:\DATA\Nova\rbc\zrbc129.xls'.
PARAMETER : P_MAX(4) OBLIGATORY DEFAULT '100'. " no.of recs in a session
PARAMETERS: P_HEADER TYPE I DEFAULT 0. " Header Lines
PARAMETERS: P_BEGCOL TYPE I DEFAULT 1 NO-DISPLAY,
P_BEGROW TYPE I DEFAULT 1 NO-DISPLAY,
P_ENDCOL TYPE I DEFAULT 100 NO-DISPLAY,
P_ENDROW TYPE I DEFAULT 32000 NO-DISPLAY.
SELECTION-SCREEN END OF BLOCK SCR1.
* AT SELECTION-SCREEN
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
*--- Validating file
PERFORM VALIDATE_FILE USING P_FILE.
* START-OF-SELECTION
START-OF-SELECTION.
*--- Perform to convert the Excel data into an internal table
PERFORM CONVERT_XLS_ITAB.
IF NOT IT_DATA[] IS INITIAL.
*--- Perform to delete Header lines
PERFORM DELETE_HEADER_EMPTY_RECS.
ENDIF.
* END OF SELECTION.
END-OF-SELECTION.
*--- Perform to upload Material Master data
PERFORM UPLOAD_MATMAS.
* Form : validate_input_file
* Description : To provide F4 help for file if read from PC
FORM VALIDATE_FILE USING F_FILE TYPE RLGRAP-FILENAME.
CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
exporting
STATIC = 'X'
CHANGING
FILE_NAME = F_FILE
EXCEPTIONS
MASK_TOO_LONG = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
*MESSAGE S010" 'Error in getting filename'.
ENDIF.
ENDFORM. " validate_input_file
*& Form CONVER_XLS_ITAB
* To convert XLS to internal table
FORM CONVERT_XLS_ITAB.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
FILENAME = P_FILE
I_BEGIN_COL = P_BEGCOL
I_BEGIN_ROW = P_BEGROW
I_END_COL = P_ENDCOL
I_END_ROW = P_ENDROW
TABLES
INTERN = IT_INTERN.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
*--- Perform to move the data into an internal data
PERFORM MOVE_DATA.
ENDFORM. " CONVERT_XLS_ITAB
*& Form MOVE_DATA
* text
FORM MOVE_DATA.
DATA : LV_INDEX TYPE I.
FIELD-SYMBOLS: <fs> type any.
*--- Sorting the internal table
SORT IT_INTERN BY ROW COL.
CLEAR IT_INTERN.
LOOP AT IT_INTERN.
MOVE IT_INTERN-COL TO LV_INDEX.
*--- Assigning the each record to an internal table row
ASSIGN COMPONENT LV_INDEX OF STRUCTURE IT_DATA TO <fs>.
*--- Asigning the field value to a field symbol
<fs> = it_intern-value.
*MOVE IT_INTERN-VALUE TO <fs>.
AT END OF ROW.
APPEND IT_DATA.
CLEAR IT_DATA.
ENDAT.
ENDLOOP.
ENDFORM. " MOVE_DATA
*& Form DELETE_HEADER_EMPTY_RECS
* To delete the Header and empty records
FORM DELETE_HEADER_EMPTY_RECS.
DATA: LV_TABIX LIKE SY-TABIX.
IF NOT P_HEADER IS INITIAL.
LOOP AT IT_DATA.
IF P_HEADER > 0 AND NOT IT_DATA IS INITIAL.
DELETE IT_DATA FROM 1 TO P_HEADER.
* P_HEADER = 0.
EXIT.
ENDIF.
ENDLOOP.
ENDIF.
CLEAR IT_DATA.
*--- To delete the empty lines from internal table
LOOP AT IT_DATA.
LV_TABIX = SY-TABIX.
IF IT_DATA IS INITIAL.
V_EMPTY = V_EMPTY + 1.
DELETE IT_DATA INDEX LV_TABIX..
ENDIF.
ENDLOOP.
CLEAR IT_DATA.
*--- Total no of recs in file
DESCRIBE TABLE IT_DATA LINES V_TOTAL.
IF V_TOTAL = 0.
*MESSAGE I013" No records in the file
F_STOP = 'X'.
STOP.
ENDIF.
ENDFORM. " DELETE_HEADER_EMPTY_RECS
*& Form UPLOAD_MATMAS
* to upload Material Master data
FORM UPLOAD_MATMAS .
LOOP AT IT_DATA.
* Header
CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
  EXPORTING
    input              = it_data-matnr
IMPORTING
   OUTPUT             =  it_data-sapmatnr
EXCEPTIONS
   LENGTH_ERROR       = 1
   OTHERS             = 2
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
BAPI_HEAD-MATERIAL = IT_DATA-sapMATNR.
BAPI_HEAD-IND_SECTOR = IT_DATA-MBRSH.
BAPI_HEAD-MATL_TYPE = IT_DATA-MTART.
BAPI_HEAD-BASIC_VIEW = 'X'.
BAPI_HEAD-PURCHASE_VIEW = 'X'.
BAPI_HEAD-ACCOUNT_VIEW = 'X'.
BAPI_HEAD-SALES_VIEW = 'X'.
BAPI_HEAD-QUALITY_VIEW = 'X'.
* Material Description
REFRESH IT_MAKT.
IT_MAKT-LANGU = IT_DATA-SPRAS.
IT_MAKT-MATL_DESC = IT_DATA-MAKTX.
APPEND IT_MAKT.
* Client Data - Basic
BAPI_MARA1-MATL_GROUP = IT_DATA-MATKL.
BAPI_MARA1-BASE_UOM = IT_DATA-MEINS.
BAPI_MARA1-UNIT_OF_WT = IT_DATA-GEWEI.
BAPI_MARA1-DIVISION = IT_DATA-SPART.
BAPI_MARA1-item_cat = it_data-mtpos_mara.
BAPI_MARA1-PROD_HIER = it_data-prdha.
bapi_marax-item_cat = 'X'.
bapi_marax-prod_hier = 'X'.
BAPI_MARAX-MATL_GROUP = 'X'.
BAPI_MARAX-BASE_UOM = 'X'.
BAPI_MARAX-UNIT_OF_WT = 'X'.
BAPI_MARAX-DIVISION = 'X'.
* Plant - Purchasing
BAPI_MARC1-PLANT = IT_DATA-WERKS.
BAPI_MARC1-PUR_GROUP = IT_DATA-EKGRP.
BAPI_MARC1-LOADINGGRP = IT_DATA-LADGR.
BAPI_MARC1-PROFIT_CTR = IT_DATA-prctr.
BAPI_MARC1-BATCH_MGMT = IT_DATA-xchpf.
bapi_marc1-qm_authgrp = 'X'.
bapi_marcx-qm_authgrp = 'X'.
BAPI_MARCX-PLANT = IT_DATA-WERKS.
BAPI_MARCX-PUR_GROUP = 'X'.
BAPI_MARCX-LOADINGGRP = 'X'.
BAPI_MARCX-PROFIT_CTR = 'X'.
BAPI_MARCX-BATCH_MGMT = 'X'.
* Accounting
BAPI_MBEW1-VAL_AREA = IT_DATA-WERKS.
BAPI_MBEW1-PRICE_CTRL = IT_DATA-VPRSV.
BAPI_MBEW1-STD_PRICE = IT_DATA-STPRS.
BAPI_MBEW1-PRICE_UNIT = IT_DATA-PEINH.
BAPI_MBEWX-VAL_AREA = IT_DATA-WERKS.
BAPI_MBEWX-PRICE_CTRL = 'X'.
BAPI_MBEWX-STD_PRICE = 'X'.
BAPI_MBEWX-PRICE_UNIT = 'X'.
* Sales Data
BAPI_MVKE1-ITEM_CAT = IT_DATA-MTPOS_MARA.
BAPI_MVKEX-ITEM_CAT = 'X'.
BAPI_MVKE1-SALES_ORG = IT_DATA-vkorg.
BAPI_MVKEX-SALES_ORG = IT_DATA-vkorg.
BAPI_MVKE1-DISTR_CHAN = IT_DATA-vtweg.
BAPI_MVKEX-DISTR_CHAN = IT_DATA-vtweg.
BAPI_MVKE1-MAT_PR_GRP = IT_DATA-kondm.
BAPI_MVKEX-MAT_PR_GRP = 'X'.
BAPI_MVKE1-ACCT_ASSGT = IT_DATA-ktgrm.
BAPI_MVKEX-ACCT_ASSGT = 'X'.
BAPI_MVKE1-MATL_GRP_1 = IT_DATA-mvgr1.
BAPI_MVKEX-MATL_GRP_1 = 'X'.
BAPI_MVKE1-MATL_GRP_2 = IT_DATA-mvgr2.
BAPI_MVKEX-MATL_GRP_2 = 'X'.
BAPI_MVKE1-MATL_GRP_3 = IT_DATA-mvgr3.
BAPI_MVKEX-MATL_GRP_3 = 'X'.
BAPI_MVKE1-matl_stats = IT_DATA-versg.
BAPI_MVKEX-matl_stats = 'X'.
*--- BAPI to create material
call function 'BAPI_MATERIAL_SAVEDATA'
exporting
HEADDATA = BAPI_HEAD
CLIENTDATA = BAPI_MARA1
CLIENTDATAX = BAPI_MARAX
PLANTDATA = BAPI_MARC1
PLANTDATAX = BAPI_MARCX
SALESDATA = BAPI_MVKE1
SALESDATAX = BAPI_MVKEX
IMPORTING
RETURN = BAPI_RETURN
TABLES
MATERIALDESCRIPTION = IT_MAKT
IF BAPI_RETURN-TYPE = 'E'.
WRITE:/ 'Error:' ,BAPI_RETURN-MESSAGE ,'for material:' ,it_data-matnr.
ELSEIF BAPI_RETURN-TYPE = 'S'.
WRITE: 'Successfully created/Changed material' ,it_data-matnr.
      CLEAR return.
      REFRESH return.
      CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
           IMPORTING
                return = return.
ENDIF.
ENDLOOP.
ENDFORM. " UPLOAD_MATMAS
Regards
Raju Chitale

Similar Messages

  • BDC code for MM01 Transaction

    Hi All,,
                 Please give Entire BDC code for MM01 Transaction.
    i will change as per my requirement.
    I think this is already done by some ABAP Consultants.
    plz dont give answers like do recording for that transaction MM01. I know recording...
    For time constraiint, I have to complete soon.....
    Thanks in Advance
    BestRegards,
    Anil

    Hi,
    The below code is using the Session Method
    report ZDS_BDC_MM01
           no standard page heading line-size 255.
    include bdcrecx1.
    *parameters: dataset(132) lower case.
    ***    DO NOT CHANGE - the generated data section - DO NOT CHANGE    ***
    *   If it is nessesary to change the data section use the rules:
    *   1.) Each definition of a field exists of two lines
    *   2.) The first line shows exactly the comment
    *       '* data element: ' followed with the data element
    *       which describes the field.
    *       If you don't have a data element use the
    *       comment without a data element name
    *   3.) The second line shows the fieldname of the
    *       structure, the fieldname must consist of
    *       a fieldname and optional the character '_' and
    *       three numbers and the field length in brackets
    *   4.) Each field must be type C.
    *** Generated data section with specific formatting - DO NOT CHANGE  ***
    data: begin of record OCCURS 0,
    * data element: MATNR
            MATNR_001(018),
    * data element: MBRSH
            MBRSH_002(001),
    * data element: MTART
            MTART_003(004),
    * data element: XFELD
            KZSEL_01_004(001),
    * data element: XFELD
            KZSEL_02_005(001),
    * data element: MAKTX
            MAKTX_006(040),
    * data element: MEINS
            MEINS_007(003),
    * data element: MAKTX
            MAKTX_008(040),
          end of record.
    *** End generated data section ***
    start-of-selection.
    *perform open_dataset using dataset.
    perform open_group.
    CALL FUNCTION 'GUI_UPLOAD'
      EXPORTING
        FILENAME                      ='C:\DHRUV.TXT'
       FILETYPE                      = 'DAT'
    *   HAS_FIELD_SEPARATOR           = ' '
    *   HEADER_LENGTH                 = 0
    *   READ_BY_LINE                  = 'X'
    *   DAT_MODE                      = ' '
    *   CODEPAGE                      = ' '
    *   IGNORE_CERR                   = ABAP_TRUE
    *   REPLACEMENT                   = '#'
    *   CHECK_BOM                     = ' '
    *   VIRUS_SCAN_PROFILE            =
    *   NO_AUTH_CHECK                 = ' '
    * IMPORTING
    *   FILELENGTH                    =
    *   HEADER                        =
      TABLES
        DATA_TAB                      = RECORD
    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.
    *do.
    LOOP AT record.
    *read dataset dataset into record.
    if sy-subrc <> 0. exit. endif.
    perform bdc_dynpro      using 'SAPLMGMM' '0060'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'RMMG1-MATNR'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform bdc_field       using 'RMMG1-MATNR'
                                  record-MATNR_001.
    perform bdc_field       using 'RMMG1-MBRSH'
                                  record-MBRSH_002.
    perform bdc_field       using 'RMMG1-MTART'
                                  record-MTART_003.
    perform bdc_dynpro      using 'SAPLMGMM' '0070'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'MSICHTAUSW-DYTXT(02)'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=ENTR'.
    perform bdc_field       using 'MSICHTAUSW-KZSEL(01)'
                                  record-KZSEL_01_004.
    perform bdc_field       using 'MSICHTAUSW-KZSEL(02)'
                                  record-KZSEL_02_005.
    perform bdc_dynpro      using 'SAPLMGMM' '4004'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform bdc_field       using 'MAKT-MAKTX'
                                  record-MAKTX_006.
    perform bdc_field       using 'BDC_CURSOR'
                                  'MARA-MEINS'.
    perform bdc_field       using 'MARA-MEINS'
                                  record-MEINS_007.
    perform bdc_dynpro      using 'SAPLMGMM' '4004'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'MAKT-MAKTX'.
    perform bdc_field       using 'MAKT-MAKTX'
                                  record-MAKTX_008.
    perform bdc_dynpro      using 'SAPLSPO1' '0300'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=YES'.
    perform bdc_transaction using 'MM01'.
    *enddo.
    ENDLOOP.
    perform close_group.
    *perform close_dataset using dataset.
    *Text elements
    * E00 Error opening dataset, return code:
    * I01 Session name
    * I02 Open session
    * I03 Insert transaction
    * I04 Close Session
    * I05 Return code =
    * I06 Error session created
    * S01 Session name
    * S02 User
    * S03 Keep session
    * S04 Lock date
    * S05 Processing Mode
    * S06 Update Mode
    * S07 Generate session
    * S08 Call transaction
    * S09 Error sessn
    * S10 Nodata indicator
    * S11 Short log
    *Messages
    * Message class: MS
    *613   Please enter a session name and user name
    The Below is the coding for the Call Transaction...
    report ZDS_BDC_MM01_2
           no standard page heading line-size 255.
    *include bdcrecx1.
    *parameters: dataset(132) lower case.
    ***    DO NOT CHANGE - the generated data section - DO NOT CHANGE    ***
    *   If it is nessesary to change the data section use the rules:
    *   1.) Each definition of a field exists of two lines
    *   2.) The first line shows exactly the comment
    *       '* data element: ' followed with the data element
    *       which describes the field.
    *       If you don't have a data element use the
    *       comment without a data element name
    *   3.) The second line shows the fieldname of the
    *       structure, the fieldname must consist of
    *       a fieldname and optional the character '_' and
    *       three numbers and the field length in brackets
    *   4.) Each field must be type C.
    *** Generated data section with specific formatting - DO NOT CHANGE  ***
    data: begin of record OCCURS 0,
    * data element: MATNR
            MATNR_001(018),
    * data element: MBRSH
            MBRSH_002(001),
    * data element: MTART
            MTART_003(004),
    * data element: XFELD
            KZSEL_01_004(001),
    * data element: MAKTX
            MAKTX_005(040),
    * data element: MEINS
            MEINS_006(003),
    * data element: MTPOS_MARA
            MTPOS_MARA_007(004),
          end of record.
    DATA: FLNAME TYPE STRING.
    *** End generated data section ***
    DATA:   BDCDATA LIKE BDCDATA    OCCURS 0 WITH HEADER LINE.
    *** MESSAGE******
    DATA: BEGIN OF MESSTAB OCCURS 0.
            INCLUDE STRUCTURE BDCMSGCOLL.
            DATA: MATNR TYPE MARA-MATNR,
          END OF MESSTAB.
    ****END OF MESSAGE****
    PARAMETERS: FILENAME TYPE RLGRAP-FILENAME.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR FILENAME.
      CALL FUNCTION 'F4_FILENAME'
       IMPORTING
         FILE_NAME           = FILENAME.
    start-of-selection.
    *perform open_dataset using dataset.
    perform open_group.
    FLNAME = FILENAME.
    CALL FUNCTION 'GUI_UPLOAD'
      EXPORTING
        FILENAME                      = FLNAME
        FILETYPE                      = 'DAT'
    *   HAS_FIELD_SEPARATOR           = ' '
    *   HEADER_LENGTH                 = 0
    *   READ_BY_LINE                  = 'X'
    *   DAT_MODE                      = ' '
    *   CODEPAGE                      = ' '
    *   IGNORE_CERR                   = ABAP_TRUE
    *   REPLACEMENT                   = '#'
    *   CHECK_BOM                     = ' '
    *   VIRUS_SCAN_PROFILE            =
    *   NO_AUTH_CHECK                 = ' '
    * IMPORTING
    *   FILELENGTH                    =
    *   HEADER                        =
      TABLES
        DATA_TAB                      = record
    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.
    LOOP AT record.
      DATA:
        CNT TYPE I.
        CNT = CNT + 1.
        REFRESH BDCDATA.
    perform bdc_dynpro      using 'SAPLMGMM' '0060'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'RMMG1-MTART'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform bdc_field       using 'RMMG1-MATNR'
                                  record-MATNR_001.
    perform bdc_field       using 'RMMG1-MBRSH'
                                  record-MBRSH_002.
    perform bdc_field       using 'RMMG1-MTART'
                                  record-MTART_003.
    perform bdc_dynpro      using 'SAPLMGMM' '0070'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'MSICHTAUSW-DYTXT(01)'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=ENTR'.
    perform bdc_field       using 'MSICHTAUSW-KZSEL(01)'
                                  record-KZSEL_01_004.
    perform bdc_dynpro      using 'SAPLMGMM' '4004'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform bdc_field       using 'MAKT-MAKTX'
                                  record-MAKTX_005.
    perform bdc_field       using 'BDC_CURSOR'
                                  'MARA-MEINS'.
    perform bdc_field       using 'MARA-MEINS'
                                  record-MEINS_006.
    perform bdc_field       using 'MARA-MTPOS_MARA'
                                  record-MTPOS_MARA_007.
    perform bdc_dynpro      using 'SAPLSPO1' '0300'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=YES'.
    *perform bdc_transaction using 'MM01'.
    CALL TRANSACTION 'MM01' USING BDCDATA
                            MODE 'N'
                            UPDATE 'A'
                            MESSAGES INTO MESSTAB.
    READ TABLE MESSTAB INTO MESSTAB INDEX CNT.
       IF MESSTAB-MSGTYP = 'E'.
         MESSTAB-MATNR = RECORD-MATNR_001.
         MODIFY MESSTAB INDEX CNT FROM MESSTAB. " TRANSPORTING MATNR.
       ENDIF.
    ENDLOOP.
    FORM OPEN_GROUP.
      CALL FUNCTION 'BDC_OPEN_GROUP'
             EXPORTING  CLIENT   = SY-MANDT
                        GROUP    = 'MM01'
                        USER     = SY-UNAME
                        KEEP     = 'X'.
    ENDFORM.
    FORM BDC_INSERT.
      CALL FUNCTION 'BDC_INSERT'
       EXPORTING
         TCODE                  = 'MM01'
    *     POST_LOCAL             = NOVBLOCAL
    *     PRINTING               = NOPRINT
    *     SIMUBATCH              = ' '
    *     CTUPARAMS              = ' '
        TABLES
          DYNPROTAB              = BDCDATA
       EXCEPTIONS
         INTERNAL_ERROR         = 1
         NOT_OPEN               = 2
         QUEUE_ERROR            = 3
         TCODE_INVALID          = 4
         PRINTING_INVALID       = 5
         POSTING_INVALID        = 6
         OTHERS                 = 7
      IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
             WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.
    END-OF-SELECTION.
    LOOP AT MESSTAB.
        IF MESSTAB-MSGTYP = 'E'.
          WRITE:/ 'ERROR OCCURED ON MATNR = ',MESSTAB-MATNR , 'MESSAGE : MATNR ALREADY EXISTS IN MARA!!!'.
        ENDIF.
      ENDLOOP.
    perform close_group.
    *perform close_dataset using dataset.
    *&      Form  close_group
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM close_group .
    CALL FUNCTION 'BDC_CLOSE_GROUP'
    EXCEPTIONS
       NOT_OPEN          = 1
       QUEUE_ERROR       = 2
       OTHERS            = 3
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
             WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    ENDFORM.                    " close_group
    *&      Form  bdc_dynpro
    *       text
    *      -->P_0270   text
    *      -->P_0271   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
    *      -->P_0275   text
    *      -->P_0276   text
    FORM bdc_field  USING  FNAM FVAL.
      IF FVAL <> ' '.
        CLEAR BDCDATA.
        BDCDATA-FNAM = FNAM.
        BDCDATA-FVAL = FVAL.
        APPEND BDCDATA.
      ENDIF.
    ENDFORM.                    " bdc_field
    *Text elements
    * E00 Error opening dataset, return code:
    * I01 Session name
    * I02 Open session
    * I03 Insert transaction
    * I04 Close Session
    * I05 Return code =
    * I06 Error session created
    * S01 Session name
    * S02 User
    * S03 Keep session
    * S04 Lock date
    * S05 Processing Mode
    * S06 Update Mode
    * S07 Generate session
    * S08 Call transaction
    * S09 Error sessn
    * S10 Nodata indicator
    * S11 Short log
    HTH
    Regards,
    Dhruv Shah

  • Error while running a BDC for the Transaction F-02

    Hi,
           I'm getting an error <b><i>"Parking not possible during Batch Input"</i></b> while running a BDC for the transaction F-02.
           When i click on the error message it displays the message [b<i>]"In Customizing, you can control whether an error message is issued."</b></i>
            How to solve this issue?.
            Waiting for ur replies.........
    Regards
    N.Senthil

    Hi,
    When you are doing the recording in SHDB, and in the same screen where the TCODE to be recorded is given, there are options that you can choose called "Recording Parameters"...Select the checkbox which says "Not a Batch Input Session", this will set the sy-binpt variable to " "(in a recording by default it is "X")...and you will not get this error...
    Also make sure while writing the BDC program to make use of the "bdc options" parameter which has this property to switch of sy-binpt...
        Refer below theard for sample bdc code for f-02.
    https://forums.sdn.sap.com/click.jspa?searchID=5126766&messageID=1538409
    Regards

  • Bdc for 3 transactions

    Hi gurus
    I am writing a bdc for 3 transaction , it runs fines if i execute them seperately , can u let me know who do i merge 3 transactions in one BDC . transactions used are FBRA, F.80 and F-04 .
    is their any specific way .... pls send the code if possible.....
    thanks in advance.
    its urgent

    Hi Shweta
    do u want to run all 3 transaction at a time or run separtely..
    If u want 3 at a time then
    define 3 internal table and 3 BDC struture.
    In FM BDC_INSERT use appropriate internal for correct transactio.
    Like...
    FM BDC_OPEN_GROUP..
    Call Function 'BDC_INSERT'
    Exporting
    tcode = 'FRBA'
    importing
    table = itab1.
    Call Function 'BDC_INSERT'
    Exporting
    tcode = 'F-04'
    importing
    table = itab2.
    Call Function 'BDC_INSERT'
    Exporting
    tcode = 'F.80'
    importing
    table = itab3.
    call FM "BDC_CLOSE_GROUP.
    Reward me if its useful
    Regards
    Ravi

  • Dynamic select views for MM01 Transaction

    Hii  Friends,
    I have an issue like i need to dynamically select the views in MM01 transaction from the BDC program
    without selecting that views manually.
    Using SHDB recording i can select the views before recording  and then call those views again
    If i want to select the views from the program how do i do it..
    If there is any way to do this in call transaction let me know plz
    Thanks in advance
    kishore

    BDC is not good for MM01 , go for bapi
    other wise go for  LSMW bapi method...
    Business Object      BUS1001006   Standard material
    Method               SAVEDATA                    Create and change materia
    Message Type         MATMAS_BAPI                 Create and change materia
    Basic Type           MATMAS_BAPI02               Create and Change Materia

  • BDC for MM01 using bapi

    HI all ,
    i am new to bapi . i have created so many bdcs to upload data in sap but havent done any bapi .
    i want to upload data through bapi  for mm01 .
    how can i achieve this and which bapi is responsible for this job . plz send any sample code for this .
    Thanks ,
    Amit Ranjan .

    Hi Amit,
    Refer to the code in the following link:
    Re: Reg Transfer of MM01 data using BAPI method
    Hope this will solve your query...

  • BDC for MM01

    Hi all.
    I need BDC code for MM01,i need to populate values depending upon "Material type",Because view changing depending upon material type.
    please give me code for that.
    To be reward all helpfull answers.
    Regards.
    jay

    Hi,
    This is a BDC for MM for T-code MM01.I hope this will help u.
    Below is the coding.
    Reward if helpful.
    Regards,
    Seevangi
    REPORT  ZMMBDC_MATERIAL_MASTER_UPD
    LINE-SIZE 255 NO STANDARD PAGE HEADING LINE-COUNT 65.
    Tables
    Structure declaration
    Work Variables and internal tables
    Constants
    Parameters
    Events: Start-Of-Selection
    data : begin of i_mara occurs 0,
            matnr like mara-matnr,
           end of i_mara.
    data : begin of ty_matdata,
            matnr like mara-matnr,   "material number
            mbrsh like rmmg1-mbrsh,  "Industry sector
            mtart like rmmg1-mtart,  "Material Type
            werks like rmmg1-werks,  "Plant
            lgort like rmmg1-lgort,  "Storage Location
            vkorg like rmmg1-vkorg,  "Sales Organization
            vtweg like rmmg1-vtweg,  "Distribution Channel
            maktx like makt-maktx,   "Material Description (Short Text)
            meins like mara-meins,   "Base Unit of Measure
            matkl like mara-matkl,   "Material Group
            bismt like mara-bismt,   "Old material number
            spart like mara-spart,   "Division
            brgew(15) ," like mara-brgew,   "Gross Weight
            ntgew(15), " like mara-ntgew,   "Net Weight
            ekgrp like marc-ekgrp,   "Purchasing Group
            gewei like mara-gewei,   "Weight Unit
            klart like rmclf-klart,  "Class Type
            taxkm like MG03STEUER-TAXKM, "Tax classification material
            ladgr like marc-ladgr,   "Loading Group
            tragr like mara-tragr,   "Transportation Group
            dismm like marc-dismm, "MRP Type
            dispo like marc-dispo, "MRP Controller (Materials Planner)
            fhori like marc-fhori, "Scheduling margin key
            disls like marc-disls, " lot size
            prmod like mpop-prmod, "Forecast model
            peran(3)," like mpop-peran,   "Number of historical periods
            anzpr(3)," like mpop-anzpr,   "Number of forecast periods
            kzini like mpop-kzini,   "Initialization indicator
            siggr(9)," like mpop-siggr,   "Tracking limit
            autru like marc-autru,   "Reset Forecast Model Automatically
            modav like mpop-modav,   "Model selection procedure
            perkz like marc-perkz, "Period Indicator
            verpr(13), " like mbew-verpr, "Moving Average Price/Periodic Unit Price
            prctr like marc-prctr, "Profit Center
            mtvfp like marc-mtvfp, "Checking Group for Availability Check
            bklas like mbew-bklas, "Valuation Class
            vprsv like mbew-vprsv, "Price control indicator
            stprs(13) ," like mbew-stprs, "Standard price
            peinh(5) ,"like mbew-peinh, "Price Unit
           end of ty_matdata,
           begin of ty_matdata1,
           matnr like mara-matnr,   "material number
            mbrsh like rmmg1-mbrsh,  "Industry sector
            mtart like rmmg1-mtart,  "Material Type
            werks like rmmg1-werks,  "Plant
            lgort like rmmg1-lgort,  "Storage Location
            vkorg like rmmg1-vkorg,  "Sales Organization
            vtweg like rmmg1-vtweg,  "Distribution Channel
            maktx like makt-maktx,   "Material Description (Short Text)
            meins like mara-meins,   "Base Unit of Measure
            matkl like mara-matkl,   "Material Group
            bismt like mara-bismt,   "Old material number
            spart like mara-spart,   "Division
            brgew(15) ," like mara-brgew,   "Gross Weight
            ntgew(15), " like mara-ntgew,   "Net Weight
            ekgrp like marc-ekgrp,   "Purchasing Group
            gewei like mara-gewei,   "Weight Unit
            klart like rmclf-klart,  "Class Type
            taxkm like MG03STEUER-TAXKM, "Tax classification material
            ladgr like marc-ladgr,   "Loading Group
            tragr like mara-tragr,   "Transportation Group
            dismm like marc-dismm, "MRP Type
            dispo like marc-dispo, "MRP Controller (Materials Planner)
            fhori like marc-fhori, "Scheduling margin key
            prmod like mpop-prmod, "Forecast model
            peran(3)," like mpop-peran,   "Number of historical periods
            anzpr(3)," like mpop-anzpr,   "Number of forecast periods
            kzini like mpop-kzini,   "Initialization indicator
            siggr(9)," like mpop-siggr,   "Tracking limit
            autru like marc-autru,   "Reset Forecast Model Automatically
            modav like mpop-modav,   "Model selection procedure
            perkz like marc-perkz, "Period Indicator
            verpr(13), " like mbew-verpr, "Moving Average Price/Periodic Unit Price
            prctr like marc-prctr, "Profit Center
            mtvfp like marc-mtvfp, "Checking Group for Availability Check
            bklas like mbew-bklas, "Valuation Class
            vprsv like mbew-vprsv, "Price control indicator
            stprs(13) ," like mbew-stprs, "Standard price
            peinh(5) ,"like mbew-peinh, "Price Unit
            message like bapiret2-message, "Error Message.
           end of ty_matdata1,
           begin of ty_error,
             matnr like mara-matnr,
             mbrsh like rmmg1-mbrsh,  "Industry sector
             mtart like rmmg1-mtart,  "Material Type
             werks like rmmg1-werks,  "Plant
             message like bapiret2-message,
           end of ty_error.
          Data                     Begin with W_                        *
    data : i_matdata like standard table of ty_matdata with header line.
    BAPIMATHEAD - Header Segment with Control Information
    data : i_headdata like bapimathead occurs 0 with header line.
    bapi_makt - Material Descriptions.
    data : i_bapi_makt like bapi_makt occurs 0 with header line.
    *bapi_mlan - Tax data
    data : i_bapi_mlan like bapi_mlan occurs 0 with header line.
    bapi_mara - Material Data at Client Level.
    data : i_clientdata like bapi_mara occurs 0 with header line.
    bapi_marax - Checkbox Structure for BAPI_MARA.
    data : i_clientdatax like bapi_marax occurs 0 with header line.
    bapi_marc - Material Data at Plant Level.
    data : i_plantdata like bapi_marc occurs 0 with header line.
    bapi_marcx - Checkbox Structure for BAPI_MARA.
    data : i_plantdatax like bapi_marcx occurs 0 with header line.
    BAPI_MARD - Material Data at Storage Location Level.
    data : i_storagelocationdata like bapi_mard occurs 0 with header line.
    bapi_mardx - Checkbox Structure for BAPI_MARD
    data : i_storagelocationdatax like bapi_mardx occurs 0 with header line.
    *bapi_mpop - Forecast Parameters
    data : i_forcastingparameter like BAPI_MPOP occurs 0 with header line.
    *bapi_mpopx - Checkbox Structure for BAPI_MPOP
    data : i_forcastingparameterx like BAPI_MPOPX occurs 0 with header line.
    *bapi_mbew - Valuation Data
    data : i_valuationdata like BAPI_MBEW occurs 0 with header line.
    *bapi_mbewx - Checkbox Structure for BAPI_MBEW
    data : i_valuationdatax like BAPI_MBEWX occurs 0 with header line.
    *bapi_mvke - Sales Data
    data : i_salesdata like BAPI_MVKE occurs 0 with header line.
    *bapi_mvkex - Checkbox Structure for BAPI_MVKE
    data : i_salesdatax like BAPI_MVKEX occurs 0 with header line.
    bapiret2 - Return parameter
    data : i_return like bapiret2 occurs 0 with header line.
    Errors displayed on screen.
    data : i_error like standard table of ty_error with header line.
    *Error data to be loaded after correction.
    data : i_matdata1 like standard table of ty_matdata1 with header line.
    *bapi_marm - Unit of measure
    data : i_bapi_marm like bapi_marm occurs 0 with header line.
    *bapi_marmx - unit of measurex
    data : i_bapi_marmx like bapi_marmx occurs 0 with header line.
    To determine error.
    data : w_flg(1).
       S E L E C T I O N     S C R E E N / P A R A M E T E R S
    selection-screen: begin of block b1 with frame.
    parameters: p_file like rlgrap-filename obligatory.
    selection-screen: end of block b1.
    selection-screen skip 1.
    selection-screen: begin of block b2 with frame.
    parameters: p_file1 like rlgrap-filename .
    selection-screen: end of block b2.
              A T   S E L E C T I O N   S C R E E N
    at selection-screen on value-request for p_file.
    WS_FILENAME_GET - Determination of a file name on the presentation
    server using a file selection dialog.
      call function 'WS_FILENAME_GET'
    exporting
       def_filename           = '*.TXT'
       def_path               = 'C:\'
       mask                   = ',.TXT,.*.'
       mode                   = 'O'
      TITLE                  = ' '
       importing
         filename               = p_file
      RC                     =
    exceptions
       inv_winsys             = 1
       no_batch               = 2
       selection_cancel       = 3
       selection_error        = 4
       others                 = 5
      if sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      endif.
                      T O P    O F     P A G E                          *
    top-of-page.
      skip.
      write : /01 'Material Number', 30 'Error Message'.
       S T  A R T   O F   S E L E C T I O N
    start-of-selection.
    perform read_data.
    perform create_material.
    perform display_error.
    *&      Form  read_data
          text
    -->  p1        text
    <--  p2        text
    form read_data.
    Uploads a file from the presentation server into an internal table.
    call function 'WS_UPLOAD'
           exporting
                codepage                = 'IBM'
                filename                = p_file
                filetype                = 'DAT'
           tables
                data_tab                = i_matdata
           exceptions
                conversion_error        = 1
                file_open_error         = 2
                file_read_error         = 3
                invalid_type            = 4
                no_batch                = 5
                unknown_error           = 6
                invalid_table_width     = 7
                gui_refuse_filetransfer = 8
                customer_error          = 9
                others                  = 10.
      if sy-subrc <> 0.
        write:/ 'File Not Uploaded'.
      endif.
    endform.                    " read_data
    *&      Form  create_material
          text
    -->  p1        text
    <--  p2        text
    form create_material.
    loop at i_matdata.
    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
      EXPORTING
        INPUT         = i_matdata-matnr
    IMPORTING
       OUTPUT        = i_matdata-matnr.
    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
      EXPORTING
        INPUT         = i_matdata-prctr
    IMPORTING
       OUTPUT        = i_matdata-prctr
    *select matnr from mara into table i_mara .
    *sort i_mara by matnr descending.
    *read table i_mara index 1.
    *i_mara-matnr = i_mara-matnr + 1.
    CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
      EXPORTING
        INPUT              =  i_mara-matnr
      IMPORTING
        OUTPUT             =  i_mara-matnr
      EXCEPTIONS
        LENGTH_ERROR       = 1
        OTHERS             = 2
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    *CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
    EXPORTING
       INPUT              =  i_matdata-matnr
    IMPORTING
       OUTPUT             =  i_matdata-matnr
    EXCEPTIONS
       LENGTH_ERROR       = 1
       OTHERS             = 2
    *IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    *ENDIF.
    i_headdata-material = i_matdata-matnr.
      i_headdata-material = i_mara-matnr.
      i_headdata-ind_sector = i_matdata-mbrsh.
      i_headdata-matl_type = i_matdata-mtart.
      i_headdata-basic_view = 'X'.
      i_headdata-mrp_view = 'X'.
      i_headdata-storage_view = 'X'.
      i_headdata-SALES_VIEW = 'X'.
      i_headdata-PURCHASE_VIEW = 'X'.
      i_headdata-FORECAST_VIEW = 'X'.
      i_headdata-ACCOUNT_VIEW = 'X'.
      i_headdata-COST_VIEW = 'X'.
      i_headdata-prt_view = 'X'.
      i_headdata-work_sched_view = 'X'.
      i_headdata-quality_view = 'X'.
      append i_headdata.
    clear i_headdata.
      i_bapi_makt-langu     = sy-langu.
      i_bapi_makt-matl_desc = i_matdata-maktx.
      append i_bapi_makt.
    clear i_bapi_makt.
      i_clientdata-matl_group = i_matdata-matkl.
      i_clientdata-old_mat_no = i_matdata-bismt.
      i_clientdata-base_uom = i_matdata-meins.
      i_clientdata-division = i_matdata-spart.
      i_clientdata-UNIT_OF_WT = i_matdata-gewei.
      i_clientdata-TRANS_GRP = i_matdata-tragr.
      i_clientdata-NET_WEIGHT = i_matdata-ntgew.
      append i_clientdata.
    clear i_clientdata.
      i_clientdatax-matl_group = 'X'.
      i_clientdatax-old_mat_no = 'X'.
      i_clientdatax-base_uom = 'X'.
      i_clientdatax-division = 'X'.
      i_clientdatax-UNIT_OF_WT = 'X'.
      i_clientdatax-TRANS_GRP = 'X'.
      i_clientdatax-NET_WEIGHT = 'X'.
      append i_clientdatax.
    clear i_clientdatax.
      i_plantdata-plant = i_matdata-werks.
      i_plantdata-mrp_type = i_matdata-dismm.
      i_plantdata-mrp_ctrler = i_matdata-dispo.
      i_plantdata-availcheck = i_matdata-mtvfp.
      i_plantdata-profit_ctr = i_matdata-prctr.
      i_plantdata-LOADINGGRP = i_matdata-ladgr.
      i_plantdata-PUR_GROUP = i_matdata-ekgrp.
      i_plantdata-AUTO_RESET = i_matdata-autru.
      i_plantdata-PERIOD_IND = i_matdata-perkz.
      i_plantdata-MRP_CTRLER = i_matdata-dispo.
      i_plantdata-SM_KEY = i_matdata-fhori.
      i_plantdata-LOTSIZEKEY = i_matdata-disls.
      append i_plantdata.
    clear i_plantdata.
      i_plantdatax-plant = i_plantdata-plant.
      i_plantdatax-mrp_type = 'X'.
      i_plantdatax-mrp_ctrler = 'X'.
      i_plantdatax-availcheck = 'X' .
      i_plantdatax-profit_ctr = 'X' .
      i_plantdatax-LOADINGGRP = 'X' .
      i_plantdatax-PUR_GROUP = 'X' .
      i_plantdatax-AUTO_RESET = 'X'.
      i_plantdatax-PERIOD_IND = 'X'.
      i_plantdatax-MRP_CTRLER = 'X'.
      i_plantdatax-SM_KEY = 'X'.
      i_plantdatax-LOTSIZEKEY = 'X'.
      append i_plantdatax.
    clear i_plantdatax.
      clear i_forcastingparameter.
      i_forcastingparameter-PLANT = i_matdata-werks.
      i_forcastingparameter-HIST_VALS = i_matdata-peran.
      i_forcastingparameter-FORE_PDS = i_matdata-anzpr.
      i_forcastingparameter-INITIALIZE = i_matdata-kzini.
      i_forcastingparameter-TRACKLIMIT = i_matdata-siggr.
      i_forcastingparameter-MODEL_SP = i_matdata-modav.
      i_forcastingparameter-FORE_MODEL = i_matdata-prmod.
      append i_forcastingparameter.
      clear i_forcastingparameterx.
      i_forcastingparameterx-PLANT = i_matdata-werks.
      i_forcastingparameterx-HIST_VALS = 'X'.
      i_forcastingparameterx-FORE_PDS = 'X'.
      i_forcastingparameterx-INITIALIZE = 'X'.
      i_forcastingparameterx-TRACKLIMIT = 'X'.
      i_forcastingparameterx-MODEL_SP = 'X'.
      i_forcastingparameterx-FORE_MODEL = 'X'.
      append i_forcastingparameterx.
      i_valuationdata-MOVING_PR = i_matdata-verpr.
      i_valuationdata-STD_PRICE = i_matdata-stprs.
      i_valuationdata-PRICE_CTRL = i_matdata-VPRSV.
      i_valuationdata-VAL_CLASS = i_matdata-bklas.
      i_valuationdata-PRICE_UNIT = i_matdata-peinh.
      i_valuationdata-VAL_AREA = i_matdata-werks.
      append i_valuationdata.
      i_valuationdatax-VAL_AREA = i_matdata-werks.
      i_valuationdatax-MOVING_PR = 'X'.
      i_valuationdatax-STD_PRICE = 'X'.
      i_valuationdatax-PRICE_CTRL = 'X'.
      i_valuationdatax-VAL_CLASS = 'X'.
      i_valuationdatax-PRICE_UNIT = 'X'.
      append i_valuationdatax.
      i_salesdata-SALES_ORG = i_matdata-vkorg.
      i_salesdata-DISTR_CHAN = i_matdata-vtweg.
      i_salesdata-DELY_UOM = i_matdata-meins.
      append i_salesdata.
      i_salesdatax-SALES_ORG = i_matdata-vkorg.
      i_salesdatax-DISTR_CHAN = i_matdata-vtweg.
      i_salesdata-DELY_UOM = 'X'.
      append i_salesdatax.
      i_bapi_marm-ALT_UNIT = i_matdata-meins.
      i_bapi_marm-GROSS_WT = i_matdata-brgew.
      append i_bapi_marm.
      i_storagelocationdata-plant = i_plantdatax-plant.
      i_storagelocationdata-stge_loc = i_matdata-lgort.
      append i_storagelocationdata.
    clear i_storagelocationdata.
      i_storagelocationdatax-plant = i_plantdatax-plant.
      i_storagelocationdatax-stge_loc = i_storagelocationdata-stge_loc.
      append i_storagelocationdatax.
    clear i_storagelocationdatax.
    i_bapi_mlan-TAXCLASS_1 = i_matdata-TAXKM.
      append i_bapi_mlan.
    BAPI - BAPI_MATERIAL_SAVEDATA is used to Create and Change Material
    Master Data.
      call function 'BAPI_MATERIAL_SAVEDATA'
        exporting
          headdata                   = i_headdata
          clientdata                 = i_clientdata
          clientdatax                = i_clientdatax
          plantdata                  = i_plantdata
          plantdatax                 = i_plantdatax
          FORECASTPARAMETERS         = i_forcastingparameter
          FORECASTPARAMETERSX        = i_forcastingparameterx
        PLANNINGDATA               =
        PLANNINGDATAX              =
          storagelocationdata        = i_storagelocationdata
          storagelocationdatax       = i_storagelocationdatax
          VALUATIONDATA              = i_valuationdata
          VALUATIONDATAX             = i_valuationdatax
        WAREHOUSENUMBERDATA        =
        WAREHOUSENUMBERDATAX       =
          SALESDATA                  = i_salesdata
          SALESDATAX                 = i_salesdatax
        STORAGETYPEDATA            =
        STORAGETYPEDATAX           =
        FLAG_ONLINE                = ' '
        FLAG_CAD_CALL              = ' '
        importing
          return                     = i_return
        tables
          materialdescription        = i_bapi_makt
          UNITSOFMEASURE             = i_bapi_marm
          UNITSOFMEASUREX            = i_bapi_marmx
        INTERNATIONALARTNOS        =
        MATERIALLONGTEXT           =
         TAXCLASSIFICATIONS         = i_bapi_mlan
        RETURNMESSAGES             =
        PRTDATA                    =
        PRTDATAX                   =
        EXTENSIONIN                =
        EXTENSIONINX               =
    if i_return-type = 'E'.
        i_error-matnr = i_mara-matnr.
        i_error-mbrsh = i_matdata-mbrsh.
        i_error-mtart = i_matdata-mtart.
        i_error-werks = i_matdata-werks.
        i_error-message = i_return-message.
      append i_error.
      clear i_error.
      w_flg = 'X'.
    *else.
    Execute external Commit when using BAPIs
    When you call BAPIs in your program that change data in the R/3
    System afterwards you must call this method to write the changes to *
    the database.
    call function 'BAPI_TRANSACTION_COMMIT'
    exporting
       wait          = 'X'
    importing
       return        = i_return
    endif.
    refresh : i_headdata ,  i_bapi_makt, i_clientdata, i_clientdatax ,
              i_plantdata, i_plantdatax,
              i_storagelocationdata,i_storagelocationdatax,
              i_salesdata , i_salesdatax ,
              i_valuationdata , i_valuationdatax,
              i_bapi_marm,i_bapi_marmx,
              i_bapi_mlan.
    clear : i_headdata ,  i_bapi_makt, i_clientdata, i_clientdatax ,
              i_plantdata, i_plantdatax, i_storagelocationdata,
              i_storagelocationdatax,
              i_valuationdata , i_valuationdatax,
              i_bapi_marm,i_bapi_marmx,
              i_bapi_mlan.
    endloop.
    endform.                    " create_material
    *&      Form  display_error
          text
    -->  p1        text
    <--  p2        text
    form display_error.
    loop at i_error.
    read table i_matdata with key matnr = i_error-matnr.
    if sy-subrc = 0.
        i_matdata1-matnr = i_mara-matnr.
        i_matdata1-mbrsh = i_matdata-mbrsh.
        i_matdata1-mtart = i_matdata-mtart.
        i_matdata1-maktx = i_matdata-maktx.
        i_matdata1-meins = i_matdata-meins.
       i_matdata1-matkl = i_matdata-matkl.
       i_matdata1-bismt = i_matdata-bismt.
       i_matdata1-zeinr = i_matdata-zeinr.
       i_matdata1-spart = i_matdata-spart.
       i_matdata1-werks = i_matdata-werks.
       i_matdata1-dismm = i_matdata-dismm.
       i_matdata1-dispo = i_matdata-dispo.
       i_matdata1-beskz = i_matdata-beskz.
       i_matdata1-sobsl = i_matdata-sobsl.
       i_matdata1-lgpro = i_matdata-lgpro.
       i_matdata1-lgfsb = i_matdata-lgfsb.
       i_matdata1-eprio = i_matdata-eprio.
       i_matdata1-mtvfp = i_matdata-mtvfp.
       i_matdata1-lgort = i_matdata-lgort.
       i_matdata1-lgpbe = i_matdata-lgpbe.
       i_matdata1-prctr = i_matdata-prctr.
       i_matdata1-message = i_error-message.
        append i_matdata1.
        clear i_matdata1.
    endif.
    endloop.
    loop at i_error.
      write :/01 i_error-matnr , 30 i_error-message.
    endloop.
    if i_error is initial.
      write :/01 text-001.
    endif.
    if w_flg = 'X'.
      call function 'WS_DOWNLOAD'
       exporting
        BIN_FILESIZE                  = ' '
         codepage                      = 'IBM'
         filename                      = p_file1
         filetype                      = 'DAT'
        MODE                          = ' '
        WK1_N_FORMAT                  = ' '
        WK1_N_SIZE                    = ' '
        WK1_T_FORMAT                  = ' '
        WK1_T_SIZE                    = ' '
        COL_SELECT                    = ' '
        COL_SELECTMASK                = ' '
        NO_AUTH_CHECK                 = ' '
      IMPORTING
        FILELENGTH                    =
        tables
          data_tab                      = i_error
        FIELDNAMES                    =
       exceptions
         file_open_error               = 1
         file_write_error              = 2
         invalid_filesize              = 3
         invalid_type                  = 4
         no_batch                      = 5
         unknown_error                 = 6
         invalid_table_width           = 7
         gui_refuse_filetransfer       = 8
         customer_error                = 9
         others                        = 10
      if sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      endif.
    endif.
    endform.                    " display_error7

  • BDC for MM01(Material creation)

    Hello Please anybody send me code for creating materials with reference to reference material and plant in sselection screen in version ECC 6.0?
    My selection screen will be::
    Reference material:                                                       Plant:

    Plz User <b>BAPI_MATERIAL_SAVEDATA</b>
    Why So :
    you will never get it to work correctly in all cases every time for all material types, it is just much easier to work with an API that is not screen dependent. Then you don't have to worry about all of the exceptions when dealing with certain material types, and such. For example, say you have a material which you want to update the po text, and you did your recording for another material, which didn't have a specific view, so now when doing BDC for this material, the screen where you select the view you want to process, may be in a different place in the table control, see what I'm getting at? Its just very much easier to work with BAPIs and is suggest to use BAPI over BDC whenever possible.
    Also still u want to go for it, check this code :
    REPORT Y730_BDC5 .
    *HANDLING TABLE CONTROL IN BDC
    DATA : BEGIN OF IT_DUMMY OCCURS 0,
    DUMMY(100) TYPE C,
    END OF IT_DUMMY.
    DATA : BEGIN OF IT_XK01 OCCURS 0,
    LIFNR(10) TYPE C,
    BUKRS(4) TYPE C,
    EKORG(4) TYPE C,
    KTOKK(4) TYPE C,
    NAME1(30) TYPE C,
    SORTL(10) TYPE C,
    LAND1(3) TYPE C,
    SPRAS(2) TYPE C,
    AKONT(6) TYPE C,
    FDGRV(2) TYPE C,
    WAERS(3) TYPE C,
    END OF IT_XK01,
    BEGIN OF IT_BANK OCCURS 0,
    BANKS(3) TYPE C,
    BANKL(10) TYPE C,
    BANKN(10) TYPE C,
    KOINH(30) TYPE C,
    LIFNR(10) TYPE C,
    END OF IT_BANK.
    DATA : IT_BDCDATA LIKE BDCDATA OCCURS 0 WITH HEADER LINE,
    IT_BDCMSGCOLL LIKE BDCMSGCOLL OCCURS 0 WITH HEADER LINE.
    CALL FUNCTION 'WS_UPLOAD'
    EXPORTING
    FILENAME = 'C:\VENDOR.TXT'
    FILETYPE = 'ASC'
    TABLES
    DATA_TAB = IT_DUMMY.
    LOOP AT IT_DUMMY.
    IF IT_DUMMY-DUMMY+0(2) = '11'.
    IT_XK01-LIFNR = IT_DUMMY-DUMMY+2(10).
    IT_XK01-BUKRS = IT_DUMMY-DUMMY+12(4).
    IT_XK01-EKORG = IT_DUMMY-DUMMY+16(4).
    IT_XK01-KTOKK = IT_DUMMY-DUMMY+20(4).
    IT_XK01-NAME1 = IT_DUMMY-DUMMY+24(30).
    IT_XK01-SORTL = IT_DUMMY-DUMMY+54(10).
    IT_XK01-LAND1 = IT_DUMMY-DUMMY+64(3).
    IT_XK01-SPRAS = IT_DUMMY-DUMMY+67(2).
    IT_XK01-AKONT = IT_DUMMY-DUMMY+69(6).
    IT_XK01-FDGRV = IT_DUMMY-DUMMY+75(2).
    IT_XK01-WAERS = IT_DUMMY-DUMMY+77(3).
    APPEND IT_XK01.
    ELSE.
    IT_BANK-BANKS = IT_DUMMY-DUMMY+2(3).
    IT_BANK-BANKL = IT_DUMMY-DUMMY+5(10).
    IT_BANK-BANKN = IT_DUMMY-DUMMY+15(10).
    IT_BANK-KOINH = IT_DUMMY-DUMMY+25(30).
    IT_BANK-LIFNR = IT_DUMMY-DUMMY+55(10).
    APPEND IT_BANK.
    ENDIF.
    ENDLOOP.
    LOOP AT IT_XK01.
    REFRESH IT_BDCDATA.
    perform bdc_dynpro using 'SAPMF02K' '0100'.
    perform bdc_field using 'BDC_CURSOR'
    'RF02K-REF_LIFNR'.
    perform bdc_field using 'BDC_OKCODE'
    '/00'.
    perform bdc_field using 'RF02K-LIFNR'
    IT_XK01-LIFNR.
    perform bdc_field using 'RF02K-BUKRS'
    IT_XK01-BUKRS.
    perform bdc_field using 'RF02K-EKORG'
    IT_XK01-EKORG.
    perform bdc_field using 'RF02K-KTOKK'
    IT_XK01-KTOKK.
    perform bdc_dynpro using 'SAPMF02K' '0110'.
    perform bdc_field using 'BDC_CURSOR'
    'LFA1-TELX1'.
    perform bdc_field using 'BDC_OKCODE'
    '/00'.
    perform bdc_field using 'LFA1-NAME1'
    IT_XK01-NAME1.
    perform bdc_field using 'LFA1-SORTL'
    IT_XK01-SORTL.
    perform bdc_field using 'LFA1-LAND1'
    IT_XK01-LAND1.
    perform bdc_field using 'LFA1-SPRAS'
    IT_XK01-SPRAS.
    perform bdc_dynpro using 'SAPMF02K' '0120'.
    perform bdc_field using 'BDC_CURSOR'
    'LFA1-KUNNR'.
    perform bdc_field using 'BDC_OKCODE'
    '/00'.
    perform bdc_dynpro using 'SAPMF02K' '0130'.
    perform bdc_field using 'BDC_CURSOR'
    'LFBK-KOINH(02)'.
    perform bdc_field using 'BDC_OKCODE'
    '=ENTR'.
    DATA : FNAM(20) TYPE C,
    IDX TYPE C.
    MOVE 1 TO IDX.
    LOOP AT IT_BANK WHERE LIFNR = IT_XK01-LIFNR.
    CONCATENATE 'LFBK-BANKS(' IDX ')' INTO FNAM.
    perform bdc_field using FNAM
    IT_BANK-BANKS.
    CONCATENATE 'LFBK-BANKL(' IDX ')' INTO FNAM.
    perform bdc_field using FNAM
    IT_BANK-BANKL.
    CONCATENATE 'LFBK-BANKN(' IDX ')' INTO FNAM.
    perform bdc_field using FNAM
    IT_BANK-BANKN.
    CONCATENATE 'LFBK-KOINH(' IDX ')' INTO FNAM.
    perform bdc_field using FNAM
    IT_BANK-KOINH.
    IDX = IDX + 1.
    ENDLOOP.
    perform bdc_dynpro using 'SAPMF02K' '0130'.
    perform bdc_field using 'BDC_CURSOR'
    'LFBK-BANKS(01)'.
    perform bdc_field using 'BDC_OKCODE'
    '=ENTR'.
    perform bdc_dynpro using 'SAPMF02K' '0210'.
    perform bdc_field using 'BDC_CURSOR'
    'LFB1-FDGRV'.
    perform bdc_field using 'BDC_OKCODE'
    '/00'.
    perform bdc_field using 'LFB1-AKONT'
    IT_XK01-AKONT.
    perform bdc_field using 'LFB1-FDGRV'
    IT_XK01-FDGRV.
    perform bdc_dynpro using 'SAPMF02K' '0215'.
    perform bdc_field using 'BDC_CURSOR'
    'LFB1-ZTERM'.
    perform bdc_field using 'BDC_OKCODE'
    '/00'.
    perform bdc_dynpro using 'SAPMF02K' '0220'.
    perform bdc_field using 'BDC_CURSOR'
    'LFB5-MAHNA'.
    perform bdc_field using 'BDC_OKCODE'
    '/00'.
    perform bdc_dynpro using 'SAPMF02K' '0310'.
    perform bdc_field using 'BDC_CURSOR'
    'LFM1-WAERS'.
    perform bdc_field using 'BDC_OKCODE'
    '/00'.
    perform bdc_field using 'LFM1-WAERS'
    IT_XK01-WAERS.
    perform bdc_dynpro using 'SAPMF02K' '0320'.
    perform bdc_field using 'BDC_CURSOR'
    'WYT3-PARVW(01)'.
    perform bdc_field using 'BDC_OKCODE'
    '=ENTR'.
    perform bdc_dynpro using 'SAPLSPO1' '0300'.
    perform bdc_field using 'BDC_OKCODE'
    '=YES'.
    CALL TRANSACTION 'XK01' USING IT_BDCDATA
    MODE 'A'
    UPDATE 'S'
    MESSAGES INTO IT_BDCMSGCOLL.
    ENDLOOP.
    FORM BDC_DYNPRO USING PROG SCR.
    CLEAR IT_BDCDATA.
    IT_BDCDATA-PROGRAM = PROG.
    IT_BDCDATA-DYNPRO = SCR.
    IT_BDCDATA-DYNBEGIN = 'X'.
    APPEND IT_BDCDATA.
    ENDFORM.
    FORM BDC_FIELD USING FNAM FVAL.
    CLEAR IT_BDCDATA.
    IT_BDCDATA-FNAM = FNAM.
    IT_BDCDATA-FVAL = FVAL.
    APPEND IT_BDCDATA.
    ENDFORM.
    All things r available in SDN, please search.
    Reward points if useful.
    Thanks
    vinsee

  • BDC for ME21N Transaction

    Dear All,
    I have a requirement to create PO using transaction ME21N. I had written a code to create PO using BDC for transaction ME21. But the user wants it to be modified to ME21N. The user wants the PO created in the foreground like the one i created fro ME21. But is it possible to use BDC for ME21N or is there any other way i can change the BAPI to foreground processing like in BDC?
    Regards,
    Karthik

    Hi Raghavender,
    This is a report to display and validate the RFQ's. And once the user selects the RFQ and clicks on Create PO from RFQ push button, it should go to transaction 'ME21N' with values from RFQ. ( similar to what we do in ME21N, when we drag RFQ from the documents overview and drop it into cart, the values are populated). I want the similar functionality to happen when the user clicks on clicks on Create PO push button. But it should happen only in the foreground and not background.
    Regards,
    Karthik

  • HI I HAVE PROBLEM WHEN IAM WRITING BDC FOR MM01

    HI,
    WHEN IAM WRITING BDC PROGRAM FOR MM01 USING SHDB RECORDING. WHEN I RECORDED SOME VIEWS I MEAN I SCROLLED DOWN AND SELECT THOSE VIEWS.
    BUT IT WILL NOT TAKE THOSE VIEWS WHEN I UPLOAD THE DATA THOSE VIEWS ARE NOT SELECTED. PLZ TELL ME HOW COULD I DO THIS.
    URGENT PLZ.
    THANKS,
    MURALI.

    Hi Murali,
    Rather of scrolling down while recording press page down button. as scroll will not get recorded during recording.
    The page down function code is P+.
    Press page down button on key board while recording.
    I had checked it through recording it had worked.
    I got BDC_OKCODE     = P+ in recording.
    This will solve your problem.
    Regards
    Narin Nandivada

  • Clarification relating to BDC for MD61 transaction

    Hi,
        Did  any one made any development for MD61 transaction. I am planning to do an BDC for upload of planning data
    for the different periods and for different materials. DId any one found any complexities in this development and
    how it is suggestible.
      I am planning to bring sales quotation data and upload as demand in MD61
    Regards
    madan

    Hi,
        Sales quotations are the proposals & their is not any reference of delivery date that we could take as production finish date i.e material availablity/ promising date in demand manangement.
        So, you need to rethink on quotation data & try to fix peiod either month or week or day that could reduce development complexity.
    Rgd,
    Chetan

  • About bdc for aiab transaction,urgent plzzzzzzzz

    hi all,
    i m doing BDC for tcode AIAB.
    here the table control is coming in to picture and i don know how to handle table control,
    so if anybody can help me to come over this issue??
    my wrk is still pending,plzz try it n giv me reply,my problm is in 2nd screen in transaction,
    plzz reply asap.
    thanks
    regards
    murty

    hi,
    Following is a sample code of handling table control in BDC.
    REPORT Y730_BDC5 .
    *HANDLING TABLE CONTROL IN BDC
    DATA : BEGIN OF IT_DUMMY OCCURS 0,
           DUMMY(100) TYPE C,
           END OF IT_DUMMY.
    DATA : BEGIN OF IT_XK01 OCCURS 0,
           LIFNR(10) TYPE C,
           BUKRS(4)  TYPE C,
           EKORG(4)  TYPE C,
           KTOKK(4)  TYPE C,
           NAME1(30) TYPE C,
           SORTL(10) TYPE C,
           LAND1(3)  TYPE C,
           SPRAS(2)  TYPE C,
           AKONT(6)  TYPE C,
           FDGRV(2)  TYPE C,
           WAERS(3)  TYPE C,
           END OF IT_XK01,
           BEGIN OF IT_BANK OCCURS 0,
           BANKS(3)  TYPE C,
           BANKL(10) TYPE C,
           BANKN(10) TYPE C,
           KOINH(30) TYPE C,
           LIFNR(10) TYPE C,
           END OF IT_BANK.
    DATA : IT_BDCDATA LIKE BDCDATA OCCURS 0 WITH HEADER LINE,
           IT_BDCMSGCOLL LIKE BDCMSGCOLL OCCURS 0 WITH HEADER LINE.
    CALL FUNCTION 'WS_UPLOAD'
    EXPORTING
       FILENAME                      = 'C:\VENDOR.TXT'
       FILETYPE                      = 'ASC'
    TABLES
       DATA_TAB                      = IT_DUMMY.
    LOOP AT IT_DUMMY.
      IF IT_DUMMY-DUMMY+0(2) = '11'.
        IT_XK01-LIFNR = IT_DUMMY-DUMMY+2(10).
        IT_XK01-BUKRS = IT_DUMMY-DUMMY+12(4).
        IT_XK01-EKORG = IT_DUMMY-DUMMY+16(4).
        IT_XK01-KTOKK = IT_DUMMY-DUMMY+20(4).
        IT_XK01-NAME1 = IT_DUMMY-DUMMY+24(30).
        IT_XK01-SORTL = IT_DUMMY-DUMMY+54(10).
        IT_XK01-LAND1 = IT_DUMMY-DUMMY+64(3).
        IT_XK01-SPRAS = IT_DUMMY-DUMMY+67(2).
        IT_XK01-AKONT = IT_DUMMY-DUMMY+69(6).
        IT_XK01-FDGRV = IT_DUMMY-DUMMY+75(2).
        IT_XK01-WAERS = IT_DUMMY-DUMMY+77(3).
        APPEND IT_XK01.
      ELSE.
        IT_BANK-BANKS = IT_DUMMY-DUMMY+2(3).
        IT_BANK-BANKL = IT_DUMMY-DUMMY+5(10).
        IT_BANK-BANKN = IT_DUMMY-DUMMY+15(10).
        IT_BANK-KOINH = IT_DUMMY-DUMMY+25(30).
        IT_BANK-LIFNR = IT_DUMMY-DUMMY+55(10).
        APPEND IT_BANK.
      ENDIF.
    ENDLOOP.
    LOOP AT IT_XK01.
    REFRESH IT_BDCDATA.
    perform bdc_dynpro      using 'SAPMF02K' '0100'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'RF02K-REF_LIFNR'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform bdc_field       using 'RF02K-LIFNR'
                                  IT_XK01-LIFNR.
    perform bdc_field       using 'RF02K-BUKRS'
                                  IT_XK01-BUKRS.
    perform bdc_field       using 'RF02K-EKORG'
                                  IT_XK01-EKORG.
    perform bdc_field       using 'RF02K-KTOKK'
                                  IT_XK01-KTOKK.
    perform bdc_dynpro      using 'SAPMF02K' '0110'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'LFA1-TELX1'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform bdc_field       using 'LFA1-NAME1'
                                  IT_XK01-NAME1.
    perform bdc_field       using 'LFA1-SORTL'
                                  IT_XK01-SORTL.
    perform bdc_field       using 'LFA1-LAND1'
                                  IT_XK01-LAND1.
    perform bdc_field       using 'LFA1-SPRAS'
                                  IT_XK01-SPRAS.
    perform bdc_dynpro      using 'SAPMF02K' '0120'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'LFA1-KUNNR'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform bdc_dynpro      using 'SAPMF02K' '0130'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'LFBK-KOINH(02)'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=ENTR'.
    DATA : FNAM(20) TYPE C,
           IDX      TYPE C.
      MOVE 1 TO IDX.
    LOOP AT IT_BANK WHERE LIFNR = IT_XK01-LIFNR.
      CONCATENATE 'LFBK-BANKS(' IDX ')' INTO FNAM.
      perform bdc_field       using FNAM
                                    IT_BANK-BANKS.
      CONCATENATE 'LFBK-BANKL(' IDX ')' INTO FNAM.
      perform bdc_field       using FNAM
                                    IT_BANK-BANKL.
      CONCATENATE 'LFBK-BANKN(' IDX ')' INTO FNAM.
      perform bdc_field       using FNAM
                                    IT_BANK-BANKN.
      CONCATENATE 'LFBK-KOINH(' IDX ')' INTO FNAM.
      perform bdc_field       using FNAM
                                    IT_BANK-KOINH.
      IDX = IDX + 1.
    ENDLOOP.
    perform bdc_dynpro      using 'SAPMF02K' '0130'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'LFBK-BANKS(01)'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=ENTR'.
    perform bdc_dynpro      using 'SAPMF02K' '0210'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'LFB1-FDGRV'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform bdc_field       using 'LFB1-AKONT'
                                  IT_XK01-AKONT.
    perform bdc_field       using 'LFB1-FDGRV'
                                  IT_XK01-FDGRV.
    perform bdc_dynpro      using 'SAPMF02K' '0215'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'LFB1-ZTERM'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform bdc_dynpro      using 'SAPMF02K' '0220'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'LFB5-MAHNA'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform bdc_dynpro      using 'SAPMF02K' '0310'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'LFM1-WAERS'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform bdc_field       using 'LFM1-WAERS'
                                  IT_XK01-WAERS.
    perform bdc_dynpro      using 'SAPMF02K' '0320'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'WYT3-PARVW(01)'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=ENTR'.
    perform bdc_dynpro      using 'SAPLSPO1' '0300'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=YES'.
    CALL TRANSACTION 'XK01' USING IT_BDCDATA
                            MODE  'A'
                           UPDATE 'S'
                         MESSAGES INTO IT_BDCMSGCOLL.
    ENDLOOP.
    FORM BDC_DYNPRO USING PROG SCR.
      CLEAR IT_BDCDATA.
      IT_BDCDATA-PROGRAM = PROG.
      IT_BDCDATA-DYNPRO  = SCR.
      IT_BDCDATA-DYNBEGIN = 'X'.
      APPEND IT_BDCDATA.
    ENDFORM.
    FORM BDC_FIELD USING FNAM FVAL.
      CLEAR IT_BDCDATA.
      IT_BDCDATA-FNAM = FNAM.
      IT_BDCDATA-FVAL  = FVAL.
      APPEND IT_BDCDATA.
    ENDFORM.
    <b>Hope this is helpful.</b>

  • Need help on BDC  for MB1A transaction.

    Hello Abapers,
    I need to create a BDC for t-code MB1A to do the Goods Issue with reference to reservation.
    I am not able to use the BAPI 'BAPI_GOODSMVT_CREATE' to do the goods issue as there are some additional functionalities (Stock Determination) to be included.
    The problem I am facing is, The stock determination will determine the Quantity, Storage Location and Valuation type for every item of the reservation. The quantity will be picked up from multiple storage locations and as a result the line item of reservation will be split into two or more for Goods Issue.
    When this happens, If the reservation is having multiple line items, tracking the next item becomes a problem.
    Please suggest a way to approach this problem.
    Usefull answers will be rewarded.
    Thanks in Advance,
    Vinutha.

    Hi
    The COMMIT before and after CALL TRANSACTION is useless, The transaction FB01 calls the commit by itself, so u need only:
    CALL TRANSACTION 'FB01' USING BDC_TAB
                                                   MODE 'N'
                                                   UPDATE 'S'
                                                   MESSAGE ITAB.
    Now ITAB is like structure BDCMSGCOLL, so after CALL Transaction u can use message statament in order to show a popup with message:
    CALL TRANSACTION 'FB01' USING BDC_TAB
                                                   MODE 'N'
                                                   UPDATE 'S'
                                                   MESSAGE ITAB.
    LOOP AT ITAB.
    MESSAGE ID ITAB-MSGID TYPE 'I' NUMBER ITAB-MSGNR
             WITH ITAB-MSGV1 ITAB-MSGV2 ITAB-MSGV3 ITAB-MSGV4.
    ENDLOOP.
    Max

  • BDC for TS01 Transaction

    Dear All
    Manual entry in the TS01(Create Security) transaction behaves for entering the amount values differently as manual entry in the amount field will get saved but the entry through program is not getting saved.
    Data is availabe in BDCDATA table but when it when it populates and gets saved, amount will be blank and transaction gets saved.
    Need urgent on this issue.
    Help is greatly appreciated.
    Thanks,
    Azhar.

    Hi Mohammed,
        The main program associated to this program is a report type program. You cannot do a BDC for such programs.
    Instead try the bapi: BAPI_FTR_SECURITY_CREATE
    Regards,
    Ravi

  • BDC for MM01 - Views not getting selected

    Hi,
    I have recorded the MM01 transaction and have developed the BDC code. While recording I selected the following views - Basic Data 1, Basic Data 2, Purchasing, Accounting 1 and Accounting 2.
    I run the BDC program by call transaction method. I selected the processing mode as 'A'. Now when I execute the program I get the Select view screen. In that Basic data1, basic data2 and purchasing views are getting selected automatically but Accounting 1 and accounting 2 views are not getting selected. When I click ok, the Plant in organization level is not picked up from excel file.
    While selecting views when I scroll the views screen then Accounting 1 and accounting 2 views are getting selected and the plant detail is picked from the excel.
    Please help.
    Regards,
    Sriram

    Hi,
    Use this BDC okcode to get the Accounting tab selected.
                                                         T     MM01                                                                               
    SAPLMGMM          0060          X                                                                               
    BDC_CURSOR     RMMG1-MTART
                                                                BDC_OKCODE     /00
                                                                RMMG1-MTART     FERT
    SAPLMGMM     0070     X                                                                               
    BDC_CURSOR     MSICHTAUSW-DYTXT(02)
                                                                BDC_OKCODE     =P+
                                                                MSICHTAUSW-KZSEL(01)     X
                                                                MSICHTAUSW-KZSEL(02)     X
    SAPLMGMM     0070     X                                                                               
    BDC_CURSOR     MSICHTAUSW-DYTXT(08)
                                                                BDC_OKCODE     =ENTR
                                                                MSICHTAUSW-KZSEL(07)     X
                                                                MSICHTAUSW-KZSEL(08)     X
    Hope this may be useful
    Thanks,
    Archana

Maybe you are looking for

  • SCA Performance Issues

    Recent datacentre design uses both CSS Content Switches and SCA SSL accelerators. Services working fine, however SSL acceleration actually SLOWS DOWN during the day. Up to four minutes to load a SSL encrypted page in the afternoon as opposed to a mor

  • Importing Table

    Hi how can i importing a table in the method? i try this     methods: merge_data               importing pf_spediumsetz type table zsd_spediumsetz, but became a error message. thx

  • Show Term store terms and respected labels

    Hi, I have a requiremnt in which i need to filter search results by Term Sets (Managed Metadata Columns), till now its done but Client also want the Label(s) of Term Set to appear in search result as well as in Refinement Panel. Please let me know if

  • Application Deployment Error - This operation retu...

    I can't deploy the XAP file to my Lumia 920 even my Lumia 920 was developer unlocked. Any solution?

  • Dynamic query disappears from group

    Hi All, I've created a group within my SCOM deployment and wanted to add Windows servers to this group dynamically, using a Dynamic inclusion Rule. However when I create the rule and click apply, it seems to save (it also says populating the group me