2009 Feb 13 6:40 AM
hello,
i have a db table zproject_details.. it has 4 fields, proj_no(pri key), proj_name, orij_name, proj_type..
i have created 2 screens, in the 1st screen i enter the proj_no and press the 'NEXT' button to
call 2nd screen.
on the 2nd screen, there are 3 drop down list boxes in which proj_name, orij_name and proj_type
are retrieved(from zproject_details) and displayed...
if i change value of any of the field in screen 2, i have to update that record in the zproject_details
too.. so when any record is changed, i modify it in an internal table thus i can change more than
one record, and when i press 'SAVE' button, all changed records are modified in zproject_details.
this is what i have done,
module STATUS_0002 output. " ouyput of screen 2
SET PF-STATUS 'xxxxxxxx'.
SET TITLEBAR 'xxx'.
data : update1(2) value '0',
update2(2) value '0',
update3(2) value '0',
flag100(2) value '0'.
TYPES : begin of itab,
proj_no type zproject_details-proj_no,
proj_name type zproject_details-proj_name,
orig_name type zproject_details-orig_name,
proj_type type zproject_details-proj_type,
end of itab.
DATA : itab TYPE standard TABLE OF itab initial size 100
with header line,
wa type itab.
select single * from zproject_details
where proj_no = PROJ_NO.
if update1 ne 1.
move zproject_details-proj_name to ZPROJ_NAME-PROJ_NAME.
endif.
if update2 ne 2.
move zproject_details-ORIG_NAME to ZORIJ_NAME-ZORIG_NAME.
endif.
if update3 ne 3.
move zproject_details-proj_type to ZORIJ_TYPE-PROJ_TYPE.
endif.
endmodule. " STATUS_0002 OUTPUT
&----
*& Module USER_COMMAND_0002 INPUT
&----
text
----
module USER_COMMAND_0002 input.
data : PROJ_NAME(35) type c,
ORIG_NAME(35) type c,
PROJ_TYPE(35) type c.
if flag100 = 0.
select single * from zproject_details into itab
where proj_no = proj_no .
flag100 = 1.
endif.
case OK_CODE.
when 'PNAME'. " function code of drop down list with values proj_name
itab-proj_name = zproj_name-PROJ_NAME.
modify table itab.
if zdemo-proj_name ne itab-proj_name.
update1 = 1.
endif.
when 'ONAME'. " function code of drop down list with values orij_name
itab-orig_name = zorij_name-zorig_name.
modify table itab .
if zdemo-orig_name ne itab-proj_name.
update2 = 2.
endif.
when 'PTYPE'. " function code of drop down list with values proj_type
itab-proj_type = zorij_type-proj_type.
modify table itab .
if zdemo-proj_type ne zorij_type-proj_type.
update3 = 3.
endif.
when 'SCREEN1'.
clear : zproj_name, zorij_name, zorij_type.
leave to screen 0001.
when 'SAVE'.
modify zproject_details from table itab .
if zdproject_details-proj_name = itab-proj_name.
message i000.
else .
message i001.
endif.
endcase.
endmodule. " USER_COMMAND_0002 INPUT
when i keep debugger on change values on screen and press 'SAVE', my itab has the modified
changed values but they are not updated in zproject_details at last..
eg: if i change the proj_name on screen
after the if stmt - if zdproject_details-proj_name = itab-proj_name.
the itab has the modified value of proj_name but change has not occured in zproject_details...
i dont understand what is wrong, i even used 'update zproject_details from table itab'...
plz help me out,
thank you...
2009 Feb 13 7:17 AM
hello Naveen,
im sorry, the stmt got copied wrong, the correct stmt is, it is not zdzproject_details and the structure
is correct, i checked it, not difficult to track, its only a 4 field table
when 'SAVE'.
modify zproject_details from table itab .
if zproject_details-proj_name = itab-proj_name.
message i000.
else .
message i001.
endif.
thank you
Edited by: aarti mane on Feb 13, 2009 8:17 AM
hello,
i have a db table zproject_details.. it has 4 fields, proj_no(pri key), proj_name, orij_name, proj_type..
i have created 2 screens, in the 1st screen i enter the proj_no and press the 'NEXT' button to
call 2nd screen.
on the 2nd screen, there are 3 drop down list boxes in which proj_name, orij_name and proj_type
are retrieved(from zproject_details) and displayed...
if i change value of any of the field in screen 2, i have to update that record in the zproject_details
too.. so when any record is changed, i modify it in an internal table thus i can change more than
one record, and when i press 'SAVE' button, all changed records are modified in zproject_details.
this is what i have done,
module STATUS_0002 output. " ouyput of screen 2
SET PF-STATUS 'xxxxxxxx'.
SET TITLEBAR 'xxx'.
data : update1(2) value '0',
update2(2) value '0',
update3(2) value '0',
flag100(2) value '0'.
TYPES : begin of itab,
proj_no type zproject_details-proj_no,
proj_name type zproject_details-proj_name,
orig_name type zproject_details-orig_name,
proj_type type zproject_details-proj_type,
end of itab.
DATA : itab TYPE standard TABLE OF itab initial size 100
with header line,
wa type itab.
select single * from zproject_details
where proj_no = PROJ_NO.
if update1 ne 1.
move zproject_details-proj_name to ZPROJ_NAME-PROJ_NAME.
endif.
if update2 ne 2.
move zproject_details-ORIG_NAME to ZORIJ_NAME-ZORIG_NAME.
endif.
if update3 ne 3.
move zproject_details-proj_type to ZORIJ_TYPE-PROJ_TYPE.
endif.
endmodule. " STATUS_0002 OUTPUT
&----
*& Module USER_COMMAND_0002 INPUT
&----
text
----
module USER_COMMAND_0002 input.
data : PROJ_NAME(35) type c,
ORIG_NAME(35) type c,
PROJ_TYPE(35) type c.
if flag100 = 0.
select single * from zproject_details into itab
where proj_no = proj_no .
flag100 = 1.
endif.
case OK_CODE.
when 'PNAME'. " function code of drop down list with values proj_name
itab-proj_name = zproj_name-PROJ_NAME.
modify table itab.
if zdemo-proj_name ne itab-proj_name.
update1 = 1.
endif.
when 'ONAME'. " function code of drop down list with values orij_name
itab-orig_name = zorij_name-zorig_name.
modify table itab .
if zdemo-orig_name ne itab-proj_name.
update2 = 2.
endif.
when 'PTYPE'. " function code of drop down list with values proj_type
itab-proj_type = zorij_type-proj_type.
modify table itab .
if zdemo-proj_type ne zorij_type-proj_type.
update3 = 3.
endif.
when 'SCREEN1'.
clear : zproj_name, zorij_name, zorij_type.
leave to screen 0001.
when 'SAVE'.
modify zproject_details from table itab .
if zdproject_details-proj_name = itab-proj_name.
message i000.
else .
message i001.
endif.
endcase.
endmodule. " USER_COMMAND_0002 INPUT
when i keep debugger on change values on screen and press 'SAVE', my itab has the modified
changed values but they are not updated in zproject_details at last..
eg: if i change the proj_name on screen
after the if stmt - if zdproject_details-proj_name = itab-proj_name.
the itab has the modified value of proj_name but change has not occured in zproject_details...
i dont understand what is wrong, i even used 'update zproject_details from table itab'...
plz help me out,
thank you...
2009 Feb 13 6:44 AM
you are modifying the internel table .... not in z table ....
please modify statement for z table .. then its work ..
2009 Feb 13 6:47 AM
plz chk the code proprely, when i press a push button 'SAVE' i modify the zproject_details table also,
when 'SAVE'.
modify zproject_details from table itab .
if zdzproject_details-proj_name = itab-proj_name.
message i000.
else .
message i001.
endif.
Edited by: aarti mane on Feb 13, 2009 7:47 AM
Edited by: aarti mane on Feb 13, 2009 7:47 AM
2009 Feb 13 6:53 AM
Hi,
r u sure that itab has same structure as zdzproject_details?
if not then it wont modify, plz check it.
Regrds,
Naveen
2009 Feb 13 6:56 AM
please check that the declaration of the internaal table..... if that declaration is not equal records are not inserted ..
2009 Feb 13 6:56 AM
Hi aarti
Cad you try using the update command ?
Use this.
LOOP AT t_breakdown1.
UPDATE znel_breakdown FROM TABLE t_breakdown1.
ENDLOOP.
2009 Feb 13 6:58 AM
im sorry, it got copied wrong, the correct stmt is,
when 'SAVE'.
modify zproject_details from table itab .
if zproject_details-proj_name = itab-proj_name.
message i000.
else .
message i001.
endif.
2009 Feb 13 6:59 AM
Hi,
Check Sy-subrc value after Modify statement. whether it is updating the table properly.
2009 Feb 13 7:03 AM
i tried loop endloop, when i debugged, cmpiler wont even go inside the loop, from the loop stmt, it directly jumps to end loop....
thank you
2009 Feb 13 7:08 AM
hi Selva,
i did sy-subrc, it shows the message i000.
modify zproject_details from table itab.
if sy-subrc = 0.
message i000.
else .
message i001.
endif.
2009 Feb 13 7:14 AM
Hello
can yu reply for this?
r u sure that itab has same structure as zdzproject_details?
if not then it wont modify, plz check it.
Regrds,
Naveen
2009 Feb 13 7:17 AM
hello Naveen,
im sorry, the stmt got copied wrong, the correct stmt is, it is not zdzproject_details and the structure
is correct, i checked it, not difficult to track, its only a 4 field table
when 'SAVE'.
modify zproject_details from table itab .
if zproject_details-proj_name = itab-proj_name.
message i000.
else .
message i001.
endif.
thank you
Edited by: aarti mane on Feb 13, 2009 8:17 AM
2009 Feb 13 7:26 AM
Hi,
modify zproject_details from table itab .
this will definetly work if zproject_details structure and Itab structure is SAME.
Regrds,
Naveen
2009 Feb 13 7:26 AM
2009 Feb 13 7:33 AM
hi Matrina,
i did try with update..
i tried
loop at itab.
update zproject_details from table itab.
endloop.
then i debugged, cmpiler wont even go inside the loop, from the loop stmt, it directly jumps to end loop....
i e1 tried without loop endloop... the values dont change, in debugger after the UPDATE stmt, the itab has the modified values, but zproject_details is not updated..
thank you
thank you
2009 Feb 13 7:38 AM
Hey
Then there is somethg wring wid the itab
It won go into the loop only if itab is initial ....
Jjus check once and send your whole code once
2009 Feb 13 8:41 AM
Aarti,
In the PAi of screen 2 you have to append values to the itab from the screen fields ...before
Module USER_COMMAND_0002 INPUT.
loop at the itab .append the screen fields to the fields of itab.append itab .endloop.
then use the modify or update to update it .
then only it ll go inside the loop of itab,.without loop if u modify it won change.
Even if one record is there it'll go insidee loop .
for e.g
this is PAI of my screen
PROCESS AFTER INPUT.
FIELD T_BREAKDOWN1-ENTRY_DATE.
FIELD T_BREAKDOWN1-PLANT.
FIELD T_BREAKDOWN1-SHIFT. (3 fields in screen)
loop at t_breakdown1.
CHAIN.
FIELD T_BREAKDOWN1-REASON.
FIELD T_BREAKDOWN1-MINS.
FIELD T_BREAKDOWN1-PICK MODULE CHECK.
ENDCHAIN.
MODULE MODIFY_TAB_9002.
(inside this i write:
t_breakdown1-entry_date = l_date.
t_breakdown1-plant = l_plant.
t_breakdown1-shift = l_shift.
t_breakdown1-reason = t_breakdown1-reason.
t_breakdown1-mins = t_breakdown1-mins.
t_breakdown1-pick = t_breakdown1-pick.
APPEND t_breakdown1.
)
endloop.
MODULE USER_COMMAND_9002.
here i give if sy-ucomm =save
2009 Feb 13 7:41 AM
hi naveen,
i checked, its only a 4 field table... actually my original project is bigger but im new to screen painter
and wanted to get concepts clear... so i did this demo screen to know how data is modified in database table from the screen, i created a database table 'zproject_details' with 4 fields proj_no(pri key), proj_name, orij_name, proj_type...
check the declaration of itab...
what is going wrong??
thank you...
2009 Feb 13 7:53 AM
hi,
itab does not go in loop probebly bcoz derz only one record in it... i have sent the code related to
screen 2, right from data declaration to the updation of the table... is the select single stmt wrong???
| User | Count |
|---|---|
| 6 | |
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |