Application Development 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: 

How to pop up an ALV dialog

Former Member
0 Kudos

Hi, in my program, before user deletes records, I need to pop up a ALV dialog in which thoes records are diaplyed, and then user can choose 'continue' to process or 'cancel' to not process. Which function module can do that?

Thanks.

1 ACCEPTED SOLUTION

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

Tom, you can strip all of the seletion functionality out of it. Here is my example, with all of the selection stripped out. It just shows the internal table to the user and the user can click green check to continue, and red X to cancel.



report zrich_0001.


type-pools: slis.

data: begin of ima occurs 0,
      matnr type makt-matnr,
      maktx type makt-maktx,
      end of ima.

data: begin of ima2 occurs 0,
      matnr type makt-matnr,
      maktx type makt-maktx,
      end of ima2.

<b>data: exit type c.</b>

data: ifldc type slis_t_fieldcat_alv .
data: xfldc type slis_fieldcat_alv .

select matnr maktx into corresponding fields of table ima
         from makt up to 100 rows.

clear xfldc.
xfldc-reptext_ddic    = 'Material Number'.
xfldc-fieldname  = 'MATNR'.
xfldc-tabname   = 'IMA'.
xfldc-outputlen  = '18'.
append xfldc to ifldc.

clear xfldc.
xfldc-reptext_ddic    = 'Material Description'.
xfldc-fieldname  = 'MAKTX'.
xfldc-tabname   = 'IMA'.
xfldc-outputlen  = '40'.
append xfldc to ifldc.

call function 'REUSE_ALV_POPUP_TO_SELECT'
     exporting
<b>          I_SELECTION          = space</b>
          i_tabname            = 'IMA'
          it_fieldcat          = ifldc
<b>     importing
          E_EXIT               = exit</b>
     tables
          t_outtab             = ima
     exceptions
          program_error        = 1
          others               = 2.

<b>if exit = space.
* Do what ever
else.
* User pressed on the cancel button, don't do anything
Endif.</b>

Regards,

Rich Heilman

8 REPLIES 8

Former Member
0 Kudos

Hi,

use the FM REUSE_ALV_POPUP_TO_SELECT..

Thanks,

Naren

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

Tom, check this sample program. This program actually allows the user to select the records in the popup, for your requirement you can just comment out the references to the CHECK field, and just accept the entire internal table as records that you want to process.




report zrich_0001.

type-pools: slis.

data: begin of ima occurs 0,
      check type c,
      matnr type makt-matnr,
      maktx type makt-maktx,
      end of ima.

data: begin of ima2 occurs 0,
      check type c,
      matnr type makt-matnr,
      maktx type makt-maktx,
      end of ima2.

data: ifldc type slis_t_fieldcat_alv .
data: xfldc type slis_fieldcat_alv .

select matnr maktx into corresponding fields of table ima
         from makt up to 100 rows.


clear xfldc.
xfldc-reptext_ddic    = ' '.
xfldc-fieldname  = 'CHECK'.
xfldc-tabname   = 'IMA'.
xfldc-outputlen  = '1'.
append xfldc to ifldc.

clear xfldc.
xfldc-reptext_ddic    = 'Material Number'.
xfldc-fieldname  = 'MATNR'.
xfldc-tabname   = 'IMA'.
xfldc-outputlen  = '18'.
append xfldc to ifldc.

clear xfldc.
xfldc-reptext_ddic    = 'Material Description'.
xfldc-fieldname  = 'MAKTX'.
xfldc-tabname   = 'IMA'.
xfldc-outputlen  = '40'.
append xfldc to ifldc.

<b>call function 'REUSE_ALV_POPUP_TO_SELECT'
     exporting
          i_checkbox_fieldname = 'CHECK'
          i_tabname            = 'IMA'
          it_fieldcat          = ifldc
     tables
          t_outtab             = ima
     exceptions
          program_error        = 1
          others               = 2.</b>

check sy-subrc  = 0.


* Write selected lines to anther itab.
loop at ima where check = 'X'.
  clear ima2.
  move ima to ima2.
  append ima2.
endloop.


* Write out other itab.

loop at ima2.
  write:/ ima2-matnr, ima2-maktx.
endloop.

Regards,

Rich Heilman

0 Kudos

Thanks Rich and Naren. But my issue is only to display those records which is in an internal table ITAB already, and then let user click 'continue' or 'cancel'. I don't need to do any selection. Can you give me any function to do that?

Tom

Former Member
0 Kudos

Hi,

If you don't want to build the field catalog..

Use the FM POPUP_WITH_TABLE_DISPLAY..

Thanks,

Naren

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

Tom, you can strip all of the seletion functionality out of it. Here is my example, with all of the selection stripped out. It just shows the internal table to the user and the user can click green check to continue, and red X to cancel.



report zrich_0001.


type-pools: slis.

data: begin of ima occurs 0,
      matnr type makt-matnr,
      maktx type makt-maktx,
      end of ima.

data: begin of ima2 occurs 0,
      matnr type makt-matnr,
      maktx type makt-maktx,
      end of ima2.

<b>data: exit type c.</b>

data: ifldc type slis_t_fieldcat_alv .
data: xfldc type slis_fieldcat_alv .

select matnr maktx into corresponding fields of table ima
         from makt up to 100 rows.

clear xfldc.
xfldc-reptext_ddic    = 'Material Number'.
xfldc-fieldname  = 'MATNR'.
xfldc-tabname   = 'IMA'.
xfldc-outputlen  = '18'.
append xfldc to ifldc.

clear xfldc.
xfldc-reptext_ddic    = 'Material Description'.
xfldc-fieldname  = 'MAKTX'.
xfldc-tabname   = 'IMA'.
xfldc-outputlen  = '40'.
append xfldc to ifldc.

call function 'REUSE_ALV_POPUP_TO_SELECT'
     exporting
<b>          I_SELECTION          = space</b>
          i_tabname            = 'IMA'
          it_fieldcat          = ifldc
<b>     importing
          E_EXIT               = exit</b>
     tables
          t_outtab             = ima
     exceptions
          program_error        = 1
          others               = 2.

<b>if exit = space.
* Do what ever
else.
* User pressed on the cancel button, don't do anything
Endif.</b>

Regards,

Rich Heilman

0 Kudos

Hi Rich and Naren, Thanks a lot! Both of your suggestions could solve my problem but they are still not the best solution because both two functions generate a new screen to display the content of the table. I hope to get the pop-up screen overlapped on the original screen. Can I do that?

Tom

0 Kudos

The reason I want to keep pop-up dialog on the same screen is let user can confirm the contents in the pop-up window by comparing with the contents on the original alv screen. So they can make sure records which would be deleted are all right.

0 Kudos

Tom, my sample program works really good and it is a popup dialog box which does overlap the screen. Here is my test program for the same, I can still see my screen 100 underneath the dialog. IT has a text field with two bottons one for ALV and another for BACK.



report zrich_0001.


type-pools: slis.

data: begin of ima occurs 0,
      matnr type makt-matnr,
      maktx type makt-maktx,
      end of ima.

data: begin of ima2 occurs 0,
      matnr type makt-matnr,
      maktx type makt-maktx,
      end of ima2.

data: ok_code type sy-ucomm.
data: exit type c.

data: ifldc type slis_t_fieldcat_alv .
data: xfldc type slis_fieldcat_alv .

select matnr maktx into corresponding fields of table ima
         from makt up to 100 rows.

clear xfldc.
xfldc-reptext_ddic    = 'Material Number'.
xfldc-fieldname  = 'MATNR'.
xfldc-tabname   = 'IMA'.
xfldc-outputlen  = '18'.
append xfldc to ifldc.

clear xfldc.
xfldc-reptext_ddic    = 'Material Description'.
xfldc-fieldname  = 'MAKTX'.
xfldc-tabname   = 'IMA'.
xfldc-outputlen  = '40'.
append xfldc to ifldc.



call screen 100.


*&---------------------------------------------------------------------*
*&      Module  STATUS_0100  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
module status_0100 output.
*  SET PF-STATUS 'xxxxxxxx'.
*  SET TITLEBAR 'xxx'.

endmodule.                 " STATUS_0100  OUTPUT
*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_0100  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
module user_command_0100 input.

  case ok_code.
    when 'BACK'.
      clear ok_code.
      leave program.
    when 'ALV'.
      clear ok_code.



      call function 'REUSE_ALV_POPUP_TO_SELECT'
           exporting
                i_selection   = space
                i_tabname     = 'IMA'
                it_fieldcat   = ifldc
           importing
                e_exit        = exit
           tables
                t_outtab      = ima
           exceptions
                program_error = 1
                others        = 2.

      if exit = space.
* Do what ever
      else.
* User pressed on the cancel button, don't do anything
      endif.

  endcase.

endmodule.                 " USER_COMMAND_0100  INPUT

Again, the dialog does overlap the screen from which it was called from. At least in my example. Are you saying that you can not see your original screen underneath the dialog box ?

Regards,

Rich Heilman