Skip to Content
avatar image
-2
Former Member

Modify internal table in a subroutine

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".

error.png (10.2 kB)
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Nov 29, 2017 at 06:29 AM

    You didn't 'type' the parameter of the internal table, you didn't define any local variable, you didn't loop or read the internal table, you didn't explicitly provide the record to modify, no index, no key, in the internal tables, etc.

    Add comment
    10|10000 characters needed characters exceeded

  • Nov 29, 2017 at 05: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.

    .

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Nov 29, 2017 at 09: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.

    Add comment
    10|10000 characters needed characters exceeded