‎2014 Dec 09 7:54 AM
Hello, probably simply question for you .. 🙂
I have dynpro, in that 3 fields from table (3 field taken from DDIC) and under that button "Insert" .. and when I press Insert, I need to take whats written in that three inputs and insert it into table .. button has function code BUT1 .. Do I have to put it into CASE okcode like BACK for example? .. Thanks.
‎2014 Dec 09 8:16 AM
Hello,
you can try it with following code. Just put the code in your PAI-Module.
TRY.
CASE sy-ucomm.
WHEN 'BUT1'.
... "Here you can program your requirements
WHEN 'BUT2'.
... "Here you can program your requirements
WHEN OTHERS.
.... "Here you can program your requirements
ENDCASE.
CLEAR sy-ucomm.
CATCH cx_static_check INTO l_exc.
MESSAGE l_exc TYPE /auk/cl_msg_t100_type=>e.
ENDTRY.
Please mark with correct answer, if it helps!
Best Regards.
Alexander
‎2014 Dec 09 8:18 AM
That CASE okcode or syucomm will work .. I need that what I have to write in BUT1, my Insert is not working ... 😕
‎2014 Dec 09 8:21 AM
‎2014 Dec 09 8:24 AM
Already have it declared ..
I need some advice how to insert that three fields by pressing BUTTON into database ..
‎2014 Dec 09 8:17 AM
I have this ..
DATA: BEGIN OF t OCCURS 0,
id TYPE ZZTABLE_PLATB-IDTRANSAKCE,
mnozstvi TYPE ZZTABLE_PLATB-CASTKA,
mena TYPE ZZTABLE_PLATB-MENA,
END OF t.
and in CASE okcode.
WHEN 'BUT1 (its my button to insert).
INSERT ZZTABLE_PLATB FROM t.
ENDCASE ..
(There is few more commands, but this is important .. ) .. Can somebody give me some advice?
‎2014 Dec 09 9:54 AM
Use the name which you have entered for the input fields on the screen layout to retrieve the data in the program.
Suppose here you have structure t, Declare the screen input fields as t-id, t-mnozstvi, t-mena respectively. And after that you can use your code
CASE okcode.
WHEN 'BUT1 (its my button to insert).
INSERT ZZTABLE_PLATB FROM t.
ENDCASE ..
the structure t will get the 3 field values.
‎2014 Dec 09 10:11 AM
Hello. I tried to APPEND t TO itab (itab like table of t WITH HEADER line) so now I just need to insert it into DATABASE ZZPLATB_UKOL
‎2014 Dec 09 10:42 AM
if you have to insert only one record than no need to append to itab. you can insert to database from the structure.
‎2014 Dec 09 10:45 AM
My mentor told me that there is no way how u can insert from itab to database when u have already something in that database ..
‎2014 Dec 09 10:52 AM
yeah true. are you trying to insert new records to the database or you are modifying the existing one???
if your requirement is to add a new record if record doesn't exist already and if record already exists then to modify with the new values , you can use 'modify' statement.
‎2014 Dec 09 10:59 AM
I am trying to add new one.. Its like transactions .. so each one has to be new one
‎2014 Dec 09 11:04 AM
then you can use insert statement. before that you can put a check if any record exists in the database with the value you are trying to insert. if no record exists you can insert otherwise you can exit.