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

push button in dynpro

Former Member
0 Likes
5,872

hi,

i have a dynpro where i have added 2 push-buttons. now i want to use the 'value' of the push-button in my apab ? but my program does not know the 2 push-buttons !

how can i implement it into abap-source ?!?

reg, Martin

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
3,260

go to dynpro

screen painter

click on the button set a name and a text

SET A Function code by doubleclick the screen painer attributes open on the right side look for fktcode

work with okcode in pai

17 REPLIES 17
Read only

Former Member
0 Likes
3,260

hi in this report u can find this push buttons and its working,


*&---------------------------------------------------------------------*
*& Report  ZPR_02
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT  ZPR_02.

TYPE-POOLS: SLIS.

*------------------------------------------------------------------------*
*  Tables Declaration.
*------------------------------------------------------------------------*
TABLES: MARA.

*------------------------------------------------------------------------*
*Internal tables and data declaration.
*------------------------------------------------------------------------*
DATA: BEGIN OF IT_MARA OCCURS 0,
        MATNR LIKE MARA-MATNR,
        MTART LIKE MARA-MTART,
        MBRSH LIKE MARA-MBRSH,
      END OF IT_MARA,

      BEGIN OF IT_MARC OCCURS 0,
        MATNR LIKE MARC-MATNR,
        WERKS LIKE MARC-WERKS,
        EKGRP LIKE MARC-EKGRP,
      END OF IT_MARC,

      BEGIN OF IT_MARD OCCURS 0,
        MATNR LIKE MARD-MATNR,
        WERKS LIKE MARD-WERKS,
        LGORT LIKE MARD-LGORT,
        LABST LIKE MARD-LABST,
      END OF IT_MARD.

DATA: WA_FIELD_CAT TYPE SLIS_FIELDCAT_ALV,
      IT_FIELD_CAT1 TYPE SLIS_T_FIELDCAT_ALV,
      IT_FIELD_CAT2 TYPE SLIS_T_FIELDCAT_ALV,
      IT_FIELD_CAT3 TYPE SLIS_T_FIELDCAT_ALV,
      WA_KEYINFO TYPE SLIS_KEYINFO_ALV,
      IT_LAYOUT TYPE SLIS_LAYOUT_ALV,
      IT_EVENTS1    TYPE SLIS_T_EVENT WITH HEADER LINE,
      IT_EVENTS2    TYPE SLIS_T_EVENT WITH HEADER LINE,
      IT_EVENTS3    TYPE SLIS_T_EVENT WITH HEADER LINE.
*------------------------------------------------------------------------*
*Selection Screen.
*------------------------------------------------------------------------*
SELECT-OPTIONS: S_MATNR FOR MARA-MATNR.

*------------------------------------------------------------------------*
*Start Of selection.
*------------------------------------------------------------------------*
START-OF-SELECTION.

*Selecting the data.
  PERFORM SELECT_DATA.

*Populating the field catelogue.
  PERFORM BUILD_FIELD_CAT.

*Displaying the final output.
  PERFORM DISPLY_OUTPUT.

*&---------------------------------------------------------------------*
*&      Form  Select_data
*&---------------------------------------------------------------------*
*       Selecting the data.
*----------------------------------------------------------------------*
FORM SELECT_DATA .

  SELECT MATNR
         MTART
         MBRSH FROM MARA
       INTO TABLE IT_MARA
       WHERE MATNR IN S_MATNR.

  IF NOT IT_MARA[] IS INITIAL.
    SELECT MATNR
           WERKS
           EKGRP FROM MARC
         INTO TABLE IT_MARC
         FOR ALL ENTRIES IN IT_MARA
         WHERE MATNR EQ IT_MARA-MATNR.
  ENDIF.

  IF NOT IT_MARC[] IS INITIAL.
    SELECT MATNR
           WERKS
           LGORT
           LABST FROM MARD
         INTO TABLE IT_MARD
         FOR ALL ENTRIES IN IT_MARC
         WHERE MATNR = IT_MARC-MATNR
         AND   WERKS = IT_MARC-WERKS.
  ENDIF.
ENDFORM.                    " Select_data
*&---------------------------------------------------------------------*
*&      Form  Build_field_cat
*&---------------------------------------------------------------------*
*      Populating the field catelogue.
*----------------------------------------------------------------------*
FORM BUILD_FIELD_CAT .

  DEFINE M_FIELDCAT1.
    WA_FIELD_CAT-TABNAME = &1.
    WA_FIELD_CAT-FIELDNAME = &2.
    WA_FIELD_CAT-SELTEXT_L = &3.
    APPEND WA_FIELD_CAT TO IT_FIELD_CAT1.
  END-OF-DEFINITION.

  DEFINE M_FIELDCAT2.
    WA_FIELD_CAT-TABNAME = &1.
    WA_FIELD_CAT-FIELDNAME = &2.
    WA_FIELD_CAT-SELTEXT_L = &3.
    APPEND WA_FIELD_CAT TO IT_FIELD_CAT2.
  END-OF-DEFINITION.

  DEFINE M_FIELDCAT3.
    WA_FIELD_CAT-TABNAME = &1.
    WA_FIELD_CAT-FIELDNAME = &2.
    WA_FIELD_CAT-SELTEXT_L = &3.
    APPEND WA_FIELD_CAT TO IT_FIELD_CAT3.
  END-OF-DEFINITION.

  M_FIELDCAT1 'MARA' 'MATNR' 'Material No'.
  M_FIELDCAT1 'MARA' 'MTART' 'Material type'.
  M_FIELDCAT1 'MARA' 'MBRSH' 'Industry Sector'.

  M_FIELDCAT2 'MARC' 'MATNR' 'Material No'.
  M_FIELDCAT2 'MARC' 'WERKS' 'Plant'.
  M_FIELDCAT2 'MARC' 'EKGRP' 'Purchasing Group'.

  M_FIELDCAT3 'MARD' 'MATNR' 'Material No'.
  M_FIELDCAT3 'MARD' 'WERKS' 'Plant'.
  M_FIELDCAT3 'MARD' 'LGORT' 'Storage Loc'.
  M_FIELDCAT3 'MARD' 'LABST' 'Valued Stock'.

  IT_EVENTS1-NAME  =  'TOP_OF_PAGE'.
  IT_EVENTS1-FORM  =  'F_TOP_OF_PAGE_ONE'.
  APPEND IT_EVENTS1.
  CLEAR IT_EVENTS1.

  IT_EVENTS2-NAME  =  'TOP_OF_PAGE'.
  IT_EVENTS2-FORM  =  'F_TOP_OF_PAGE_TWO'.
  APPEND IT_EVENTS2.
  CLEAR IT_EVENTS2.

  IT_EVENTS3-NAME  =  'TOP_OF_PAGE'.
  IT_EVENTS3-FORM  =  'F_TOP_OF_PAGE_THREE'.
  APPEND IT_EVENTS3.
  CLEAR IT_EVENTS3.

ENDFORM.                    " Build_field_cat
*&---------------------------------------------------------------------*
*&      Form  disply_output
*&---------------------------------------------------------------------*
*      Displaying the final output.
*----------------------------------------------------------------------*
FORM DISPLY_OUTPUT .

  CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'
    EXPORTING
      I_CALLBACK_PROGRAM = SY-REPID.

  CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
    EXPORTING
      IS_LAYOUT                        = IT_LAYOUT
      IT_FIELDCAT                      = IT_FIELD_CAT1[]
      I_TABNAME                        = 'IT_MARA'
      IT_EVENTS                        = IT_EVENTS1[]
*   IT_SORT                          = IT_SORT
*   I_TEXT                           = ' '
    TABLES
      T_OUTTAB                         = IT_MARA     .

  CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
    EXPORTING
      IS_LAYOUT                        = IT_LAYOUT
      IT_FIELDCAT                      = IT_FIELD_CAT2[]
      I_TABNAME                        = 'IT_MARC'
      IT_EVENTS                        = IT_EVENTS2[]
*   IT_SORT                          = IT_SORT
*   I_TEXT                           = ' '
    TABLES
      T_OUTTAB                         = IT_MARC    .

  CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
    EXPORTING
      IS_LAYOUT                        = IT_LAYOUT
      IT_FIELDCAT                      = IT_FIELD_CAT3[]
      I_TABNAME                        = 'IT_MARD'
      IT_EVENTS                        = IT_EVENTS3[]
*   IT_SORT                          = IT_SORT
*   I_TEXT                           = ' '
    TABLES
      T_OUTTAB                         = IT_MARD    .

  CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_DISPLAY'
* EXPORTING
*   I_INTERFACE_CHECK             = ' '
*   IS_PRINT                      = IS_PRINT
*   I_SCREEN_START_COLUMN         = 0
*   I_SCREEN_START_LINE           = 0
*   I_SCREEN_END_COLUMN           = 0
*   I_SCREEN_END_LINE             = 0
* IMPORTING
*   E_EXIT_CAUSED_BY_CALLER       = E_EXIT_CAUSED_BY_CALLER
*   ES_EXIT_CAUSED_BY_USER        = ES_EXIT_CAUSED_BY_USER
* EXCEPTIONS
*   PROGRAM_ERROR                 = 1
*   OTHERS                        = 2
            .
  IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.

ENDFORM.                    " disply_output

*&---------------------------------------------------------------------*
*&      Form  top_of_page_one
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM F_TOP_OF_PAGE_ONE.
  WRITE: / 'Header details (MARA)'.
ENDFORM.                    "top_of_page_one

*&---------------------------------------------------------------------*
*&      Form  top_of_page_one
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM F_TOP_OF_PAGE_TWO.
  WRITE: / 'Item details (MARC)'.
ENDFORM.                    "top_of_page_one

*&---------------------------------------------------------------------*
*&      Form  top_of_page_one
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM F_TOP_OF_PAGE_THREE.
  WRITE: / 'Item details (MARD)'.
ENDFORM.                    "top_of_page_one

<REMOVED BY MODERATOR>

venkat.

Edited by: Alvaro Tejada Galindo on Mar 6, 2008 10:41 AM

Read only

Former Member
0 Likes
3,260

Hi,

When you create the push buttons on the screen in SE51 there is a field called FctCODE...function code in the properties window. You have to give a code here.

Use that code in your program in the case stmt as

when ok_code = the the code you give for the pushbutton.

This is how you can let your program to know that the user has clicked on that particular button.

I hope it helps.

Thanks

Edited by: Alchemi on Mar 6, 2008 9:00 AM

Read only

Former Member
0 Likes
3,261

go to dynpro

screen painter

click on the button set a name and a text

SET A Function code by doubleclick the screen painer attributes open on the right side look for fktcode

work with okcode in pai

Read only

0 Likes
3,260

thank you all very much !

i have entered a fct.code now, BUT:

my program does not know 'ok_code' ???

how can i get access to the fct.code ?

reg, Martin

Read only

0 Likes
3,260

In your program u have to declare the OK_CODE field like sy-ucomm.

in the SE51 attributes u should give the OK_CODE field name in the ON code field.

- Selva

Read only

0 Likes
3,260

In PAI


    module user_command_ok_code.

then in module


module user_command_ok_code input.
   ok_code = sy-ucomm.
  if ok_code eq XXXX'
    " do somethng
  endif.,

endmodule.

Read only

0 Likes
3,260

ooooooooookay, now i've got it

but why can't i use sy-ucomm directly ?

if sy-ucomm = ....................... and so on ?

best regards, Martin

Read only

0 Likes
3,260

usually ok_code will be the place holder for sy-ucomm.

you can also use sy-ucomm directly

a®

Read only

Former Member
0 Likes
3,260

Sorry guys, but here is the next question:

i now have a problem with radio-buttons:

i have 3 radio buttons, but only ONE of them should be 'active'. now all 3 of them are switched 'on'.

how can i handle this ?

best regards, Martin

Read only

0 Likes
3,260

You need to make 3 radio buttons in to a group.

ie

In the layout> edit> grouping> radio button group>

a®

Read only

0 Likes
3,260

When you create these radiobutton for your own report use the following code:

parameters : rb_1 radiobutton group one,

rb_2 radiobutton group one.

If you're creating a dialog program you should do the following:

place (drag and drop) the radiobuttons onto your screen, mark them (box) and the click left mouse button. Choose radiobutton group and then define.

Regards,

Micky.

Read only

0 Likes
3,260

thanks !

well, the next problem

now button 1 and 2 is 'ON' when entering the screen, button 3 is 'OFF'.

i have grouped all 3 buttons as you explained to me.

i only want ONE button to be clickable.

and how does my program now know WHICH button is 'ON' ???

i know, a lot of questions, but i am new to dynpro programming

best r. Martin

Read only

0 Likes
3,260

In module user_command

say your radio button variables in the screen are like rad1 rad2 rad3


if rad1  eq 'X'.
  "do something
endif.
if rad2  eq 'X'.
  "do something
endif.
if rad3  eq 'X'.
  "do something
endif.

a®

Read only

0 Likes
3,260

this is not working:

what is rad1, rad2 and rad3 ? the name of the buttons or the fct.code ?

when i group the radio buttons and enter a fct.code ALL 3 of them are getting

the SAME fct.code AUTOMATICLY.

and if rad1, 2 ........ are the names of the buttons, they are not known by my program.

reg, Martin

Read only

0 Likes
3,260

okay, i found out that i have to declare the names in the program !

so there is one problem left:

why are always TWO of the radio buttons ON ?

reg, Martin

Read only

former_member194669
Active Contributor
0 Likes
3,260

This is because of grouping

Here the sample screen download with 3 radio buttons . Try to save it as txt file and create a screen 100 upload the same and see


****************************************************************																																
*   THIS FILE IS GENERATED BY THE SCREEN PAINTER.              *																																
*   NEVER CHANGE IT MANUALLY, PLEASE !                         *																																
****************************************************************																																
%_DYNPRO																																
Z011111_48																																
0100																																
700																																
             40																																
%_HEADER																																
Z011111_48                              0100 0100      2 12192 37  0  0 27120  0G D                              20080306114022																																
%_DESCRIPTION																																
test																																
%_FIELDS																																
RAD1	C	CHAR	  1	80	00	80	00	00	  2	  7		  0	  0	  0		  0	A				  0	  0	101                                                                                RAD1	
RAD2	C	CHAR	  1	80	00	80	00	00	  2	 10		  0	  0	  0		  0	A				  0	  0	101                                                                                RAD1	
RAD3	C	CHAR	  1	80	00	80	00	00	  2	 13		  0	  0	  0		  0	A				  0	  0	101                                                                                RAD1	
OK_CODE		CHAR	 20	80	10	00	00	00	255	  1	O	  0	  0	  0		  0					  0	  0								____________________		
%_FLOWLOGIC																																
PROCESS BEFORE OUTPUT.																																
* MODULE STATUS_0100.																																
*																																
PROCESS AFTER INPUT.																																
																																
 MODULE USER_COMMAND_0100.																																
%_PARAMS																																
																																

Read only

0 Likes
3,260

ars,

thank you very much !

the problem was the following: you have to mark ALL 3 BUTTONS and then group it !!!

i (as windows-used user) i thougt i can mark the first and the last with shift-key...........thats

very bad in dynpro editor !!!!

now it works fine !

full points for you !

b. reg, Martin