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 file in open dataset

ashish_gupta11
Explorer
0 Likes
830

Hi experts ,

i m getting output in a standard way . all the fields are displaying in one column .

this is my code .

DATA: L_DATA LIKE RLGRAP-FILENAME VALUE '/usr/sap/dev/sys/global/substanc' .

OPEN DATASET L_DATA FOR OUTPUT IN TEXT MODE ENCODING DEFAULT .

IF SY-SUBRC <> 0.

MESSAGE E208(00) WITH 'Error Opening File'.

ENDIF.

LOOP AT I_DOWNLOAD INTO I_WA.

TRANSFER I_WA-WERKS TO L_DATA.

TRANSFER I_WA-MATNR TO L_DATA .

TRANSFER I_WA-MAKTX TO L_DATA.

TRANSFER I_WA-MEINS TO L_DATA.

TRANSFER I_WA-PQTY TO L_DATA.

TRANSFER I_WA-FKLMG1 TO L_DATA.

TRANSFER I_WA-DQTY TO L_DATA.

TRANSFER I_WA-DOFORCAST TO L_DATA.

TRANSFER I_WA-DUFORCAST TO L_DATA.

TRANSFER I_WA-WAQTY TO L_DATA.

TRANSFER I_WA-OFORCAST TO L_DATA.

TRANSFER I_WA-UFORCAST TO L_DATA.

ENDLOOP.

CLOSE DATASET L_DATA.

IF SY-SUBRC <> 0.

MESSAGE E208(00) WITH 'Error Closing File'.

ENDIF.

Thanks,

Ashish Gupta

Moderator Message: Basic and Duplicate Post.

Edited by: kishan P on Dec 10, 2010 3:05 PM

Hi experts ,

i m getting output in a standard way . all the fields are displaying in one column .

this is my code .

DATA: L_DATA LIKE RLGRAP-FILENAME VALUE '/usr/sap/dev/sys/global/substanc' .

OPEN DATASET L_DATA FOR OUTPUT IN TEXT MODE ENCODING DEFAULT .

IF SY-SUBRC <> 0.

MESSAGE E208(00) WITH 'Error Opening File'.

ENDIF.

LOOP AT I_DOWNLOAD INTO I_WA.

TRANSFER I_WA-WERKS TO L_DATA.

TRANSFER I_WA-MATNR TO L_DATA .

TRANSFER I_WA-MAKTX TO L_DATA.

TRANSFER I_WA-MEINS TO L_DATA.

TRANSFER I_WA-PQTY TO L_DATA.

TRANSFER I_WA-FKLMG1 TO L_DATA.

TRANSFER I_WA-DQTY TO L_DATA.

TRANSFER I_WA-DOFORCAST TO L_DATA.

TRANSFER I_WA-DUFORCAST TO L_DATA.

TRANSFER I_WA-WAQTY TO L_DATA.

TRANSFER I_WA-OFORCAST TO L_DATA.

TRANSFER I_WA-UFORCAST TO L_DATA.

ENDLOOP.

CLOSE DATASET L_DATA.

IF SY-SUBRC <> 0.

MESSAGE E208(00) WITH 'Error Closing File'.

ENDIF.

Thanks,

Ashish Gupta

Moderator Message: Basic and Duplicate Post.

Edited by: kishan P on Dec 10, 2010 3:05 PM

5 REPLIES 5
Read only

former_member242255
Active Contributor
0 Likes
804

Write the TRANSFER only once.

LOOP AT I_DOWNLOAD INTO I_WA.

TRANSFER I_WA TO L_DATA.

ENDLOOP.

Read only

0 Likes
804

Hi Sravan,

Thanks for replay .

I did the same but i was getting error message .

"I_WA" cannot be a table, a reference, a string, or contain any of

these objects. any of these objects

This is my internal table and work area definition.

DATA : I_DOWNLOAD TYPE TABLE OF TY_DOWNLOAD WITH HEADER LINE,

I_WA TYPE TY_DOWNLOAD.

Thanks ,

Ashish Gupta

Read only

0 Likes
804

Hi Ashish ,

Does you decleration of TY_DOWNLOAD , have a component of type string .

May be that is causing the issue.

If not please include the decleration in your reply .

Regards,

Arun

Read only

nabheetscn
SAP Champion
SAP Champion
0 Likes
804

Write Transfer WA only one time and make sure the other work area has the same fields so as to populate fields correctly.

Thanks

Nabheet

Read only

Former Member
0 Likes
804

Hi,

Define a string of length I_WA.

Move the work area to string.

Transfer ld_sting to l_dataset.

Regards

Praveen