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

Not mutually convertible in a unicode program

0 Likes
2,594

New to SAP and ABAP, getting a unicode error. Below is a snippet of the code that I'm trying to fix.

I have tried

Data: APRPRV like line of i0025p

but I get the message that APRPRV has already been declared.

*****************CODE SNIPPET*****************

FORM cmp_0025flds.

REFRESH: aprprv, aprcur.

* add prv & cur appraisals by offsets to data flds
w-aproff = 110. "initial offset
DO 6 TIMES. "could be up to 6 sets

* lod prv appraisal set
aprprv = i0025p+w-aproff(8).
APPEND aprprv.

* lod cur appraisal set
aprcur = i0025c+w-aproff(8).
APPEND aprcur.

* increment offset within set
ADD +8 TO w-aproff.

ENDDO.

* for each prv appraisal set having data
LOOP AT aprprv WHERE krt NE space.
w-seq = sy-tabix.

* read prv & cur appraisal data flds using set offsets
READ TABLE aprprv INDEX sy-tabix.
READ TABLE aprcur INDEX sy-tabix.

* compare prv to cur for difference; prt differences
IF aprprv NE aprcur.
w-fldchgmade = on.
WRITE: /08 'PRV' INTENSIFIED NO-GAP, 12 w-seq INTENSIFIED,
14 aprprv-krt, 19 aprprv-pkt, 29 aprprv-ksu,
60 'CUR' INTENSIFIED NO-GAP, w-seq INTENSIFIED,
66 aprcur-krt, 71 aprcur-pkt, 81 aprcur-ksu.
ENDIF.

ENDLOOP.

ENDFORM.

*****************CODE SNIPPET*****************

This is the code in the report that feeds to the previous snippet

*  strucs for internal infotyp arrays
DATA:
  BEGIN OF aprcur OCCURS 0,     "to compare prv vs cur
    krt TYPE bukrt,
    pkt TYPE bupkt,
    ksu TYPE buksu,
  END OF   aprcur,
  BEGIN OF aprprv OCCURS 0,     "to compare prv vs cur
    krt TYPE bukrt,
    pkt TYPE bupkt,
    ksu TYPE buksu,
  END OF   aprprv,
  BEGIN OF apr,
    krt TYPE bukrt,
    pkt TYPE bupkt,
    ksu TYPE buksu,
  END OF   apr.

I've gone through many of the previous answered questions, not sure if maybe because the responses are 10 years old, or I just don't have enough knowledge of where to proprely declare. Any help will be greatly appreciated.

7 REPLIES 7
Read only

Sandra_Rossi
Active Contributor
2,444

Thank you for formatting the code nicely.

I'm not sure what message is your question about (either "Not mutually convertible in a unicode program" or "APRPRV has already been declared"). I guess you have the first syntax error, and you tried to fix it and got another message.

About the first one, I think it's because of all lines of this kind because i0025p is a structure, so you should access by using its components instead of positioning by offset (difficult to know what position 110 corresponds to...):

aprprv = i0025p+w-aproff(8).

By trying to declare again APRPRV, you don't address the syntax error (and you provoke another error).

Read only

0 Likes
2,444

I'm sorry if I'm not explaining correctly. What I'm trying to solve is the unicode error. I have researched the Q&A here and most of the solutions point to declaring the structure, I tried that, and of course it errored.

Read only

0 Likes
2,444

Please don't click "Answer", it's reserved to solutions, instead use "Comment" (see texts explaining what they are about).

Read only

matt
Active Contributor
2,444

Which line shows the error?

(I don't know where you got this code from but it's very old style ... and not even that well written for then. Global variables should never be addressed directly in a form. They should be passed as parameters. And forms are obsolete anyway).

Read only

0 Likes
2,444

This code is very old, we are in the mist of an upgrade and need to correct the unicode before moving forward, so rewriting at the moment isn't on the table.

The error is on this line:

aprcur = i0025c+w-aproff(8).
Read only

0 Likes
2,444

Also at this line as well:

aprprv = i0025p+w-aproff(8).
Read only

RaymondGiuseppi
Active Contributor
2,444

Often HR programs use some dummy field as a parameter referencing any infotype, that can trigger some Unicode errors. SAP provided a class (CL_HR_PNNNN_TYPE_CAST) to convert those dummy to/from the actual ddic structure (or you can play yourself with assign statement)

" I suppose the I0025p/c fields refer to Infotype 0025
  DATA: pa0025 TYPE pa0025.
  call method cl_hr_pnnnn_type_cast=>prelp_to_pnnnn
    exporting
      prelp = i0025p
    importing
      pnnnn = pa0025.
  aprprv-krt = pa0025-krt01. " etc.

NB: If you feel confident enough, you can also play with some ASSIGN pa0025-comp1 INCREMENT inc TO <sub> to loop between group of subfield krt/plt/ksu.