Application Development 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: 

Syntax error in modify statement

Former Member
0 Kudos

Hi Friends,

There is an Internal table IT_STATUS which is the Parameter in BADI Method IF_EX_WORKORDER_UPDATE~BEFORE_UPDATE.

Below is the code i have written

Data:  wa_status type cobai_s_status,
                   stat TYPE TABLE OF jstat,
                   wa_stat type jstat.

      CALL FUNCTION 'STATUS_READ'
        EXPORTING
         client                 = sy-mandt
          objnr                  = gv_objnr
*     ONLY_ACTIVE            = ' '
*   IMPORTING
*     OBTYP                  =
*     STSMA                  =
*     STONR                  =
       TABLES
         status                 = stat
       EXCEPTIONS
         object_not_found       = 1
         OTHERS                 = 2
                .
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ELSE.
       loop at it_status into wa_status.
        read table stat into wa_stat with key STAT = wa_status-stat.
        if sy-subrc = 0.
         wa_status-stat = wa_stat-stat.
         wa_status-INACT = wa_stat-INACT.
         modify it_status from wa_status transporting stat inact.
        endif.
       endloop.
      ENDIF.

At Modify statement it is giving a syntax error 'The <b>field "IT_STATUS" cannot be changed.-</b>'. what could be the reason?

Please provide me the solution.

Thanks & Regards,

Satish

1 ACCEPTED SOLUTION

former_member195698
Active Contributor
0 Kudos

Hello Satish,

The table IT_STATUS is am Importing Parameter for the Method BEFORE_UPDATE and you cannot Modify the Importing parameter of a Method.

Regards,

Abhishek

11 REPLIES 11

Former Member
0 Kudos

I haven't tested this so no guarantees:

data: status_index type sy-tabix.       "<====

LOOP AT it_status INTO wa_status.
  status_index = sy-tabix.      "<=====
  READ TABLE stat INTO wa_stat WITH KEY stat = wa_status-stat.
  IF sy-subrc = 0.
    wa_status-stat = wa_stat-stat.
    wa_status-inact = wa_stat-inact.
    MODIFY it_status index status_index       "<=====
      FROM wa_status TRANSPORTING stat inact.
  ENDIF.
ENDLOOP.

Rob

0 Kudos

Sorry Rob, No Luck.

Thanks,

Satish

0 Kudos

Can you post your code with my modifications?

Rob

0 Kudos

Hi Rob,

This is the whole code which i had written in method

METHOD if_ex_workorder_update~before_update.
  DATA: gv_aufnr TYPE afih-aufnr,
        gv_objnr TYPE jest-objnr,
        stat TYPE TABLE OF jstat,
        wa_stat TYPE jstat,
        wa_header TYPE cobai_s_header,
        wa_status TYPE cobai_s_status,
        it_status_new TYPE cobai_t_status.

  DATA: status_index TYPE sy-tabix.
  BREAK-POINT.
  LOOP AT it_header INTO wa_header.
    SELECT SINGLE aufnr FROM afih INTO gv_aufnr WHERE warpl = wa_header-warpl AND abnum = 1.
    IF sy-subrc = 0.

      CONCATENATE 'OR' gv_aufnr INTO gv_objnr.
      CALL FUNCTION 'STATUS_READ'
        EXPORTING
         client                 = sy-mandt
          objnr                  = gv_objnr
*     ONLY_ACTIVE            = ' '
*   IMPORTING
*     OBTYP                  =
*     STSMA                  =
*     STONR                  =
       TABLES
         status                 = stat
       EXCEPTIONS
         object_not_found       = 1
         OTHERS                 = 2
                .
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ELSE.
        LOOP AT it_status INTO wa_status.
          status_index = sy-tabix.
          READ TABLE stat INTO wa_stat WITH KEY stat = wa_status-stat.
          IF sy-subrc = 0.
            wa_status-stat = wa_stat-stat.
            wa_status-inact = wa_stat-inact.
            MODIFY it_status INDEX status_index FROM wa_status TRANSPORTING stat inact.
          ENDIF.
        ENDLOOP.
      ENDIF.
    ENDIF.
  ENDLOOP.
ENDMETHOD.

Hope it will get resolved

Regards,

Satish

0 Kudos

Hello Satish,

The table IT_STATUS is am Importing Parameter for the Method BEFORE_UPDATE and you cannot Modify the Importing parameter of a Method.

Is this not correct??? Hope your issue is solved

Regards,

Abhishek

former_member195698
Active Contributor
0 Kudos

Hello Satish,

The table IT_STATUS is am Importing Parameter for the Method BEFORE_UPDATE and you cannot Modify the Importing parameter of a Method.

Regards,

Abhishek

0 Kudos

Abhishek,

Thanks for the reply, but IT_STATUS is updating the Work Order User Status with initial status after Creating the Work Order. I need to change that status.

Regards,

Satish

0 Kudos

I use the Field symbols to change the tables which are not changable.

Try like this in BADI.

  FIELD-SYMBOLS: <tab> type COBAI_T_STATUS.

  ASSIGN ('(SAPLCOIH)IT_STATUS') TO <tab>. 
 <tab> = IT_STATUS.
" SAPLCOIH  is main program
" IT_STATUS table you want to change of the program  - I am not sure which table you are changing from the main program.

Regards,

Naimesh Patel

0 Kudos

Hi Naimesh,

Thanks for the reply.

IT_STATUS is the table parameter in BADI Method IF_EX_WORKORDER_UPDATE~BEFORE_UPDATE.

This Internal table will update the System Status & User Status of the Work Order when it is created and updating.

Before updating the system status & User status, i need to change those values from the program to update with my values.

Hope you understood my scenario.

Regards,

Satish

0 Kudos

Hi Satish,

Do you mean to say that IT_STATUS is a "TABLES" parameter? Did you try using "CHANGING"?

Also, here's something that i found in SAP Help.

<b>For sorted tables and hashed tables, no table key components may be specified after TRANSPORTING.</b>

Have you checked it?

0 Kudos

Hi Satish,

years later, I have the same problem.

I'm sure, you have the solution for me.

Thanks in advance.

Wolfgang