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 with code to transfer data from aplication server to itab

Former Member
0 Likes
983

DATA: fname TYPE rlgrap-filename value '.\SUBSTANC11111111.TXT',

wa_tab1 TYPE t_tab1,

it_tab1 TYPE TABLE OF t_tab1.

OPEN DATASET FNAME FOR INPUT in TEXT MODE ENCODING DEFAULT.

do.

IF SY-SUBRC = 0.

write 'opened'.

read dataset fname into wa_tab1.

APPEND wa_tab1 to it_tab1.

ELSE.

exit.

ENDIF.

ENDDO.

close DATASET fname.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
955

Hello,

I think the problem is with the file path you are giving.

Check the subrc value after OPEN DATASET.

8 REPLIES 8
Read only

Former Member
0 Likes
955

Try this alternate solution. Instead of directly reading to internal table, read the to the string and then move to internal table.

data : l_string type string.
read dataset fname into l_string.
move the data from l_string to wa_itab1 and then Append to It_tab1

Regards

Vinod

Read only

Former Member
0 Likes
955

I guess the problem is with the sy-subrc check done for the open datset statement. Instead check it for read dataset statement and check

Read only

Former Member
0 Likes
956

Hello,

I think the problem is with the file path you are giving.

Check the subrc value after OPEN DATASET.

Read only

0 Likes
955

Hello,

check the sy-subrc after Read.

Read only

Former Member
0 Likes
955

Welocme to SDN Network.

Always using subrc check after read statement is a good practice. Change your code like this and check.

do.

write 'opened'.

read dataset fname into wa_tab1.

IF SY-SUBRC = 0.

APPEND wa_tab1 to it_tab1.

endif.

ELSE.

exit.

ENDDO.

Regards

VEnk@

Read only

Former Member
0 Likes
955

THANKS A LOT

Read only

0 Likes
955

What was the problem you faced and how you solved it?

Read only

0 Likes
955

Useful answer must be rewarded and the solution has to be posted.