‎2016 Oct 14 10:12 AM
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.
‎2016 Oct 14 1:02 PM
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.
‎2016 Oct 14 11:24 AM
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 GJAHRas
DATA(PA_FY1)TYPE GJAHR.is not valid ABAP.
JNN
‎2016 Oct 14 1:02 PM
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.
‎2016 Oct 14 3:51 PM
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).
‎2016 Oct 15 1:40 PM
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
‎2016 Oct 17 5:05 PM
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.
‎2016 Oct 17 5:41 PM
or
DATA(FIN_STRT_DATE) = CONV string( PA_FY1 ) && '04' && '01'.FIN_STRT_DATE will have type string.