12-03-2007 6:41 PM
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
12-03-2007 7:22 PM
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
12-03-2007 7:04 PM
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
12-03-2007 7:08 PM
12-03-2007 7:20 PM
12-03-2007 7:24 PM
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
12-03-2007 7:27 PM
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
12-03-2007 7:22 PM
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
12-03-2007 7:29 PM
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
12-03-2007 8:28 PM
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
12-04-2007 9:42 AM
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
12-05-2007 5:48 AM
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?
02-18-2015 4:24 PM
Hi Satish,
years later, I have the same problem.
I'm sure, you have the solution for me.
Thanks in advance.
Wolfgang