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

:) Unicode Problem

Former Member
0 Likes
1,715

Hi,

I am having an Unicode problem. I have an Internal table as follows.

DATA: BEGIN OF iedid4 OCCURS 10.
        INCLUDE STRUCTURE edid4.
DATA: END OF iedid4.

A structure is as follows:

DATA: wa_firstline(1000),
      wa_header       LIKE e1bpache04,
      wa_gl_line_item LIKE e1bpacgl04,
      wa_curr_fields  LIKE e1bpaccr04,
      infname         LIKE ibipparms-path,
      idocnum         LIKE edid4-docnum,
      pdcount         LIKE zpdcount-runcount,
      trans_date      LIKE sy-datum,
      pp_end_date     LIKE sy-datum,
      recon_docnum(10),
      o_path          LIKE filename-fileintern,
      t_runid         LIKE pevsh-runid,
      &pernr          LIKE ppdit-pernr.

When I call the following statement,

READ TABLE iedid4 INTO wa_firstline INDEX 1

I am getting the following error.

A line of "IEDID4" and "WA_FIRSTLINE" are not mutually convertible in a Unicode program.

Can somebody help me out?.

Thanks,

Raj.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,660

Raj,

As a "golden rule", you should avoid changing data defs at all costs. IF it must be done, it must be done carefully.

This program is changing values into type CHAR, for example, from INT. This is very dangerous.

After the Unicode conversion, you might want to re-visit this program and do some house-cleaning on it.

15 REPLIES 15
Read only

Former Member
0 Likes
1,660

In unicode systems, they have to have the same structures. Since you declared the internal table IEDID4 with header line, you don't need the additional INTO clause with your READ statement. You can do this.

READ TABLE iedid4 INDEX 1.

wa_firstline = i_edid4.

or declare 'wa_firstline' like iedid4.

Read only

Former Member
0 Likes
1,660

iedid4 and wa_firstline MUST be of the same type in Unicode.

Declare like this:

data: wa_firstline type edid4.

Reward points as well.

Read only

0 Likes
1,660

What about length of wa_firstline(1000)?.

Srinvas, i think we should use type instead of like.

I have another statement I modified as both of you mentione like this,

READ TABLE iedid4 INDEX 2.
    wa_inrec = iedid4.

the structure of wa_inrec is as follows,

DATA: wa_inrec    TYPE inrec,

the structure of inrec is as follows,

TYPES: BEGIN OF inrec ,
          data(1000),
       END OF inrec.

Here also I get the same error,

"WA_INREC" and "IEDID4" are not mutually convertible. In Unicode

Thanksa-a-lot for you help Srinavas, and John.

Raj.

Message was edited by: Raj

Read only

0 Likes
1,660

Declare as:

data: inrec type IEDID4.

Read only

0 Likes
1,660

Hi John,

inrec is an internal table, how can I declare it as data: inrec type iedid4 ?.

Thanks,

Raj.

Read only

0 Likes
1,660

In this defintion:

TYPES: BEGIN OF inrec ,

data(1000),

END OF inrec.

inrec is NOT an internal table. It is a simple, custom-built data type.

data: in_tbl type table of inrec with header line.

would be an internal table of TYPE inrec.

Read only

0 Likes
1,660

Hi Raj,

John is talking about the wa_inrec. Basically you cannot move the contents of your internal table record to a flat structure of 1000 characters particularly if the EDID4 structure has non-character like fields. The problem is with the field DTINT2 of this structure. I think you actually need to do MOVE IEDID4-SDATA TO WA_INREC. Then it will be fine.


TYPES: BEGIN OF inrec ,
          data(1000),
       END OF inrec.

DATA: BEGIN OF iedid4 OCCURS 10.
        INCLUDE STRUCTURE edid4.
DATA: END OF iedid4.
DATA: wa_inrec    TYPE inrec.



READ TABLE iedid4 INDEX 2.
wa_inrec = iedid4-sdata.

Read only

0 Likes
1,660

Srinivas and John,

Thanks for the help. Ya that suggestion worked. But In other statement like this,

MOVE wa_firstline+68(932) TO wa_header.

It throws me an error like this,

The offset declaration "68" exceeds the length of the character-type start (=66) of the structure. This is not allowed in Unicode programs.

Thanks-a-lot.

Raj.

Read only

0 Likes
1,660

What is the latest definition of your wa_firstline? Is it same as EDID4?

In that case, as I explained, you still have to avoid the field DTINT2. The total length of all the fields upto this field(MANDT, DOCNUM, COUNTER, SEGNUM, SEGNAM, PSGNUM, HLEVEL) = 66. This field is 5 characters,. So you should write your statment as

MOVE wa_firstline+71(929) TO wa_header.

changed the offset length.

Message was edited by: Srinivas Adavi

Read only

0 Likes
1,660

In your system, what is "wa_header" declared as... wa_header LIKE e1bpache04 ?

If so, not sure of your R/3 version... please send the def of e1bpache04.

Read only

0 Likes
1,660

Look at the long text of the error message and then click on the 'Rules for Converting to Unicode'. Here it explains that if you are moving like this, the types of the fields of source should be compatible with that of the target. So if you look at your statement, wa_firstline+68(932) has two initial characters which are of integer type while the target has the first two initial characters as character type.

Srinivas

Read only

0 Likes
1,660

John,

The wa-header is declared as e1bpache04 only.

Srinivas,

Whats the way to go now?. I tried with offset wa_firstline+71(929), its not correct.

Thanks,

Raj.

Read only

0 Likes
1,660

ok let us go back to the basics and see. What is it that you are trying to achieve by moving this offset to wa_header? I thought you want to move the IDoc data to this structure, then you have to simply do this.

wa_header = wa_firstline-sdata.

sdata is the field that will always contain the actual data. All other fields of EDID4 are just control information that you don't need for your processing.

Can you please your latest code again and also specify the requirement?

Srinivas

Read only

0 Likes
1,660

Hi Srinas, Thanks for the help. Please find the code as follows.

FORM convert_idoc.

  DATA: totallines TYPE i,
        currline TYPE i,
        offsetline TYPE i,
        offset TYPE i.

* REad FIrstLine
*  read table itab_inrecs into wa_firstline index 1.
  READ TABLE iedid4  INDEX 1.
     wa_firstline = iedid4.

* Read Header
*  read table itab_inrecs into wa_inrec index 2.
  READ TABLE iedid4  INDEX 2.
     wa_inrec = iedid4-sdata.
*  move wa_inrec-data+63 to wa_header.
  MOVE wa_firstline+68(932) TO wa_header.
* get total lines
  DESCRIBE TABLE iedid4 LINES totallines.
  currline = 2.                        " sy-tabix
  offset = ( totallines - 2 ) / 2.
  totallines = currline + offset.
  WHILE currline < totallines.
    offsetline = currline + offset.
    READ TABLE iedid4 INTO wa_inrec INDEX currline.
*   read table itab_inrecs into wa_inrec index currline.
    MOVE wa_inrec-data+68 TO wa_gl_line_item.
    IF wa_gl_line_item-gl_account = '1339003000' OR
       wa_gl_line_item-gl_account = '1339001000'.
      currline = currline + 1.
      CLEAR: wa_gl_line_item, wa_inrec.
      CONTINUE.
    ENDIF.
    READ TABLE iedid4 INTO wa_inrec INDEX offsetline .
    MOVE wa_inrec-data+68 TO wa_curr_fields.
    PERFORM build_outrec.
    currline = currline + 1.
  ENDWHILE.

ENDFORM.                               " CONVERT_IDOC

Read only

Former Member
0 Likes
1,661

Raj,

As a "golden rule", you should avoid changing data defs at all costs. IF it must be done, it must be done carefully.

This program is changing values into type CHAR, for example, from INT. This is very dangerous.

After the Unicode conversion, you might want to re-visit this program and do some house-cleaning on it.