<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: BDC in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/bdc/m-p/2610214#M598714</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;     Only thing we want to use debugging and see whether the datas from the flat file has been loaded properly in to the internal table...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If u need to check any conditions means u want to use the if statments to check and as per the conditions u can insert the elements&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;REWARD IF USEFUL&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 04 Aug 2007 12:21:43 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2007-08-04T12:21:43Z</dc:date>
    <item>
      <title>BDC</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/bdc/m-p/2610211#M598711</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;how to do validations in BDC's?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 04 Aug 2007 10:46:29 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/bdc/m-p/2610211#M598711</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-08-04T10:46:29Z</dc:date>
    </item>
    <item>
      <title>Re: BDC</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/bdc/m-p/2610212#M598712</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;make question meaning full&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 04 Aug 2007 11:04:05 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/bdc/m-p/2610212#M598712</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-08-04T11:04:05Z</dc:date>
    </item>
    <item>
      <title>Re: BDC</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/bdc/m-p/2610213#M598713</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For a BDC upload you need to write a program which created BDC sessions. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Steps: &lt;/P&gt;&lt;P&gt;1. Work out the transaction you would use to create the data manually. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. Use transaction SHDB to record the creation of one material master data. &lt;/P&gt;&lt;P&gt;    Click the New recording button or the Menu - Recording - Create &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3. Save the recording, and then go back a screen and go to the overview. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;4. Select the recording and click on Edit - Create Program. Give the program a Z name, and select transfer from recording. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;5. Edit the program. You will see that all the data you entered is hard-coded into the program. You need to make the following changes: &lt;/P&gt;&lt;P&gt;5.1 After the start-of-selection, Call ws_upload to upload the file (the excel file needs to be saved as TAB separated). &lt;/P&gt;&lt;P&gt;5.2 After the open-group, Loop on the uploaded data. For each line, perform &amp;lt;b&amp;gt;validation&amp;lt;/b&amp;gt; checks on the data, then modify the perform bdc_field commands to use the file data. &lt;/P&gt;&lt;P&gt;5.3. After perform bdc_transaction, add the endloop. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Execute the program. It will have options to create a batch session or to process directly. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;These are all my finds . Might be it will be useful to you. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Direct call of transactions, session handling: &lt;/P&gt;&lt;P&gt;/nxxxx This terminates the current transaction, and starts transaction xxxx &lt;/P&gt;&lt;P&gt;  &lt;/P&gt;&lt;P&gt;/n This terminates the transaction. This generally corresponds to pressing F15 to go back. &lt;/P&gt;&lt;P&gt;  &lt;/P&gt;&lt;P&gt;/nend This termiantes all separate sessions and logs off (corresponds to System - Logoff). &lt;/P&gt;&lt;P&gt;  &lt;/P&gt;&lt;P&gt;/nex This terminates all separate sessions and logs off immediately (without any warning!). &lt;/P&gt;&lt;P&gt;  &lt;/P&gt;&lt;P&gt;/oxxxx This opens a new session and starts transaction xxxx in This session. &lt;/P&gt;&lt;P&gt;  &lt;/P&gt;&lt;P&gt;/o This lists existing sessions and allows deletion or opening of a new session. &lt;/P&gt;&lt;P&gt;  &lt;/P&gt;&lt;P&gt;/i This terminates the current session (corresponds to System End &lt;/P&gt;&lt;P&gt;  &lt;/P&gt;&lt;P&gt;/i1, /i2,... This terminates the session with the number given. &lt;/P&gt;&lt;P&gt;  &lt;/P&gt;&lt;P&gt;.xyzw Fast path: 'xyzw' refers to the underlined letters in the menus. This type of navigation is uncommon and is provided more for emergencies (such as a defective mouse). &lt;/P&gt;&lt;P&gt;  &lt;/P&gt;&lt;P&gt;Batch &lt;/P&gt;&lt;P&gt;The following commands can be entered in correction mode ('Process in foreground' or 'Display errors only') when processing a batch input session: &lt;/P&gt;&lt;P&gt;  &lt;/P&gt;&lt;P&gt;/n This terminates the current batch input transaction and characterizes it as &lt;/P&gt;&lt;P&gt;  &lt;/P&gt;&lt;P&gt;/bdel This deletes the current batch input transaction. &lt;/P&gt;&lt;P&gt;  &lt;/P&gt;&lt;P&gt;/bend This terminates batch input processing and sets the session to Failed &lt;/P&gt;&lt;P&gt;  &lt;/P&gt;&lt;P&gt;/bda This switches from Display errors only to Process in foreground &lt;/P&gt;&lt;P&gt;  &lt;/P&gt;&lt;P&gt;/bde This switches from Process in foreground to Display errors only &lt;/P&gt;&lt;P&gt;  &lt;/P&gt;&lt;P&gt;ABAP/4 &lt;/P&gt;&lt;P&gt;/h This switches into debugging mode. &lt;/P&gt;&lt;P&gt;  &lt;/P&gt;&lt;P&gt;/hs This switches into debugging mode and activates the debugging of system functions. &lt;/P&gt;&lt;P&gt;  &lt;/P&gt;&lt;P&gt;Buffer &lt;/P&gt;&lt;P&gt;WARNING: Resetting buffers can significantly change the performance of the entire system for a long time. &lt;/P&gt;&lt;P&gt;It should therefore only be used where there is a good reason tdso. As of release 3.0B system administator authorization is required (authorization object (S_ADMI_FCD). The action is noted in the system log. &lt;/P&gt;&lt;P&gt;  &lt;/P&gt;&lt;P&gt;/$SYNC This resets all buffers of the application server &lt;/P&gt;&lt;P&gt;  &lt;/P&gt;&lt;P&gt;/$CUA This resets the CUA buffer of the application server &lt;/P&gt;&lt;P&gt;  &lt;/P&gt;&lt;P&gt;/$TAB This resets the TABLE buffers of the application server &lt;/P&gt;&lt;P&gt;  &lt;/P&gt;&lt;P&gt;/$NAM This resets the nametab buffer of the application server &lt;/P&gt;&lt;P&gt;  &lt;/P&gt;&lt;P&gt;/$DYNP This resets the screen buffer of the application server &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Direct Input.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Without calling the screens but all the validations should be done and only for master datas upload.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Direct Input method:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. Only for error free datas and also master data &lt;/P&gt;&lt;P&gt;updation.&lt;/P&gt;&lt;P&gt;2. It will directly updates the database table. No &lt;/P&gt;&lt;P&gt;screens involved.&lt;/P&gt;&lt;P&gt;3. Transaction BMVO or Program RBMVSHOW has been &lt;/P&gt;&lt;P&gt;used.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BDC(Batch Input Session):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. Screens will be called programmatically.&lt;/P&gt;&lt;P&gt;2. First sessions will be created then we'll run the seesions in SM35 transaction.&lt;/P&gt;&lt;P&gt;3.Synchronous database update. After the processing the session only database update will occur.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For BDC:&lt;/P&gt;&lt;P&gt;&lt;A href="http://myweb.dal.ca/hchinni/sap/bdc_home.htm" target="test_blank"&gt;http://myweb.dal.ca/hchinni/sap/bdc_home.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://www.sdn.sap.com/irj/sdn/wiki?path=/display/home/bdc&amp;amp;" target="test_blank"&gt;https://www.sdn.sap.com/irj/sdn/wiki?path=/display/home/bdc&amp;amp;&lt;/A&gt;;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sap-img.com/abap/learning-bdc-programming.htm" target="test_blank"&gt;http://www.sap-img.com/abap/learning-bdc-programming.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sapdevelopment.co.uk/bdc/bdchome.htm" target="test_blank"&gt;http://www.sapdevelopment.co.uk/bdc/bdchome.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sap-img.com/abap/difference-between-batch-input-and-call-transaction-in-bdc.htm" target="test_blank"&gt;http://www.sap-img.com/abap/difference-between-batch-input-and-call-transaction-in-bdc.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://help.sap.com/saphelp_47x200/helpdata/en/69/c250684ba111d189750000e8322d00/frameset.htm" target="test_blank"&gt;http://help.sap.com/saphelp_47x200/helpdata/en/69/c250684ba111d189750000e8322d00/frameset.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sapbrain.com/TUTORIALS/TECHNICAL/BDC_tutorial.html" target="test_blank"&gt;http://www.sapbrain.com/TUTORIALS/TECHNICAL/BDC_tutorial.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Check these link:&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sap-img.com/abap/difference-between-batch-input-and-call-transaction-in-bdc.htm" target="test_blank"&gt;http://www.sap-img.com/abap/difference-between-batch-input-and-call-transaction-in-bdc.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sap-img.com/abap/question-about-bdc-program.htm" target="test_blank"&gt;http://www.sap-img.com/abap/question-about-bdc-program.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.itcserver.com/blog/2006/06/30/batch-input-vs-call-transaction/" target="test_blank"&gt;http://www.itcserver.com/blog/2006/06/30/batch-input-vs-call-transaction/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.planetsap.com/bdc_main_page.htm" target="test_blank"&gt;http://www.planetsap.com/bdc_main_page.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A class="jive_macro jive_macro_message" href="https://community.sap.com/" __jive_macro_name="message" modifiedtitle="true" __default_attr="2491514"&gt;&lt;/A&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;&amp;lt;u&amp;gt;Check this sample one&amp;lt;/u&amp;gt;&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
 
 
******Internal Table for Header Data.
 
TYPES : BEGIN OF type_header,
        kschl LIKE konv-kschl,
        vkorg LIKE vbak-vkorg,
        vtweg LIKE komg-spart,
        matnr LIKE mvke-matnr,
        kbetr(11) TYPE c,
        datab(10) TYPE c,
        datbi(10) TYPE c,
        END OF type_header.
****Internal Table for Item Level.
TYPES : BEGIN OF type_item, 
        kschl LIKE konv-kschl,
        vkorg LIKE vbak-vkorg,
        vtweg LIKE komg-spart,
        matnr LIKE mvke-matnr,
        kbetr(11)  TYPE c,
        datab(10) TYPE c,
        datbi(10) TYPE c,
       END OF type_item.
 
******Error Table For not found in MVKE.
TYPES : BEGIN OF type_error ,
        kschl LIKE konv-kschl,
        vkorg LIKE vbak-vkorg,
        vtweg LIKE komg-spart,
        matnr LIKE mvke-matnr, 
        kbetr LIKE konp-kbetr,
        datab(10) TYPE c,
        datbi(10) TYPE c,
        text(100) TYPE c,
        END OF type_error.
 
****For error Messages
TYPES : BEGIN OF type_mtab,
        matnr   LIKE mara-matnr,
        msgtyp  LIKE bdcmsgcoll-msgtyp,
        msgid   LIKE bdcmsgcoll-msgid,
        msgnr   LIKE bdcmsgcoll-msgnr,
        text(100) TYPE c,
        END OF type_mtab.
 
****Internal Table
TYPES: BEGIN OF type_mvke,
       matnr LIKE mvke-matnr,
       vkorg LIKE mvke-vkorg,
       vtweg LIKE mvke-vtweg,
       END OF type_mvke.
 
****Internal Table
TYPES : BEGIN OF type_tvkov,
        vkorg LIKE tvkov-vkorg,
        vtweg LIKE tvkov-vtweg,
        END OF type_tvkov.
 
** Declaring Internal Tables
 
DATA : t_header TYPE STANDARD TABLE OF type_header,
       t_item TYPE STANDARD TABLE OF type_item,
       t_mvke TYPE STANDARD TABLE OF type_mvke,
       t_tvkov TYPE STANDARD TABLE OF type_tvkov,
       t_error TYPE STANDARD TABLE OF type_error,
       t_mtab TYPE STANDARD TABLE OF type_mtab.
 
 
** Work Area Declaration.
DATA : wa_header LIKE LINE OF t_header,
       wa_item LIKE LINE OF t_item,
       wa_error LIKE LINE OF t_error,
       wa_mtab LIKE LINE OF t_mtab,
       wa_tvkov LIKE LINE OF t_tvkov,
       wa_mvke LIKE LINE OF t_mvke.
 
 
**Rows for Table with Excel Data********
DATA: t_xls_file LIKE alsmex_tabline OCCURS 0 WITH HEADER LINE.
 
***Constant.
DATA : c_params LIKE ctu_params.
DATA : c_ans(1) TYPE c.
DATA : v_count(4) TYPE c. " To show No.of records
 
 
DATA :  bdctab LIKE bdcdata OCCURS 10 WITH HEADER LINE.      " BDCDATA
DATA :  tmess_mtab  LIKE  bdcmsgcoll OCCURS 10 WITH HEADER LINE.
 
 
************************************************************************
**
**  SELECTION SCREEN
************************************************************************
**
SELECTION-SCREEN : BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
PARAMETERS : p_fname LIKE rlgrap-filename OBLIGATORY.
SELECTION-SCREEN : END OF BLOCK b1.
**********************************************************************
* END OF SELECTION SCREEN.
**********************************************************************
 
DATA : repid LIKE sy-repid.
DATA : v_matnr(50) TYPE c, "used for line items
       v_kbetr(50) TYPE c, "used for line items
       v_dat1(50) TYPE c,  "used for line items
       v_dat(50) TYPE c.   "used for line items
 
DATA : v_lindx(5) TYPE n ,"index counter for first 14 records.
       v_lindx1(5) TYPE n  VALUE '01', "index counter for  13 records.
       v_item(5) TYPE c,  "To increment the line index
       v_pgedwn2  TYPE i . "For Pagedown Counter
 
 
DATA:  v_currentrow TYPE i.  "For Current Row
 
DATA  v_bdc(50) TYPE c." Text to apper in Confrim POPUP Window.
 
 
************AT SELECTION-SCREEN
 
AT SELECTION-SCREEN  ON VALUE-REQUEST FOR p_fname.
  PERFORM get_filename USING p_fname.
 
 
 
*************START-OF-SELECTION
START-OF-SELECTION.
 
******Values for Ctu_params to Transaction
  c_params-defsize = 'X'.
  c_params-dismode = 'N'.
  c_params-updmode = 'S'.
 
******Refresh
 
  PERFORM f_refresh.
 
*********To upload File.
  PERFORM upload_file.
 
****User Confrimation only BDC will Process
  IF c_ans = '1'.
** *** BDC Process.
    PERFORM read_data.
  ELSE.
    FORMAT COLOR 3 INTENSIFIED .
    WRITE:/ 'Selected not to Process the Upload'.
    EXIT.
  ENDIF.
******On completion of  Process Refresh the Internal Table
  REFRESH :  t_xls_file,
               t_header,
               t_item,
               t_mvke,
               t_tvkov.
 
  CLEAR :    t_xls_file,
             wa_header,
             wa_item,
             wa_mvke,
             wa_tvkov.
***************************************
***********Display Messages
  WRITE : /01 'Status',19 'Status Text'.
  WRITE  AT 0(150) sy-uline.
  LOOP AT t_mtab INTO wa_mtab.
    WRITE :/01 wa_mtab-msgtyp,19 wa_mtab-text.
  ENDLOOP.
 
  SKIP 2.
  SORT t_error BY matnr.
  WRITE  AT 0(150) sy-uline.
  WRITE 'ERROR MESSAGES'.
  WRITE  AT 0(150) sy-uline.
  WRITE :/01 'Material.No',20 'Status Text'.
  WRITE  AT 0(150) sy-uline.
  LOOP AT t_error INTO wa_error WHERE matnr NE ' '.
! 
    WRITE:/01 wa_error-matnr,20 wa_error-text.
  ENDLOOP.
 
 
*---------------------------------------------------------------------*
*&amp;amp;      Form  get_filename
*&amp;amp;---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      --&amp;gt;P_FILENAME  text
*----------------------------------------------------------------------*
FORM get_filename USING    p_fname.
 
 
*****To read the file from Presentation Server
  CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
   EXPORTING
     program_name        =  repid
    dynpro_number      ! ; =   syst-dynnr
      field_name          = p_fname
*   STATIC              = ' '
    mask                = '*.XLS'
    CHANGING
      file_name           = p_fname
 EXCEPTIONS
   mask_too_long       = 1
   OTHERS              = 2
            .
  IF sy-subrc &amp;lt;&amp;gt; 0.
* * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*   WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.
 
ENDFORM.                    " get_filename
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  upload_file
*&amp;amp;---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  --&amp;gt;  p1        text
*  &amp;lt;--  p2        text
*----------------------------------------------------------------------*
FORM upload_file.
 
  DATA : frow VALUE 2 TYPE i,
         fcol VALUE 1 TYPE i,
         erow VALUE 10000 TYPE i,
         ecol VALUE 7  TYPE i,
         ecol1 VALUE 1 TYPE i,
         c_col1 TYPE i VALUE '0001',
         c_col2 TYPE i VALUE '0002',
         c_col3 TYPE i VALUE '0003',
       &amp;amp;nb! sp; c_col4 TYPE i VALUE '0004',
         c_col5 TYPE i VALUE '0005',
         c_col6 TYPE i VALUE '0006',
         c_col7 TYPE i VALUE '0007'.
 
***FM used to UPLOAD data from Flat file
 
  CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
       EXPORTING
            filename                = p_fname
            i_begin_col             = fcol
            i_begin_row             = frow
            i_end_col               = ecol
            i_end_row               = erow
       TABLES
            intern                  = t_xls_file
       EXCEPTIONS
            inconsistent_parameters = 1
            upload_ole              = 2
            OTHERS                  = 3.
 
  IF sy-subrc &amp;lt;&amp;gt; 0.
    MESSAGE e000.
  ENDIF.
 
 
****T_XLS_FILE is initial, stop the process &amp;amp; throw message
  IF t_xls_file[] IS INITIAL. 
    FORMAT COLOR 6 ON INTENSIFIED ON.
    WRITE:/ 'No Data  Exists '.
    FORMAT COLOR OFF INTENSIFIED OFF.
    STOP.
  ELSE.
 
 
* Sort table by rows and colums
    SORT t_xls_file BY row col.
 
* Get first row retrieved
    READ TABLE t_xls_file INDEX 1.
 
 
* Set first row retrieved to current row
    v_currentrow = t_xls_file-row.
 
 
**Loop  to move data in internal Table
    LOOP AT t_xls_file .
*   Reset values for next row
      IF t_xls_file-row NE v_currentrow.
        APPEND wa_header TO t_header.
        CLEAR wa_header.
        v_currentrow = t_xls_file-row.
      ENDIF.
 
      CASE t_xls_file-col.
        WHEN  c_col1.                              "Kschl
          wa_header-kschl = t_xls_file-value.
        WHEN c_col2.                              "Vkorg
          wa_header-vkorg = t_xls_file-value.
        WHEN c_col3.                              "vtweg
          wa_header-vtweg = t_xls_file-value.
        WHEN c_col4.                              "Matnr
          wa_header-matnr = t_xls_file-value.
        WHEN c_col5.                              "Kbetr
          wa_header-kbetr = t_xls_file-value.
        WHEN c_col6.                              "FROm
          wa_header-datab   = t_xls_file-value.
        WHEN c_col7.                              "TO
          wa_header-datbi   = t_xls_file-value.
 
      ENDCASE.
    ENDLOOP.
    APPEND wa_header TO t_header.
    CLEAR wa_header.
  ENDIF.
****To process the data
  PERFORM f_process.
 
 
ENDFORM.                    " upload_file
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  READ_DATA
*&amp;amp;---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------* 
*  --&amp;gt;  p1        text
*  &amp;lt;--  p2        text
*----------------------------------------------------------------------*
FORM read_data.
 
****To make Uniq Records in Header Level
  SORT t_header BY kschl vkorg vtweg.
  DELETE ADJACENT DUPLICATES FROM t_header COMPARING
                                   kschl vkorg vtweg .
  SORT t_item BY vkorg vtweg matnr.
  DATA : wa1_item TYPE type_item.
  DATA : l_cnt TYPE i.
  DATA : flag(1) TYPE c. "to process the Line item.
 
 
 
***Looping Header Table.
 
  LOOP AT t_header INTO wa_header.
***************************************
 
    PERFORM bdc_dynpro      US! ING 'SAPMV13A' '0100'.
    PERFORM bdc_field       USING 'BDC_CURSOR'
                                  'RV13A-KSCHL'.
    PERFORM bdc_field       USING 'BDC_OKCODE'
                                    '=ANTA'.
    PERFORM bdc_field       USING 'RV13A-KSCHL'
                                  wa_header-kschl.
    PERFORM bdc_dynpro      USING 'SAPLV14A' '0100'.
    PERFORM bdc_field       USING 'BDC_CURSOR'
                                  'RV130-SELKZ(03)'.
    PERFORM bdc_field       USING 'BDC_OKCODE'
                                  '=WEIT'.
    PERFORM bdc_field       USING 'RV130-SELKZ(03)'
                                  'X'.
 
    PERFORM bdc_dynpro      USING 'SAPMV13A' '1004'.
    PERFORM bdc_field       USING 'BDC_CURSOR'
                                  'KOMG-VKORG'.
 
    PERFORM bdc_field       USING 'KOMG-VKORG'
                                   wa_header-vkorg.
    PERFORM bdc_field       USING 'KOMG-VTWEG'
                                   wa_header-vtweg.
 
****To handle Line Items.
    LOOP AT t_item INTO wa1_item WHERE vkorg = wa_header-vkorg AND
                                  vtweg = wa_header-vtweg.
      wa_item = wa1_item.
 
 
 
******Flag Set only After processing  first 14 records .
      IF flag = ' '.
        v_lindx  = v_lindx + 01.
        SHIFT  v_lindx LEFT DELETING LEADING '0'.
        v_item  = v_lindx .
 
        CONCATENATE 'KOMG-MATNR(' v_item ')'  INTO v_matnr.
 
        PERFORM bdc_field           USING v_matnr
                                      wa_item-matnr.
 
        CONCATENATE 'KONP-KBETR(' v_item ')' INTO v_kbetr.
 
        PERFORM bdc_field       USING v_kbetr
                                      wa_item-kbetr.
 
 
        CONCATENATE 'RV13A-DATAB(' v_item ')' INTO v_dat.
 
        PERFORM bdc_field       USING  v_dat
                                      wa_item-datab.
 
 
        CONCATENATE 'RV13A-DATBI(' v_item ')' INTO v_dat1.
 
        PERFORM bdc_field       USING  v_dat1
                                      wa_item-datbi.
 
 
        IF  v_item = 14.
          flag = 'X'.
 
          PERFORM bdc_field       USING 'BDC_OKCODE'
                                              '/00'.
 
          PERFORM bdc_field       USING 'BDC_OKCODE'
                                             '=P+'.
 
          PERFORM bdc_dynpro      USING 'SAPMV13A' '1004'.
 
          CLEAR v_lindx.
          CLEAR v_item.
          CONTINUE.
        ENDIF.
      ENDIF.
 
 
 
***Flag is Set  after Processing of 14 records.
****** TO process rest of Records
      IF flag = 'X'.
 
 
        v_pgedwn2  = v_pgedwn2 + 1.
        v_lindx1  = v_lindx1 + 01.
        SHIFT  v_lindx1 LEFT DE! LETING LEADING '0'.
        v_item  = v_lindx1 .
 
        CONCATENATE 'KOMG-MATNR(' v_it! em ')'  INTO v_matnr.
 
        PERFORM bdc_field           USING v_matnr
                                      wa_item-matnr.
 
        CONCATENATE 'KONP-KBETR(' v_item ')' INTO v_kbetr.
 
        PERFORM bdc_field       USING v_kbetr
                                      wa_item-kbetr.
 
 
        CONCATENATE 'RV13A-DATAB(' v_item ')' INTO v_dat.
 
        PERFORM bdc_field       USING  v_dat
                                      wa_item-datab.
 
 
        CONCATENATE 'RV13A-DATBI(' v_item ')' INTO v_dat1.
 
        PERFORM bdc_field       USING  v_dat1
                                      wa_item-datbi.
 
        IF v_pgedwn2 = 13.
 
 
 
          PERFORM bdc_field       USING 'BDC_OKCODE'
                                              '/00'.
 
 
          PERFORM bdc_field       USING 'BDC_OKCODE'
                                             '=P+'.
 
          PERFORM bdc_dynpro      USING 'SAPMV13A' '1004'.
 
 
          v_pgedwn2 = 0.
          v_lindx1 = 1.
          CLEAR v_item.
 
          CONTINUE.
        ENDIF.
      ENDIF.
 
 
    ENDLOOP.
 
    PERFORM bdc_field       USING 'BDC_OKCODE'
                               '=SICH'.
 
****** Calling Transaction after Processing All items.
 
    CALL TRANSACTION 'VK11' USING bdctab
                       OPTIONS FROM c_params MESSAGES INTO tmess_mtab.
*
    REFRESH bdctab.
    CLEAR : bdctab.
    CLEAR : wa_item.
    CLEAR : wa1_item.
    CLEAR : wa_header.
    CLEAR : l_cnt.
    CLEAR : v_lindx1.
    CLEAR:  v_pgedwn2,v_lindx.
 
 
 
    LOOP AT tmess_mtab .
      l_cnt =  l_cnt + 1.
      READ TABLE t_item INTO wa_item INDEX l_cnt .
! 
 
      CALL FUNCTION 'MASS_MESSAGE_GET' "To get the Message Text
           EXPORTING
                arbgb             = tmess_mtab-msgid
                msgnr             = tmess_mtab-msgnr
                msgv1             = tmess_mtab-msgv1
                msgv2             = tmess_mtab-msgv2
                msgv3             = tmess_mtab-msgv3
                msgv4           !   = tmess_mtab-msgv4
           IMPORTING
                msgtext           = wa_mtab-text
           EXCEPTIONS
                message_not_found = 1
                OTHERS            = 2.
      IF sy-subrc &amp;lt;&amp;gt; 0.
*        MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*        WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      wa_mtab-matnr   = wa_item-matnr.
      wa_mtab-msgtyp  = tmess_mtab-msgtyp.
      wa_mtab-msgid   = tmess_mtab-msgid.
      wa_mtab-msgn! r   = tmess_mtab-msgnr.
      APPEND wa_mtab TO t_mtab.
      CLEAR wa_mtab-text.
      CLEAR wa_item.
    ENDLOOP.
 
  ENDLOOP.
 
ENDFORM.                    " READ_DATA
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  BDC_DYNPRO
*&amp;amp;---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      --&amp;gt;P_0300   text
*      --&amp;gt;P_0301   text
! 
*----------------------------------------------------------------------*
*----------------------------------------------------------------------*
*        Start new screen                                              *
*----------------------------------------------------------------------*
FORM bdc_dynpro USING program dynpro.
 
  CLEAR bdctab.
  bdctab-program  = program.
  bdctab-dynpro   = dynpro.
  bdctab-dynbegin = 'X'.
  APPEND bdctab.
 
ENDFORM.                    " BDC_DYNPRO
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  BDC_FIELD
*&amp;amp;---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      --&amp;gt;P_0305   text
*      --&amp;gt;P_WA_HEADER_KSCHL  text
*----------------------------------------------------------------------*
*----------------------------------------------------------------------*
*        Insert field                                                  *
*----------------------------------------------------------------------*
FORM bdc_field USING fnam fval.
  CLEAR bdctab.
  bdctab-fnam = fnam.
  bdctab-fval = fval.
  APPEND bdctab.
 
ENDFORM.                    " BDC_FIELD
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  bdc_trc_ansaction
*&amp;amp;---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      --&amp;gt;P_0527   text
*----------------------------------------------------------------------
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  f_Process
*&amp;amp;---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  --&amp;gt;  p1        text
*  &amp;lt;--  p2        text
*----------------------------------------------------------------------*! 
FORM f_process.
  DATA : l_todate(12) TYPE c,
         l_frdate(12) TYPE c.
***Select for all entries of material in Header "Flat File Materials".
  IF NOT t_header[] IS INITIAL.
   SELECT matnr vkorg vtweg FROM mvke INTO TABLE t_mvke FOR ALL ENTRIES
                           IN t_header WHERE matnr = t_header-matnr AND
                                             vkorg = t_header-vkorg AND
                                                 vtweg = t_header-vtweg.
 
  ENDIF.
 
*********select Sales.org &amp;amp; Dist.channel.
 
  IF NOT t_header[] IS INITIAL.
    SELECT vkorg vtweg FROM tvkov INTO TABLE t_tvkov FOR ALL ENTRIES IN
                                t_header WHERE vkorg = t_header-vkorg
                                           AND vtweg = t_header-vtweg.
 
 
  ENDIF.
 
 
 
***Checking for material in Sales Master Table
  SORT t_mvke BY matnr vkorg vtweg.
  SORT t_tvkov BY vkorg vtweg.
  LOOP AT t_header INTO wa_header.
    READ TABLE t_mvke INTO wa_mvke WITH KEY matnr = wa_header-matnr
                                             vkorg = wa_header-vkorg
                                ! ;  vtweg = wa_header-vtweg BINARY SEARCH.
    IF sy-subrc &amp;lt;&amp;gt; 0.
      wa_error = wa_header.
    &amp;amp;nb! sp; MOVE text-011 TO  wa_error-text.
      APPEND wa_error TO t_error.
      DELETE TABLE t_header FROM wa_header.
    ELSE.
 
********Date Validations
      IF ( wa_header-datab  NE ' ! ;  '  AND  wa_header-datbi NE  '  ' ) .
 
        l_todate = wa_header-datab.
 
        l_frdate = wa_header-datbi.
 
        REPLACE '.' INTO l_toda! te WITH ''.
        REPLACE '.' INTO l_todate WITH ''.
 
        CONDENSE l_todate NO-GAPS.
 
 
        REPLACE '.' INTO l_frdate WITH ''.
        REPLACE '.' INTO l_frdate WITH ''.
 
        CONDENSE l_frdate NO-GAPS.
 
 
        IF l_frdate &amp;lt; l_todate.
          wa_error = wa_header .
          MOVE text-012 TO wa_error-text.
          APPEND wa_error TO t_error.
          DELETE TABLE t_header FROM wa_header.
        ENDIF.
      ELSE.
        wa_error = wa_header .
        MOVE text-016 TO wa_error-text.
        APPEND wa_error TO t_error.
        DELETE TABLE t_header FROM wa_header.
      ENDIF.
 
    ENDIF.
********Rate Validation.
    IF wa_header-kbetr = '   '.
      wa_error = wa_header .
      MOVE text-017 TO wa_error-text.
      APPEND wa_error TO t_error.
      DELETE TABLE t_header FROM wa_header.
 
    ENDIF.
************************************************************************
    READ TABLE t_tvkov INTO wa_tvkov WITH KEY vkorg = wa_header-vkorg
                                               BINARY SEARCH.
    IF sy-subrc  = 0.
      READ TABLE t_tvkov INTO wa_tvkov WITH KEY vtweg = wa_header-vtweg
                                                   BINARY SEARCH.
      IF sy-subrc  &amp;lt;&amp;gt; 0.
        wa_error = wa_header.
        MOVE text-015 TO  wa_error-text.
        WRITE wa_header-vtweg TO wa_error-text+13(4).
        APPEND wa_error TO t_error.
      ENDIF.
    ELSE.
      wa_error = wa_header.
      MOVE text-013 TO  wa_error-text.
      WRITE wa_header-vkorg TO wa_error-text+9(4).
      APPEND wa_error TO t_error.
    ENDIF.
    CLEAR wa_header.
  ENDLOOP.
 
 
*****Deleting Duplicate Material  Form Header "Flat File Data".
  SORT t_header BY kschl vkorg vtweg matnr.
  DELETE ADJACENT DUPLICATES FROM t_header COMPARING
        kschl! vkorg vtweg matnr .
 
*  ****Data Moving from Header to Item Level.
  t_item[] = t_header[].
 
 
*To count No.of records in Item Table.
  DESCRIBE TABLE t_item  LINES v_count.
 
  CONCATENATE text-014 ' ' v_count INTO  v_bdc.
 
****Popup to get Confirmation from user to process BDC
  CALL FUNCTION 'POPUP_TO_CONFIRM'
       EXPORTING
            titlebar       = 'Confirmation of File Data'
            text_question  = v_bdc
            text_button_1  = 'Confirm'
            text_button_2  = 'Cancel Run'
            default_button = '1'
       IMPORTING
            answer         = c_ans.
  .
  IF sy-subrc &amp;lt;&amp;gt; 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-! MSGV3 SY-MSGV4.
  ENDIF.
 
 
 
ENDFORM.                    " f_Process
*
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  f_Refresh
*&amp;amp;---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  --&amp;gt;  p1        text
*  &amp;lt;--  p2        text
*----------------------------------------------------------------------*
FORM f_refresh.
  REFRESH :  t_xls_file,
             t_header,
             t_item,
             t_mvke,
             t_tvkov,
             t_error,
             t_mtab.
 
  CLEAR :    t_xls_file,
             wa_header,
             wa_item,
             wa_mvke,
             wa_tvkov,
             wa_error,
             wa_mtab.
 
 
ENDFORM.                    " f_Refresh
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Reward all helpfull answers&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Pavan&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: &lt;/P&gt;&lt;P&gt;        Pavan praveen&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 04 Aug 2007 11:40:49 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/bdc/m-p/2610213#M598713</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-08-04T11:40:49Z</dc:date>
    </item>
    <item>
      <title>Re: BDC</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/bdc/m-p/2610214#M598714</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;     Only thing we want to use debugging and see whether the datas from the flat file has been loaded properly in to the internal table...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If u need to check any conditions means u want to use the if statments to check and as per the conditions u can insert the elements&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;REWARD IF USEFUL&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 04 Aug 2007 12:21:43 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/bdc/m-p/2610214#M598714</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-08-04T12:21:43Z</dc:date>
    </item>
  </channel>
</rss>

