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: 

No data in popup with FM 'REUSE_ALV_POPUP_TO_SELECT'

ThomasSchmutz
Explorer
0 Kudos

Hi,

For a report I'm trying to get a popup in which the desired fieldnames of a given table can be chosen by selecting a checkbox.

Therefor I'm using the FM 'REUSE_ALV_POPUP_TO_SELECT'. In combination with a created dictionary table I was able to get a fully functional popup. Now I would like to do this without dictionary table, but as result I get only a popup with correct header, but no data. To specify there are no data and the grid has minimal distance between the fields.

Any ideas?

Regards,

Th. Schmutz

Below the code:

 
REPORT  z_tablecount_1_sdn. 

TYPE-POOLS: slis, abap. 

TABLES: dd04t. 

DATA: i_private TYPE slis_data_caller_exit, 
      i_selfield TYPE slis_selfield, 
      w_exit(1) TYPE c, 
      w_chk TYPE c. 

DATA: gt_fieldcat TYPE slis_t_fieldcat_alv, 
      wa_fieldcat TYPE slis_fieldcat_alv, 
      g_repid LIKE sy-repid. 

DATA: BEGIN OF ls_zouttab OCCURS 0. 
        INCLUDE STRUCTURE dd03l. 
DATA:   ddlanguage LIKE dd04t-ddlanguage, 
        ddtext LIKE dd04t-ddtext, 
        reptext LIKE dd04t-reptext, 
        scrtext_s LIKE dd04t-scrtext_s, 
        scrtext_m LIKE dd04t-scrtext_m, 
        scrtext_l LIKE dd04t-scrtext_l. 
DATA:   w_chk TYPE c. 
DATA: END OF ls_zouttab. 

DATA: lt_zouttab LIKE TABLE OF ls_zouttab. 

SELECTION-SCREEN BEGIN OF BLOCK eing. 
PARAMETERS: p_table TYPE dd03l-tabname OBLIGATORY. 
SELECTION-SCREEN END OF BLOCK eing. 

INITIALIZATION. 

AT SELECTION-SCREEN. 

START-OF-SELECTION. 

  g_repid = sy-repid. 

  CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE' 
   EXPORTING 
     i_program_name               = sy-repid 
    i_internal_tabname            = 'LS_ZOUTTAB' 
*     i_structure_name             = LS_ZOUTTAB 
     i_client_never_display       = 'X' 
     i_inclname                   = sy-repid 
     i_bypassing_buffer           = 'X' 
*    I_BUFFER_ACTIVE              = 
    CHANGING 
     ct_fieldcat                  = gt_fieldcat[] 
   EXCEPTIONS 
     inconsistent_interface       = 1 
     program_error                = 2 
     OTHERS                       = 3 
            . 
  IF sy-subrc <> 0. 
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno 
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. 
  ENDIF. 

  DATA: ls_fcat   LIKE LINE OF gt_fieldcat. 

  LOOP AT gt_fieldcat INTO ls_fcat. 
    CASE ls_fcat-fieldname. 
      WHEN 'TABNAME' 
        OR 'FIELDNAME'. 
        ls_fcat-no_out = ''. 
        ls_fcat-key = 'X'. 
      WHEN 'DDTEXT'. 
        ls_fcat-no_out = ''. 
        ls_fcat-key = ''. 
      WHEN OTHERS. 
        ls_fcat-no_out = 'X'. 
        ls_fcat-key = ''. 
    ENDCASE. 

    ls_fcat-outputlen =  ls_fcat-intlen. 

    MODIFY gt_fieldcat FROM ls_fcat INDEX syst-tabix. 
  ENDLOOP. 

  SELECT * FROM dd03l INTO CORRESPONDING FIELDS OF TABLE lt_zouttab 
    WHERE tabname = p_table  . 

  DELETE lt_zouttab WHERE  fieldname CP '.INCLUDE*'. 
  SORT lt_zouttab BY position. 

  LOOP AT lt_zouttab INTO ls_zouttab. 

    SELECT SINGLE ddlanguage ddtext reptext scrtext_s scrtext_m 
    scrtext_l FROM dd04t 
      INTO CORRESPONDING FIELDS OF ls_zouttab 
       WHERE rollname = ls_zouttab-rollname 
       AND   ddlanguage = 'DE' 
       AND   as4local = 'A'. 

    MODIFY lt_zouttab FROM ls_zouttab. 
  ENDLOOP. 

  CALL FUNCTION 'REUSE_ALV_POPUP_TO_SELECT' 
       EXPORTING 
           i_title                 = p_table 
           i_selection             = 'X' 
           i_zebra                 = 'X' 
*           i_screen_start_column   = 10 
*           i_screen_start_line     = 5 
*           i_screen_end_column     = 135 
*           i_screen_end_line       = 30 
           i_checkbox_fieldname    = 'W_CHK' 
*          I_LINEMARK_FIELDNAME    = 
*          I_SCROLL_TO_SEL_LINE    = 'X' 
           i_tabname               = 'lt_zouttab' 
*          i_structure_name        = 
           it_fieldcat             = gt_fieldcat[] 
*          IT_EXCLUDING            = 
*          I_CALLBACK_PROGRAM      = 
*          I_CALLBACK_USER_COMMAND = 
*          IS_PRIVATE             = I_PRIVATE 
     IMPORTING 
            es_selfield             = i_selfield 
            e_exit                  = w_exit 
       TABLES 
            t_outtab                = lt_zouttab 
       EXCEPTIONS 
            program_error           = 1 
            OTHERS                  = 2. 

  IF sy-subrc <> 0. 
*    MESSAGE i000(0k) WITH sy-subrc. 
  ENDIF. 

1 ACCEPTED SOLUTION

andreas_mann3
Active Contributor
0 Kudos

try 1st:

1) use g_repid instead of sy-repid

2) fm 'REUSE_ALV_FIELDCATALOG_MERGE' processes only variables defined with like

and not with type or include

hope that helps

Andreas

3 REPLIES 3

andreas_mann3
Active Contributor
0 Kudos

try 1st:

1) use g_repid instead of sy-repid

2) fm 'REUSE_ALV_FIELDCATALOG_MERGE' processes only variables defined with like

and not with type or include

hope that helps

Andreas

0 Kudos

Thanks for your answer.

Replaced sy-repid with g_repid and also changed the data definition. So now it looks like:

DATA: BEGIN OF ls_zouttab OCCURS 0.
        INCLUDE STRUCTURE dd03l.
DATA:   ddlanguage LIKE dd04t-ddlanguage,
        ddtext LIKE dd04t-ddtext,
        reptext LIKE dd04t-reptext,
        scrtext_s LIKE dd04t-scrtext_s,
        scrtext_m LIKE dd04t-scrtext_m,
        scrtext_l LIKE dd04t-scrtext_l.
DATA:   w_chk like abap_false. "TYPE c.
DATA: END OF ls_zouttab.

According to the FM documentation LIKE or INCLUDE STRUCTURE should work.

Dictionary references are only considered if the keywords LIKE or INCLUDE STRUCTURE (not TYPE) are used.

regards,

Thomas

0 Kudos

Finally found the problem - so just for the record...

In FM 'REUSE_ALV_FIELDCATALOG_MERGE' the CHANGING table gt_fieldcat[] is getting filled for column 'tabname' with the structure name 'LS_ZOUTTAB'.

Corresponding to the function module documentation of the FM 'REUSE_ALV_POPUP_TO_SELECT' for the field tabname (internal output table):

Name of the internal output table which contains the field FIELDCAT-FIELDNAME.

So, changing structure name to table name in the code as follows made it works:

...

LOOP AT gt_fieldcat INTO ls_fcat.

ls_fcat-tabname = 'lt_zouttab'. "<-- new line

CASE ls_fcat-fieldname.

WHEN 'TABNAME'

OR 'FIELDNAME'.

ls_fcat-no_out = ''.

ls_fcat-key = 'X'.

WHEN 'DDTEXT'.

ls_fcat-no_out = ''.

ls_fcat-key = ''.

WHEN OTHERS.

ls_fcat-no_out = 'X'.

ls_fcat-key = ''.

ENDCASE.

...

cheers

Thomas