INSERT or MoDIFY statement
hi,
I have to insert a data for my ztable,for 1st time it is updating the data,but for the second time (since all the key fields are same as 1st record),it is going to modify the data in my table.(since i have used modify statement),But i want both the records.
any idea?
hi
MODIFY - Will update the table, if the data already exists, if NOT inserts new rows.
UPDATE - Will update the table, errors out if the data is not found.
In case of MODIFY the sy-subrc is always 0 so you would't know whether the data is actually updated or not.
INSERT - Inserting Data in Database Tables
Update Modify Insert stmts we use when we want to do some change / Insertion
(1) to database table from internal table or
(2) from work area to internal table.
( AA ) Update
If the intended record in the internal table is found in databse table means it will just update that record.
syntax to update database table from itab:::::
UPDATE dbtab FROM TABLE itab
Changes to lines made with the UPDATE command only becomefinal after a database commit
Without using internal table we can update database table directly as shown below:::::::::::::::::::::
TABLES SFLIGHT.
UPDATE SFLIGHT SET SEATSOCC = SEATSOCC + 3
WHERE CARRID = 'LH' AND
CONNID = '0400' AND
FLDATE = '19950228'.
( BB ) Modify is used to insert new record if the record doesnt exist in datbase table.system check this on primary key basis.
If the intended record in the internal table is found in databse table means it will just update that record.So here its equal to UPDATE stmt.
For changes to database table we use syntax as below ::::
MODIFY DatabaseTable FROM TABLE itab.
For changes to Internal table we use syntax as below ::::
MODIFY itab FROM wa INDEX idx.
http://TRANSPORTING f1 ... fn WHERE cond.
( CC ) Insert stmt is used to insert New records into databse table from internal table or to internal table from work area.
By default, data is only inserted in the current client. However, ifyou use the CLIENT SPECIFIED addition, you can switch off theautomatic client handling.
You cannot insert a table line if the table alreadycontains a record with the same primary key.
Syntax::::::::::
INSERT INTO dbtab CLIENT SPECIFIED VALUES wa.
or
INSERT (dbtabname) CLIENT SPECIFIED FROM TABLE itab.
Example
Adding customer "Robinson" to client 002:
TABLES SCUSTOM.
SCUSTOM-MANDT = '002'.
SCUSTOM-ID = '12400177'.
SCUSTOM-NAME = 'Robinson'.
SCUSTOM-POSTCODE = '69542'.
SCUSTOM-CITY = 'Heidelberg'.
SCUSTOM-CUSTTYPE = 'P'.
SCUSTOM-DISCOUNT = '003'.
SCUSTOM-TELEPHONE = '01234/56789'.
INSERT INTO SCUSTOM CLIENT SPECIFIED VALUES SCUSTOM.
Re: difference update and insert
The specified item was not found.
/message/4622903#4622903 [original link is broken]
regards,
Vipul
Similar Messages
-
Database Updation and Insertion using Modify Statement
Hi All,
I am using Modify statment for data insertion and updation
MODIFY zmpit_ven_bgg_rg FROM TABLE t_ven_bgg .
But I am getting error
The type of the database table and work area (or internal table) "T_VEN_BGG" are not compatible.
I have defined my internal table of below type :
TYPES : BEGIN OF ty_ven_bgg,
mandt TYPE mandt,
lifnr TYPE lfa1-lifnr,
bgg TYPE zmpit_ven_bgg_rg-matkl,
ind TYPE zmpit_ven_bgg_rg-active_ind,
created_by TYPE zmpit_ven_bgg_rg-created_by,
created_on TYPE zmpit_ven_bgg_rg-created_on,
last_changed_by TYPE zmpit_ven_bgg_rg-last_changed_by,
last_changed_on TYPE zmpit_ven_bgg_rg-last_changed_on,
remarks TYPE zmpit_ven_bgg_rg-remarks,
ind1(1) TYPE c,
END OF ty_ven_bgg.
Here, ind1 is not field of the table.
I have added a new field Remarks in the table and thus i included it in the Internal table also.
Above Modify statement was working fine without Remarks field. I am not able to understand the error
as work area is also of type ty_ven_bgg.
Please suggest some solution.
Regards,
NibhaHi,
Though you have creaated one more internal tsble without the indc field, but you can do it using the same intrenal table by simply using
1. MOVE-CORRESPONDING <internal table> to <ztable>.
2.MODIFY <ztable>.
will solve your problem
Secondly declare the internal table using DATA after structure has been declared using TYPES.
This is better approach to follow.
Pooja -
Insert or Modify statement from internal table to database table
Hi All,
I have three tables wakh, wrf and wakp. I have an internal table with 5 columns col1, col2, col3, col4 and col5.
The value in Col1 is my article no and the articleno. is in the table wakh. The value in col2 is my ccode and it is in the table wrf. The rest three columns col3, col4 and col5 are unit, qty and price and they are in the wakp table. Now when my articleno is equal to ccode I need to update the col3, col4 and col5 values in the wakp. wakp has around 20 columns.
Can anyone of you guys please give me the code for this issue. Your help is highly appreciated and thanks for all for your time.
Cheers,
ChengHi Rob,
let me explain you the whole process what i am trying to do. I have a screen where there are 3 fields. In my first field I have a promoiton no. As soon as the user enters the promotion no. its description will be populated in my second field. If the promotion is not maintained then it will throw an error. In my third field User will upload an excel sheet which has 5 columns articleno, colorcode, salesunit, qty, mdprice. Here articleno is coming from wakh and colorcode is in wrf_charval table and the rest three fields are coming from wakp table. So for the article no. which is in col1. and for its corresponding colorcode which is in col3 i need to update col3, col4, col5 values.
With my below code I am able to upload the excel into internal table and display it. So instead of displaying I need to update in the database. Can you please let me know how I need to attach the function module within my code and update accordingly.
REPORT ZTest.
tables : wakh, wakt.
Parameter: PromoID type wakh-aktnr, PromoDec type wakt-aktkt, p_file LIKE rlgrap-filename
DEFAULT 'c:\test.xls' OBLIGATORY. " File Name
*FileName type string.
*file_nm type localfile.
TYPES: BEGIN OF t_datatab,
col1(25) TYPE c,
col2(30) TYPE c,
col3(30) TYPE c,
col4(30) TYPE c,
col5(30) TYPE c,
END OF t_datatab.
DATA: it_datatab TYPE STANDARD TABLE OF t_datatab INITIAL SIZE 0,
wa_datatab TYPE t_datatab.
Data : p_table type t_datatab occurs 0 with header line.
DATA : gd_scol TYPE i VALUE '1',
gd_srow TYPE i VALUE '2',
gd_ecol TYPE i VALUE '5',
gd_erow TYPE i VALUE '65536'.
DATA: it_tab TYPE filetable,
gd_subrc TYPE i.
field-symbols : <fs>.
AT selection-screen on PromoID.
select single * from wakh where aktnr = PromoID.
if sy-subrc EQ 0.
select aktkt from wakt into PromoDec where aktnr eq PromoID.
endselect.
else.
message A000(ZI) with 'Promotion ID is not Maintained.'.
endif.
*Title : Excel Uploading
*Selection screen definition
*SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
*PARAMETERS: p_file LIKE rlgrap-filename
DEFAULT 'c:\test.xls' OBLIGATORY. " File Name
*SELECTION-SCREEN END OF BLOCK b1.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
REFRESH: it_tab.
CALL METHOD cl_gui_frontend_services=>file_open_dialog
EXPORTING
window_title = 'Select File'
default_filename = '*.xls'
multiselection = ' '
CHANGING
file_table = it_tab
rc = gd_subrc.
LOOP AT it_tab INTO p_file.
so_fpath-sign = 'I'.
so_fpath-option = 'EQ'.
append so_fpath.
ENDLOOP.
START-OF-SELECTION.
PERFORM upload_excel_file TABLES it_datatab
USING p_file
gd_scol
gd_srow
gd_ecol
gd_erow.
END-OF-SELECTION.
END-OF-SELECTION.
LOOP AT it_datatab INTO wa_datatab.
WRITE:/ wa_datatab-col1,
wa_datatab-col2,
wa_datatab-col3,
wa_datatab-col4,
wa_datatab-col5.
ENDLOOP.
*& Form UPLOAD_EXCEL_FILE
upload excel spreadsheet into internal table
-->P_TABLE Table to return excel data into
-->P_FILE file name and path
-->P_SCOL start column
-->P_SROW start row
-->P_ECOL end column
-->P_EROW end row
FORM upload_excel_file TABLES p_table
USING p_file
p_scol
p_srow
p_ecol
p_erow.
DATA : lt_intern TYPE kcde_cells OCCURS 0 WITH HEADER LINE.
Has the following format:
Row number | Colum Number | Value
i.e. 1 1 Name1
2 1 Joe
DATA : ld_index TYPE i.
Note: Alternative function module - 'ALSM_EXCEL_TO_INTERNAL_TABLE'
CALL FUNCTION 'KCD_EXCEL_OLE_TO_INT_CONVERT'
EXPORTING
filename = p_file
i_begin_col = p_scol
i_begin_row = p_srow
i_end_col = p_ecol
i_end_row = p_erow
TABLES
intern = LT_INTERN
EXCEPTIONS
inconsistent_parameters = 1
upload_ole = 2
OTHERS = 3.
IF sy-subrc <> 0.
FORMAT COLOR COL_BACKGROUND INTENSIFIED.
WRITE:/ 'Error Uploading file'.
EXIT.
ENDIF.
IF lt_intern[] IS INITIAL.
FORMAT COLOR COL_BACKGROUND INTENSIFIED.
WRITE:/ 'No Data Uploaded'.
EXIT.
ELSE.
SORT lt_intern BY row col.
LOOP AT lt_intern.
MOVE lt_intern-col TO ld_index.
assign component ld_index of structure
p_table to <fs>.
move : lt_intern-value to <fs>.
MOVE lt_intern-value TO p_table.
AT END OF row.
APPEND p_table.
CLEAR p_table.
ENDAT.
ENDLOOP.
ENDIF.
ENDFORM.
Thanks for your valuable time.
Cheng -
How to use "where" clause in modify statement
Hi
can any1 telll me is it possible to use a where clause in a modify statemetn. I want to use modify statemetn to insert a new recoed in a database table.
Regards
Sabahuddin AhmedMODIFY itab - itab_lines
Syntax :
... itab FROM wa TRANSPORTING comp1 comp2 ... WHERE log_exp.
With these additions the MODIFY statement assigns the content of the comp1 comp2 ... components of the wa work area specified after TRANSPORTING to all lines in the itab table that meet the logical condition log_exp. The wa work area must be compatible with the line type of the internal table.
The TRANSPORTING addition has the same effect as changing individual lines. The WHERE addition can only be specified together with the TRANSPORTING addition. After WHERE, any logical expression can be specified in which the first operand of each individual comparison is a component of the internal table. All logical expressions are therefore possible, with the exception of IS ASSIGNED, , and IS SUPPLIED. It is not possible to dynamically specify a component using bracketed character-type data objects.
While for standard tables and hashed tables all lines in the internal table are checked for the logical expression of the WHERE statement, for sorted tables, optimized access can be achieved by checking at least one opening part of the table key for parity using AND linked queries in the logical expression.
Example
Change the contents of the planetype component for all lines in the sflight_tab internal table in which this component contains the value p_plane1 to the value p_plane2.
PARAMETERS: p_carrid TYPE sflight-carrid,
p_connid TYPE sflight-connid,
p_plane1 TYPE sflight-planetype,
p_plane2 TYPE sflight-planetype.
DATA sflight_tab TYPE SORTED TABLE OF sflight
WITH UNIQUE KEY carrid connid fldate.
DATA sflight_wa TYPE sflight.
SELECT *
FROM sflight
INTO TABLE sflight_tab
WHERE carrid = p_carrid AND
connid = p_connid.
sflight_wa-planetype = p_plane2.
MODIFY sflight_tab FROM sflight_wa
TRANSPORTING planetype WHERE planetype = p_plane1.
reward if useful -
Hi,
When i am trying to update a z table by using modify statement, i am getting the following error:
Short text
SQL error in the database when accessing a table.
What happened?
When writing a data record to the database (i.e. when
updating the database), only part of the data field was
written (updated). The rest was truncated.
Error analysis
An exception occurred that is explained in detail below.
The exception, which is assigned to class 'CX_SY_OPEN_SQL_DB', was not caught
in
procedure "FILLTABLE" "(FORM)", nor was it propagated by a RAISING clause.
Since the caller of the procedure could not have anticipated that the
exception would occur, the current program is terminated.
The reason for the exception is:
The problem has arisen because, within the database interface,
one of the data buffers made available for the INSERT (UPDATE)
is longer than the maximum defined in the database.
On the other hand, it may be that the length in the NAMETAB
does not match the maximum length defined in the database.
(In this case, the length in the NAMETAB is longer.)
Please guide me how this error can be resolved.
Thanks and RegardsHi,
The error message is as follows:
Short text
SQL error in the database when accessing a table.
What happened?
When writing a data record to the database (i.e. when
updating the database), only part of the data field was
written (updated). The rest was truncated.
Error analysis
An exception occurred that is explained in detail below.
The exception, which is assigned to class 'CX_SY_OPEN_SQL_DB', was not caught
in
procedure "FILLTABLE" "(FORM)", nor was it propagated by a RAISING clause.
Since the caller of the procedure could not have anticipated that the
exception would occur, the current program is terminated.
The reason for the exception is:
The problem has arisen because, within the database interface,
one of the data buffers made available for the INSERT (UPDATE)
is longer than the maximum defined in the database.
On the other hand, it may be that the length in the NAMETAB
does not match the maximum length defined in the database.
(In this case, the length in the NAMETAB is longer.)
Moderator message - Please respect the 2,500 character maximum when posting. Post only the relevant portions of dump
Edited by: Rob Burbank on May 1, 2010 5:59 PM -
Insert or modifying employee status in pa0000 using HR_MAINTAIN_MASTERDATA
hi abapers
i am using HR_MAINTAIN_MASTERDATA to insert or modify employee status (pa0000-stat1).
IN HR_MAINTAIN_MASTERDATA there is return statement. and i am giving BAPIRETURN1.and pass data to proposed_values table.
when i check return iIS iNITIAL or not. return is coming initial. what does it mean??
actually i am new in HR module. plz help
thanks
SachinIf you paste the code where you call the Function Module it will help. You don't pass anything to Return, this is where the system places the information after you call the Function Module. If Return-Type is ' ' or Return-Type = 'I', it should indicate that the function module did what you wanted.
-
SQL Error in the modify statement
Hi All,
We are facing an SQL error while uploading an archive file. The error is
caused while executing a modify statement which leads to a dump. The
text given in the SM21 logs is
'Database error -1 with SEL access to table SMMW_MCD_DMY_AVE'
The dump generated in ST22 says DBIF_RSQL_SQL_ERROR
Database error text........: "[Microsoft][SQL Native Client]Session Provider:
Connection has been closed by peer [xFFFFFFFF]. "
Any pointers to figure out how to resolve this could be really helpful.
Regards,
LijiHi,
This sounds like internal message 0000062076 2010
which I'm currently working on.
If it is this BUZ-upload problem: ask your system responsible to set the instance profile parameter
dbs/mss/packet_size=8192
After the R3-system is restarted, the transaction should work.
The problem was caused by an UPSERT-command writing a 170 MB BLOB.
UPSERT means: all values for the row are provided. Try first an UPDATE, if this fails with NOT FOUND insert.
This UPDATE, IF NOT FOUND INSERT is send as one batch to the database server.
For SQL Server 9.00, a batch may only
consist of 64K network packets. The default network packet size is 4K. 4K * 64KB == 256 MB.
The 170 MB BLOB is sent twice, so we don't fit in the 64K packets.
This breaks the connection and you get on client side the"Connection has been closed by peer".
On server side you see (SQL Server error log) "A fatal error occurred while reading the input stream from the network. The session will be terminated."
If you want to increase the network packet size used by your db connections in the SAP work processes, you can use the profile parameter
dbs/mss/packet_size.
Maximal setting is 32767. In your case I would recommend 8192.
Best regards,
Guenther
Edited by: Guenther Drach on Jan 7, 2010 3:13 PM
Edited by: Guenther Drach on Jan 7, 2010 3:15 PM -
Number of rows inserted is different in bulk insert using select statement
I am facing a problem in bulk insert using SELECT statement.
My sql statement is like below.
strQuery :='INSERT INTO TAB3
(SELECT t1.c1,t2.c2
FROM TAB1 t1, TAB2 t2
WHERE t1.c1 = t2.c1
AND t1.c3 between 10 and 15 AND)' ....... some other conditions.
EXECUTE IMMEDIATE strQuery ;
These SQL statements are inside a procedure. And this procedure is called from C#.
The number of rows returned by the "SELECT" query is 70.
On the very first time call of this procedure, the number rows inserted using strQuery is *70*.
But in the next time call (in the same transaction) of the procedure, the number rows inserted is only *50*.
And further if we are repeating calling this procedure, it will insert sometimes 70 or 50 etc. It is showing some inconsistency.
On my initial analysis it is found that, the default optimizer is "ALL_ROWS". When i changed the optimizer mode to "rule", this issue is not coming.
Anybody faced these kind of issues?
Can anyone tell what would be the reason of this issue..? any other work around for this...?
I am using Oracle 10g R2 version.
Edited by: user13339527 on Jun 29, 2010 3:55 AM
Edited by: user13339527 on Jun 29, 2010 3:56 AMYou have very likely concurrent transactions on the database:
>
By default, Oracle Database permits concurrently running transactions to modify, add, or delete rows in the same table, and in the same data block. Changes made by one transaction are not seen by another concurrent transaction until the transaction that made the changes commits.
>
If you want to make sure that the same query always retrieves the same rows in a given transaction you need to use transaction isolation level serializable instead of read committed which is the default in Oracle.
Please read http://download.oracle.com/docs/cd/E11882_01/appdev.112/e10471/adfns_sqlproc.htm#ADFNS00204.
You can try to run your test with:
set transaction isolation level serializable;If the problem is not solved, you need to search possible Oracle bugs on My Oracle Support with keywords
like:
wrong results 10.2Edited by: P. Forstmann on 29 juin 2010 13:46 -
Problem in modifying a table through modify statement
Hi,
I am trying to update a 'Z' table in which there are 5 fields comprising of primary key. Out of them 2 key fields are defined as a part of seconadry index with 'Unique' option selected.
As per the requirement, I am trying to update the table using modify statement so whenever this statement occurs it will check the primary keys and accordingly try to modify a record or insert a new record.
But as there is Unique Index defined on 2 of the key fields the Modify query isHi,
Your syntax for MODIFY is not correct.
As other friends suggested you can have index and you can modify the internal table.
Whenever we are modifying internal table inside LOOP, we can omit index as system will take current row by default. So MODIFY statement should be written as follows:
MODIFY T_ITPO5 from W_ITPO5 transporting AUFNR
You can LOOP FROM INDEX also for the same to improve performance.
data: wv_index like sy-tabix.
sort T_ITPO5 by aufnr.
sort T_ITPO4 by aufnr.
wv_index = 1.
LOOP AT T_ITPO5 INTO W_ITPO5.
LOOP AT T_ITPO4 INTO W_ITPO4 from wv_index.
if W_ITPO4-aufnr eq W_ITPO5-aufnr.
IF ITPO4-NTGEW 0 .
CALL FUNCTION 'ZGET_ITEM_WEIGHT'
EXPORTING
P_BUID = W_ITPO4-WERKS
P_ITEMID = W_ITPO4-MATNR
P_QTY = 1
P_UOM = W_ITPO4-MEINS
P_UOM1 = 'KG'
IMPORTING
P_RETVAL = W_ITPO4-WTKG.
TOTWT1 = W_ITPO4-WTKG * W_ITPO4-MENGE.
IF W_ITPO4-BWART = '261'.
W_ITPO5-I_QTY = W_ITPO5-I_QTY + TOTWT1.
ELSEIF W_ITPO4-BWART = '101' OR W_ITPO4-BWART = '531'.
W_ITPO5-I_QTY = W_ITPO5-I_QTY - TOTWT1.
ENDIF. " IF W_ITPO4-BWART = '261'.
endif.
elseif W_ITPO4-aufnr gt W_ITPO5-aufnr.
move sy-tabix to wv_index.
exit.
endif. " if W_ITPO4-aufnr eq W_ITPO5-aufnr.
ENDLOOP.
MODIFY T_ITPO5 FROM W_ITPO5 transporting aufnr.
ENDLOOP. -
How to replace the update staement with a modify statement
how to convert this update stat to a modify stat?
Message was edited by:
Ashwin AHi
MODIFY <DB TABLE> FROM <INTERNAL TABLE>
To insert or change a single line in a database table, use the following:
MODIFY <target> FROM <wa> .
The contents of the work area <wa> are written to the database table <dbtab>. The work area <wa> must be a data object with at least the same length and alignment as the line structure of the database table. The data is placed in the database table according to the line structure of the table, and regardless of the structure of the work area. It is a good idea to define the work area with reference to the structure of the database table.
If the database table does not already contain a line with the same primary key as specified in the work area, a new line is inserted. If the database table does already contain a line with the same primary key as specified in the work area, the existing line is overwritten. SY-SUBRC is always set to 0.
A shortened form of the above statement is:
MODIFY <dbtab>.
In this case, the contents of the table work area <dbtab> are inserted into the database table with the same name. You must declare this table work area using the TABLES statement. In this case, it is not possible to specify the name of the database table dynamically. Table work areas with the same name as the database table (necessary before Release 4.0) should no longer be used for the sake of clarity.
Reward points if useful
Regards
Anji -
Short dump - CX_SY_OPEN_SQL_DB during MODIFY statement
In production system, sometimes it dumps with this error:
Runtime Errors DBIF_RSQL_INVALID_RSQL
Exception CX_SY_OPEN_SQL_DB
And here is the code cause this problems:
CALL FUNCTION 'ENQUEUE_E_TABLE'
EXPORTING
mode_rstable = 'E'
tabname = 'ZVKN_TRPHIST'.
MODIFY zvkn_trsphist FROM TABLE lt_trsphist. <<<<<< Error
CALL FUNCTION 'DEQUEUE_E_TABLE'
EXPORTING
mode_rstable = 'E'
tabname = 'ZVKN_TRPHIST'.
IF sy-subrc EQ 0.
return-type = 'S'.
ELSE.
ROLLBACK WORK.
return-type = 'E'.
ENDIF.
I have tried to use ENQUEUE statement with WAIT but no succeed. How to manage with no dump?Hi, thanks for your reply.
Did you mean that adding COMMIT WORK AND WAIT when ENQUEUE is success and before modify statement?
I not get it clearly. I use the code below. Is this ok to transport to Production?
CALL FUNCTION 'ENQUEUE_E_TABLE'
EXPORTING
MODE_RSTABLE = 'E'
TABNAME = 'ZVKN_TRPHIST'
* VARKEY =
* X_TABNAME = ' '
* X_VARKEY = ' '
* _SCOPE = '2'
_WAIT = 'X'
* _COLLECT = ' '
EXCEPTIONS
FOREIGN_LOCK = 1
SYSTEM_FAILURE = 2
OTHERS = 3
IF SY-SUBRC <> 0.
return-type = 'E'.
return-number = sy-msgno.
return-id = sy-msgid.
CALL FUNCTION 'MESSAGE_TEXT_BUILD'
EXPORTING
msgid = sy-msgid
msgnr = sy-msgno
msgv1 = sy-msgv1
msgv2 = sy-msgv2
msgv3 = sy-msgv3
msgv4 = sy-msgv4
IMPORTING
message_text_output = return-message.
ROLLBACK work.
RETURN.
ELSE.
COMMIT WORK AND WAIT.
MODIFY zvkn_trsphist FROM TABLE lt_trsphist.
CALL FUNCTION 'DEQUEUE_E_TABLE'
EXPORTING
mode_rstable = 'E'
tabname = 'ZVKN_TRPHIST'.
RETURN-type = 'S'.
ENDIF. -
Syntax error in modify statement
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,
SatishHi 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 -
Problem in using modify statement inside a Perform
Hi Experts,
loop at t_data into wa_data.
IF wa_data1-zbukrs IS INITIAL.
wa_data1-zstat = 'E'.
w_messg = 'Company code is blank in upload data'.
CONCATENATE wa_data1-zbukrs w_messg INTO w_msg
SEPARATED BY space.
CONCATENATE w_msg wa_data1-zmsg INTO w_msg
SEPARATED BY
'|'.
wa_data1-zmsg = w_msg.
MODIFY t_data1 FROM wa_data1.
endif.
IF wa_data1-zfwcd IS INITIAL.
wa_data1-zstat = 'E'.
w_messg = 'Forwarder code is blank in upload data'.
CONCATENATE wa_data1-zfwcd w_messg INTO w_msg
SEPARATED BY space.
CONCATENATE w_msg wa_data1-zmsg INTO w_msg
SEPARATED BY
'|'.
wa_data1-zmsg = w_msg.
MODIFY t_data1 FROM wa_data1.
endif.
IF wa_data1-zinvno IS INITIAL.
wa_data1-zmsg = w_msg.
MODIFY t_data1 FROM wa_data1.
wa_data1-zstat = 'E'.
w_messg = 'Invoice number is blank in upload data'.
CONCATENATE wa_data1-zinvno w_messg INTO w_msg
SEPARATED BY space.
CONCATENATE w_msg wa_data1-zmsg INTO w_msg
SEPARATED BY
'|'.
wa_data1-zmsg = w_msg.
MODIFY t_data1 FROM wa_data1.
endif.
endloop.
My doubt is:
wa_data1-zstat = 'E'.
w_messg = 'Company code is blank in upload data'.
CONCATENATE wa_data1-zbukrs w_messg INTO w_msg
SEPARATED BY space.
CONCATENATE w_msg wa_data1-zmsg INTO w_msg
SEPARATED BY
'|'.
wa_data1-zmsg = w_msg.
MODIFY t_data1 FROM wa_data1.
i want write the above code to be written in a perform statement
becos iam using the above code in multiple places in my program.
but the problem iam facing is modify not working in perform statement.
Regards,
Raj.hi Raj,
use FIELD-SYMBOLS so that you don't have to use MODIFY statement.
FIELD-SYMBOLS: <fs> like line of T_data.
loop at t_data ASSIGNING <fs>.
IF <fs>-zbukrs IS INITIAL.
<fs>-zstat = 'E'.
w_messg = 'Company code is blank in upload data'.
CONCATENATE <fs>-zbukrs w_messg INTO w_msg
SEPARATED BY space.
CONCATENATE w_msg <fs>-zmsg INTO w_msg
SEPARATED BY '|'.
<fs>-zmsg = w_msg.
endif.
IF <fs>-zfwcd IS INITIAL.
<fs>-zstat = 'E'.
w_messg = 'Forwarder code is blank in upload data'.
CONCATENATE <fs>-zfwcd w_messg INTO w_msg
SEPARATED BY space.
CONCATENATE w_msg <fs>-zmsg INTO w_msg
SEPARATED BY '|'.
<fs>-zmsg = w_msg.
endif.
endloop. -
Unicode error free MODIFY statement
HI All,
I have midify statement in a loop like this.
loop at itab into wa_itab.
modify itab from wa_itab index tabx.
endloop.
I am working in ECC 6.0. It is showing unicode error at modify statement. Please suggest me the correct statemnt.ANy extension for modify statemnt..?
Thanks,
kishoreLOOP AT IT_VBRK.
<b> CTAB = SY-TABIX.</b>
LOOP AT IT_T001 WHERE BUKRS = IT_VBRK-BUKRS.
IF SY-SUBRC = 0.
IT_VBRK-BUTXT = IT_T001-BUTXT.
<b> MODIFY IT_VBRK INDEX CTAB.</b>
CLEAR CTAB.
ENDIF.
ENDLOOP.
ENDLOOP.
The problem may be with SY-TABIX, check the above code -
Hi all ,
I have a problem in MODIFY statement.
I have 2 internal statement.
1. It_final and 2. it_tab.
The number of datas in it_tab is greater than it_final.
But i want to loop it_tab and modify the fields of it_final.
How can i do this.
Please help me to solve this <<text removed>>
Regards and thanks,
vidhya.
Edited by: Matt on Dec 20, 2008 6:49 PM "as early as possible." not permitted>
Vidhya M wrote:
> Can we modify it_final without looping it?
Yes we can.But only when you are trying to modify fields which have similar values though.
Syntax would be some like
MODIFY itab FROM wa TRANSPORTING f1 f2 ... WHERE cond.
Look at SAP help of [Changing Several Lines Using a Condition|http://help.sap.com/erp2005_ehp_04/helpdata/EN/fc/eb35eb358411d1829f0000e829fbfe/frameset.htm]
Maybe you are looking for
-
How can I cut and paste from Delta Computer Systems (land roles) to Google Docs using my new MacBook Pro?
-
Content in browser view is not aligned properly but looks fine in design/live view
Here is my site: www.kaleongdesigns.com Here is the coding: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head> <meta http-equiv="C
-
External Lacie hard Drive would not Mount on my imac
HI all, I have had this Hard Drive for a few years now, worked great, no issues at all. Even after upgrading to 10.8 it continued to work. A few days ago my cleaning lady moved the computer and disconected the Lacie drive (connected via Firewire) and
-
How to Add 15 Days to the current Date in eCATT
Hello eCATT Guru's, How to add 15 days to the current date in eCATT. I have changed the Date format to mm/dd/yyyy. now i want to add 15 days to the sy-datum. How to do that.do any one know? Thanks in Advance, Raj
-
N8-Switching Phone memory to Mass Storage
Hi N8's Phone memory is only 250MB. The default memory for storage mails and other stuff is phone memory. How can I switch to MASS STORAGE or MEMORY CARD. specially mailForExchange msgs? Thanks