09-20-2007 12:10 PM
Hi Folks,
I have written a code like below. But when i am chking it showing an error as....
"A line of itab and WA_T_DATA are not mutually convertable. In a unicode program itab must have the same structure of a Unicode character". So, any one can help me on this....my code is.
&----
*& Report ZTESTREPORT_ITEM
*&
&----
REPORT ZTESTREPORT_ITEM.
TABLES: ZCRM_DM_VBRP.
TYPES: BEGIN OF TS_ZCRM_DM_VBRP,
VBELN LIKE ZCRM_DM_VBRP-VBELN,
POSNR LIKE ZCRM_DM_VBRP-POSNR,
AUBEL LIKE ZCRM_DM_VBRP-AUBEL,
AUPOS LIKE ZCRM_DM_VBRP-AUPOS,
MATNR LIKE ZCRM_DM_VBRP-MATNR,
CHARG LIKE ZCRM_DM_VBRP-CHARG,
WERKS LIKE ZCRM_DM_VBRP-WERKS,
FKIMG LIKE ZCRM_DM_VBRP-FKIMG,
NETWR LIKE ZCRM_DM_VBRP-NETWR,
ERDAT LIKE ZCRM_DM_VBRP-ERDAT,
UVALL LIKE ZCRM_DM_VBRP-UVALL,
END OF TS_ZCRM_DM_VBRP,
TT_ZCRM_DM_VBRP TYPE STANDARD TABLE OF TS_ZCRM_DM_VBRP.
Declaration of work area
DATA : WA_ZCRM_DM_VBRP TYPE TS_ZCRM_DM_VBRP,
ITAB TYPE TT_ZCRM_DM_VBRP.
DATA: T_OPTIONS TYPE TABLE OF RFC_DB_OPT INITIAL SIZE 10,
T_FIELDS TYPE TABLE OF RFC_DB_FLD INITIAL SIZE 10.
STRUCTURE DECLARATION
TYPES: BEGIN OF TS_DATA. "OCCURS 0,
INCLUDE STRUCTURE TAB512 .
TYPES: END OF TS_DATA,
TT_DATA TYPE STANDARD TABLE OF TS_DATA .
*WORK AREA DECLARATION
DATA: WA_T_DATA TYPE TS_DATA,
INTERNAL TABLE DECLARATION
ITAB1 TYPE TT_DATA.
********************************************************************************
START-OF-SELECTION *
********************************************************************************
START-OF-SELECTION.
*CALLING FUNCTION MODULE TO READ TABLE FROM REMOTE CLIENT.
CALL FUNCTION 'RFC_READ_TABLE' DESTINATION 'DAACLNT060'
EXPORTING
QUERY_TABLE = 'ZCRM_DM_VBRP'
DELIMITER = ' '
NO_DATA = ' '
ROWSKIPS = 0
ROWCOUNT = 0
TABLES
OPTIONS = T_OPTIONS
FIELDS = T_FIELDS
DATA = ITAB1
EXCEPTIONS
TABLE_NOT_AVAILABLE = 1
TABLE_WITHOUT_DATA = 2
OPTION_NOT_VALID = 3
FIELD_NOT_VALID = 4
NOT_AUTHORIZED = 5
DATA_BUFFER_EXCEEDED = 6
OTHERS = 7 .
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
LOOP THE INTERNAL TABLE
LOOP AT ITAB1 INTO WA_T_DATA.
*APPEND WORK AREA TO THE INTENAL TABLE
APPEND WA_T_DATA TO ITAB.
ENDLOOP.
*INSERT INTERNAL TABLE DATA TO Z TABLE
INSERT ZCRM_DM_VBRP FROM TABLE ITAB.
CLAER THE WORK AREA.
CLEAR WA_T_DATA.
09-20-2007 12:20 PM
HI,
U have to declare itab as
data : itab type standard table of ZCRM_DM_VBRP ..Now u have to make move-corresponding from itab1 to itab ..like this
LOOP AT ITAB1 INTO WA_T_DATA.
move-corresponding WA_T_DATA TO ITAB.
append itab.
CLEAR WA_T_DATA.
ENDLOOP.
*INSERT INTERNAL TABLE DATA TO Z TABLE
INSERT ZCRM_DM_VBRP FROM TABLE ITAB.
Reward points if u find useful..
Regards,
Nagaraj
09-20-2007 12:16 PM
Hi,
Go to Program Attributes:
Uncheck Unicode option.
Now activate it.
Regards,
Rama.Pammi
09-20-2007 12:16 PM
Hi,
Change your code like,
TABLES: ZCRM_DM_VBRP.
<b>DATA</b> : <b>BEGIN OF WA_TS_ZCRM_DM_VBRP</b>,
VBELN LIKE ZCRM_DM_VBRP-VBELN,
POSNR LIKE ZCRM_DM_VBRP-POSNR,
AUBEL LIKE ZCRM_DM_VBRP-AUBEL,
AUPOS LIKE ZCRM_DM_VBRP-AUPOS,
MATNR LIKE ZCRM_DM_VBRP-MATNR,
CHARG LIKE ZCRM_DM_VBRP-CHARG,
WERKS LIKE ZCRM_DM_VBRP-WERKS,
FKIMG LIKE ZCRM_DM_VBRP-FKIMG,
NETWR LIKE ZCRM_DM_VBRP-NETWR,
ERDAT LIKE ZCRM_DM_VBRP-ERDAT,
UVALL LIKE ZCRM_DM_VBRP-UVALL,
END OF <b>WA_TS_ZCRM_DM_VBRP</b>,
Declaration of work area
<b>DATA : ITAB LIKE STANDARD TABLE OF WA_TS_ZCRM_DM_VBRP with hedaer line.</b>
Thanks,
Reward If Helpful.
09-20-2007 12:18 PM
Hi,
U try with this,
<b>DATA : WA_ZCRM_DM_VBRP TYPE TS_ZCRM_DM_VBRP,
ITAB LIKE TABLE OF WA_ZCRM_DM_VBRP.</b>
Regards,
Padmam.
09-20-2007 12:20 PM
HI,
U have to declare itab as
data : itab type standard table of ZCRM_DM_VBRP ..Now u have to make move-corresponding from itab1 to itab ..like this
LOOP AT ITAB1 INTO WA_T_DATA.
move-corresponding WA_T_DATA TO ITAB.
append itab.
CLEAR WA_T_DATA.
ENDLOOP.
*INSERT INTERNAL TABLE DATA TO Z TABLE
INSERT ZCRM_DM_VBRP FROM TABLE ITAB.
Reward points if u find useful..
Regards,
Nagaraj
09-20-2007 12:22 PM
Hi,
Structure of itab and WA_T_DATA are not same .
These structures shud be same inorder to avoid these error.
As u r using the statement :
APPEND WA_T_DATA TO ITAB , which have diff structure and so is the error.
Both shud have same structure
revrt back if any issues,
reward if helpful.
regards,
Naveen
09-20-2007 1:02 PM
09-20-2007 12:23 PM
Hi,
The reason for the error is that the table ITAB and the work area WA_T_DATA are having different structures(i.e fields).
WA_T_DATA has only one field(WA), whereas internal table ITAB has many fields(VBELN,POSNR..etc), hence it is not possible to insert an entry into internal table ITAB using the work area WA_T_DATA(due to difference in structures).
If you want to do a successful insert into the internal table declare a new work area of the type ZCRM_DM_VBRP and use this work area to append the rows to internal table ITAB.
For eg:
data: wa_itab type ZCRM_DM_VBRP .
Move: wa_t_data+0(10) to wa_itab-vbeln,
wa_t_data+10(6) to wa_itab-posnr.
NOTE: The above move logic depends on your requirement to split the fields....
append wa_itab to itab.
Hope this helps..
Regards,
Dilli
09-20-2007 1:18 PM
&----
*& Report ZTESTREPORT_ITEM
*&
&----
REPORT ZTESTREPORT_ITEM.
TABLES: ZCRM_DM_VBRP.
TYPES: BEGIN OF TS_ZCRM_DM_VBRP,
VBELN LIKE ZCRM_DM_VBRP-VBELN,
POSNR LIKE ZCRM_DM_VBRP-POSNR,
AUBEL LIKE ZCRM_DM_VBRP-AUBEL,
AUPOS LIKE ZCRM_DM_VBRP-AUPOS,
MATNR LIKE ZCRM_DM_VBRP-MATNR,
CHARG LIKE ZCRM_DM_VBRP-CHARG,
WERKS LIKE ZCRM_DM_VBRP-WERKS,
FKIMG LIKE ZCRM_DM_VBRP-FKIMG,
NETWR LIKE ZCRM_DM_VBRP-NETWR,
ERDAT LIKE ZCRM_DM_VBRP-ERDAT,
UVALL LIKE ZCRM_DM_VBRP-UVALL,
END OF TS_ZCRM_DM_VBRP,
TT_ZCRM_DM_VBRP TYPE STANDARD TABLE OF TS_ZCRM_DM_VBRP.
Declaration of work area
DATA : WA_ZCRM_DM_VBRP TYPE TS_ZCRM_DM_VBRP,
ITAB TYPE TT_ZCRM_DM_VBRP.
DATA: T_OPTIONS TYPE TABLE OF RFC_DB_OPT INITIAL SIZE 10,
T_FIELDS TYPE TABLE OF RFC_DB_FLD INITIAL SIZE 10.
STRUCTURE DECLARATION
TYPES: BEGIN OF TS_DATA. "OCCURS 0,
INCLUDE STRUCTURE TAB512 .
TYPES: END OF TS_DATA,
TT_DATA TYPE STANDARD TABLE OF TS_DATA .
*WORK AREA DECLARATION
<b>DATA: WA_T_DATA TYPE TS_ZCRM_DM_VBRP.</b>
INTERNAL TABLE DECLARATION
ITAB1 TYPE TT_DATA.
********************************************************************************
START-OF-SELECTION *
********************************************************************************
START-OF-SELECTION.
*CALLING FUNCTION MODULE TO READ TABLE FROM REMOTE CLIENT.
CALL FUNCTION 'RFC_READ_TABLE' DESTINATION 'DAACLNT060'
EXPORTING
QUERY_TABLE = 'ZCRM_DM_VBRP'
DELIMITER = ' '
NO_DATA = ' '
ROWSKIPS = 0
ROWCOUNT = 0
TABLES
OPTIONS = T_OPTIONS
FIELDS = T_FIELDS
DATA = ITAB1
EXCEPTIONS
TABLE_NOT_AVAILABLE = 1
TABLE_WITHOUT_DATA = 2
OPTION_NOT_VALID = 3
FIELD_NOT_VALID = 4
NOT_AUTHORIZED = 5
DATA_BUFFER_EXCEEDED = 6
OTHERS = 7 .
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
LOOP THE INTERNAL TABLE
LOOP AT ITAB1 INTO WA_T_DATA.
*APPEND WORK AREA TO THE INTENAL TABLE
APPEND WA_T_DATA TO ITAB.
ENDLOOP.
*INSERT INTERNAL TABLE DATA TO Z TABLE
INSERT ZCRM_DM_VBRP FROM TABLE ITAB.
CLAER THE WORK AREA.
CLEAR WA_T_DATA.