Application Development and Automation 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: 
Read only

Split Command is not working....

former_member188829
Active Contributor
0 Likes
2,869

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

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,014

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

16 REPLIES 16
Read only

Former Member
0 Likes
2,014

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.

Read only

Former Member
0 Likes
2,014

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

Read only

0 Likes
2,014

Hi Ranganath,

Can you just modify my code and send me your code by using

CL_ABAP_CHAR_UTILITIES->HORIZONTAL_TAB

Regards,

Kiran.

Read only

Former Member
0 Likes
2,014

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

Read only

0 Likes
2,014

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)...

Read only

0 Likes
2,014

Are you using this symbol => or this ->?

Use =>

Regards,

Satish

Read only

0 Likes
2,014

Hi Satish,

am using =>

Read only

0 Likes
2,014

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

Read only

0 Likes
2,014

Hi,

It is showing...error..

CL_ABAP_CHAR_UTILITIES DEFINITION LOAD Statement missing..

Read only

0 Likes
2,014

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

Read only

0 Likes
2,014

Hi,

current version is SAP 4.7EE. and in se24 CL_ABAP_CHAR_UTILITIES is available....

Read only

0 Likes
2,014

Thanks to all....

Solved by myself.....

Read only

former_member404244
Active Contributor
0 Likes
2,014

Hi,

Check the below link

Regards,

Nagaraj

Read only

Former Member
0 Likes
2,014

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.

Read only

0 Likes
2,014

Hi Michael,

Still it is showing same output...

Read only

Former Member
0 Likes
2,015

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