‎2007 Feb 19 5:57 AM
i have two tables zfm_handy (key fields r telnum and kartnr ) and zfmkstel key fields r telnum and nrart) i m writtin coding for based on zfm_handy key fields to get the corresponding data filled by using report.their new requirement is telnum is the telephone number +49(151)11111111 fot this telnum nrart and proz1 fields showing blank thwy ask me u must fill these fields nrart = 'h'(key field) and proz1 = 100,00( not a key field) . how can i fill with this record.
data : fs_zfm_handy like zfm_handy,
fs_zfmkstel like zfmkstel,
fs_temp_zfm_handy like zfm_handy,
fs_temp_zfmkstel like zfmkstel.
data : t_table1 like table of fs_zfm_handy.
data : ok_code type sy-ucomm,
save_ok like sy-ucomm.
data : f1_rec type i.
*
*data : w_telnum like fs_temp_zfm_handy-telnum,
w_kartnr like fs_temp_zfm_handy-kartnr.
*
*data : ok_code(4).
call screen 600.
----
MODULE status_0600 OUTPUT
----
*
----
module status_0600 output.
set pf-status 'ZSTATUS'.
loop at screen.
*if screen-name = fs_temp_zfmkstel-kostl1 or screen-name = fs_temp_zfm_handy-zutart or
screen-name = fs_temp_zfm_handy-pernr or screen-name = fs_temp_zfm_handy-zdate or
screen-name = fs_temp_zfm_handy-pinnr or screen-name = fs_temp_zfm_handy-puknr or
screen-name = fs_temp_zfm_handy-tarif1 or screen-name = fs_temp_zfm_handy-tarif2 or
screen-name = fs_temp_zfm_handy-tarif3 or screen-name = fs_temp_zfm_handy-gtype or
screen-name = fs_temp_zfm_handy-imei or screen-name = fs_temp_zfm_handy-twincard or
screen-name = fs_temp_zfm_handy-twinbill or screen-name = fs_temp_zfm_handy-einbau or
screen-name = fs_temp_zfm_handy-beschr or screen-name = fs_temp_zfm_handy-text1 or
screen-name = fs_temp_zfm_handy-text2 or screen-name = fs_temp_zfm_handy-text3.
if screen-name = fs_temp_zfmkstel-kostl1.
if f1_rec = 1.
screen-input = 0.
else.
screen-input = 1.
endif.
modify screen.
endif.
endloop.
endmodule. "status_0600 OUTPUT
----
MODULE USER_COMMAND_0600 INPUT
----
*
----
MODULE USER_COMMAND_0600 INPUT.
*ok_save = ok_code.
save_ok = ok_code.
CLEAR OK_CODE.
**
*CASE ok_code.
case save_ok.
when 'SAVE'.
IF f1_rec ne 1 .
if sy-subrc = 0.
update zfm_handy from fs_temp_zfm_handy.
insert zfm_handy from fs_temp_zfm_handy.
MODIFY zfm_handy from fs_temp_zfm_handy.
if sy-subrc = 0.
insert zfmkstel from fs_temp_zfmkstel.
if sy-subrc = 0.
fs_temp_zfmkstel-telnum = fs_temp_zfm_handy-telnum.
commit work.
INSERT ZFMKSTEL FROM FS_TEMP_ZFMKSTEL.
if sy-subrc = 0.
message s000(0) with 'record havebeen updated successfully'.
MODIFY ZFMKSTEL FROM FS_TEMP_ZFMKSTEL.
else.
delete zfm_handy from fs_temp_zfm_handy.
endif.
endif.
else.
update zfm_handy from fs_temp_zfm_handy.
if sy-subrc eq 0.
fs_temp_zfmkstel-telnum = fs_temp_zfm_handy-telnum.
update zfmkstel from fs_temp_zfmkstel.
if sy-subrc eq 0.
message s000(0) with 'update sucessfully'.
endif.
endif.
endif.
endif.
WHEN 'NEW'.
Clear fs_temp_zfm_handy.
clear fs_temp_zfmkstel.
clear f1_rec.
WHEN 'EXIT'.
LEAVE PROGRAM.
when OTHERS.
if fs_temp_zfm_handy-telnum ne fs_zfm_handy-telnum or
fs_temp_zfm_handy-kartnr ne fs_zfm_handy-kartnr.
clear f1_rec.
if not fs_temp_zfm_handy-telnum is initial.
if fs_temp_zfm_handy-kartnr is initial.
clear: w_telnum , w_kartnr.
move fs_temp_zfm_handy-telnum to w_telnum.
move fs_temp_zfm_handy-kartnr to w_kartnr.
select * from zfm_handy into table t_table1 where telnum = fs_temp_zfm_handy-telnum.
IF sy-subrc EQ 0 and sy-dbcnt GT 1.
message s000(0) with 'Mob:Nr has more that 1 entry. Please enter Karten number also to select the desired record'.
ELSEIF
sy-subrc EQ 0 and sy-dbcnt EQ 1.
read table t_table1 into fs_zfm_handy index 1.
If sy-subrc eq 0.
fs_temp_zfm_handy = fs_zfm_handy.
f1_rec = 1.
endif.
endif.
else.
select single * from zfm_handy into fs_zfm_handy where telnum = fs_temp_zfm_handy-telnum
and kartnr = fs_temp_zfm_handy-kartnr.
If sy-subrc eq 0.
fs_temp_zfm_handy = fs_zfm_handy.
f1_rec = 1.
endif.
endif.
if f1_rec = 1.
select single * from zfmkstel into fs_zfmkstel where telnum = fs_temp_zfm_handy-telnum.
If sy-subrc eq 0.
fs_temp_zfmkstel = fs_zfmkstel.
endif.
endif.
endif.
endif.
endcase.
endmodule. "USER_COMMAND_0600 INPUT
‎2007 Feb 19 6:13 AM
SORRY I DINT GO THROUGH YOUR FULL CODING BUT WHAT I CAN UNDERSTAND YOU WANT TO MODIFY SOME EXISTING VALUE IN DATABASE TABLE.
JUST DO LIKE THAT.
SELECT F1 F2 FROM DBTAB WHERE F1 = <VALUE>.
HERE F1 IS THE KEY FIELD.
IF SY-SUBRC = 0.
UPDATE DBTAB SET F2 = <VALUES> WHERE F1 = <VALUE>.
COMMIT WORK.
ENDIF.
ONLY F1 IS THE KEY FIELD HERE.
REGARDS
SHIBA DUTTA
‎2007 Feb 19 6:32 AM
Hi,
I hope the problem is here,
when 'SAVE'.
IF f1_rec ne 1 .
* if sy-subrc = 0.
* update zfm_handy from fs_temp_zfm_handy.
insert zfm_handy from fs_temp_zfm_handy.<b>( Here check whether fs_temp_zfm_handy is having the value for the fields nrart and proz1 )</b>
* MODIFY zfm_handy from fs_temp_zfm_handy.
* if sy-subrc = 0.
* insert zfmkstel from fs_temp_zfmkstel.
if sy-subrc = 0.
fs_temp_zfmkstel-telnum = fs_temp_zfm_handy-telnum.<b>Add
fs_temp_zfmkstel-nrart = fs_temp_zfm_handy-nrart.
fs_temp_zfmkstel-proz1 = fs_temp_zfm_handy-proz1.</b>
commit work.
INSERT ZFMKSTEL FROM FS_TEMP_ZFMKSTEL.
if sy-subrc = 0.
message s000(0) with 'record havebeen updated successfully'.
* MODIFY ZFMKSTEL FROM FS_TEMP_ZFMKSTEL.
else.
delete zfm_handy from fs_temp_zfm_handy.
endif.
endif.
else.
update zfm_handy from fs_temp_zfm_handy.
if sy-subrc eq 0.
fs_temp_zfmkstel-telnum = fs_temp_zfm_handy-telnum.<b>Add
fs_temp_zfmkstel-nrart = fs_temp_zfm_handy-nrart.
fs_temp_zfmkstel-proz1 = fs_temp_zfm_handy-proz1.</b>
update zfmkstel from fs_temp_zfmkstel.
* if sy-subrc eq 0.
* message s000(0) with 'update sucessfully'.
* endif.
endif.
endif.
* endif.Try to debug and compare with the table so taht u can figure out exactly where the problem is occuring.