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

Runtime Error in OPEN DATASET

former_member308418
Participant
0 Likes
2,172

Dear All,

I am trying to upload a text file in application server. But I am getting the run time error which says-

" For the statement

"TRANSFER f TO ..."

only character-type data objects are supported at the argument position

"f".

In this case. the operand "f" has the non-character-type "u". The

current program is a Unicode program. In the Unicode context, the type

'X' or structures containing not only character-type components are

regarded as non-character-type."

If I remove the quantity fields then the error does not happen. But I have to take quantity fields also. Plz tell me what to do. My code is,

DATA FILENAME like rlgrap-filename VALUE 'MIGO_VALUE.txt'.
TABLES VBAK.

DATA D_MSG_TEXT(50).

DATA : BEGIN OF it_mseg OCCURS 0,
       mblnr TYPE mseg-mblnr,
       mjahr TYPE mseg-mjahr,
       matnr TYPE mseg-matnr,
*       erfmg TYPE mseg-erfmg,
       werks TYPE mseg-werks,
       lgort TYPE mseg-lgort,
       END OF it_mseg.
DATA wa LIKE it_mseg.

SELECT mblnr mjahr matnr werks lgort FROM mseg INTO CORRESPONDING FIELDS OF TABLE it_mseg WHERE bwart = '101'.
SORT it_mseg BY mblnr.
OPEN DATASET FILENAME FOR OUTPUT IN TEXT MODE ENCODING DEFAULT
                      MESSAGE D_MSG_TEXT.
if sy-subrc eq 0.
message 'File created succesfully in SAP System'(002) type 'S'.
endif.

IF SY-SUBRC NE 0.
  WRITE: 'File cannot be opened. Reason:', D_MSG_TEXT.
  EXIT.
ENDIF.
* Transferring Data
LOOP AT it_mseg INTO wa.
TRANSFER wa to filename.
ENDLOOP.
* Closing the File
CLOSE DATASET FILENAME.

Thanks,

Tripod.

13 REPLIES 13
Read only

Former Member
0 Likes
1,605

send the whole thing in string .. that will solve the problem..

make all the itab fields as char

loop at itab.

concatenate f1 f2 f3... into string by space

transfer..

Br,

Vijay

Read only

Former Member
0 Likes
1,605

Hi,

In this case please concatenate the fields of the WA to a variable (Type C may be some 100 length) inside the LOOP of IT_MSEG then use the TRANSFER for this variable to filename. Like TRANSFER V_DATA (Type c) to filename.

Please implement this logic and let me know in case of any.

Regards,

SRinivas

Read only

0 Likes
1,605

Thanks Sri for your help. I tried to apply the logic, but the error i am getting here is -

"IT_MSEG-ERFMG" must be a character-like data object (data type C, N,D, T, or STRING) STRING).

Same case here, if I remove ERFMG field, i do not get such error.


data ld_string type string.

LOOP AT it_mseg INTO wa.
  CONCATENATE it_mseg-mblnr it_mseg-mjahr it_mseg-matnr it_mseg-erfmg it_mseg-werks it_mseg-lgort INTO ld_string. 
     endloop.

With regards,

Tripod.

Read only

0 Likes
1,605

You are in the correct way. Before to concatenate copy the amount field into another field with type C or string and then do the concatenate with all the other felds.

It has to work.

Read only

0 Likes
1,605

Hi,

As Manel said you need to move that Quantity field to a variable of type C using WRITE TO statement. Then concatenate this variable value along with the other variables. In this way the error can be rectified. As in you post you have commented the quantity so I have not given this solution.

Please implement this and let me know in case of any.

Regards,

SRinivas

Read only

Former Member
0 Likes
1,605

Hi,

DATA : BEGIN OF itab OCCURS 0,

mblnr TYPE mseg-mblnr,

mjahr TYPE mseg-mjahr,

matnr TYPE mseg-matnr,

erfmg(17) TYPE C, -


> declare this field as Char field

werks TYPE mseg-werks,

lgort TYPE mseg-lgort,

END OF itab.

Declare this field as Char field and move the value into this field using Write statement.

Read only

0 Likes
1,605

Hi, In this case this field is showing 0. I mean value shows 0.00 here if i use data type C.

Thanks,

Tripod.

Read only

0 Likes
1,605

It is not possible. Maybe the value for MSEG-EFMG = 0?

It is usually when you have to copy a value into a char. Check that because it has to work.

LOOP table.

Copy EFMG into a new char.

Concatenate.

Transfer.

ENDLOOP.

regards,

Manel

Read only

0 Likes
1,605

you did do itab-erfmg = sometable-erfmg? Or something similar? DEBUG and see what you're doing wrong....

Read only

0 Likes
1,605

Thanks Manel. My problem is solved now. I used your logic and getting value now.

Now a file is saved in SAP directory. But I dont know the next process how this file will be transferred to other system. For that purpose should I have to do some more ABAP or my task has finished ? As I have no idea how other system will retrieve data from this file, I am confused about this. Plz give me some idea if have any.

Thanks,

With regards,

Tripod.

Read only

0 Likes
1,605

Hello Gurus,

When I am double clicking my file on application server using tcode- All01, all fields are showing 0 or empty. But the length of the file is showing 70824 byte. Can you plz tell me why it is happening so?

Thanks,

With regards,

Tripod.

Read only

Former Member
0 Likes
1,605

Hi,

For transferring the data to application server you can use only the data types.

C, N, D, T, S.

Apart from this it will give the dump.

Please correct the field in your internal table as per the above mentioned data types.

With Regards,

Vimal Khare.

Read only

Former Member
0 Likes
1,605

Hi,

Create a new workarea in which the quantity field is decalred as character type.

while transferring the data, assign the internal table quantity field to this work area character field and then transfer the wa to the file.

It will work.