Application Development 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: 

how to rectify th esyntax error...

Former Member
0 Kudos

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.

1 ACCEPTED SOLUTION

former_member404244
Active Contributor
0 Kudos

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

8 REPLIES 8

Former Member
0 Kudos

Hi,

Go to Program Attributes:

Uncheck Unicode option.

Now activate it.

Regards,

Rama.Pammi

Former Member
0 Kudos

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.

Former Member
0 Kudos

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.

former_member404244
Active Contributor
0 Kudos

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

Former Member
0 Kudos

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

0 Kudos

hi Deva,

Can u give me the logic....

Thanks in advance...

Former Member
0 Kudos

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

Former Member
0 Kudos

&----


*& 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.