2014 Jun 02 11:33 AM
Hi Experts,
I am new to ABAP.
I have a Ztable and with F4 help and pushbutton syntax I am pulling the data from Ztable on my screen (Created by Screen painter) in MPP:
I have 4 pushbuttons: Get_Data, Edit, Delete and Save.
If I want to edit a pulled data from Ztable, then what sud be the syntax for Edit pushbutton in sy-ucomm.
My code on Mod Poll (Main progg) Screen in:
module USER_COMMAND_9000 input.
Case sy-ucomm.
****************************************************************************
*To Populate Data into Mitarbeiter through Pushbuttons
****************************************************************************
When 'OK_GETM'.
IF ZLT_MITA-M1 is NOT INITIAL.
SELECT SINGLE *
FROM ZLT_MITA
Where M1 = ZLT_MITA-M1.
ENDIF.
When 'OK_DELETEM'.
IF ZLT_MITA-M1 is NOT INITIAL.
DELETE
FROM ZLT_MITA
Where M1 = ZLT_MITA-M1.
IF sy-subrc = 0.
MESSAGE S000(8i) With 'Data deleted'.
ENDIF.
ENDIF.
When 'OK_EDITM'.
Update ZLT_MITA. ------------------------------> This doesn#t Edits the existing data in Ztable
IF sy-subrc = 0.
MESSAGE s000(8i) With 'Data Updated'.
ENDIF.
When 'OK_SAVEM'.
Modify ZLT_MITA.
IF sy-subrc = 0.
MESSAGE s000(8i) With 'Data Saved'.
ENDIF.
Can nay one please help me out.
Regards
Deepika
2014 Jun 02 12:42 PM
Hi Deepika,
Can you please tell what is the difference in the functionality of your Edit and Save buttoons with respect to the database changes ?
Regards,
Rachna
Hi Deepika,
Can you please tell what is the difference in the functionality of your Edit and Save buttoons with respect to the database changes ?
Regards,
Rachna
2014 Jun 02 12:19 PM
Hi Deepika,
Use the statement
Update ZLT_MITA from wa(workarea)
Or Modify ZLT_MITA from wa(workarea)
Regards,
VJ
2014 Jun 02 12:35 PM
Hi Vijay,
Thanks for replying.
I defined in the mod Poll ( mian progg) as : but it still doesn't edit's the Ztable
TABLES: ZLT_MITA, ZLT_kunde, ZLT_auftrag1.
TYPES: Begin of ty_mita.
Include Structure ZLT_mita.
TYPES: END of ty_mita.
DATA: it_mita TYPE TABLE OF ty_mita,
wa_mita TYPE ty_mita.
And then for user command as:
module USER_COMMAND_9000 input.
Case sy-ucomm.
****************************************************************************
*To Populate Data into Mitarbeiter through Pushbuttons
****************************************************************************
When 'OK_GETM'.
IF ZLT_MITA-M1 is NOT INITIAL.
SELECT SINGLE *
FROM ZLT_MITA
Where M1 = ZLT_MITA-M1.
ENDIF.
When 'OK_DELETEM'.
IF ZLT_MITA-M1 is NOT INITIAL.
DELETE
FROM ZLT_MITA
Where M1 = ZLT_MITA-M1
AND M2 = ZLT_MITA-M2.
IF sy-subrc = 0.
MESSAGE S000(8i) With 'Data deleted'.
ENDIF.
ENDIF.
When 'OK_EDITM'.
LOOP at it_mita into wa_mita.
Update ZLT_MITA from wa_mita.
IF sy-subrc = 0.
MESSAGE s000(8i) With 'Data Updated'.
ENDIF.
ENDLOOP.
When 'OK_SAVEM'.
Modify ZLT_MITA.
IF sy-subrc = 0.
MESSAGE s000(8i) With 'Data Saved'.
ENDIF.
Regards
Deepika
2014 Jun 02 12:35 PM
Hi Deepika,
Use this code:
When 'OK_EDITM'.
IF ZLT_MITA-M1 is NOT INITIAL.
Modify ZLT_MITA from table <Internal Table>.
IF sy-subrc = 0.
Commit Work.
MESSAGE S000(8i) With 'Data Updated'.
ENDIF.
ENDIF.
Hope this will Help You
Regards,
RM
2014 Jun 02 12:44 PM
Hi Mahesg,
Thanks.
I did this as per ur suggestion, sy-subrc = 0, but still the edited data is not overwritten in Ztable ZLT_mita:
When 'OK_EDITM'.
* LOOP at it_mita into wa_mita.
IF ZLT_MITA-M1 is NOT INITIAL.
Modify ZLT_MITA from it_mita.
IF sy-subrc = 0.
Commit work.
MESSAGE s000(8i) With 'Data Updated'.
ENDIF.
ENDIF.
Regards
Deepika
2014 Jun 02 12:50 PM
Hi Deepika,
I guess, your code should be as following:
IF zlt_mita-m1 IS NOT INITIAL.
MODIFY zlt_mita FROM TABLE it_mita.
IF sy-subrc = 0.
COMMIT WORK.
MESSAGE s000(8i) WITH 'Data Updated'.
ENDIF.
ENDIF.
Regards,
Anubhab
2014 Jun 02 12:58 PM
Hi Anubhab,
Anubhab Chirui wrote:
javascript:;Also please check the condition on which you are updating dbtable.
IF ZLT_MITA-M1 is NOT INITIAL. I guess there's something wrong with your condition. Please modify your condition as per your requirement.
Thanks, but what can the condition be.
I pull data in the screen in Mod pool and then I would like to edit either or both of the fields ZLT_mita-m1 or ZLT_mita-m2 ,
And that can be done if the field are NOT initial.
Regards
Deepika
2014 Jun 02 1:12 PM
Hi Anubhab,
I used the same above code: sy-subrc =0 but data in Ztable is not updated.
Say I am changing
M1 M2
From Roberto DAS908
To Roberto Singh DAS750
sy-subrc= 0 , but in Ztable data " Roberto DAS908" is not updated to " Roberto Singh DAS750"
Regards
Depika
2014 Jun 02 1:14 PM
Hi Deepika,
I think you have selected only one record into ZT_MITA to display in the screen field. Better define the screen fields with some different names and then you can code as below:
SELECT SINGLE *
FROM zt_mita
INTO wa_mita (work-area of type zt_mita)
WHERE <your condition>.
Do whatever modification you need to do with data in WA_MITA and then,
IF wa_mita-m1 IS NOT INITIAL.
MODIFY zlt_mita FROM wa_mita.
IF sy-subrc = 0.
COMMIT WORK.
MESSAGE s000(8i) WITH 'Data Updated'.
ENDIF.
ENDIF.
Regards,
Anubhab
2014 Jun 02 1:16 PM
Whats the structure of your ztable? Does it have any primary key?
2014 Jun 02 1:21 PM
2014 Jun 02 1:27 PM
2014 Jun 02 12:42 PM
Hi Deepika,
Can you please tell what is the difference in the functionality of your Edit and Save buttoons with respect to the database changes ?
Regards,
Rachna
2014 Jun 02 12:46 PM
Hi Rachana,
My edit button: should enable the user to make any correction in the already existing data in Ztable
Save: function should add new data to Ztable.
Suppose: Zlt_Mita has the following value:
ZLT_Mita-M1 ZLT_Mita-M2
Deepika Singh BAS110
No I want to change the data from Module Pool : Here I want to change Deepika Singh to Deepika Singh BAS500
Then now the same data should be overwitten in Ztable and now my Ztable: ZLT Mita should have the following value:
ZLT_Mita-M1 ZLT_Mita-M2
Deepika Singh BAS500
Regards
Deepika
2014 Jun 02 12:59 PM
Hi,
Is your screen field name same as that of the z table?
Are you editing one record at a time or using table ctrl?
Are the key fields populated in the work area?
In debug check the work area has the changed data.
Regards
Sree
2014 Jun 02 1:05 PM
Hi, Sree,
I am not using tctrl.
I am just using input/out fields connected to ZLT_mita-m1 and ZLT_mita-m2 in Screen painter.
I populate these field with f4 search help. And now I want o , EDIT it eithe M1 or M2 or both M1 and M2.
I debugged with the above code. wa_mita doesn't shows any value but sy-subrc = 0.
Funny.
Regards
Deepika
2014 Jun 02 1:16 PM
Hi,
If your screen field name is same as that of Z table field name then ,
there will be no data in work area.
In that case check the fields ZLT_mita-m1 and ZLT_mita-m2 has changed values in debug mode
If the ZLT_mita-m1 and ZLT_mita-m2 has changed values then use modify to update ztable.
Regards
Sree
2014 Jun 02 1:21 PM
Hi Deepika,
Please tell me what is the key field in your Ztable ?
If ZLT_Mita-M2 or the combination of ( ZLT_Mita-M1 and ZLT_Mita-M2) is the key field in your ztable, please keep in mind that you cannot edit or change the value for the key field for an existing record in a table. If the value for the key field changes, you must insert an entire new record in the table.
Regards,
Rachna
2014 Jun 02 1:25 PM
Hi Rachana,
I think both ( Plz refer the attachement)
Regards
Deepika
2014 Jun 02 1:29 PM
Hi,
Both the fileds are Key fields of the table. So you will not be able to edit the values.
Instead new values will be inserted in the table.
Use a new field like number, which will be your key field and use it to change the values.
MANDT key field
NUMBER key field
M1
M2
Regards
Sree
2014 Jun 02 2:22 PM
Hi all,
Thanks for your inputs.
Although as I am populating the ztable through another code and hence that restricts me to remove the primary KEYS. So I think under such restriction, I should remove the EDIT pushbutton and then work with a combination of DELETE and SAVE button to update the data in the Ztable.
Regards
Deepika
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |