‎2007 Sep 17 4:14 AM
Hi Gurus,
Could you please give me the code, on how can I use the modify with where statement to update dictionary table from an internal table. In this case, I don't want to use update with set statement as I have many fields.
Thanks,
David.
‎2007 Sep 17 4:18 AM
Hi,
Why do you need a WHERE clause for a MODIFY statement.
The DATA that is there in the WORKAREA you want to insert will ACT as the WHERE Cluase in MODIFY statement so you dont need WHERE clause for MODIFY.
SInce The values in the WORKAREA or the TABLE that you use in MODIFY will act as the condition for either INSERTING or UPDATING the database table you dont need WHERE CLAUSE.
So make sure that you populate all the PRIMARY KEY fields in the WORKAREA or the TABLE before you use MODIFY statement.
Cheers,
Simha.
‎2007 Sep 17 4:20 AM
<b>1st Type</b>
DATA message_wa TYPE t100.
DATA message_wa TYPE t100.
message_wa-sprsl = 'EN'.
message_wa-arbgb = 'MYMSGCLASS'.
message_wa-msgnr = '100'.
message_wa-text = 'Some new message ...'.
MODIFY t100 FROM message_wa.
<b>2nd Type</b>
DATA message_wa TYPE t100.
message_wa-sprsl = 'EN'.
message_wa-arbgb = 'MYMSGCLASS'.
message_wa-msgnr = '100'.
message_wa-text = 'Some new message ...'.
append message_wa to itab_message.
MODIFY t100 FROM itab_message.
MODIFY statement INSERT's a new record, if it doesnt find existing record.
‎2007 Sep 17 4:48 AM
hi,
TABLES : mkpf,
mseg,
zamatdoc,
mara.
DATA :BEGIN OF gi_mkpf OCCURS 100,
mblnr LIKE mkpf-mblnr,
mjahr LIKE mkpf-mjahr,
END OF gi_mkpf.
data gi_mseg like zamatdoc occurs 100 with header line.
DATA: BEGIN OF gi_mseg OCCURS 0.
INCLUDE STRUCTURE zamatdoc.
DATA: END OF gi_mseg.
DATA: gv_date(11)," LIKE ekpo-aedat,
gv_date1(11),
year(4),
month(2),
day(2),
flag(1),
read_flag(1).
DATA :char TYPE i,
count TYPE i.
*select-options : s_mtart for mara-mtart obligatory.
SELECTION-SCREEN: BEGIN OF BLOCK b1 WITH FRAME TITLE text-110.
SELECT-OPTIONS : records FOR char. " OBLIGATORY.
SELECTION-SCREEN : END OF BLOCK b1.
START-OF-SELECTION.
gv_date1 = sy-datum.
year = gv_date1+0(4).
month = gv_date1+4(2).
day = gv_date1+6(2).
year = year - 3.
CLEAR gv_date1.
CONCATENATE year month day INTO gv_date1.
CONCATENATE day month year INTO gv_date1.
SELECT mblnr
mjahr
FROM mkpf
INTO TABLE gi_mkpf
WHERE budat <= gv_date1.">" and BUDAT >= ).
IF sy-subrc = 0.
SORT gi_mkpf BY mblnr.
DELETE ADJACENT DUPLICATES FROM gi_mkpf.
CLEAR count.
IF NOT gi_mkpf[] IS INITIAL.
IF NOT records-low IS INITIAL .
IF NOT records-high IS INITIAL.
DESCRIBE TABLE gi_mkpf LINES count.
IF records-high < count.
DELETE gi_mkpf FROM records-high TO count.
ENDIF.
IF records-low <> 1.
IF records-low <> 0.
DELETE gi_mkpf FROM 1 TO records-low.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
SELECT matnr werks FROM mseg INTO CORRESPONDING FIELDS OF TABLE gi_mseg
PACKAGE SIZE 100 FOR ALL ENTRIES IN gi_mkpf
WHERE mblnr = gi_mkpf-mblnr
AND mjahr = gi_mkpf-mjahr.
MODIFY zamatdoc FROM TABLE gi_mseg.
COMMIT WORK.
ENDSELECT.
regards
siva
‎2007 Sep 17 4:54 AM
hi,
see this exp..
DATA: BEGIN OF TAB OCCURS 500,
FLAG TYPE C,
COMP(20) TYPE C,
END OF TAB.
CLEAR TAB-FLAG.
MODIFY TAB TRANSPORTING FLAG WHERE FLAG = 'X'.
regards,
‎2007 Sep 17 4:56 AM
Hi David.
You cannot use the Where Clause while MODIFYing the DB table from Internal Table.
Syntax:
MODIFY <DBTABLE> FROM TABLE <ITAB>.
This statement will MODIFY the record if it exists otherwise it will INSERT a new record.
So better to use.
UPDATE <DBTABLE> FROM TABLE <ITAB>.
<b>reward if Helpful.</b>