‎2017 Nov 29 5:36 AM
Hello guys, I can not modify an internal table in a subrutine, if I put my code out of subrutine it is possible but in a subroutine is not possible. Please see:
FORM f_zpr0 TABLES I_IT_MATERIALES.
SELECT SINGLE * FROM A306 INTO WA_A306
WHERE KAPPL = 'V'
AND KSCHL = V_CONDICION "****** Se realiza busqueda por precio normal ZPR0 ************
AND MATNR = WA_MATERIALES-MATNR
AND VKORG = WA_MATERIALES-VKORG
AND VTWEG = WA_MATERIALES-VTWEG
AND DATBI >= SY-DATUM.
IF SY-SUBRC NE 0.
SELECT SINGLE * FROM A304 INTO WA_A304
WHERE KAPPL = 'V'
AND KSCHL = V_CONDICION
AND MATNR = WA_MATERIALES-MATNR
AND VKORG = WA_MATERIALES-VKORG
AND VTWEG = WA_MATERIALES-VTWEG
AND DATBI >= SY-DATUM.
ELSE.
WA_MATERIALES-ZPR0 = WA_A306-KNUMH.
MODIFY I_IT_MATERIALES FROM WA_MATERIALES TRANSPORTING ZPR0.
V_CONDICION = 'ZPR2'.
ENDIF.
ENFORM.
I get the follow error:
The specified type does not have a structure and therefore does not have a component called "ZPR0".

‎2017 Nov 29 6:29 AM
‎2017 Nov 29 6:29 AM
‎2017 Nov 29 9:36 AM
There is no type defined for Table I_IT_MATERIALS.
System is not getting the type for the same so you are getting error.
It might be working in the program because you have defined table I_IT_MATERIALS there itself so program was getting proper structure.
While taking the table into the subroutine,type the structure also.
‎2017 Nov 29 5:13 PM
In addition to all that was said here, try to avoid subroutines and move into classes as subroutines are obsolete. In new programs, methods must be used instead.
.