Save flat file in bdc

in bdc we have to save the flat file in desktop or c drive?plz tell
Edited by: Alvaro Tejada Galindo on Feb 7, 2008 10:15 AM

Hi,
check the  code for better understanding.
Regards
Bala.M
REPORT  zi_flatfile_zisobj.
* Data Declaration
* Internal Tables
DATA : BEGIN OF itd_zisobj OCCURS 0 ,
zinref        LIKE  zisobj-zinref,
ziaccomtype   LIKE  zisobj-ziaccomtype,
zietgnr       LIKE  zisobj-zietgnr,
zioldnref     LIKE  zisobj-zioldnref,
zicnttyp      LIKE  zisobjcnt-zicnttyp,
END OF itd_zisobj.
DATA : file_length TYPE i.
START-OF-SELECTION.
PERFORM data_selection_join.
PERFORM gui_download_file.
END-OF-SELECTION.
*&      Form  data_selection_join
*       text
*  -->  p1        text
*  <--  p2        text
FORM data_selection_join .
* Data selection and Inner join based on Contract Type Eq 'U'.
SELECT   a~zinref
a~ziaccomtype
a~zietgnr
a~zioldnref
b~zicnttyp
INTO  CORRESPONDING FIELDS OF TABLE itd_zisobj
FROM ( zisobj AS a INNER JOIN zisobjcnt AS b ON a~zicountry  = b~zicountry
AND a~ziplace    = b~ziplace
AND a~zihouse    = b~zihouse
AND a~ziaccom    = b~ziaccom
AND b~zicnttyp   = 'U' ) .
ENDFORM.                    " data_selection_join
*&      Form  gui_download_file
*       text
*  -->  p1        text
*  <--  p2        text
FORM gui_download_file .
* FM to download to the presentation server
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
*   BIN_FILESIZE                    =
filename                        = 'H:\TEST1.TXT'
filetype                        = 'ASC'
append                          = ' '
write_field_separator           = ','
header                          = '00'
trunc_trailing_blanks           = ' '
write_lf                        = 'X'
col_select                      = ' '
col_select_mask                 = ' '
dat_mode                        = ' '
confirm_overwrite               = ' '
no_auth_check                   = ' '
codepage                        = ' '
*   IGNORE_CERR                     = ABAP_TRUE
replacement                     = '#'
write_bom                       = ' '
trunc_trailing_blanks_eol       = 'X'
wk1_n_format                    = ' '
wk1_n_size                      = ' '
wk1_t_format                    = ' '
wk1_t_size                      = ' '
*   WRITE_LF_AFTER_LAST_LINE        = ABAP_TRUE
*   SHOW_TRANSFER_STATUS            = ABAP_TRUE
IMPORTING
filelength                      =  file_length
TABLES
data_tab                       = itd_zisobj
*   FIELDNAMES                      =
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 NE 0.
MESSAGE e398(00) WITH 'Error in Downloading File' 'TEST1.TXT' 'Retry'.
ENDIF.
ENDFORM.                    " gui_download_file

Similar Messages

  • Reg : Error in flat file in BDC

    hi friends...
    let consider 10 records in my flat file...
    suppose 5th record is error means
    In BDC Session method, what happen records before and after the error record, its get update or not ? like
    In BDC Call Transaction method, what happen records before and after the error record, its get update or not ?
    please give me some detail...
    Regards
    Selva

    Hi,
    In call transaction method you will have an option of Displaying No screens, all screens and Error screens,
    If you select No screens all other records except error records will be process and messages will be collected by an internal table of type bdcmsgcoll.
    In all screens you need to process each screen manually yourself by selecting the OK code. It is kinda like debugging. So when you encounter the error screen you can change the error data and proceed.
    When you select error screens it will stop when the error occurs. So you need to correct the error and continue with the further processing.
    Regards,
    Pramod

  • Date format in flat file of bdc

    Hi Folks,
    In BDC I have a flat file which has to be uploaded from a flat file and 4 users are using each of one has their date format.
    so inorder to get their required date format what i need to do .

    Hi,
           use the below logic in your code.
    SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-031.
    PARAMETERS: date1 RADIOBUTTON GROUP rad1 DEFAULT 'X',                                     "SAP date format YYYYDDMM
                date2 RADIOBUTTON GROUP rad1,                                                 "Date format like aprial31, 2006
                date3 RADIOBUTTON GROUP rad1,                                                 "Date format like 31 apr,2006
                date4 RADIOBUTTON GROUP rad1,                                                 "Date format like DD/MM/YYYY
                date5 RADIOBUTTON GROUP rad1.                                                 "Date format like DD.MM.YYYY
    SELECTION-SCREEN END OF BLOCK b2
    FORM getmonth .
      SELECT mnr
             ktx
             ltx
       INTO TABLE T_month
       FROM t247
       WHERE spras = 'EN'.
      IF sy-subrc NE '0'.
          MESSAGE I                                                          "Message - Not able to get month values from the table T247
      ENDIF.
    ENDFORM.                                                                               
    DATA : temp_date(16)  TYPE c,
             temp1_date(60) TYPE c,
             year(4)        TYPE c,
             daymonth(11)   TYPE c,
             daymonth1(11)  TYPE c,
             month(9)       TYPE c,
             day(2)         TYPE c,
             mon            LIKE t247-ktx,
             len            TYPE i   .
      MOVE date TO temp1_date .
      CONDENSE temp1_date NO-GAPS.
      MOVE temp1_date TO temp_date .
      IF date2 EQ 'X'.                                                                     "The date format is like Aprial 31, 2007
        CONDENSE temp_date NO-GAPS.
        SPLIT date AT ',' INTO daymonth year.
        IF STRLEN( year ) NE '4'.
          error = 'X'.
          WRITE :  'Invalid date format.'.
        ELSE.
          daymonth1 = daymonth.
          CONDENSE daymonth1 NO-GAPS.
          _len      = STRLEN( _daymonth1 ).
          l_len      = 13 - len.
          SHIFT daymonth1 RIGHT BY len PLACES.
          CONDENSE daymonth1 NO-GAPS.
          month    = daymonth1.
          CONDENSE month NO-GAPS.
          SORT t_month BY monthltx.
          READ TABLE t_month WITH KEY monthltx =  month.
          IF sy-subrc <> 0.
            error = 'X'.
            WRITE : 'Invalid date format.' .
          ELSE.
            len = STRLEN( month ).
            CONDENSE daymonth NO-GAPS.
            SHIFT daymonth LEFT BY len PLACES.
            day =  daymonth.
            CONDENSE day NO-GAPS.
            CONCATENATE year t_month-monthnumber day INTO o_date.
          ENDIF.
        ENDIF.
      ELSEIF p_date3 EQ 'X'.                                                                "The date format is like 31 apr, 2007
        CONDENSE temp_date NO-GAPS.
        SPLIT i_date AT ',' INTO daymonth year.
        IF STRLEN( year ) NE '4'.
          error = 'X'.
          WRITE :  'Invalid date format.'.
        ELSE.
          daymonth1 = daymonth.
          CONDENSE daymonth1 NO-GAPS.
          SHIFT daymonth1 LEFT BY 2 PLACES.
          CONDENSE daymonth1 NO-GAPS.
          month  = daymonth1.
          CONDENSE month NO-GAPS.
          TRANSLATE month TO UPPER CASE.
          SORT t_month BY monthstx.
          MOVE month to mon.
          READ TABLE t_month WITH KEY monthstx = mon.                                 
          IF sy-subrc <> 0.
            error = 'X'.
            WRITE : 'Invalid date format.' .
          ELSE.
            CONDENSE daymonth NO-GAPS.
            day =  daymonth+0(2).
            CONDENSE day NO-GAPS.
            CONCATENATE year t_month-monthnumber day INTO o_date.
         ENDIF.
       ENDIF.
      ELSEIF p_date4 EQ 'X' OR p_date5 EQ 'X'.                                             "Date format is like DD.MM.YYYY or DD/MM/YYYY
        CONDENSE temp_date NO-GAPS.
        IF STRLEN( temp_date ) EQ 10.
          o_date0(4) = temp_date6(4).
          o_date4(2) = temp_date3(2).
          o_date6(2) = temp_date0(2).
        ELSE.
          error = 'X'.
          WRITE : 'Invalid date format.' .
        ENDIF.
    ENDIF.
    IF STRLEN( o_date ) NE '8'.
         error = 'X'.
         WRITE : 'Invalid date format.'.
    ENDIf.
    ENDFORM.                                                                               
    regards

  • How To handle complex Flat File in BDC( V.V. Urgent)

    Hi All,
    Anybody help in these case.
    I have to write the BDC for a complex File.
    Here is the Scenario
    I An recording for Tcode CN21.
    1network -> many activities
    1 Activity ->many components
    Any body Help ifor this case,
    Points will be awarded.
    Regards,
    Jayasimha

    Hi Jayasimha
    Can u explain what is the problem that u are facing? we will be able to help u if u let u know what is the problem.
    as far as what u have mentioned, first do a recording in SHDB for the transaction CN21 and then in the program get all the data from the flat file into an internal table. then build a BDC.
    Cheers

  • Flat file in bdc

    hi experts ?
    who will create the flat file in real time ?
    who ll run that bdc program in real time ?
    what is abaper role exactly involved in bdc ? only coding or some thing else ? or we have to run that program ?

    Satish,
    Based on the structure given to you initially you have to build the bdc program. In the same way process team or functional folks will provide the file to you. Before you upload the data with the original file u have to test your program for all the test conditions to make sure  your program is working well.
    When comes to the point of running the BDC program it depends upon the requirement.
    If the requirement is to run the bdc program only once or twice then u have to run the program. If it is continous daily batch job then u need to schedule a background job or some other concerned persons will take care of that if you give your program name, variant and proper timings when this needs to be run.
    Role of the abaper would be.........
    Verifying the structure of the flat file along with all the fields, field lenghts and types then building the proper program, testing the program to make sure it will run with out any major problems and once u get the file make sure that file is in the correct format which is mentioned earlier.

  • How to capture errors records in flat file in BDC

    hi ,
        i would like to know how to capture error records while  uploading a flat file to screen through BDC .
    appreciatable solutions are rewarded.
    thanks,
    shan

    Hi shan,
    write this code, it will solve your problem.
    DATA : BDCTAB LIKE BDCDATA OCCURS 0 WITH HEADER LINE.
    DATA : I_MSG LIKE BDCMSGCOLL OCCURS 0 WITH HEADER LINE.
    DATA : BEGIN OF I_ERR OCCURS 0,
              MATNR(18),
              FLAG(1),
              MSG(100),
           END OF I_ERR.
    DATA :V_LINES TYPE I.
    LOOP AT ITAB.
    REFRESH BDCTAB.
    PERFORM SCREEN USING: 'SAPLMGMM' '0060'.
    PERFORM FIELD USING: 'RMMG1-MATNR'  ITAB-MATNR,
                          'RMMG1-MBRSH' ITAB-MBRSH ,
                          'RMMG1-MTART' ITAB-MTART,
                          'BDC_OKCODE' '/00'.
    PERFORM SCREEN USING: 'SAPLMGMM' '0070'.
    PERFORM FIELD USING: 'MSICHTAUSW-KZSEL(01)' 'X' ,
                         'MSICHTAUSW-KZSEL(02)' 'X' ,
                         'MSICHTAUSW-KZSEL(09)' 'X' ,
                         'BDC_OKCODE' '=ENTR'.
    PERFORM SCREEN USING: 'SAPLMGMM' '0080'.
    PERFORM FIELD USING: 'RMMG1-WERKS' ITAB-WERKS,
                         'BDC_OKCODE' '=ENTR'.
    PERFORM SCREEN USING: 'SAPLMGMM' '4004'.
    PERFORM FIELD USING:  'MAKT-MAKTX' ITAB-MAKTX,
                          'MARA-MEINS' 'EA' ,
                          'MARA-MATKL' '001',
                          'BDC_OKCODE' '/00'.
    PERFORM SCREEN USING: 'SAPLMGMM' '4004'.
    PERFORM FIELD USING:  'BDC_OKCODE' '/00'.
    PERFORM SCREEN USING: 'SAPLMGMM' '4000'.
    PERFORM FIELD USING:  'MAKT-MAKTX' ITAB-MAKTX,
                          'MARA-MEINS' 'EA',
                          'MARC-EKGRP' '001',
                          'MARA-MATKL' '001',
                          'BDC_OKCODE' '=BU'.
    CALL TRANSACTION 'MM01' USING BDCTAB
                            MODE 'A'
                            MESSAGES INTO I_MSG.
    FINDING LAST MESSAGE IN THE I_MSG TABLE*****
    DESCRIBE TABLE I_MSG LINES V_LINES.
    ACCORDING TO THE V_LINES NUMBER TABLE WILL BE READ****
    READ TABLE I_MSG INDEX V_LINES.
    CALL FUNCTION 'FORMAT_MESSAGE'
    EXPORTING
       ID              = I_MSG-MSGID
       LANG            = '-D'
       NO              = I_MSG-MSGNR
       V1              = I_MSG-MSGV1
       V2              = I_MSG-MSGV2
       V3              = I_MSG-MSGV3
       V4              = I_MSG-MSGV4
    IMPORTING
       MSG             = I_ERR-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.
    ENDIF.
    IF I_MSG-MSGID EQ 'M3' AND I_MSG-MSGNR EQ '800'.
    I_ERR-FLAG = 'S'.
    ELSE.
    I_ERR-FLAG = 'E'.
    ENDIF.
    I_ERR-MATNR = ITAB-MATNR.
    APPEND I_ERR.
    CLEAR I_ERR.
    ENDLOOP.
    WRITE:/ 'SUCCESS RECORDS' COLOR COL_POSITIVE.
    SKIP.
    WRITE:/ 'MATERIAL' COLOR COL_HEADING, 20 'MESSAGE' COLOR COL_HEADING.
    LOOP AT I_ERR WHERE FLAG EQ 'S'.
    WRITE:/ I_ERR-MATNR, 20 I_ERR-MSG.
    ENDLOOP.
    SKIP 2.
    WRITE:/ 'ERROR RECORDS' COLOR COL_NEGATIVE.
    SKIP.
    WRITE:/ 'MATERIAL' COLOR COL_HEADING, 20 'MESSAGE' COLOR COL_HEADING.
    LOOP AT I_ERR WHERE FLAG EQ 'E'.
    WRITE:/ I_ERR-MATNR, 20 I_ERR-MSG.
    ENDLOOP.
    *&      Form  SCREEN
         SCREEN
    form SCREEN  using P_PROG P_SCREEN.
    BDCTAB-PROGRAM = P_PROG.
    BDCTAB-DYNPRO = P_SCREEN.
    BDCTAB-DYNBEGIN = 'X'.
    APPEND BDCTAB.
    CLEAR  BDCTAB.
    endform.                    " SCREEN
    *&      Form  FIELD
       FIELD
    form FIELD  using  FNAME FVAL .
    BDCTAB-FNAM = FNAME.
    BDCTAB-FVAL = FVAL.
    APPEND BDCTAB.
    CLEAR BDCTAB.
    endform.                    " FIELD
    Thanks,
    Murali

  • Flat files in BDC

    hi......to everybody.....
    i am working on session method with two application(transaction)s.
    i have the data in two flat files separate related to those applications in presentation server.
    how to update the data into the data base?
    Message was edited by:
            Alvaro Tejada Galindo

    HI,
    there is no difference as far as the code is concerned for the BDC.. only change is u use bdc_open_group,bdc_insert and bdc_close_group function modules instead of call transaction..
    See the example
    REPORT Z_PCA_PL
                         MESSAGE-ID ZYFI
                         NO STANDARD PAGE HEADING
                         LINE-SIZE  100.
    Progname    : ZF_BDCP_PCPLANE_01                                     *
    Request no  : RTDK905785
    Description : Profit center plan data upload for KIMO dates
    LOGICAL DB  :            VERSION OF :                                *
    AUTHOR      : Krishna M
    DATE        : 28/04/2004
    MODIFICATION LOG (latest change first):                              *
      TABLES
    *-- Imternal table declaration.
    DATA : BEGIN OF IT_UPLOAD OCCURS 0,
           YEAR(4),                        " Year Variable
           PROFIT(10),                     " Profit Center Variable
           GLACCOUNT(13),                  " GL account Variable
           AMOUNT(10),                     " Amount Variable
           END OF IT_UPLOAD.
    *-- Declaration of bdc data.
    DATA: IT_BDCDATA LIKE BDCDATA OCCURS 0 WITH HEADER LINE.
    *-Internal table for message control
    *data : msgtab like bdcmsgcoll occurs 0 with header line.
    *--Selection screen declaration
    SELECTION-SCREEN  BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
              PARAMETERS:  P_FILE LIKE RLGRAP-FILENAME OBLIGATORY.
    SELECTION-SCREEN END OF BLOCK B1.
             A T  S E L E C T I O N - S C R E E N .
    *--Value request for the file.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
      PERFORM VALUE_REQUEST.
                   S T A R T - O F - S E L E C T I O N
    START-OF-SELECTION.
    *-- Upload data into internal table it_upload.
      PERFORM UPLOAD.
      PERFORM PROFIT_CENTER.
      PERFORM BDC_OPEN_GROUP.
      PERFORM CALL_TRANSACTION.
    *-- Close the bdc group
        PERFORM BDC_CLOSE_GROUP.
    *&      Form  upload
    Uploading of the flat file into the internal table
    FORM UPLOAD.
      CALL FUNCTION 'WS_UPLOAD'
           EXPORTING
                FILENAME            = P_FILE
                FILETYPE            = 'DAT'
           TABLES
                DATA_TAB            = IT_UPLOAD
           EXCEPTIONS
                CONVERSION_ERROR    = 1
                FILE_OPEN_ERROR     = 2
                FILE_READ_ERROR     = 3
                INVALID_TABLE_WIDTH = 4
                INVALID_TYPE        = 5
                NO_BATCH            = 6
                UNKNOWN_ERROR       = 7
                OTHERS              = 8.
      IF SY-SUBRC <> 0 .
        MESSAGE E999 WITH TEXT-002.      "File cannot be Uploaded
      ENDIF.
    ENDFORM.                    " upload
    *&      Form  value_request
          IN PUT HEPL REQUEST
    FORM VALUE_REQUEST.
      CALL FUNCTION 'WS_FILENAME_GET'
           EXPORTING
                DEF_FILENAME     = ' '
                DEF_PATH         = 'C:\'
                MASK             = ',.txt,.*.'
                MODE             = 'S'
                TITLE            = TEXT-003  "'Upload'
           IMPORTING
                FILENAME         = P_FILE
           EXCEPTIONS
                INV_WINSYS       = 1
                NO_BATCH         = 2
                SELECTION_CANCEL = 3
                SELECTION_ERROR  = 4
                OTHERS           = 5.
      CASE SY-SUBRC.
        WHEN 3.
          MESSAGE I999 WITH TEXT-004.        "Selection Cancel
        WHEN 4.
          MESSAGE I999 WITH TEXT-005.        "Selection Error'.
      ENDCASE.
    ENDFORM.                    " value_request
            form call_transaction.
    FORM CALL_TRANSACTION.
      IF NOT IT_UPLOAD[] IS INITIAL.
        LOOP AT IT_UPLOAD.   " loop at it_upload
          PERFORM FILL_BDC.
        ENDLOOP.
      ELSE.
        MESSAGE E999 WITH TEXT-010. " 'No records found'.
      ENDIF.
    ENDFORM.
    *&      Form  fill_bdc
         This form is used to fill the bdcdata & call the transaction    *
    FORM FILL_BDC.
          PERFORM PROFIT_CENTER_UPLOAD.
    ENDFORM.
    *&      Form  Profit_Center_Upload.
    FORM PROFIT_CENTER_UPLOAD.
       PERFORM FILL_BDCDATA USING:
        'SAPLKPP0'               '1000'                           'X',
        'bdc_cursor'             'kpp0b-value(03)'                ' ',
        'kpp0b-value(03)'        IT_UPLOAD-YEAR                   ' ',
        'bdc_cursor'             'kpp0b-value(06)'                ' ',
        'kpp0b-value(06)'        IT_UPLOAD-PROFIT                 ' ',
        'bdc_cursor'             'kpp0b-value(09)'                ' ',
        'kpp0b-value(09)'        IT_UPLOAD-GLACCOUNT              ' ',
        'bdc_okcode'              '/00'                           ' ',
        'BDC_OKCODE'              '=CSUB'                         ' ',
        'SAPLKPP2'               '0103'                           'X',
        'bdc_cursor'             'BDC03(01)'                      ' ',
        'BDC03(01)'              IT_UPLOAD-AMOUNT                 ' ',
        'BDC_OKCODE'              '/00'                           ' ',
        'BDC_OKCODE'              '=CBUC'                         ' '.
    PERFORM BDC_INSERT.
    ENDFORM.
    *&      Form  fill_bdcdata
    This form is used to fill the IT_BDCDATA table                      *
    FORM FILL_BDCDATA USING PROGRAM  TYPE C
                              DYNPRO   TYPE ANY
                              DYNBEGIN TYPE C.
      IF DYNBEGIN = 'X'.
        IT_BDCDATA-PROGRAM  = PROGRAM.
        IT_BDCDATA-DYNPRO   = DYNPRO.
        IT_BDCDATA-DYNBEGIN = DYNBEGIN.
      ELSE.
        IT_BDCDATA-FNAM     = PROGRAM.
        IT_BDCDATA-FVAL     = DYNPRO.
      ENDIF.
      APPEND IT_BDCDATA.
      CLEAR  IT_BDCDATA.
    ENDFORM.                  " fill_bdcdata
    form profit_center
    FORM PROFIT_CENTER.
      PERFORM FILL_BDCDATA USING:
        'SAPLSPO4'               '0300'                           'X',
        'SVALD-VALUE(01)'        '0100'                           ' ',
        'BDC_OKCODE'             '=FURT'                          ' ',
        'SAPLKPP6'               '1007'                           'X',
        'RKPP6-PLPROF'           'RTA-PC-K'                       ' ',
        'BDC_OKCODE'             '=CWEI'                          ' '.
    ENDFORM.
          form bdc_open_group.
    FORM BDC_OPEN_GROUP.
      CALL FUNCTION 'BDC_OPEN_GROUP'
           EXPORTING
                CLIENT = SY-MANDT
                GROUP  = '7KE1'
                KEEP   = 'X'
                USER   = SY-UNAME.
      IF SY-SUBRC NE 0.                    "Error in Opening error session
        MESSAGE E999 WITH TEXT-007.        "'Unable to open BDC Group'.
      ELSE.
        MESSAGE S999 WITH TEXT-008.       "Session created successfully"
      ENDIF.
    ENDFORM.
           form bdc_insert
    FORM BDC_INSERT.
    CALL FUNCTION 'BDC_INSERT'
        EXPORTING
             TCODE            = '7KE1'
         TABLES
              DYNPROTAB        = IT_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 E999 WITH TEXT-006.
        'Unable to Insert using Transaction 7KE1'.
      ENDIF.
      REFRESH IT_BDCDATA.
      CLEAR   IT_BDCDATA.
    ENDFORM.
    *&      Form  BDC_CLOSE_GROUP
       This form is used to close the group that is opend.
    FORM BDC_CLOSE_GROUP.
      CALL FUNCTION 'BDC_CLOSE_GROUP'
           EXCEPTIONS
                NOT_OPEN    = 1
                QUEUE_ERROR = 2
                OTHERS      = 3.
    ENDFORM.                    " BDC_CLOSE_GROUP
    Thanks
    Mahesh

  • Line item -  flat file - BDC

    hi gurus.......
    could some one get me a real time flat file for BDC line items.
    maximum points will be rewarded.

    hi Rohit
    what I mean is , for T codes like XK01 we have a multiple line items for a single vendor.
    I need to practice BDC for T codes which has line items (ex  ME21) .
    It would be more helpfull for me if u provide me with flat file which u have use in real time for BDC , which has multiple line items for a single header.
    am I clear?

  • Procedure to save the output of a query into excel file or flat file

    Procedure to save the output of a query into excel file or flat file
    I want to store the output of my query into a file and then export it from sql server management studio to a desired location using stored procedure.
    I have run the query --
    DECLARE @cmd VARCHAR(255)
    SET @cmd = 'bcp "select * from dbo.test1" queryout "D:\testing2.xlsx;" -U "user-PC\user" -P "" -c '
    Exec xp_cmdshell @cmd
    error message--
    SQLState = 28000, NativeError = 18456
    Error = [Microsoft][SQL Server Native Client 10.0][SQL Server]Login failed for user 'user-PC\user'.
    NULL
    Goel.Aman

    Hello,
    -T:
    Specifies that the bcp utility connects to SQL Server with a trusted connection using integrated security. The security credentials of the network user,
    login_id, and password are not required. If
    –T is not specified, you need to specify
    –U and –P to successfully log in.
    -U:
    Specifies the login ID used to connect to SQL Server.
    Note: When the bcp utility is connecting to SQL Server with a trusted connection using integrated security, use the
    -T option (trusted connection) instead of the
    user name and password combination
    I would suggest you take a look at the following article:
    bcp Utility: http://technet.microsoft.com/en-us/library/ms162802.aspx
    A similar thread regarding this issue:
    http://social.msdn.microsoft.com/Forums/sqlserver/en-US/b450937f-0ef5-427a-ae3b-115335c0d83c/bcp-connection-error-sqlstate-28000-nativeerror-18456?forum=sqldataaccess
    Regards,
    Elvis Long
    TechNet Community Support

  • Problem in the BDC program to upload the data from a flat file.

    Hi,
    I am required to write a BDC program to upload the data from a flat file. The conditions are as mentioned below:-
    1) Selection Screen will be prompted to user and user needs to provide:- File Path on presentation server (with F4 help for this obligatory parameter) and File Separator e.g. @,#,$,%,... etc(fields in the file will be separated by using this special character) or fields may be separated by tab(tab delimited).
    2) Finally after the data is uploaded, following messages need to be displayed:-
    a) Total Number of records successfully uploaded.
    b) Session Name
    c) Number of Sessions created.
    Problem is when each record is fetched from flat file, the record needs to be split into individual fields separated by delimiter or in case tab separated, then proceeding in usual manner.
    It would be great if you provide me either the logic, pseudocode, or sample code for this BDC program.
    Thanks,

    Here is an example program,  if you require the delimitor to be a TAB, then enter TAB on the selection screen, if you require the delimitor to be a comma, slash, pipe, whatever, then simply enter that value.  This example is simply the uploading of the file, not the BDC, I assume that you know what to do once you have the data into the internal table.
    REPORT zrich_0001.
    TYPES: BEGIN OF ttab,
            rec TYPE string,
           END OF ttab.
    TYPES: BEGIN OF tdat,
           fld1(10) TYPE c,
           fld2(10) TYPE c,
           fld3(10) TYPE c,
           fld4(10) TYPE c,
           END OF tdat.
    DATA: itab TYPE TABLE OF ttab.
    data: xtab like line of itab.
    DATA: idat TYPE TABLE OF tdat.
    data: xdat like line of idat.
    DATA: file_str TYPE string.
    DATA: delimitor TYPE string.
    PARAMETERS: p_file TYPE localfile.
    PARAMETERS: p_del(5) TYPE c.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
      DATA: ifiletab TYPE filetable.
      DATA: xfiletab LIKE LINE OF ifiletab.
      DATA: rc TYPE i.
      CALL METHOD cl_gui_frontend_services=>file_open_dialog
        CHANGING
          file_table = ifiletab
          rc         = rc.
      READ TABLE ifiletab INTO xfiletab INDEX 1.
      IF sy-subrc = 0.
        p_file = xfiletab-filename.
      ENDIF.
    START-OF-SELECTION.
      TRANSLATE p_del TO UPPER CASE.
      CASE p_del.
        WHEN 'TAB'.
          delimitor = cl_abap_char_utilities=>horizontal_tab.
        WHEN others.
          delimitor = p_del.
      ENDCASE.
      file_str = p_file.
      CALL METHOD cl_gui_frontend_services=>gui_upload
        EXPORTING
          filename = file_str
        CHANGING
          data_tab = itab.
      LOOP AT itab into xtab.
        CLEAR xdat.
        SPLIT xtab-rec AT delimitor INTO xdat-fld1
                                         xdat-fld2
                                         xdat-fld3
                                         xdat-fld4.
        APPEND xdat to idat.
      ENDLOOP.
      LOOP AT idat into xdat.
        WRITE:/ xdat-fld1, xdat-fld2, xdat-fld3, xdat-fld4.
      ENDLOOP.
    Regards,
    Rich Heilman

  • BDC ---Data maintainance at flat file

    Hi All,
    Iam a BI resource learning ABAP.
    I have started learning abap in that currently working with BDC.
    Here iam trying to extract data from flat file(note pad) for practice purpose and extraxting data by session method fore ground process.
    Here in flat file i want to maintain two table of data and want to insert this data in related tables.
    i have created note pad file
    for vendor data and customer data have maintained data horizontally like
    lifnr    name1     land1     kunnr    name1   land1
    1      xx               US      2        yyyy            UK
    Finally the data is geting inserted in the lfa1 and kna1 table are like
    lifnr 1 record s at vendor table and kunnr2 record is at customer table.
    but now i want to maintain data at note pad as in vertical like
    lifnr    name1     land1 (not maintaining these fileds in note pad only values giving in note pad)
    1      xx               US
    kunnr    name1   land1
    2        yyyy            UK
    So is there any way to maintain my data in note pad like this.
    please advice.
    regards
    Saha

    hie
    I hope i understood you well, you want to maintain many records in your flat file you are still able to pick them all.  Please elaborate what you mean by maintaining your records in vertical format???
    Vendor file
    1,200,ABC,02
    2,200,DEF,02
    Customer file
    1,200,QWE,02
    2,200,SDW,02
    The two sets of data seem to be different ie Customer and Vendor thus i think you should maintain the two as separate files and pick both at the same time.
    regards
    Isaac Prince

  • HOW TO SAVE THE FLAT FILE.

    Hi Exports,
         Flat file comes to our Internal table.then i build our logic.After that i wann to save this flat file is some location(may be in presentation/ application server).that to file name along with date,time and location.agin i run the pgm and save same location and file name is also same.
    here iam giving file format.
    emp no               file name        location.
    1                          XXX               h:\kkk.txt
    2
    3
    4
    5
    again i am running same pgm
    emp no               file name        location.
    6                           XXX               h:\kkk.txt
    7
    8
    9
    10
    file name and location same but diff emp no.
    Regards,
    Krishna.

    Hi Krishna Kumar,
    if u wnat to download in to presentation server..
    then use GUI_DOWNLOAD.
    if u want to save in application server (in AL11) then u need to use
    open data set...
      DATA : dl_string(250).           " String
    *--Open data set
        OPEN DATASET dg_filename FOR INPUT IN TEXT MODE ENCODING DEFAULT.
        IF sy-subrc <> 0.
          dg_subrc = sy-subrc.
        ELSE.
    *--Transfer data
          DO.
            READ DATASET dg_filename INTO dl_string.
            IF sy-subrc = 0.
              APPEND dl_string TO dt_data.
              CLEAR  dl_string.
            ELSE.
              EXIT.
            ENDIF.
          ENDDO.
    *--Close data set
          CLOSE DATASET dg_filename.
        ENDIF.

  • Flat file (BDC)

    Hi friends........ now i want to upload the data from flat file  through recording method  to  "MMO1" tranction now how can i anlyze the data from flate file this data is related for particular field

    Hi chakri,
    If your flat file is of EXCEL file then in the first row write all your field name save Material No, Industry Sector, Material Group....and start uploading the data in the excel starting from 2nd row.
    By which you can start uploading your material master from 2nd row and you can have heading for your field to know which value is of which field.
    Cheers!!
    VEnk@

  • Flat  file to upload data using BDC for transaction MM01

    Hi
    I am trying to update data using bdc code has been attached below using a txt file.
    It is updating the first set of data into the table mara ,but  for the rest it is not
    All the data from txt file has being loaded to internal table , but the problem is it does not gets updated from internal table to the database .
    Only the first set of data has been loaded ,<u><b> rest of the data is not loaded</b></u>
    <u><b>content of txt file</b></u>
    zsc     zsc     kg     
    zsv     zsv     kg     
    zsb     zsb     kg
    <u><b>Actual code</b></u>
    report ZMAT_UPLOAD
           no standard page heading line-size 255.
    types declaration..........................................................................
    types : begin of t_mat,
       matnr(20),
       desc(50),
       uom(5),
    end of t_mat.
    internal table and workarea declaration.......................................
    data : i_mat type table of t_mat.
    data : wa_mat type t_mat.
    include bdcrecx1.
    start-of-selection.
    moving the flat file content to internal table................................
    CALL FUNCTION 'UPLOAD'
         EXPORTING
             FILETYPE   = 'DAT'
         TABLES
             data_tab   = i_mat.
    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 open_group.
    loop at i_mat into wa_mat.
    perform bdc_dynpro      using 'SAPLMGMM' '0060'.
    perform bdc_field       using 'BDC_CURSOR'
                                       'RMMG1-MATNR'.
    perform bdc_field       using 'BDC_OKCODE'
                                        '=AUSW'.
    perform bdc_field       using 'RMMG1-MATNR'
                                        wa_mat-matnr.
    perform bdc_field       using 'RMMG1-MBRSH'
                                        'P'.
    perform bdc_field       using 'RMMG1-MTART'
                                        'ZOH'.
    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)'
                                        'X'.
    perform bdc_dynpro   using 'SAPLMGMM' '4004'.
    perform bdc_field       using 'BDC_OKCODE'
                                        '=BU'.
    perform bdc_field       using 'MAKT-MAKTX'
                                        wa_mat-desc.
    perform bdc_field       using 'BDC_CURSOR'
                                        'MARA-MEINS'.
    perform bdc_field       using 'MARA-MEINS'
                                        wa_mat-uom.
    perform bdc_field       using 'MARA-MTPOS_MARA'
                                        'NORM'.
    perform bdc_transaction using 'MM01'.
    endloop.
    Perform close_group.

    Hi Sumant,
    just concentrate on bold one
    report ZMAT_UPLOAD
    no standard page heading line-size 255.
    types declaration..........................................................................
    <b>
    data : begin of t_mat occurs 0,
    matnr(20),
    desc(50),
    uom(5),
    end of t_mat.</b>
    internal table and workarea declaration.......................................
    <b>*data : i_mat type table of t_mat.
    *data : wa_mat type t_mat.</b>
    include bdcrecx1.
    start-of-selection.
    moving the flat file content to internal table................................
    CALL FUNCTION 'UPLOAD'
    EXPORTING
    FILETYPE = 'DAT'
    TABLES
    <b>data_tab = i_mat.---> t_mat.</b>
    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 open_group.
    <b>loop at i_mat into wa_mat.------>loop at t_mat.</b>
    perform bdc_dynpro using 'SAPLMGMM' '0060'.
    perform bdc_field using 'BDC_CURSOR'
    'RMMG1-MATNR'.
    perform bdc_field using 'BDC_OKCODE'
    '=AUSW'.
    perform bdc_field using 'RMMG1-MATNR'
    <b>wa_mat-matnr.---->t_mat-matnr(change in this for ur wa to t_mat.</b>
    perform bdc_field using 'RMMG1-MBRSH'
    'P'.
    perform bdc_field using 'RMMG1-MTART'
    'ZOH'.
    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)'
    'X'.
    perform bdc_dynpro using 'SAPLMGMM' '4004'.
    perform bdc_field using 'BDC_OKCODE'
    '=BU'.
    perform bdc_field using 'MAKT-MAKTX'
    wa_mat-desc.
    perform bdc_field using 'BDC_CURSOR'
    'MARA-MEINS'.
    perform bdc_field using 'MARA-MEINS'
    wa_mat-uom.
    perform bdc_field using 'MARA-MTPOS_MARA'
    'NORM'.
    perform bdc_transaction using 'MM01'.
    endloop.
    Perform close_group.
    Reward points for helpful answers.
    Thanks
    Naveen khan
    Message was edited by:
            Pattan Naveen
    Message was edited by:
            Pattan Naveen

  • 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,

Maybe you are looking for