Monday, December 20, 2010
This program illustrates you on how to create dynamic internal table, how to use TEXT_CONVERT_TEX_TO_SAP function module.

REPORT znpmmm0201.
TYPES:BEGIN OF ty_file,
      data(4096) TYPE c,
    END OF ty_file.
TYPE-POOLS:truxs.
DATA: wa_file      TYPE ty_file.
DATA: it_file      TYPE STANDARD TABLE OF ty_file,
    it_data      TYPE truxs_t_text_data.
DATA: gv_dref      TYPE REF TO data,
    file_name    TYPE string.
FIELD-SYMBOLS: <gf_itab> TYPE STANDARD TABLE,
             <wa>      TYPE ANY.
PARAMETERS:p_table TYPE rsrd1-tbma_val,
         p_file  TYPE string.
*&---------------------------------------------------------------------*
*& START-OF-SELECTION
*&---------------------------------------------------------------------*
START-OF-SELECTION.
  "Create Dynamic internal table
  CREATE DATA gv_dref TYPE TABLE OF (p_table).
  ASSIGN gv_dref->* TO <gf_itab>.
  "Upload file
  p_file = 'C:\temp\upload_data.txt'.
  CALL FUNCTION 'GUI_UPLOAD'
    EXPORTING
      filename = p_file
      filetype = 'ASC'
    TABLES
      data_tab = it_file.
  "Convert to SAP Standards
  APPEND LINES OF it_file TO it_data.
  CLASS cl_abap_char_utilities DEFINITION LOAD.
  DATA: l_field_seperator.
  l_field_seperator = cl_abap_char_utilities=>horizontal_tab.
  REPLACE ALL OCCURRENCES OF '|' IN TABLE it_data WITH l_field_seperator.

  CALL FUNCTION 'TEXT_CONVERT_TEX_TO_SAP'
    EXPORTING
      i_field_seperator    = l_field_seperator
      i_tab_raw_data       = it_data
    TABLES
      i_tab_converted_data = <gf_itab>.
  "Update database table given on S-Screen
  MODIFY (p_table) FROM TABLE <gf_itab>.

0 comments:

Post a Comment

Your useful comments, suggestions are appreciated.Your comments are moderated.

Followers

Contact Form

Name

Email *

Message *

Web Dynpro ABAP Book

An SAP Consultant

Follow US


Want to Contribute ?

If you are interested in writing about the new stuff you learn everyday while working, please write to the.sap.consultants@gmail.com.

Click on Contribution for more details.