Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

BDC doubt

Former Member
0 Kudos

Hi all

I've some doubt in BDC. i have to update data from txt to sap internal table. How can i enter data in notepad. How can i separate one data from other (Tab or space). pls explain.

8 REPLIES 8

dani_mn
Active Contributor
0 Kudos

Hi,

You can separate two columns by tab. and then using the function modoule 'GUI_UPLOAD' you can upload data from txt file to internal table.

Regards,

Wasim Ahmed

Former Member
0 Kudos

1st enter all the data into excell in proper way.Save as your excel file to .txt file with Tab delimeted .... then use the GUI_UPLOAD function module to upload that file

Former Member
0 Kudos

Hello,

If you are uploading from notepad,

If you can either seperate by tabs in case of internal tables with fields.

you can also seperate by commas and split it into internal table.

Regards,

krishna

former_member181962
Active Contributor
0 Kudos

Hi Muthu,

You can define the separator as space or tab. it is your choice.

Once you upload that file into an internal table with only one field that can hold all the fields in a single line of the file, you can split that string using split command.

data: begin of itab occurs 0,

data(400),

end of itab.

call function 'GUI_UPLOAD'

TABLES

DATA_TAB = ITAB

.

.

..

V_SEPARATOR = SPACE." OR CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB

LOOP AT ITAB.

SPLIT ITAB-DATA AT V_SEPARATOR INTO ITAB_NEW-FIELD1 ITAB_NEW-FIELD2....

APPEND ITAB_NEW.

CLEAR ITAB_NEW.

ENDLOOP.

rEGARDS,

RAVI

Former Member
0 Kudos

Hi Muthu,

1) Enter the data in Excel, in the data format you need.

2) Then save the file SAVE AS --> in save as type option give Text(Tab Delimited option) and proceed. Now you have your Data file.

3)In your program. Declare an Internal Table of type your Data file format.

4)

Consider this code.


REPORT zztest_arun.


DATA : vfile TYPE string,
       it_data TYPE STANDARD TABLE OF mara. "Your Data File type

PARAMETERS : fname TYPE rlgrap-filename.

START-OF-SELECTION.

  vfile    = fname.
  CONDENSE vfile NO-GAPS.

  CALL FUNCTION 'GUI_UPLOAD'
    EXPORTING
      filename                = vfile
      filetype                = 'ASC'
 <b>     has_field_separator     = '#'</b>
    TABLES
      data_tab                = it_data
    EXCEPTIONS
      file_open_error         = 1
      file_read_error         = 2
      no_batch                = 3
      gui_refuse_filetransfer = 4
      invalid_type            = 5
      no_authority            = 6
      unknown_error           = 7
      bad_data_format         = 8
      header_not_allowed      = 9
      separator_not_allowed   = 10
      header_too_long         = 11
      unknown_dp_error        = 12
      access_denied           = 13
      dp_out_of_memory        = 14
      disk_full               = 15
      dp_timeout              = 16
      OTHERS                  = 17.
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.

Note : <b> has_field_separator = '#'</b> means the seperator in the data file in tab.

Regards,

Arun Sambagri.

naimesh_patel
Active Contributor
0 Kudos

Hello Muthu,

Create your data in the EXCEL and save it as .txt or .csv file. After use WS_upload or GUI_upload to upload that txt file.

Regards,

Naimesh

Former Member
0 Kudos

Hai Kumar

You can saparate two columns by field length

I am sending you some example Flat file

MATNR(18) MBRSH(1)MTART(4) MAKTX(40) MEINS(3)

PRANIT_011 CCOUP This is Testing material kg

check with this code

tables : mara.

data : begin of it_mara occurs 0,

matnr like mara-matnr,

mbrsh like mara-mbrsh,

mtart like mara-mtart,

maktx like makt-maktx,

meins like mara-meins,

end of it_mara.

start-of-selection.

perform upload_data.

&----


*& Form upload_data

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM upload_data .

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

FILENAME = 'c:\mat_bdc.txt'

FILETYPE = 'ASC'

TABLES

DATA_TAB = it_mara.

IF SY-SUBRC = 0.

SORT IT_MARA BY MATNR.

ENDIF.

ENDFORM. " upload_data

flat file structure is

PRANIT_011 CCOUP This is Testing material kg

PRANIT_012 CCOUP This is Testing material kg

PRANIT_013 CCOUP This is Testing material kg

PRANIT_014 CCOUP This is Testing material kg

PRANIT_015 CCOUP This is Testing material kg

Regards

Sreeni

Message was edited by: Sreenivasulu Ponnadi

0 Kudos

hi,

DO this way..

  W_WSU_FILENAME02 = 'C:tempupload.txt'.
  W_WSU_FILETYPE02 = 'DAT'.
  CALL FUNCTION 'GUI_UPLOAD'
    EXPORTING
      FILENAME                      = W_WSU_FILENAME02
      FILETYPE                      = W_WSU_FILETYPE02
<b>      HAS_FILED_SEPARATOR           = 'X'</b>
    TABLES
      DATA_TAB                      = ITAB_INFILE
    EXCEPTIONS
      FILE_OPEN_ERROR               = 1
      FILE_READ_ERROR               = 2
      NO_BATCH                      = 3
      GUI_REFUSE_FILETRANSFER       = 4
      INVALID_TYPE                  = 5
      NO_AUTHORITY                  = 6
      UNKNOWN_ERROR                 = 7
      BAD_DATA_FORMAT               = 8
      HEADER_NOT_ALLOWED            = 9
      SEPARATOR_NOT_ALLOWED         = 10
      HEADER_TOO_LONG               = 11
      UNKNOWN_DP_ERROR              = 12
      ACCESS_DENIED                 = 13
      DP_OUT_OF_MEMORY              = 14
      DISK_FULL                     = 15
      DP_TIMEOUT                    = 16
      OTHERS                        = 17
            .
  IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.

Regards,

Santosh