‎2008 Jan 22 10:23 AM
Hi,
In the application server this file('C:\usr\sap\QAS\DVEBMGS00\work\test1.txt')
contains the data...
asd#c#fert#desc1#kg#00101
as#c#fert#desc1#kg#00101
and the code i have written for this is...
DATA:
P_FILE LIKE RLGRAP-FILENAME VALUE
'C:\usr\sap\QAS\DVEBMGS00\work\test1.txt'.
DATA: V_RECORD(200).
DATA:BEGIN OF ITAB OCCURS 0,
MATNR LIKE MARA-MATNR,
MBRSH LIKE MARA-MBRSH,
MTART LIKE MARA-MTART,
MAKTX LIKE MAKT-MAKTX,
MEINS LIKE MARA-MEINS,
MATKL LIKE MARA-MATKL,
END OF ITAB.
DATA:BEGIN OF WA,
MATNR LIKE MARA-MATNR,
MBRSH LIKE MARA-MBRSH,
MTART LIKE MARA-MTART,
MAKTX LIKE MAKT-MAKTX,
MEINS LIKE MARA-MEINS,
MATKL LIKE MARA-MATKL,
END OF WA.
START-OF-SELECTION.
OPEN DATASET P_FILE FOR INPUT IN TEXT MODE ENCODING DEFAULT.
DO.
READ DATASET P_FILE INTO V_RECORD.
IF SY-SUBRC NE 0.
EXIT.
ENDIF.
SPLIT V_RECORD AT '#'
INTO
WA-MATNR WA-MBRSH WA-MTART WA-MAKTX WA- MEINS WA-MATKL. APPEND WA TO ITAB.
ENDDO.
LOOP AT ITAB INTO WA.
WRITE:/ WA-MATNR.
ENDLOOP.
and the output is coming like this..
asd#c#fert#desc1#k
as#c#fert#desc1#kg
but my output should come like this...
asd
as
‎2008 Jan 22 11:06 AM
HI ....
Try this.. it will work.
Define a variable which refers to horizontal tab and then use it.
constatns c_tab type ref to CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
SPLIT V_RECORD AT c_tab
INTO
WA-MATNR WA-MBRSH WA-MTART WA-MAKTX WA- MEINS WA-MATKL. APPEND WA TO ITAB.
Regards,
Sai Ramesh
‎2008 Jan 22 10:27 AM
Hi,
Do as below :
loop at v_record.
SPLIT V_RECORD AT '#'
INTO
WA-MATNR WA-MBRSH WA-MTART WA-MAKTX WA- MEINS WA-MATKL.
APPEND WA TO ITAB.
endloop.
Thanks,
Sriram Ponna.
‎2008 Jan 22 10:29 AM
Hi
You cannot do a SPLIT by comparing with character '#'. Internally that might be tab separated, or someother field separator being used. But in debugger you might see it as '#'s ... If it is a tab separated file, then may be you can use CL_ABAP_CHAR_UTILITIES->HORIZONTAL_TAB instead of '#' as the field separator.
Regards
Ranganath
‎2008 Jan 22 10:33 AM
Hi Ranganath,
Can you just modify my code and send me your code by using
CL_ABAP_CHAR_UTILITIES->HORIZONTAL_TAB
Regards,
Kiran.
‎2008 Jan 22 10:32 AM
Hi,
Do like this
SPLIT V_RECORD AT CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB INTO
WA-MATNR WA-MBRSH WA-MTART WA-MAKTX WA- MEINS WA-MATKL.
Regards,
Satish
‎2008 Jan 22 10:39 AM
Hi,
i tried but it is showing the error message...
Direct access to components of global class cl_abap_char_utilities is not possible.(cl_abap_char_utilities definition is missing)...
‎2008 Jan 22 10:42 AM
Are you using this symbol => or this ->?
Use =>
Regards,
Satish
‎2008 Jan 22 10:45 AM
‎2008 Jan 22 10:57 AM
Hi Kiran
May be the file you are reading is not a tab delimited file. If you can provide the right file separator then we can try to help you better. You can download the file to presenatation server and open it in Notepad to get more details.
Regards
Ranganath
‎2008 Jan 22 10:58 AM
Hi,
It is showing...error..
CL_ABAP_CHAR_UTILITIES DEFINITION LOAD Statement missing..
‎2008 Jan 22 11:07 AM
Then try this
Data: CR type c value CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
SPLIT V_RECORD AT CR INTO
WA-MATNR WA-MBRSH WA-MTART WA-MAKTX WA- MEINS WA-MATKL.
Which Version of SAP R/3 you are using? Can you check whether you have CL_ABAP_CHAR_UTILITIES class is availavble or not?
Regards,
Satish
‎2008 Jan 22 11:16 AM
Hi,
current version is SAP 4.7EE. and in se24 CL_ABAP_CHAR_UTILITIES is available....
‎2008 Jan 22 2:01 PM
‎2008 Jan 22 10:32 AM
‎2008 Jan 22 10:39 AM
Hi,
after the append statement, clear the wa.
like:
SPLIT V_RECORD AT '#'
INTO
WA-MATNR WA-MBRSH WA-MTART WA-MAKTX WA- MEINS WA-MATKL.
APPEND WA TO ITAB.
clear wa.
enddo.
Regards,
Renjith Michael.
‎2008 Jan 22 10:41 AM
‎2008 Jan 22 11:06 AM
HI ....
Try this.. it will work.
Define a variable which refers to horizontal tab and then use it.
constatns c_tab type ref to CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
SPLIT V_RECORD AT c_tab
INTO
WA-MATNR WA-MBRSH WA-MTART WA-MAKTX WA- MEINS WA-MATKL. APPEND WA TO ITAB.
Regards,
Sai Ramesh