$(function () { pageContext.i18n.modTalk = 'moderation talk'; pageContext.i18n.replyToComment = 'Reply'; pageContext.i18n.modTalkEmpty = 'moderation talk is empty'; pageContext.url.getModTalk = "/comments/%25ID%25/listModTalk.json"; pageContext.url.possibleCommentRecipients = "/comments/%ID%/possibleRecipients.json"; pageContext.url.commentEdit = '/comments/%25ID%25/edit.html'; pageContext.url.commentView = '/comments/%ID%/view.html'; pageContext.i18n.commentVisibility = { 'full': 'Viewable by all users', 'op': 'Viewable by the original poster', 'mod': 'Viewable by moderators', 'opAndMod': 'Viewable by moderators and the original poster', 'other': 'Advanced visibility', 'dialogTitle': 'Comment visibility', 'selectGroups': 'Visible to groups', 'selectOther': 'Other recipients', 'selectOriginalPoster': 'Original poster', 'selectModerators': 'Moderators', 'selectAssignees': 'Asked to answer users' }; pageContext.i18n.commentMenuLabels = { 'comment-edit': 'comments.menu.edit', 'comment-delete': 'comments.menu.delete', 'comment-convert': 'comments.menu.convert' };pageContext.i18n.answer= { bestAnswer: 'Best Answer', controlBar : { accept: 'Accept', unaccept: 'Unaccept', acceptCommand: 'Accept this answer as correct', cancelAcceptedCommand: 'Remove this answers accepted status' } }; window.croles = { u: false, op: false, m: false, og: false, as: false, ag: false, dc: false, doc: false, eo: false, ea: false }; tools.init({ q: { e: false, ew: false, eo: false, r: false, ro: false, d: false, dow: false, fv: false, c: false, co: false, p: false, tm: false , ms: false, mos: false }, n: { f: false, vf: false, vfo: false, vr: false, vro: false, c: false, co: false, vu: false, vd: false, w: false, wo: false, l: false }, c: { e: false, eo: false, d: false, dow: false, ta: false, tao: false, l: false }, a: { e: false, ew: false, eo: false, d: false, dow: false, a: false, aoq: false, ao: false, tc: false, tco: false, p: false, tm: false }, pc: croles }, { tc: true, nsc: true }); commandUtils.initializeLabels(); }); Skip to Content
0

Issue with Inline Declaration Assignment

Oct 14, 2016 at 09:12 AM

219

avatar image
P D

Hi Experts,

Please find my below code.

DATA : PA_FY TYPE GJAHR.    " SUCCEEDING FINANCIAL YEAR.
DATA(PA_FY1) = PA_FY + 1.

**/-- FINANCIAL YEAR STARTING DATE

CONCATENATE PA_FY '04' '01' INTO DATA(FIN_STRT_DATE).

**/-- FINACIAL YEAR ENDING DATE

CONCATENATE PA_FY1 '03' '31' INTO DATA(FIN_END_DATE).

This code is returning error message .

"PA_FY1" must be character-type data object (data type C,N,D,T or string)

But if i declare 'PA_FY1' as

DATA(PA_FY1) TYPE GJAHR.

Then it wont throw any error message.

B.R.

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

6 Answers

Best Answer
Sandra Rossi Oct 14, 2016 at 12:02 PM
6

DATA(PA_FY1)= PA_FY +1.

The compiler determines the types as explained here: Calculation type

Based on the documentation: PA_FY being of type N, and 1 being an Integer, then the calculation type will be Packed (type P).

Consequently, PA_FY1 is also defined as type P.

If you comment the erroneous code, and if you debug, you'll be able to see the real type of PA_FY1.

Share
10 |10000 characters needed characters left characters exceeded
Raghu Govindarajan Oct 17, 2016 at 04:05 PM
5

Taking both Horst Keller's response and Sandra Rossi's into account, you could combine them and use the statement

DATA(PA_FY1) = CONV gjahr( PA_FY + 1 ).

This will force the data type gjahr onto PA_FY1.

Share
10 |10000 characters needed characters left characters exceeded
Horst Keller
Oct 15, 2016 at 12:40 PM
4

Besides all the other correct answers here, think about using the CONV operator in order to enforce the correct type at operand positions. Then, you cannot use CONCATENATE but &&:

... = ... && CONV string( ... ) && ...

Horst

Share
10 |10000 characters needed characters left characters exceeded
Horst Keller
Oct 17, 2016 at 04:41 PM
0

or

DATA(FIN_STRT_DATE) = CONV string( PA_FY1 ) && '04' && '01'.

FIN_STRT_DATE will have type string.

Share
10 |10000 characters needed characters left characters exceeded
Jacques Nomssi Oct 14, 2016 at 10:24 AM
-3

Your statement

DATA(PA_FY1)= PA_FY +1.

is not valid because the type of the defined variable PA_FY1 cannot be determined from the left hand side of the term: PA_FY is character-like, 1 is a number. So which type should the compiler use? That is how the error message should be understood, I guess.

And you probably mean

DATA PA_FY1 TYPE GJAHR

as

DATA(PA_FY1)TYPE GJAHR.

is not valid ABAP.

JNN

Share
10 |10000 characters needed characters left characters exceeded
Revolla Fernandes Oct 14, 2016 at 02:45 PM
-4

"PA_FY1" must be character-type data object (data type C,N,D,T or string) is self explanatory.

But DATA(PA_FY1)= PA_FY +1. is not a valid ABAP stmt, how does it not throw you an error?

Show 1 Share
10 |10000 characters needed characters left characters exceeded

DATA(PA_FY1) = PA_FY + 1.

is a valid statement as of ABAP 7.40

The syntax error is probably for this line, because PA_FY1 is of type P :

CONCATENATE PA_FY1 '03' '31' INTO DATA(FIN_END_DATE).
0