‎2006 Mar 08 10:28 AM
Hi,
In the following program, i am getting the "error
itab-wrbtr must be a character-type data object (data type C,N,DT or String )".
How to avoid this please let me know, i need to use the same data type.
data : begin of itab occurs 0,
BLDAT(10) TYPE C,
BLART(2) TYPE C,
BUKRS(4) TYPE C,
BUDAT(10) TYPE C,
MONAT(2) TYPE C,
WAERS(5) TYPE C,
NEWBS(2) TYPE C,
NEWKO(17) TYPE C,
WRBTR TYPE P decimals 2,
VALUT(10) TYPE C,
GSBER(4) TYPE C,
TNEWBS(2) TYPE C,
TNEWKO(17) TYPE C,
TWRBTR TYPE p decimals 2,
end of itab.
PARAMETERS : p_file LIKE rlgrap-filename OBLIGATORY.
data : i_bdcdata like bdcdata occurs 0 with header line.
data : i_bdcmsgcoll like bdcmsgcoll occurs 0 with header line.
DATA : filename TYPE string.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
CLEAR p_file.
CALL FUNCTION 'F4_FILENAME'
IMPORTING
file_name = p_file.
start-of-selection.
filename = p_file.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = filename
FILETYPE = 'ASC'
HAS_FIELD_SEPARATOR = 'X'
HEADER_LENGTH = 0
READ_BY_LINE = 'X'
DAT_MODE = ' '
CODEPAGE = ' '
IGNORE_CERR = ABAP_TRUE
REPLACEMENT = '#'
CHECK_BOM = ' '
VIRUS_SCAN_PROFILE =
IMPORTING
FILELENGTH =
HEADER =
TABLES
DATA_TAB = itab1
EXCEPTIONS
FILE_OPEN_ERROR = 1
FILE_READ_ERROR = 2
NO_BATCH = 3
GUI_REFUSE_FILETRANSFER = 4
INVALID_TYPE = 5
NO_AUTHORITY = 6
UNKNOWN_ERROR = 7
BAD_DATA_FORMAT = 8
HEADER_NOT_ALLOWED = 9
SEPARATOR_NOT_ALLOWED = 10
HEADER_TOO_LONG = 11
UNKNOWN_DP_ERROR = 12
ACCESS_DENIED = 13
DP_OUT_OF_MEMORY = 14
DISK_FULL = 15
DP_TIMEOUT = 16
OTHERS = 17
.
V_COUNT = 1.
LOOP AT ITAB1.
IF V_COUNT = 1.
SPLIT ITAB1 AT ',' INTO ITAB-BLDAT ITAB-BLART ITAB-BUKRS ITAB-BUDAT ITAB-MONAT
ITAB-WAERS ITAB-NEWBS ITAB-NEWKO ITAB-WRBTR ITAB-VALUT ITAB-GSBER
Please help me out.
Thanks,
Pavan.
‎2006 Mar 08 10:32 AM
Hi Pavan!
Just use two tables, one for upload (because either you use binary mode or for text mode all fields have to be character type), second for rest of program.
With a loop ... move-corresponding ... append ... endloop you can fill the second table and you get the field conversion.
Regards,
Christian
‎2006 Mar 08 10:32 AM
Hi Pavan
Declare itab-wrbtr as type 'C' i.e, Character type . Hope this way you will not come acorss such error.
Regards,
Santosh
‎2006 Mar 08 10:33 AM
Hi,
In BDC,we cannot use type p.That's why the error is coming.
Declare
WRBTR(15) type c
in declaring itab.
Length should be equal to the output lenght of WRBTR.
‎2006 Mar 08 10:33 AM
u can not use p type instead of it use char type.
regards
vinod
‎2006 Mar 08 10:34 AM
Hi pavan,
1. there are two mistakes.
2. we cannot use split ITAB1
bcos itab1 is a internal table,
split expects a string(ie. CHARACTER FIELD)
eg.
SPLIT 'ABCD' AT ',' INTO ITAB-BLDAT ITAB-BLART ITAB-BUKRS ITAB-BUDAT ITAB-MONAT
ITAB-WAERS ITAB-NEWBS ITAB-NEWKO
*ITAB-WRBTR
ITAB-VALUT ITAB-GSBER
3. second mistake is
*ITAB-WRBTR
This needs to be again a character field.
4. So what u can do is,
use another character field for splitting,
and then assign to your original numeric variable.
*----
4. If your requirement is uploading a file
into internal table,
then make the file TAB DELIMITED,
and just use GUI_UPLOAD.
It will work nice. (there will be no need to use split ';')
5. In that case also, use all character fields,
in internal table,
after uploading,
transfer to another internal table with
corresponding numeric fields.
regards,
amit m.
Message was edited by: Amit Mittal
‎2006 Mar 08 10:34 AM
Hi Pavan,
In ITAB declaration u have defined the values WRBTR TYPE P decimals 2.
it makes problem when u use split command. So defione it as C after splitting the value get it as packed decimal for WRBTR by defining some other variable.
Thanks
eswar
‎2006 Mar 08 10:37 AM
whats the definition of itab1.
to use split, concatenate the field has to be of type C,N,d or t
i am not sure but try the addition <b>IN BYTE MODE</b>
Regards
Raja
‎2006 Mar 08 10:38 AM
the error is coming because of the below code...
SPLIT ITAB1 AT ',' INTO ITAB-BLDAT ITAB-BLART ITAB-BUKRS ITAB-BUDAT ITAB-MONAT
ITAB-WAERS ITAB-NEWBS ITAB-NEWKO ITAB-WRBTR ITAB-VALUT ITAB-GSBERsince you have used type p and you are using split, so it will give that error. to avoid declare type c variable as above stated.
regards
vijay
‎2006 Mar 08 10:44 AM
Hi ,
WRBTR output length is of 16.when u declear
WRBTR TYPE P decimals 2, it will take only 13 characters .
Thanks
Vikranth
‎2006 Mar 08 10:48 AM
Hi ,
WRBTR output length is of 16.when u declear
WRBTR TYPE P decimals 2, it will take only 13 characters .so take a variable lenght of 16 char and pass that WRBTR to that variable and then use it.i think this will solve u r problem
Thanks
Vikranth