Take Values from Selection-Screen and Issue Message

My program fills a ztable taking values from the selection-screen. Now, if it a record with the same primary keys , then I need to issue a warning saying that 'Entry for the same combination already exist,'.. The user has to have an option of either cancelling the updation or go ahead with the updation. How do I go about it.

If the program is a report,  then use message i.... with 'text'. It will show a message on screen and go back to the selection screen.

start-of-selection.

select single from * your ztable where ...
if sy-subrc ?> 0
  message ... with 'Primary key exists!!!'
else
  perform the insert.
endif.

Or...
start-of-selection.
 insert ztable.
 if sy-subrc ?> 0.
   message ... with 'Primary key exists!'.
 endif.

then use pop_up_to_confirm_step:

   data: l_respuesta. "local variable to hold the answer. 
   clear l_respuesta.
   call function 'POPUP_TO_CONFIRM_STEP'
                 exporting
                     defaultoption = 'N'
                  textline1  = 'Primary key exists in the database'
                 textline2  = 'Do you want to update?'
                  titel      = 'popup Title'
*           START_COLUMN  = 25
*           START_ROW     = 6
                 importing
                    answer        = l_respuesta
                 exceptions
                      others        = 1.

           if l_respuesta = 'J'.
     modify ztable.
     if sy-subrc = 0.
      mesage i ... with 'Data updated'
     endif.
    else.
      mesage i ... with 'No row updated'
         endif. 

ABAP Tips by : Horacio.

Related ABAP Topics:
Table CDHDR and CDPOS Usage

Get help for your ABAP problems
Do you have a ABAP Question?

SAP Books
SAP Certification, Interview Questions, Functional, Basis Administration and ABAP Programming Reference Books

More ABAP Tips

Main Index
SAP Basis, ABAP Programming and Other IMG Stuff
http://www.erpgreat.com

All the site contents are Copyright © www.erpgreat.com and the content authors. All rights reserved.
All product names are trademarks of their respective companies.  The site www.erpgreat.com is in no way affiliated with SAP AG.
Every effort is made to ensure the content integrity.  Information used on this site is at your own risk.
 The content on this site may not be reproduced or redistributed without the express written permission of
www.erpgreat.com or the content authors.