Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Button in Dynpro

Former Member
0 Likes
2,697

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.

12 REPLIES 12
Read only

Former Member
0 Likes
2,029

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

Read only

0 Likes
2,029

That CASE okcode or syucomm will work .. I need that what I have to write in BUT1, my Insert is not working ... 😕

Read only

0 Likes
2,029

Data ok_code =  sy-ucomm.

Read only

0 Likes
2,029

Already have it declared ..

I need some advice how to insert that three fields by pressing BUTTON into database ..

Read only

Former Member
0 Likes
2,029

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?

Read only

0 Likes
2,029

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.

Read only

0 Likes
2,029

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

Read only

0 Likes
2,029

if you have to insert only one record than no need to append to itab. you can insert to database from the structure.

Read only

0 Likes
2,029

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 ..

Read only

0 Likes
2,029

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.

Read only

0 Likes
2,029

I am trying to add new one.. Its like transactions .. so each one has to be new one

Read only

0 Likes
2,029

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.