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

Problem in reading records

Former Member
0 Likes
644

Hi Gurus,

I have to read the following data into my internal table by splitting at | into workarea.

800|ZIXBSVCREQ|47114711|L2|FB2FFF5916C299489D0613840D4ED507|ZIXDSVCREF|20080502|00000000|FAX|47114711|20070312||

800|ZIXBSVCREQ|80004711|L2|7E9C31636213D44688EBD6593D633D53|ZIXDSVCREF|20060502|00000000|FAX|80004711|20080312|89224444|

800|ZIXBSVCREQ|90004711|L2|E777FD51E6798449977005A20C754B30|ZIXDSVCREF|20070502|00000000|FAX|90004711|20060312||

If the last field value is blank, it move the | into the workarea and so into the internal table.

How to avoid the copying of | into the workarea and internal table?

Please reply soon.

Regards,

Rahul

Hi Gurus,

I have to read the following data into my internal table by splitting at | into workarea.

800|ZIXBSVCREQ|47114711|L2|FB2FFF5916C299489D0613840D4ED507|ZIXDSVCREF|20080502|00000000|FAX|47114711|20070312||

800|ZIXBSVCREQ|80004711|L2|7E9C31636213D44688EBD6593D633D53|ZIXDSVCREF|20060502|00000000|FAX|80004711|20080312|89224444|

800|ZIXBSVCREQ|90004711|L2|E777FD51E6798449977005A20C754B30|ZIXDSVCREF|20070502|00000000|FAX|90004711|20060312||

If the last field value is blank, it move the | into the workarea and so into the internal table.

How to avoid the copying of | into the workarea and internal table?

Please reply soon.

Regards,

Rahul

4 REPLIES 4
Read only

naimesh_patel
Active Contributor
0 Likes
623

Use SPLIT command.

Regards,

Naimesh Patel

Read only

Former Member
0 Likes
623

Put a check before moving the value to the table like:

split '800|ZIXBSVCREQ|47114711|L2|FB2FFF5916C299489D0613840D4ED507|ZIXDSVCREF|20080502|00000000|FAX|47114711|20070312||'

into wa-fdl1

wa-fld2

....

wa-fldn at '|'.

perform zinitial using :

wa-fdl1,

wa-fld2,

....

wa-fldn.

append wa to itab.

form zinitial using p_fld type c.

if p_fld = 'I'.

clear p_fld.

endif.

endform.

Regards,

Joy.

Read only

Former Member
0 Likes
623

I am sure you are reading from the text file. Loop at the table from where it is comming and then use the SPLIT command..

check this example.

DATA: str1 TYPE string,

str2 TYPE string,

str3 TYPE string,

itab TYPE TABLE OF string,

text TYPE string.

text = `What a drag it is getting old`.

SPLIT text AT space INTO: str1 str2 str3,

TABLE itab.

Shreekant

Read only

Former Member
0 Likes
623

Hi,

READ DATASET l_floc INTO l_fdata.

l_floc - filelocation

l_fdata - string

IF sy-subrc EQ 0.

SPLIT l_fdata AT '|' INTO it_tab-f1 it_tab-f2 it_tab-fn.

ENDIF.

Regards,

Srini