Validation in BDC

hi experts,
                       I am uploading customer details from legacy file to SAP systems.
Can I write single BDC program to change the customer details or else to create a new customer based on the customer number in legacy file.
                 If yes, how can i do it. its very urgent. pls solve my problem
                                                                                thanking u,

Try to code in this scenario:
if record exist
    call transaction 'xd02' using bdcdata.......
else.
    call transaction 'xd01' using bdcdata.......
endif.

Similar Messages

  • What are the validations in bdc?

    what are the validations in bdc?

    Hi,
    you should validate the data before passing it to the SAP System thru BDC.Normally we wont write any routine for calling the BDC Program instead we will execute it directly or schedule as the background job depending on the data load.I would advice you to schedule a background job rather than calling from a routine...
    Usually when you do a BDC, you have the data in a flat file. So, you can upload the data into a internal table and validate the data first, by writing routines and then finally by doing a CALL TRANSACTION / BDC SESSION.
    Regards,
    Ram
    Pls reward points if helpful

  • How to do input validation in BDC's?

    hai,
       I am Rajesh, I want to know how and where to write input validation code in BDC's. Please help me on this.
    Thanking you

    Hi and welcome
    all key-fields (and fields with a check-table) are checked by SAP-standard in your called transaction in BDC too.
    if you want to validate additional:
    1)load you data from flat file into itab
    2)check fields:
    -against checktable
    -format (date,currency)
    -value
    A.
    pls reward usful answers
    Message was edited by: Andreas Mann

  • Validations in bdc progaram FB60

    Hai experts,
    where can i do validations on this feilds,these data come from excel file.
    *1. Company Code
    2. Vendor Code
    3. Date
    4. GL Code
    5. Business area
    6. Cost Center    
    7. Withholding tax liability   *
    thanks
    sitaram

    1. Company Code
    Table T001 field BUKRS
    2. Vendor Code
    Tables LFA1 field LIFNR and LFB1 fields BUKRS LIFNR
    3. Date
    Use function module like FI_PERIOD_CHECK
    4. GL Code
    Tables SKA1 field SAKNR (and key KTOPL from T001) and SKB1 fields BUKRS and SAKNR
    5. Business area
    Table TGSB field GSBER.
    6. Cost Center
    Table CSKS field KOSTL (key KOKRS depend on Customizing, look at table TKA02 to find links between society BUKRS control area KOKRS and GSBER business area)
    7. Withholding tax liability
    Table T5C2J field QSTPF
    Regards

  • Validation for BDC program

    hi,
    In BDC programe I have to check (or) validate the file path at selection screen events .
    if the selected file is wrong error message should be triggered. how i can do this.
    with regards,
    Srinath

    Hello Reddy,
    In the following example,
    purchase order fields are taken in through a text-file, if the fields do not match the fields of internal table, then just throw an error in GUI_UPLOAD saying , 'FILE CANNOT BE UPLOADED' or say 'UPLOADING FAILED'.
    * STRUCTURE FOR PURCHASE ORDER TABLE                                  *
    TYPES:
      BEGIN OF type_s_mat,
        eeind TYPE rm06b-eeind,            " Delivery Date
        txz01 TYPE eban-txz01,             " Short Text
        menge TYPE eban-menge,             " Quantity
        meins TYPE eban-meins,             " Units
        preis TYPE eban-preis,             " Price
      END OF type_s_mat.                   " BEGIN OF TYPE_S_MAT
    * FIELD STRING FOR PURCHASE ORDER TABLE                               *
    DATA:
      fs_mat TYPE type_s_mat.
    * INTERNAL TABLE FOR PURCHASE ORDER TABLE                             *
    DATA:
         t_mat LIKE
      STANDARD TABLE
            OF fs_mat.
    * INTERNAL TABLE FOR BATCH DATA TRANSFER                              *
    DATA:
         t_bdc TYPE
      STANDARD TABLE
            OF bdcdata
          WITH HEADER LINE.
    * INTERNAL TABLE FOR MESSAGES                                         *
    DATA:
    t_messages TYPE
      STANDARD TABLE
            OF bdcmsgcoll
          WITH HEADER LINE.
    * Work Variables                                                      *
    DATA:
      w_filename TYPE rlgrap-filename,     " Selected File-Name
      w_msg(72) TYPE c,                    " Messages
      w_filename1 TYPE string.             " Full-Path
    *      INITIALIZATION                                                 *
    INITIALIZATION.
      PARAMETERS p_file(128).              " Name of File to be opened
    *      AT SELECTION-SCREEN ON VALUE-REQUEST                           *
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
      PERFORM open_mat_file.
      p_file = w_filename.
    *      START-OF-SELECTION                                             *
    START-OF-SELECTION.
      IF p_file IS INITIAL.
        MESSAGE 'No File Selected' TYPE 'S' DISPLAY LIKE 'E'.
      ELSE.
        PERFORM open_file.
      ENDIF.                               " IF P_FILE IS INITIAL
    *&      Form  open_mat_file
    * This Subroutine opens Material File of the Presentation Server.
    * This Subroutine has got no Interface Parameters.
    FORM open_mat_file .
      CALL FUNCTION 'F4_FILENAME'
    * EXPORTING
    *   PROGRAM_NAME        = SYST-CPROG
    *   DYNPRO_NUMBER       = SYST-DYNNR
    *   FIELD_NAME          = ' '
       IMPORTING
         file_name          = w_filename.
    ENDFORM.                               " FORM OPEN_MAT_FILE
    *&      Form  open_file
    * This Subroutine facilitates file upload on Presentation Server.
    * This Subroutine has got no Interface Parameters.
    FORM open_file .
      w_filename1 = w_filename.
      CALL FUNCTION 'GUI_UPLOAD'
        EXPORTING
         filename                      =  w_filename1
         filetype                      = 'ASC'
    *     has_field_separator           = ' '
    *    HEADER_LENGTH                 = 0
    *    READ_BY_LINE                  = 'X'
    *    DAT_MODE                      = ' '
    *    CODEPAGE                      = ' '
    *    IGNORE_CERR                   = ABAP_TRUE
    *    REPLACEMENT                   = '#'
    *  IMPORTING
    *    FILELENGTH                    =
    *    HEADER                        =
        TABLES
          data_tab                     = t_mat
       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 'Uploading Failed'  TYPE 'S' DISPLAY LIKE 'E'.
      ELSE.
        PERFORM populating_bdc.
      ENDIF.                               " IF SY-SUBRC NE 0
    ENDFORM.                               " FORM OPEN_FILE
    *&      Form  populating_bdc
    * This Subroutine Populates data in Transaction ME51
    * This Subroutine has got no Interface Parameters.
    FORM populating_bdc .
      LOOP AT t_mat INTO fs_mat.
        PERFORM screens USING 'SAPMM06B' '0100'.
        PERFORM fields USING 'EBAN-BSART' 'NB'.
        PERFORM fields USING 'EBAN-KNTTP' 'X'.
        PERFORM fields USING 'RM06B-LPEIN' 'T'.
        PERFORM fields USING 'RM06B-EEIND' fs_mat-eeind.
        PERFORM fields USING 'EBAN-WERKS' '1000'.
        PERFORM fields USING 'EBAN-EKGRP' '100'.
        PERFORM fields USING 'EBAN-MATKL' '006'.
        PERFORM fields USING 'BDC_OKCODE' '/00'.
        PERFORM screens USING 'SAPMM06B' '0106'.
        PERFORM fields USING 'EBAN-TXZ01' fs_mat-txz01.
        PERFORM fields USING 'EBAN-MENGE' fs_mat-menge.
        PERFORM fields USING 'EBAN-MEINS' fs_mat-meins.
        PERFORM fields USING 'BDC_OKCODE' '/00'.
        PERFORM screens USING 'SAPMM06B' '0102'.
        PERFORM fields USING 'EBAN-PREIS' fs_mat-preis.
        PERFORM fields USING 'BDC_OKCODE' '/00'.
        PERFORM screens USING 'SAPMM06B' '0505'.
        PERFORM fields USING 'COBL-KOSTL' '1000'.
        PERFORM fields USING 'BDC_OKCODE' '/00'.
        PERFORM screens USING 'SAPMM06B' '0106'.
        PERFORM fields USING 'BDC_OKCODE' 'BU'.
        CALL TRANSACTION 'ME51' USING t_bdc MODE 'A' MESSAGES INTO
        t_messages.
        IF sy-subrc EQ 0.
          LOOP AT t_messages.
            CALL FUNCTION 'FORMAT_MESSAGE'
              EXPORTING
                id        = t_messages-msgid
                lang      = sy-langu
                no        = t_messages-msgnr
                v1        = t_messages-msgv1
                v2        = t_messages-msgv2
                v3        = t_messages-msgv3
                v4        = t_messages-msgv4
              IMPORTING
                msg       = w_msg
              EXCEPTIONS
                not_found = 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.
            ELSE.
              WRITE:/ w_msg.
            ENDIF.                         " IF SY-SUBRC <> 0
          ENDLOOP.                         " LOOP AT T_MAT INTO FS_MAT
        ENDIF.                             " IF SY-SUBRC EQ 0
      ENDLOOP.                             " LOOP T_MAT INTO FS_MAT
    ENDFORM.                               " FORM POPULATING_BDC
    *&      Form  screens
    * This Subroutine populates program name and screen numbers.
    *      -->VALUE(P_PROG)   PROGRAM NAME
    *      -->VALUE(P_SCRNO)  SCREEN NUMBER
    FORM screens USING value(p_prog) value(p_scrno).
      t_bdc-program = p_prog.
      t_bdc-dynpro = p_scrno.
      t_bdc-dynbegin = 'X'.
      APPEND t_bdc.
    ENDFORM.                               " FORM SCREENS
    *&      Form  fields
    * This Subroutine populates Field Value and Field name
    *      -->VALUE(P_FNAM)  Field Name
    *      -->VALUE(P_FVAL)  Field Value
    FORM fields USING value(p_fnam) value(p_fval).
      t_bdc-fnam = p_fnam.
      t_bdc-fval = p_fval.
      APPEND t_bdc.
    ENDFORM.                               " FORM FIELDS
    Hope the above given example, helps you.
    Thanks: Zahackson

  • In RFC how to uploading data using bdc

    Hi, Experts
    In RFC how to use bdc program for uploading data
    any example plz.
    my requrement for tcode ME21.
    thank you in advance.
    with best regards
        sai

    Thank u  reply
    my requirement is in function moudle 
    ( Program will be called from non-sap system with the data in the form of table as per the structure given above. Then the program will do the some validation for the data.  If data validated correct, BDC will be run for creating DO
    condition is )
    ex:
    if T_itab –KNTTP = ‘K’,
    Run BDC for transaction ME21.
    ( in that you should not use upload and ws_upload )
    in put paramer is taking value for structure (non- sap ) run the bdc update in sap system.
    plz any sample program
    regards
    sai

  • BDC- Message Interrupting Upload

    Hi Gurus,
    I am doin an batch session ( BDC) for mass data upload.
    May i know how i am supposed to omit an message ( warning etc) due to which the upload stops.
    Regards,
    Navin

    The Error messages ,if any ,will come if you are uploading thru BDC in E mode.
    This can be avoided only by removing the cause of the error message,
    programmatically in the BDC program itself.
    Say u are getting an error message because of blank entry in one field..
    Then catch that error in the BDC program itself and throw an error. So that it will not go the screen.
    Allow the controll to go to the screen, if all the entries are perfect.
    That is... place al the screen validations in BDC program.

  • Validation error in BDC

    Hi friends,
    I am doing a BDC for F-03 and everything is working fine except when the the BDC is executed at background mode i.e N.
    It is working good at A and E but it gives a custom validation error at background processing.
    I am searching SDN since yesterday and found this is caused by S and W messages but i have diffused then but then too the error is encountered.
    No idea why my PROFIT CENTER value is not populated at BACKGROUND mode.
    Any ideas?
    Please help.
    Thanks much.

    Hi Park,
    If you have GUI objects like pop-up screens, etc it will not work. Check out these links for more information.
    Re: Docking container could not be created - while running batch job
    Re: Multiple OO ALV Container - Background Execution
    Thanks and Best Regards,
    Dinesh.

  • BDC (Flat File Data Validation) - Code

    I am trying to validate flat file data BEFORE performing BDC (Call Trans. or Session)..
    Pls help me out in below code for xk02..
    DATA: BEGIN OF itab occurs 0,  "ITAB having flat file data.
          lifnr(16) ,
          bukrs(4),
          ekorg(4),
          END OF itab.
    DATA: BEGIN OF int_final occurs 0,
          lifnr(16) ,
          bukrs(4),
          ekorg(4),
          status(6),
          message(6),
          END OF int_final.
    DATA: int_final TYPE TABLE OF int_final.
    DATA: wa_itab TYPE TABLE OF itab.
    DATA: validate_itab TYPE TABLE OF itab. "VALIDATE_ITAB having master data.
    DATA: wa_validate_itab TYPE TABLE OF itab.
    FORM data_validation .
    SELECT LFB1LIFNR LFB1BUKRS LFM1~EKORG INTO TABLE validate_itab
             FROM LFB1 INNER JOIN LFM1 ON LFB1LIFNR = LFM1LIFNR.
    IF sy-subrc = 0.
    SORT validate_itab BY lifnr bukrs ekorg.
    ENDIF.
    LOOP AT itab INTO wa_itab.
    READ TABLE validate_itab WITH KEY
    lifnr = itab-lifnr
    bukrs = itab-bukrs
    ekorg = itab-ekorg
    BINARY SEARCH.
    IF sy-subrc NE 0.
    PERFORM f_error_log USING text-005. "Invalid Value Set
    CONTINUE.
    ENDIF.
    ENDLOOP.
    ENDFORM.                    " data_validation
    *&      Form  f_error_log
    FORM f_error_log USING l_message TYPE string.
    CLEAR : fs_final.
    fs_final-lifnr = itab-lifnr.
    fs_final-bukrs = itab-bukrs.
    fs_final-ekorg = itab-ekorg.
    fs_final-status = text-014. "Error
    fs_final-message = l_message.
    APPEND fs_final TO int_final.
    ENDFORM.                    " f_error_log
    Thanks..

    Hi GAurav,
    I have a small question in th validation.
    In LFM1~LIFNR does not contian any value how u r comparing both and one more thing After getting the data using GUI_upload u will get the data into validate_tab.
    Loop at Vlidate_tab into wa_itab.
    SELECT LFB1LIFNR LFB1BUKRS LFM1~EKORG INTO TABLE validate_itab
    FROM LFB1 INNER JOIN LFM1 ON LFB1~LIFNR =  wa_itab-lifnr.
    endllop.
    Thanks,

  • BAPI,BADI ,BDC,ALE ,IDOC,USER EXIT,VALIDATION AND SMART FORMS.

    Dear Experts,
    I am pretty new in BAPI,BADI ,BDC,ALE ,IDOC,USER EXIT,VALIDATION AND SMART FORMS.
    Pls let me know for these topics shall i put the question in this community or should i put in any other form. Pl suggest me .
    Regards
    Shivas

    Plz SEARCH in SCN before posting ,you will get lot of posts .
    Don't use all caps in the subject line

  • BDC validation for vk11

    Hi friends
        I have created a bdc(by call transaction ) to upload data to tcode  vk11 and it works fine but also I need to add a validation that if a duplicate value is found in local file that is already found in vk01 it should give information that value already found  how this can be achieved .

    Hi,
    1.Get all the values into internal table.
    2. get all the values from vk11 DB table.
    3. Loop VK11 table records and read the internal table records. If sy-subrc fails, then process the BDC.
    Regards,
    Veda Moorthy Rajan

  • BDC with lots of validations and conversions

    hi to all experts,
                           i need a sample  bdc program with lots of validations and conversion.
    thanks

    Hi,
    REPORT  ZMMFTS01A_MAINTAIN_SOURCE_LIST NO STANDARD PAGE HEADING
            LINE-SIZE 250.
    TABLES eord.
    ***Types Declaration
    **Type of Upload File
    TYPES : BEGIN OF ty_final,
             matnr(018),       "Material No
             werks(004),       "Plant
             vdatu(010),       "valid From
             bdatu(010),       "valid To
             lifnr(010),       "Vendor
             ekorg(004),       "Purchase Org
             reswk(004),       "Plant from which material is procured
             ebeln(010),       "Agreement
             ebelp(005),       "Item
             feskz(003),       "Fix
             notkz(003),       "Blk
             autet(003),       "MRP
            END OF ty_final.
    **Type for Error Records
    TYPES : BEGIN OF ty_errmsg,
             matnr(018),
             werks(004),
             vdatu(010),
             bdatu(010),
             lifnr(010),
             ekorg(004),
             reswk(004),
             ebeln(010),
             ebelp(005),
             feskz(003),
             notkz(003),
             autet(003),
             messg(200),
            END OF ty_errmsg.
    **Type to get the existing no of records before comparison
    TYPES : BEGIN OF ty_eord,
             matnr LIKE eord-matnr,
             werks LIKE eord-werks,
             erdat LIKE eord-erdat,
             vdatu LIKE eord-vdatu,
             bdatu LIKE eord-bdatu,
             lifnr LIKE eord-lifnr,
             flifn LIKE eord-flifn,
             ebeln LIKE eord-ebeln,
             ebelp LIKE eord-ebelp,
             febel LIKE eord-febel,
             reswk LIKE eord-reswk,
             notkz LIKE eord-notkz,
             ekorg LIKE eord-ekorg,
             autet LIKE eord-autet,
            END OF ty_eord.
    **Type to get the no of records in the Database after comparison
    TYPES : BEGIN OF ty_eord1,
             vdatu LIKE eord-vdatu,
             bdatu LIKE eord-bdatu,
            END OF ty_eord1.
    ***Data Declarations
    DATA : v_repid    LIKE sy-repid,
           v_datfm    LIKE usr01-datfm,
           v_message(200),
           v_err_rec  TYPE i,
           v_errors   TYPE i,
           v_updated  TYPE i,
           v_matnr    TYPE matnr,
           v_lines    TYPE i,
           v_eord_row TYPE i,
           s_count(2) TYPE n,
           v_fnam(20) TYPE c,
           v_tabix(2) TYPE n,
           v_vdatu(10),
           v_bdatu LIKE eord-bdatu,
           v_datum(10),
           f_option type ctu_params.
    ****Begin of Changes by Pavan  Ticket 648507            "D13K948908
    DATA : s_vdatu  TYPE sy-datum,
           s_bdatu  TYPE sy-datum.
    ****End of Changes By Pavan    Ticket 648507            "D13K948908
    ***Internal Tables Declaration
    DATA : it_eord       TYPE STANDARD TABLE OF ty_eord    WITH HEADER LINE,    "Internal Table for Appending all the Rows of DB Table EORD
           it_bdcdata    TYPE STANDARD TABLE OF bdcdata    WITH HEADER LINE,   
           it_final      TYPE STANDARD TABLE OF ty_final   WITH HEADER LINE,   
           it_err_rec    TYPE STANDARD TABLE OF ty_final   WITH HEADER LINE,  
           it_messtab    TYPE STANDARD TABLE OF bdcmsgcoll WITH HEADER LINE, 
           it_errmsg     TYPE STANDARD TABLE OF ty_errmsg  WITH HEADER LINE,   
           it_eord1      TYPE STANDARD TABLE OF ty_eord1   WITH HEADER LINE,   
           it_ctu_params TYPE STANDARD TABLE OF ctu_params WITH HEADER LINE.
    DATA : wa_final LIKE LINE OF it_final.
    ***Constants
    CONSTANTS : c_1  TYPE i VALUE '1',
                c_12 TYPE i VALUE '12',
                c_x         VALUE 'X'.
    ***Selection Screen
    SELECTION-SCREEN : BEGIN OF BLOCK header WITH FRAME TITLE text-002.
    SELECTION-SCREEN SKIP.
    PARAMETERS  P_FNAME LIKE RLGRAP-FILENAME OBLIGATORY.
    SELECTION-SCREEN : END OF BLOCK header.
                     I N I L I T I A L I Z A T I O N                          *
    INITIALIZATION.
      it_ctu_params-updmode = 'S'.
      it_ctu_params-defsize = 'X'.
      it_ctu_params-dismode = 'N'.
      APPEND it_ctu_params.
                   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_FNAME.
      PERFORM file_get.
                    S T A R T   O F   S E L E C T I O N                       *
    START-OF-SELECTION.
      PERFORM upload_xcel.
      IF NOT it_final[] IS INITIAL.
        SORT it_final BY matnr werks lifnr ekorg reswk ebeln ebelp.
        DESCRIBE TABLE it_final LINES v_lines.
      ENDIF.
    **To Know the Date Format for the user name in user master record
      SELECT SINGLE datfm FROM usr01
                          INTO v_datfm
                          WHERE bname = sy-uname.
    **Updating the Database based on the Combinations of Vendor/PPL/Porg and Agreement/Item
      LOOP AT it_final.
    *****Begin of Changes By Pavan   Ticket 648507            "D13K948908
        CLEAR : s_vdatu, s_bdatu.
        CONCATENATE it_final-vdatu6(4) it_final-vdatu0(2) it_final-vdatu+3(2) INTO s_vdatu.
        CONCATENATE it_final-bdatu6(4) it_final-bdatu0(2) it_final-bdatu+3(2) INTO s_bdatu.
        PERFORM plant_conversion USING it_final-werks.
    *****End of Changes By Pavan     Ticket 648507            "D13K948908
        REFRESH it_eord[].
        v_matnr = it_final-matnr.
    **Adding preceeding Zeroes to the Material No
        CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
          EXPORTING
            INPUT  = v_matnr
          IMPORTING
            OUTPUT = v_matnr.
    **Adding preceeding Zeroes to the Vendor
        CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
          EXPORTING
            INPUT  = it_final-lifnr
          IMPORTING
            OUTPUT = it_final-lifnr.
    **Adding preceeding Zeroes to the Item
        CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
          EXPORTING
            INPUT  = it_final-ebelp
          IMPORTING
            OUTPUT = it_final-ebelp.
        TRANSLATE it_final-feskz TO UPPER CASE.
        TRANSLATE it_final-notkz TO UPPER CASE.
    Select the Existing Records from EORD for the Combination of Material and Plant of New Record
        SELECT matnr
               werks
               erdat
               vdatu
               bdatu
               lifnr
               flifn
               ebeln
               ebelp
               febel
               reswk
               notkz
               ekorg
               autet FROM eord INTO corresponding fields of TABLE it_eord
                      WHERE matnr EQ v_matnr
                        AND werks EQ it_final-werks.
        SORT it_eord BY matnr werks vdatu bdatu erdat lifnr ekorg reswk ebeln ebelp.
        IF sy-subrc EQ 0.
          LOOP AT it_eord.
    If the Combination of Old Records Vendor/PPL/Porg is same and Agreement/Item
    is also same then delete the Old Record and Upload the New Record
            IF it_eord-MATNR = V_MATNR        AND
               it_eord-WERKS = IT_FINAL-WERKS AND
               it_eord-LIFNR = IT_FINAL-LIFNR AND
               it_eord-EKORG = IT_FINAL-EKORG AND
               it_eord-RESWK = IT_FINAL-RESWK AND
               it_eord-EBELN = IT_FINAL-EBELN AND
               it_eord-EBELP = IT_FINAL-EBELP.
    *****Begin of Changes By Pavan   Ticket 648507            "D13K948908
              IF s_vdatu GT it_eord-bdatu OR s_bdatu LT it_eord-vdatu.
              ELSE.
    *****End of Changes By Pavan     Ticket 648507            "D13K948908
                v_tabix = sy-tabix.
                PERFORM bdc_dynpro USING  'SAPLMEOR' '0200'.
                PERFORM bdc_field USING : 'EORD-MATNR' it_final-matnr,
                                          'EORD-WERKS' it_final-WERKS,
                                          'BDC_OKCODE' '/00'.
                PERFORM bdc_dynpro USING  'SAPLMEOR' '0205'.
                CONCATENATE 'RM06W-SELKZ(' v_tabix ')'  INTO v_fnam.
                PERFORM bdc_field USING : v_fnam 'X'.
                PERFORM bdc_field  USING 'BDC_OKCODE' '=LOES'.
                PERFORM bdc_dynpro USING 'SAPLSPO1'   '0200'.
                PERFORM bdc_field  USING 'BDC_OKCODE' '=YES'.
                PERFORM bdc_dynpro USING  'SAPLMEOR' '0205'.
                PERFORM bdc_field  USING 'BDC_OKCODE' '=BU'.
              ENDIF.
            ELSE.
    If the Combination of Old Records Vendor/PPL/Porg is same and Agreement/Item
    is different, if the FIX of the Existing one is X and also the FIX of the New one
    is X then deselect the FIX of the Old one, if the MRP of the Old one is 1 and also
    the MRP of the New one is 1 then delete the MRP of the Old one, if the FIX and MRP
    of the Old one is X,1 and if it is same for the new one also, then delete the FIX
    and MRP of the Old one and insert the new one also
              IF it_eord-lifnr = it_final-lifnr AND
                 it_eord-ekorg = it_final-ekorg AND
                 it_eord-reswk = it_final-reswk AND
                 it_eord-ebeln NE '' AND it_final-ebeln NE ''.
                IF it_eord-ebeln NE it_final-ebeln OR it_eord-ebelp NE it_final-ebelp.
                  IF it_eord-febel EQ 'X' OR it_eord-autet EQ '1'.
                    v_tabix = sy-tabix.
                    IF it_final-feskz = 'X' AND it_final-autet = '1'.
                   it_eord-febel = ''.
                   it_eord-autet = ''.
    *****Begin of Changes By Pavan   Ticket 648507            "D13K948908
                      IF s_vdatu GT it_eord-bdatu OR s_bdatu LT it_eord-vdatu.
                      ELSE.
    *****End of Changes By Pavan     Ticket 648507            "D13K948908
                        PERFORM bdc_dynpro USING  'SAPLMEOR' '0200'.
                        PERFORM bdc_field USING : 'EORD-MATNR' it_final-matnr,
                                         'EORD-WERKS' it_final-WERKS,
                                         'BDC_OKCODE' '/00'.
                        PERFORM bdc_dynpro USING  'SAPLMEOR' '0205'.
                        CONCATENATE 'RM06W-FESKZ(' v_tabix ')'  INTO v_fnam.
                        PERFORM bdc_field1 USING : v_fnam SPACE.
                        CONCATENATE 'EORD-AUTET(' v_tabix ')'  INTO v_fnam.
                        PERFORM bdc_field1 USING : v_fnam SPACE.
                        PERFORM bdc_field  USING 'BDC_OKCODE' '=BU'.
                      ENDIF.
                    ELSEIF
                     it_final-feskz = 'X'.
                   it_eord-febel = ''.
    *****Begin of Changes By Pavan   Ticket 648507            "D13K948908
                      IF s_vdatu GT it_eord-bdatu OR  s_bdatu LT it_eord-vdatu.
                      ELSE.
    *****End of Changes By Pavan     Ticket 648507            "D13K948908
                        PERFORM bdc_dynpro USING  'SAPLMEOR' '0200'.
                        PERFORM bdc_field USING : 'EORD-MATNR' it_final-matnr,
                                         'EORD-WERKS' it_final-WERKS,
                                         'BDC_OKCODE' '/00'.
                        PERFORM bdc_dynpro USING  'SAPLMEOR' '0205'.
                        CONCATENATE 'RM06W-FESKZ(' v_tabix ')'  INTO v_fnam.
                        PERFORM bdc_field1 USING : v_fnam SPACE.
                        PERFORM bdc_field  USING 'BDC_OKCODE' '=BU'.
                      ENDIF.
                    ELSEIF
                     it_final-autet = '1'.
                   it_eord-autet  = ''.
    *****Begin of Changes By Pavan   Ticket 648507            "D13K948908
                      IF s_vdatu GT it_eord-bdatu OR  s_bdatu LT it_eord-vdatu.
                      ELSE.
    *****End of Changes By Pavan     Ticket 648507            "D13K948908
                        PERFORM bdc_dynpro USING  'SAPLMEOR' '0200'.
                        PERFORM bdc_field USING : 'EORD-MATNR' it_final-matnr,
                                         'EORD-WERKS' it_final-WERKS,
                                         'BDC_OKCODE' '/00'.
                        PERFORM bdc_dynpro USING  'SAPLMEOR' '0205'.
                        CONCATENATE 'EORD-AUTET(' v_tabix ')'  INTO v_fnam.
                        PERFORM bdc_field1 USING : v_fnam SPACE.
                        PERFORM bdc_field  USING 'BDC_OKCODE' '=BU'.
                      ENDIF.
                    ENDIF.
                  ENDIF.
                ENDIF.
              ENDIF.
            ENDIF.
            CLEAR it_eord.
            IF NOT it_bdcdata[] IS INITIAL.
              CALL TRANSACTION 'ME01' USING it_bdcdata
                                      OPTIONS FROM it_ctu_params.
              REFRESH it_bdcdata[].
              EXIT.
            ENDIF.
          ENDLOOP.
        ENDIF.
          ENDIF.
        CLEAR : v_matnr, it_final.
      ENDLOOP.
      REFRESH : it_eord[].
      FREE it_eord.
    **Updating the Records of Upload File into ME01
      LOOP AT it_final INTO wa_final.
        it_final = wa_final.
        CLEAR v_matnr.
        TRANSLATE it_final-feskz TO UPPER CASE.
        TRANSLATE it_final-notkz TO UPPER CASE.
    *****Begin of Changes By Pavan   Ticket 648507            "D13K948908
        PERFORM plant_conversion USING wa_final-werks.
    *****End of Changes By Pavan     Ticket 648507            "D13K948908
    **To convert the Valid From and Valid To into User's Format
        CASE v_datfm.
          WHEN 1.
            CONCATENATE it_final-vdatu3(2) '.' it_final-vdatu0(2) '.' it_final-vdatu+6(4) INTO it_final-vdatu.
            CONCATENATE it_final-bdatu3(2) '.' it_final-bdatu0(2) '.' it_final-bdatu+6(4) INTO it_final-bdatu.
          WHEN 2.
            CONCATENATE it_final-vdatu0(2) '/' it_final-vdatu3(2) '/' it_final-vdatu+6(4) INTO it_final-vdatu.
            CONCATENATE it_final-bdatu0(2) '/' it_final-bdatu3(2) '/' it_final-bdatu+6(4) INTO it_final-bdatu.
          WHEN 3.
            CONCATENATE it_final-vdatu0(2) '-' it_final-vdatu3(2) '-' it_final-vdatu+6(4) INTO it_final-vdatu.
            CONCATENATE it_final-bdatu0(2) '-' it_final-bdatu3(2) '-' it_final-bdatu+6(4) INTO it_final-bdatu.
          WHEN 4.
            CONCATENATE it_final-vdatu6(4) '.' it_final-vdatu0(2) '.' it_final-vdatu+3(2) INTO it_final-vdatu.
            CONCATENATE it_final-bdatu6(4) '.' it_final-bdatu0(2) '.' it_final-bdatu+3(2) INTO it_final-bdatu.
          WHEN 5.
            CONCATENATE it_final-vdatu6(4) '/' it_final-vdatu0(2) '/' it_final-vdatu+3(2) INTO it_final-vdatu.
            CONCATENATE it_final-bdatu6(4) '/' it_final-bdatu0(2) '/' it_final-bdatu+3(2) INTO it_final-bdatu.
          WHEN 6.
            CONCATENATE it_final-vdatu6(4) '-' it_final-vdatu0(2) '-' it_final-vdatu+3(2) INTO it_final-vdatu.
            CONCATENATE it_final-bdatu6(4) '-' it_final-bdatu0(2) '-' it_final-bdatu+3(2) INTO it_final-bdatu.
    ***End of Changes by Pavan                       "D13K945062
          WHEN 'A'.
            CONCATENATE it_final-vdatu6(4) '/' it_final-vdatu3(2) '/' it_final-vdatu+0(2) INTO it_final-vdatu.
            CONCATENATE it_final-bdatu6(4) '.' it_final-bdatu3(2) '.' it_final-bdatu+0(2) INTO it_final-bdatu.
          WHEN 'B'.
            CONCATENATE it_final-vdatu6(4) '/' it_final-vdatu3(2) '/' it_final-vdatu+0(2) INTO it_final-vdatu.
            CONCATENATE it_final-bdatu6(4) '.' it_final-bdatu3(2) '.' it_final-bdatu+0(2) INTO it_final-bdatu.
          WHEN 'C'.
            CONCATENATE it_final-vdatu6(4) '/' it_final-vdatu3(2) '/' it_final-vdatu+0(2) INTO it_final-vdatu.
            CONCATENATE it_final-bdatu6(4) '.' it_final-bdatu3(2) '.' it_final-bdatu+0(2) INTO it_final-bdatu.
        ENDCASE.
          AT NEW werks.
        CLEAR s_count.
        REFRESH : it_bdcdata[], it_eord1[].
        PERFORM bdc_dynpro USING  'SAPLMEOR' '0200'.
        PERFORM bdc_field USING : 'EORD-MATNR' it_final-matnr,
                                  'EORD-WERKS' it_final-WERKS,
                                  'BDC_OKCODE' '/00'.
        PERFORM bdc_dynpro USING  'SAPLMEOR' '0205'.
    **Adding preceeding Zeroes to the Material No
        CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
          EXPORTING
            INPUT  = it_final-matnr
          IMPORTING
            OUTPUT = v_matnr.
    **To know the Number of records in EORD after Updating with new records
        SELECT vdatu
               bdatu FROM EORD
                     INTO TABLE it_eord1
                     WHERE matnr = v_matnr
                       AND werks = it_final-werks.
        DESCRIBE TABLE it_eord1 LINES v_eord_row.
        s_count = v_eord_row + 1.
          ENDAT.
        CONCATENATE 'EORD-VDATU(' s_count ')'  INTO v_fnam.
        PERFORM bdc_field USING : v_fnam it_final-VDATU.
        CONCATENATE 'EORD-BDATU(' s_count ')'  INTO v_fnam.
        PERFORM bdc_field USING : v_fnam it_final-BDATU.
        CONCATENATE 'EORD-EKORG(' s_count ')'  INTO v_fnam.
        PERFORM bdc_field USING : v_fnam  it_final-EKORG.
        CONCATENATE 'EORD-LIFNR(' s_count ')'  INTO v_fnam.
        PERFORM bdc_field USING : v_fnam it_final-LIFNR.
        CONCATENATE 'EORD-RESWK(' s_count ')'  INTO v_fnam.
        PERFORM bdc_field USING : v_fnam it_final-RESWK.
        CONCATENATE 'EORD-EBELN(' s_count ')'  INTO v_fnam.
        PERFORM bdc_field USING : v_fnam it_final-EBELN.
        CONCATENATE 'EORD-EBELP(' s_count ')'  INTO v_fnam.
        PERFORM bdc_field USING : v_fnam it_final-EBELP.
        CONCATENATE 'RM06W-FESKZ(' s_count ')' INTO v_fnam.
        PERFORM bdc_field USING : v_fnam it_final-FESKZ.
        CONCATENATE 'EORD-NOTKZ(' s_count ')'  INTO v_fnam.
        PERFORM bdc_field USING : v_fnam it_final-NOTKZ.
        CONCATENATE 'EORD-AUTET(' s_count ')'  INTO v_fnam.
        PERFORM bdc_field USING : v_fnam it_final-AUTET.
         AT END OF werks.
        PERFORM bdc_field USING 'BDC_OKCODE' '=BU'.
        REFRESH it_messtab[].
        CALL TRANSACTION 'ME01' USING it_bdcdata
                                OPTIONS FROM it_ctu_params
                                    MODE 'A'
                                  UPDATE 'L'
                             MESSAGES INTO it_messtab.
        IF SY-SUBRC NE 0.
          it_err_rec-matnr = it_final-matnr.
          it_err_rec-werks = it_final-werks.
          it_err_rec-vdatu = it_final-vdatu.
          it_err_rec-bdatu = it_final-bdatu.
          it_err_rec-lifnr = it_final-lifnr.
          it_err_rec-ekorg = it_final-ekorg.
          it_err_rec-reswk = it_final-reswk.
          it_err_rec-ebeln = it_final-ebeln.
          it_err_rec-ebelp = it_final-ebelp.
          it_err_rec-feskz = it_final-feskz.
          it_err_rec-notkz = it_final-notkz.
          it_err_rec-autet = it_final-autet.
          APPEND it_err_rec.
          CLEAR it_err_rec.
          PERFORM format_message.
        ENDIF.
         ENDAT.
      ENDLOOP.
    **To Upload the Error Records into another Excel File
      IF NOT it_err_rec[] IS INITIAL.
        PERFORM errors_file.
        DESCRIBE TABLE it_err_rec LINES v_err_rec.
        v_errors = v_err_rec - 1.
      ELSE.
        v_errors = 0.
      ENDIF.
      v_updated = v_lines - v_errors.
      WRITE : /2 'RUN DATE    :' color COL_NORMAL, 20 sy-datum,
              /2 'RUN TIME    :' color COL_NORMAL, 20 sy-uzeit.
      SKIP 2.
      WRITE : /2 'FILE PATH   :' color COL_NORMAL, 20 p_fname.
      SKIP 2.
      WRITE : /2 'RESULTS' color COL_NORMAL.
      SKIP.
      WRITE : /2 'Number of Rows in the Upload File  :' color COL_NORMAL, v_lines,
              /2 'Number of Rows Updated             :' color COL_NORMAL, v_updated,
              /2 'Number of Error Records            :' color COL_NORMAL, v_errors.
      IF it_errmsg[] IS NOT INITIAL.
        SKIP 2.
        WRITE : /2 'Details of the Error Records' color COL_NORMAL.
        SKIP.
        ULINE.
        FORMAT COLOR COL_NORMAL.
        WRITE : /2 'Material',
                22 'Plant',
                28 'Valid From',
                40 'Valid To',
                52 'Vendor',
                64 'Porg',
                70 'PPL',
                76 'Agreement',
                88 'Item',
                94 'Fix',
                98 'Blk',
                102 'MRP',
                106 'Err. Description'.
        FORMAT COLOR OFF.
        ULINE.
        LOOP AT it_errmsg.
          AT NEW autet.
            WRITE : /2 it_errmsg-matnr,
                    22 it_errmsg-werks,
                    28 it_errmsg-vdatu,
                    40 it_errmsg-bdatu,
                    52 it_errmsg-lifnr,
                    64 it_errmsg-ekorg,
                    70 it_errmsg-reswk,
                    76 it_errmsg-ebeln,
                    88 it_errmsg-ebelp,
                    94 it_errmsg-feskz,
                    98 it_errmsg-notkz,
                    102 it_errmsg-autet.
          ENDAT.
          WRITE    106 it_errmsg-messg.
        ENDLOOP.
      ENDIF.
                     E N D   O F   S E L E C T I O N                     *
    END-OF-SELECTION.
    *&      Form  file_get
          Selects the File Name and Path
    FORM file_get .
      CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
        EXPORTING
          PROGRAM_NAME  = v_repid
          DYNPRO_NUMBER = SYST-DYNNR
          FIELD_NAME    = p_fname
        CHANGING
          FILE_NAME     = p_fname
        EXCEPTIONS
          MASK_TOO_LONG = 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.
    ENDFORM.                    " file_get
    *&      Form  upload_xcel
          Uploading data to an Internal Table
    FORM upload_xcel .
      DATA: BEGIN OF it_intern OCCURS 0.
              INCLUDE STRUCTURE ALSMEX_TABLINE. " Rows for Table with Excel Data
      DATA: END OF it_intern.
      DATA v_no_rows  TYPE i VALUE 9999.
      FIELD-SYMBOLS : <fs1>.
      CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
        EXPORTING
          FILENAME                = P_FNAME
          I_BEGIN_COL             = c_1
          I_BEGIN_ROW             = c_1
          I_END_COL               = c_12
          I_END_ROW               = v_no_rows
        TABLES
          INTERN                  = it_intern
        EXCEPTIONS
          INCONSISTENT_PARAMETERS = 1
          UPLOAD_OLE              = 2
          OTHERS                  = 3.
      IF SY-SUBRC NE 0.
        MESSAGE text-016 TYPE 'I'.
      ENDIF.
      LOOP AT it_intern.
        ASSIGN COMPONENT it_intern-col OF STRUCTURE
        it_final TO <fs1>.
        IF sy-subrc NE 0.
          EXIT.
        ENDIF.
        <fs1> = it_intern-value.
        AT END OF row.
          APPEND it_final.
          CLEAR  it_final.
        ENDAT.
      Endloop.
      FREE it_intern.
    ***To Delete the Headings from the Internal Table.
      DELETE it_final WHERE matnr CA 'MATmat'.
    ENDFORM.                    " upload_xcel
    *&      Form  bdc_dynpro
          Populate Screen Name
    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.                    " bdc_dynpro
    *&      Form  bdc_field
         Populate Screen Field
    FORM bdc_field  USING    FNAM
                             FVAL.
      IF FVAL <> SPACE.
        CLEAR it_bdcdata.
        it_bdcdata-FNAM = FNAM.
        it_bdcdata-FVAL = FVAL.
        APPEND it_bdcdata.
      ENDIF.
    ENDFORM.                    " bdc_field
    *&      Form  bdc_field
         Populate Screen Field
    FORM bdc_field1   USING   FNAM
                             FVAL.
      CLEAR it_bdcdata.
      it_bdcdata-FNAM = FNAM.
      it_bdcdata-FVAL = FVAL.
      APPEND it_bdcdata.
    ENDFORM.                    " bdc_field
    *&      Form  errors_file
          Downloads the Error Records
    FORM errors_file .
      DATA : l_fname  TYPE string,
             l_var1   TYPE string,
             l_var2   TYPE string.
      l_fname = p_fname.
      SPLIT l_fname at '.' into l_var1 l_var2.
      CONCATENATE l_var1 '_error.' l_var2 INTO l_fname.
    **To Write the Headings in the Excel File
      it_err_rec-matnr = text-003.
      it_err_rec-werks = text-004.
      it_err_rec-vdatu = text-005.
      it_err_rec-bdatu = text-006.
      it_err_rec-lifnr = text-007.
      it_err_rec-ekorg = text-008.
      it_err_rec-reswk = text-009.
      it_err_rec-ebeln = text-010.
      it_err_rec-ebelp = text-011.
      it_err_rec-feskz = text-012.
      it_err_rec-notkz = text-013.
      it_err_rec-autet = text-014.
      INSERT it_err_rec INDEX 1.
      CLEAR it_err_rec.
      CALL FUNCTION 'GUI_DOWNLOAD'
        EXPORTING
          FILENAME                = l_fname
          FILETYPE                = 'DAT'
         APPEND                  = ' '
         CONFIRM_OVERWRITE       = ' '
        TABLES
          DATA_TAB                = it_err_rec
        EXCEPTIONS
          FILE_WRITE_ERROR        = 1
          NO_BATCH                = 2
          GUI_REFUSE_FILETRANSFER = 3
          INVALID_TYPE            = 4
          NO_AUTHORITY            = 5
          UNKNOWN_ERROR           = 6
          HEADER_NOT_ALLOWED      = 7
          SEPARATOR_NOT_ALLOWED   = 8
          FILESIZE_NOT_ALLOWED    = 9
          HEADER_TOO_LONG         = 10
          DP_ERROR_CREATE         = 11
          DP_ERROR_SEND           = 12
          DP_ERROR_WRITE          = 13
          UNKNOWN_DP_ERROR        = 14
          ACCESS_DENIED           = 15
          DP_OUT_OF_MEMORY        = 16
          DISK_FULL               = 17
          DP_TIMEOUT              = 18
          FILE_NOT_FOUND          = 19
          DATAPROVIDER_EXCEPTION  = 20
          CONTROL_FLUSH_ERROR     = 21
          OTHERS                  = 22.
      IF SY-SUBRC EQ 0.
        MESSAGE text-015 TYPE 'S'.
      ENDIF.
    ENDFORM.                    " errors_file
    *&      Form  format_message
          To Write the Error Records
    FORM format_message .
      IF NOT it_messtab[] IS INITIAl.
        LOOP AT it_messtab.
          IF it_messtab-msgtyp = 'E'.
            CALL FUNCTION 'FORMAT_MESSAGE'
              EXPORTING
                ID        = it_messtab-msgid
                LANG      = sy-langu
                NO        = it_messtab-msgnr
                V1        = it_messtab-msgv1
                V2        = it_messtab-msgv2
                V3        = it_messtab-msgv3
                V4        = it_messtab-msgv4
              IMPORTING
                MSG       = v_message
              EXCEPTIONS
                NOT_FOUND = 1
                OTHERS    = 2.
            IF SY-SUBRC EQ 0.
              it_errmsg-matnr = it_final-matnr.
              it_errmsg-werks = it_final-werks.
              it_errmsg-vdatu = it_final-vdatu.
              it_errmsg-bdatu = it_final-bdatu.
              it_errmsg-ekorg = it_final-ekorg.
              it_errmsg-lifnr = it_final-lifnr.
              it_errmsg-reswk = it_final-reswk.
              it_errmsg-ebeln = it_final-ebeln.
              it_errmsg-ebelp = it_final-ebelp.
              it_errmsg-feskz = it_final-feskz.
              it_errmsg-notkz = it_final-notkz.
              it_errmsg-autet = it_final-autet.
              it_errmsg-messg = v_message.
              APPEND it_errmsg.
              CLEAR : it_errmsg, v_message.
            ENDIF.
          ENDIF.
        ENDLOOP.
      ENDIF.
    ENDFORM.                    " format_message
    *&      Form  plant_conversion
         Adding preceeding Zeroes
         -->P_IT_FINAL_WERKS  text
    FORM plant_conversion  USING    P_VAR.
        CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
          EXPORTING
            INPUT  = P_VAR
          IMPORTING
            OUTPUT = P_VAR.
    ENDFORM.                    " plant_conversion
    Hope it helps!!!
    Regards,
    Pavan

  • Sales order creation:  validations on input data in BDC

    HI,
    i am using document type, sales org, distr chan, division, Custommer po num, incoterms1, payment terms, material, quantity, plant, item category, partner role, partner number.
      kindly let me know what validations i need to make on these before uploading.

    try with this.
    BAPI_SALESORDER_SIMULATE and see the documentation.
    No BDC.
    Regards
    Prabhu

  • Unable to run BDC due to start-of-selection

    Hi Experts,
    I am running BDC for ROH type.
    The data is in the excel file so I am performing the below operation.
    In the BDC recording before perform open group there is "START-OF-SELECTION" and I also have a START-OF-SELECTION for excel uploading now how wud both would go together..
    My requirement is  to select the file through F4 then choose BDC type session or call transaction
    and upload the data
    Since I have 2 start-of-selection nothing happens after F8.
    Help is really appreciated and rewarded.
    Selection-screen begin of block b1 with frame title text-001.
    parameter: f_name type rlgrap-filename default 'D:\Cost_element_KS06.xls'.
    parameter : p_begcol type i default 1 no-display,
                p_begrow type i default 2 no-display,
                p_endcol type i default 8 no-display,
                p_endrow type i default 46 no-display.
    selection-screen end of block b1.
    at selection-screen on value-request for f_name.
    perform f_get_file using f_name.
    start-of-selection.
    perform f_xls_itab using f_name changing it_excel.
    perform f_move_data.
    include bdcrecx1.
    start-of-selection.
    perform open_group.
    loop at t_ks06 to wa.
    " Here I have the BDC recording recorderd through SHDB for ROH
    endloop.
    perform close_group.
    Ranjith N.

    Hi Avinash,
    I have made the following modification but stil the same.
    report ZNRD_BDC_UPD_COSTELEMENT
           no standard page heading line-size 255.
    * Declaring work area and internal tables
    data : begin of t_ks06 occurs 0,
           KOKRS type KOKRS,      " Controlling area
           KSTAR type KSTAR,      " Cost element
           DATAB type DATAB,      " Valid from date
           DATBI type DATBI,      " Valid to  date
           KTEXT type KTEXT,      " Name
           LTEXT type LTEXT,      " Description
           KATYP type KATYP,      " Cost element cat
           KOSTL type KOSTL,      " Cost center
           end of t_ks06.
    data : wa like line of t_ks06.
    data : it_excel type alsmex_tabline occurs 0 with header line.
    *data : flg_mv(1) type n value 0.    " Flag to check data Moved.
    selection-screen begin of block b1 with frame title text-001.
    parameter: f_name type rlgrap-filename default 'C:\Documents and Settings\Administrator\Desktop\Project_data\Cost_element_KS06.xls'.
    parameter : p_begcol type i default 1 no-display,
                p_begrow type i default 2 no-display,
                p_endcol type i default 8 no-display,
                p_endrow type i default 46 no-display.
    selection-screen end of block b1.
    " Iam performing all subroutines under at selection-screen and under start-of-selection Iam calling the bdc
    but still nothing happens. please help
    at selection-screen on value-request for f_name.
    perform f_get_file using f_name.
    perform f_xls_itab using f_name changing it_excel.
    perform f_move_data.
    *perform f_display_data.
    start-of-selection.
    perform open_group.
    loop at t_ks06 to wa.
    perform bdc_dynpro      using 'SAPLKMA4' '0200'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'CSKBZ-KOKRS'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform bdc_field       using 'CSKBZ-KOKRS'
                                  wa-KOKRS.
    perform bdc_field       using 'CSKBZ-KSTAR'
                                  wa-KSTAR.
    perform bdc_field       using 'CSKBZ-DATAB_ANFO'
                                  wa-DATAB.
    perform bdc_field       using 'CSKBZ-DATBI_ANFO'
                                  wa-DATBI.
    perform bdc_dynpro      using 'SAPLKMA4' '0299'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'CSKBZ-EIGEN'.
    perform bdc_field       using 'CSKBZ-KTEXT'
                                  wa-KTEXT.
    perform bdc_field       using 'CSKBZ-LTEXT'
                                  wa-LTEXT.
    perform bdc_field       using 'CSKBZ-KATYP'
                                  wa-KATYP.
    perform bdc_dynpro      using 'SAPLKMA4' '0299'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=VKON'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'CSKBZ-KTEXT'.
    perform bdc_field       using 'CSKBZ-KTEXT'
                                  wa-KTEXT.
    perform bdc_field       using 'CSKBZ-LTEXT'
                                  wa-LTEXT.
    perform bdc_field       using 'CSKBZ-KATYP'
                                  wa-KATYP.
    perform bdc_dynpro      using 'SAPLKMA4' '0299'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '/00'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'CSKBZ-KOSTL'.
    perform bdc_field       using 'CSKBZ-KOSTL'
                                  wa-KOSTL.
    perform bdc_dynpro      using 'SAPLKMA4' '0299'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=BU'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'CSKBZ-KOSTL'.
    perform bdc_field       using 'CSKBZ-KOSTL'
                                  wa-KOSTL.
    perform bdc_transaction using 'KA06'.
    endloop.
    perform close_group.
    include bdcrecx1.
    *&      Form  f_get_file
    *       text
    *      -->P_FILE_NAM  text
    form f_get_file  using    p_file_nam.
    call function 'KD_GET_FILENAME_ON_F4'
    exporting
       program_name        = syst-repid
       dynpro_number       = syst-dynnr
    *   FIELD_NAME          = ' '
    *   STATIC              = ' '
    *   MASK                = ' '
      changing
        file_name           = f_name
    exceptions
       mask_too_long       = 1
       others              = 2.
    endform.                    " f_get_file
    *&      Form  f_xls_itab
    *       text
    *      -->P_FILE_NAM  text
    *      <--P_IT_EXCEL  text
    form f_xls_itab  using    p_file_nam changing p_it_excel.
    call function 'ALSM_EXCEL_TO_INTERNAL_TABLE'
      exporting
        filename                      = f_name
        i_begin_col                   = p_begcol
        i_begin_row                   = p_begrow
        i_end_col                     = p_endcol
        i_end_row                     = p_endrow
      tables
        intern                        = it_excel
    exceptions
       inconsistent_parameters       = 1
       upload_ole                    = 2
       others                        = 3.
    endform.                    " f_xls_itab
    *&      Form  f_move_data
    *       text
    *  -->  p1        text
    *  <--  p2        text
    form f_move_data.
    data : lv_index type i.
    field-symbols <fs>.
    * Sorting the internal table
    sort it_excel by row col.
    clear it_excel.
    loop at it_excel.
      move it_excel-col to lv_index.
    * Assigning each record to the internal table row.
      assign component lv_index of structure wa to <fs>.
    * Assigning the field value to a field symbol
      move it_excel-value to <fs>.
      at end of row.
      append wa to t_ks06.
    *   flg_mv = 1.
      clear wa.
      endat.
    endloop.
    endform.                    " f_move_data
    *&      Form  f_display_data
    *       text
    *  -->  p1        text
    *  <--  p2        text
    form f_display_data.
      write:/1 sy-uline(140).
      write:/1 sy-vline,  'Cont area',        " Controlling area
             16 sy-vline, 'Cost ele',         " Cost element
             31 sy-vline, 'Valid from',       " Valid from  date
             46 sy-vline, 'Valid to '  ,      " Valid to date
             61 sy-vline, 'Name',             "Cost element cat
             76 sy-vline, 'Description',      " Cost center
             101 sy-vline,  'Cost ele cat',   " Cost element cat
             126 sy-vline, 'Cost center',     " Cost center
             140 sy-vline.
    write:/1 sy-uline(140).
    skip 1.
    clear wa.
    loop at t_ks06 into wa.
      write:/2 sy-uline(139).
      write:/2  sy-vline,  wa-KOKRS,      " Controlling area
             16 sy-vline, wa-KSTAR,      " Cost element
             31 sy-vline, wa-DATAB,      " Valid from date
             46 sy-vline, wa-DATBI,      " Valid to date
             61 sy-vline, wa-KTEXT,      " Name
             76 sy-vline, wa-LTEXT,      " Description
             101 sy-vline, wa-KATYP,     " Cost element cat
             120 sy-vline, wa-KOSTL,     " Cost center
             140 sy-vline.
    endloop.
    endform.                    " f_display_data
    Regards,
    Ranjith

  • Fields in a BDC table

    hai gurus....
    What are the fields in a BDC table???
    Thanks
    Pavan

    hi,
    i hope this answer will helps you..........,
    the BDCDATA table contains fields are...
    <b>BDCDATA-PROGRAM</b>-----> this field describes the module pool program name which we are used for vaidating and updating the data.
    <b>BDCDATA-DYNPRO</b>----
    > this field describes the currently active screen.
    <b>BDCDATA-DYNBEGIN</b>-------> this field describes the default or initial screen.
    <b>BDCDATA-FNAM</b>----
    > this field describes the field name which we are used in validations.
    <b>BDCDATA-FVAL</b>----
    > this field describes the field value which we are used in validations.
    by using the above table we perfome the mapping logic in BDC for validating and updating the legacy system data.
    regards,
    Ashok Reddy
    Message was edited by:
            Ashok Reddy

Maybe you are looking for