Quantcast
Channel: SCN : All Content - ABAP Development
Viewing all articles
Browse latest Browse all 8332

How To UPLOAD a DATA (.DAT) fiel from PC to internal table and then split it into the data different columns

$
0
0

Hi all,

I am new to ABAP Development. I need to upload a .DAT file (the file doesn#t have any proper structure-- Please find the .DAT file in the attachment). After uploading the DATA (.DAT) fiel I need to split in into different columns. Refering the attached .DAT fiel the fields in bracets like:

[Arbeitstag],  [Pecunia], [Mita], [Kunde], [Auftrag] and  [Position] are different fields that need to be arranged in columns in an internal table. this .DAT fiel which I want to upload and then SPLIT it into various fields will will treated as MASTER DATA table for further programming. The program that I had written is as below. Also please refer the attached .DAT table.

 

Please if any one could help me. i searched a lot in different forums but couldn't find me  a solution. Also note that the attached fiel is in text (.txt) format here but in real situation the same fiel is in DATA (.DAT) format.

 

*&---------------------------------------------------------------------*

*& Report  ZDEMO_ZEITERFASSUNG9

*&

*&---------------------------------------------------------------------*

*&

*&

*&---------------------------------------------------------------------*

 

 

REPORT  ZDEMO_ZEITERFASSUNG9.

 

Types: Begin of ttab,

        Rec(1000) type c,

       End of ttab.

 

DATA: itab  type table of ttab.

DATA: wa_tab type ttab.

DATA: file_str type string.

 

Parameters: p_file type localfile.


At selection-screen on value-request for p_file.

                                       CALL FUNCTION 'KD_GET_FILENAME_ON_F4'

                                        EXPORTING

*                                          PROGRAM_NAME        = SYST-REPID

*                                          DYNPRO_NUMBER       = SYST-DYNNR

*                                          FIELD_NAME          = ' '

                                           STATIC              = 'X'

*                                          MASK                = ' '

                                         CHANGING

                                           file_name           = p_file.

*                                        EXCEPTIONS

*                                          MASK_TOO_LONG       = 1

*                                          OTHERS              = 2

                                                 .

 

Start-of-Selection.

  file_str = P_file.

 

  CALL FUNCTION 'GUI_UPLOAD'

    EXPORTING

      filename                      = '\\10.10.1.92\Volume_1\_projekte\Zeiterfassung-SAP\BUP_ZEIT.DAT'   " This the file  source address

      FILETYPE                      = 'DAT'

      HAS_FIELD_SEPARATOR           = ';'

*     HEADER_LENGTH                 = 0

*     READ_BY_LINE                  = 'X'

*     DAT_MODE                      = ' '

*     CODEPAGE                      = ' '

*     IGNORE_CERR                   = ABAP_TRUE

*     REPLACEMENT                   = '#'

*     CHECK_BOM                     = ' '

*     VIRUS_SCAN_PROFILE            =

*     NO_AUTH_CHECK                 = ' '

*   IMPORTING

*     FILELENGTH                    =

*     HEADER                        =

    tables

      data_tab                      = itab

   EXCEPTIONS

     FILE_OPEN_ERROR               = 1

     FILE_READ_ERROR               = 2

     NO_BATCH                      = 3

     GUI_REFUSE_FILETRANSFER       = 4

     INVALID_TYPE                  = 5

     NO_AUTHORITY                  = 6

     UNKNOWN_ERROR                 = 7

     BAD_DATA_FORMAT               = 8

     HEADER_NOT_ALLOWED            = 9

     SEPARATOR_NOT_ALLOWED         = 10

     HEADER_TOO_LONG               = 11

     UNKNOWN_DP_ERROR              = 12

     ACCESS_DENIED                 = 13

     DP_OUT_OF_MEMORY              = 14

     DISK_FULL                     = 15

     DP_TIMEOUT                    = 16

     OTHERS                        = 17

 

            .

  IF sy-subrc <> 0.

* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

  ENDIF.

 

  LOOP at itab into wa_tab.

     

        WRITE: / wa_tab.

 

  ENDLOOP.

 

I will be grateful to all you experts for ur inputs

regards

Chandan Singh


Viewing all articles
Browse latest Browse all 8332

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>