Quantcast
Channel: SCN : All Content - ABAP Development
Viewing all articles
Browse latest Browse all 8332

insert only modified fields of screen to ztable through primary key

$
0
0

Hello Gurus,

 

       I have created an application where data in fetched from the select option(Matnr) and displayed on the screen i.e

MATNR, BSTME, MEINS, MAKTX, EKGRP, ZZPROPIRIND, ZZPROPIVCODE, ZZMPRCA, ZZSC, ZZCPAI .

                    Now these are the fields which are displayed on the screen.I have used table control.

Now the fields in my ZTABLE are.

UPDAT, UPTMS, UPUSR , CHANGE_DOC_NO, MATNR, BSTME, MEINS, MAKTX, EKGRP, ZZPROPIRIND, ZZPROPIVCODE, ZZMPRCA, ZZSC, ZZCPAI .

                    Now when the user try's to modify the MAKTX (description) of any particular MATNR(material) and click on update then the whole data is inserted into the ZTABLE with its date , time , username and the change document number which are all primary key including matnr .

                    The problem I am facing is that when ever user try's to modify more than one field for more than one record then whole record being searched through the select option , with same change doc number goes into the ztable.

   * Where I only want that only the modified row should be inserted into the ztable.

** My change_doc_number working great and also data is being modified but complete data in being saved in ztable which I don't want.I only want to save the modified row.How can we do that.

*** Also the changes should be saved for every changes made to the record.Changes shouldn't be re-written.

**** As I know my CHANGE_DOC_NO is primary and unique so I have to use that but how to use.

below is the code that I use

 

MODULE UPD_DATA INPUT.

CASE SY-UCOMM.

   WHEN'UPDATE'.

            PERFORM NUMBER_GENERATION.

        MESSAGE I001 WITH CHANGE_DOC_NO.

     IF sy-subrc <> '0'.

                                                 "Update

           LOOPAT  G_ZMATERIAL1_ITAB INTO  G_ZMATERIAL1_WA .

                 G_ZMATERIAL1_WA-UPDAT         = SY-DATUM.

                 G_ZMATERIAL1_WA-UPTMS         = SY-UZEIT.

                 G_ZMATERIAL1_WA-UPUSR         = SY-UNAME.

                 G_ZMATERIAL1_WA-CHANGE_DOC_NO = CHANGE_DOC_NO.

 

              INSERT  INTO ZMATERIAL_DESCP VALUES  G_ZMATERIAL1_WA .

       CLEAR G_ZMATERIAL1_WA .

     ENDLOOP.

 

     ELSE.


*      DELETE FROM ZMATERIAL_DESCP.

*      IF SY-SUBRC = 0.

*        COMMIT WORK.

*      ENDIF.                                                             "Insert

 

     LOOPAT  G_ZMATERIAL1_ITAB INTO  G_ZMATERIAL1_WA .

                 G_ZMATERIAL1_WA-UPDAT         = SY-DATUM.

                 G_ZMATERIAL1_WA-UPTMS         = SY-UZEIT.

                 G_ZMATERIAL1_WA-UPUSR         = SY-UNAME.

                 G_ZMATERIAL1_WA-CHANGE_DOC_NO = CHANGE_DOC_NO.

 

       MODIFY ZMATERIAL_DESCP FROM  G_ZMATERIAL1_WA  .

       CLEAR  G_ZMATERIAL1_WA .

     ENDLOOP.

     ENDIF.

 

 

 

     ENDCASE.

ENDMODULE.    

 

 

Thanks in advance

Gaurav Gautam   

 


 



Viewing all articles
Browse latest Browse all 8332

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>