‎2009 Jan 05 8:47 AM
Hi Experts,
I am reading from application server
Could you please let me know the data type to be specified for hex-tab-char
Please refer to the code below.
open dataset p_apfile for input in text mode ENCODING DEFAULT.
if sy-subrc ne 0.
message s398(00) with 'File' p_apfile
'Not found or Problem in opening file'.
stop.
else.
do.
clear v_line.
read dataset p_apfile into v_line.
if sy-subrc ne 0.
exit.
else.
split v_line at hex-tab-char into
it_upload-field1
.
.
Thanks in Advance,
Regards,
IFF
‎2009 Jan 05 8:52 AM
hi,
SEE THIS EX.
*--->Types Declaration
TYPES:BEGIN OF t_data,
line TYPE char200,
END OF t_data.
*--->Internal Table Declaration
*--->"Structure for the function module SUBST_GET_FILE_LIST
data : it_file_list TYPE TABLE OF rsfillst.
*--->work Area Declaration
data : wa_file_list LIKE LINE OF it_file_list.
*--->Variables Declaration
DATA : v_file TYPE string, "Variable For File name
v_title TYPE string. "#EC NEEDED
*---->Constants Declaration
CONSTANTS : c_star TYPE rsmrgstr-name VALUE '*'.
*--->REFERENCE DATA DECLARATIONS
DATA : dref TYPE REF TO data.
*--->FIELD-SYMBOLS DECLARATIONS
FIELD-SYMBOLS:<wa_data> TYPE ANY,
<line> TYPE ANY.
*--->Internal Table Declaration
DATA : it_kunnr TYPE TABLE OF ztbmd_cupart. "Customer Partner Details
*--->work Area Declaration
DATA : wa_kunnr LIKE LINE OF it_kunnr.
*--->Root Directory Declaration
DATA: root_dir TYPE rsmrgstr-path VALUE 'I:\usr\sap\OGD\DVEBMGS20\work\'.
&----
*--->start of selection
&----
START-OF-SELECTION.
CREATE DATA dref TYPE t_data.
*--->Get file name from directory
PERFORM get_file_name.
*--->Get Data From Application Server
PERFORM open_data_set.
&----
*--->End Of Selection
&----
END-OF-SELECTION.
*--->Insert Data Into Data Base Table
PERFORM insert_data.
&----
*& Form GET_FILE_NAME
&----
FORM get_file_name.
*--This function module will get the name of files
*--existing in a folder of the application server
CALL FUNCTION 'SUBST_GET_FILE_LIST'
EXPORTING
dirname = root_dir
filenm = c_star
TABLES
file_list = it_file_list
EXCEPTIONS
access_error = 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.
*--Get File Name
LOOP AT it_file_list INTO wa_file_list.
IF wa_file_list-name = '20081222.txt'.
CONCATENATE root_dir wa_file_list-name
INTO v_file.
ENDIF.
ENDLOOP.
ENDFORM. " GET_FILE_NAME
&----
*& Form OPEN_DATA_SET
&----
FORM open_data_set .
ASSIGN dref->* TO <wa_data>.
TRY.
OPEN DATASET v_file FOR INPUT IN TEXT MODE ENCODING DEFAULT.
ENDTRY.
IF sy-subrc = 0.
DO.
READ DATASET v_file INTO <wa_data> MAXIMUM LENGTH 200.
IF sy-subrc = 0.
ASSIGN COMPONENT 'LINE' OF STRUCTURE <wa_data> TO <line>.
IF sy-subrc = 0.
SPLIT <line> AT '|' INTO wa_kunnr-stpno "Sold To Party Number
wa_kunnr-partf "Partner Function
wa_kunnr-kunnr. "Customer Number
wa_kunnr-mandt = sy-mandt. "Client
*--->Conversion Exit To Add Leading Zeros
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = wa_kunnr-stpno
IMPORTING
output = wa_kunnr-stpno.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = wa_kunnr-kunnr
IMPORTING
output = wa_kunnr-kunnr.
*--->Append Work Area To Internal table
APPEND wa_kunnr TO it_kunnr.
CLEAR wa_kunnr.
ENDIF.
ELSE.
CLOSE DATASET v_file.
EXIT.
ENDIF.
ENDDO.
ENDIF.
ENDFORM. " OPEN_DATA_SET
‎2009 Jan 05 8:50 AM
Hi,
This is the one
c_tab TYPE c VALUE cl_abap_char_utilities=>horizontal_tab,
‎2009 Jan 05 8:50 AM
hi,
use this way
split v_line at CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB into
it_upload-field1
.
.
‎2009 Jan 05 8:52 AM
hi,
SEE THIS EX.
*--->Types Declaration
TYPES:BEGIN OF t_data,
line TYPE char200,
END OF t_data.
*--->Internal Table Declaration
*--->"Structure for the function module SUBST_GET_FILE_LIST
data : it_file_list TYPE TABLE OF rsfillst.
*--->work Area Declaration
data : wa_file_list LIKE LINE OF it_file_list.
*--->Variables Declaration
DATA : v_file TYPE string, "Variable For File name
v_title TYPE string. "#EC NEEDED
*---->Constants Declaration
CONSTANTS : c_star TYPE rsmrgstr-name VALUE '*'.
*--->REFERENCE DATA DECLARATIONS
DATA : dref TYPE REF TO data.
*--->FIELD-SYMBOLS DECLARATIONS
FIELD-SYMBOLS:<wa_data> TYPE ANY,
<line> TYPE ANY.
*--->Internal Table Declaration
DATA : it_kunnr TYPE TABLE OF ztbmd_cupart. "Customer Partner Details
*--->work Area Declaration
DATA : wa_kunnr LIKE LINE OF it_kunnr.
*--->Root Directory Declaration
DATA: root_dir TYPE rsmrgstr-path VALUE 'I:\usr\sap\OGD\DVEBMGS20\work\'.
&----
*--->start of selection
&----
START-OF-SELECTION.
CREATE DATA dref TYPE t_data.
*--->Get file name from directory
PERFORM get_file_name.
*--->Get Data From Application Server
PERFORM open_data_set.
&----
*--->End Of Selection
&----
END-OF-SELECTION.
*--->Insert Data Into Data Base Table
PERFORM insert_data.
&----
*& Form GET_FILE_NAME
&----
FORM get_file_name.
*--This function module will get the name of files
*--existing in a folder of the application server
CALL FUNCTION 'SUBST_GET_FILE_LIST'
EXPORTING
dirname = root_dir
filenm = c_star
TABLES
file_list = it_file_list
EXCEPTIONS
access_error = 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.
*--Get File Name
LOOP AT it_file_list INTO wa_file_list.
IF wa_file_list-name = '20081222.txt'.
CONCATENATE root_dir wa_file_list-name
INTO v_file.
ENDIF.
ENDLOOP.
ENDFORM. " GET_FILE_NAME
&----
*& Form OPEN_DATA_SET
&----
FORM open_data_set .
ASSIGN dref->* TO <wa_data>.
TRY.
OPEN DATASET v_file FOR INPUT IN TEXT MODE ENCODING DEFAULT.
ENDTRY.
IF sy-subrc = 0.
DO.
READ DATASET v_file INTO <wa_data> MAXIMUM LENGTH 200.
IF sy-subrc = 0.
ASSIGN COMPONENT 'LINE' OF STRUCTURE <wa_data> TO <line>.
IF sy-subrc = 0.
SPLIT <line> AT '|' INTO wa_kunnr-stpno "Sold To Party Number
wa_kunnr-partf "Partner Function
wa_kunnr-kunnr. "Customer Number
wa_kunnr-mandt = sy-mandt. "Client
*--->Conversion Exit To Add Leading Zeros
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = wa_kunnr-stpno
IMPORTING
output = wa_kunnr-stpno.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = wa_kunnr-kunnr
IMPORTING
output = wa_kunnr-kunnr.
*--->Append Work Area To Internal table
APPEND wa_kunnr TO it_kunnr.
CLEAR wa_kunnr.
ENDIF.
ELSE.
CLOSE DATASET v_file.
EXIT.
ENDIF.
ENDDO.
ENDIF.
ENDFORM. " OPEN_DATA_SET
‎2009 Jan 05 8:54 AM
Hello IFF,
From the code you have put, i understand you are splitting v_line at the tabs. You have to use CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB in place of hex-tab-char.
CONSTANTS:
C_TAB TYPE CHAR2 VALUE CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
split v_line at C_TAB into ...
Hope this helps.
BR,
Suhas
Edited by: Suhas Saha on Jan 5, 2009 9:55 AM
‎2009 Jan 05 8:57 AM
declare a varibel g_tab of type CL_ABAP_CHAR_UTILITIES => TAB.
SPlit the V_LINE at g_tab into the wa_tab.
append wa_tab to it_tab.
This is the way u need to folllow up.
Regards
John.
‎2009 Jan 06 11:47 AM