Application Development 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: 

How I could do the oposite

Former Member
0 Kudos

Basically I would like to fill an internal table. How I could do the oposite of:

check not filename is initial.

open dataset filename for output in text mode encoding non-unicode.

if sy-subrc ne 0.

write: / msg, filename.

exit.

endif.

loop at t_download.

transfer t_download to filename.

endloop.

close dataset filename.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

Try this..

DATA: BEGIN OF itab OCCURS 0,

knumv type konv-knumv,

kposn type konv-kposn,

stunr type konv-stunr,

kschl type konv-kschl,

kwert type konv-kwert,

END OF itab.

DATA: v_string type string.

DATA:

dsn(20) VALUE '/usr/test.dat'.

OPEN DATASET dsn.

IF sy-subrc = 0.

DO.

READ DATASET dsn INTO v_string.

IF sy-subrc <> 0.

EXIT.

ELSE.

SPLIT v_string AT cl_abap_char_utilities=>horizontal_tab

INTO itab-knumv itab-kposn itab-stunr itab-kschl

itab-kwert.

APPEND itab.

ENDIF.

ENDDO.

ENDIF.

CLOSE DATASET dsn.

Thanks,

Naren

5 REPLIES 5

Former Member
0 Kudos

Hi,

Do you want to read the file data??

DATA:

dsn(20) VALUE '/usr/test.dat',

t_data type string occurs 0 with header line.

OPEN DATASET dsn.

IF sy-subrc = 0.

DO.

READ DATASET dsn INTO t_data.

IF sy-subrc <> 0.

EXIT.

ELSE.

APPEND t_data.

ENDIF.

ENDDO.

ENDIF.

CLOSE DATASET dsn.

LOOP AT t_data.

WRITE: / t_data.

ENDLOOP.

Thanks,

Naren

Former Member
0 Kudos

Thank you Narren

i assigned you points. Do you know how I could perform oposite of this complete part. Knowing the sturcture.of internal table result. Basically(after your preavious answer I have the string but how coud I de-concatenate it). Actually the opposite of:

loop at result.

CONCATENATE v_download result-knumv INTO v_download .

CONCATENATE v_download result-kposn INTO v_download SEPARATED BY

cl_abap_char_utilities=>horizontal_tab.

CONCATENATE v_download result-stunr INTO v_download SEPARATED BY

cl_abap_char_utilities=>horizontal_tab.

CONCATENATE v_download result-kschl INTO v_download SEPARATED BY

cl_abap_char_utilities=>horizontal_tab.

CONCATENATE v_download result-kwert INTO v_download SEPARATED BY

cl_abap_char_utilities=>horizontal_tab.

append v_download to t_download. clear v_download.

endloop.

check not filename is initial.

open dataset filename for output in text mode encoding non-unicode.

if sy-subrc ne 0.

write: / msg, filename.

exit.

endif.

loop at t_download.

transfer t_download to filename.

endloop.

close dataset filename.

0 Kudos

Hi,

Once you have the entire records in a single line of the internal table.

You can split the line at the horizontal tab and store them into separate fields and append it into another internal table.

Since you are appending the horizontal_tab as the delimiter, i used the same to split it.

Regards

Subramanian

Former Member
0 Kudos

Hi,

Try this..

DATA: BEGIN OF itab OCCURS 0,

knumv type konv-knumv,

kposn type konv-kposn,

stunr type konv-stunr,

kschl type konv-kschl,

kwert type konv-kwert,

END OF itab.

DATA: v_string type string.

DATA:

dsn(20) VALUE '/usr/test.dat'.

OPEN DATASET dsn.

IF sy-subrc = 0.

DO.

READ DATASET dsn INTO v_string.

IF sy-subrc <> 0.

EXIT.

ELSE.

SPLIT v_string AT cl_abap_char_utilities=>horizontal_tab

INTO itab-knumv itab-kposn itab-stunr itab-kschl

itab-kwert.

APPEND itab.

ENDIF.

ENDDO.

ENDIF.

CLOSE DATASET dsn.

Thanks,

Naren

Former Member
0 Kudos

Great answer. I gave you maximum points.

only

OPEN DATASET dsn for input in text mode encoding non-unicode.

was needed