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: 

Problem with ALV Report Column

Former Member
0 Kudos
275

Hi

I have ALV report that got tons of columns and most of them are showing correctly. But there are two or three where i have a do sum checked got a small problem. The HEADING of the columns says NUMBER instead of its column name...

Look at my code:


********************************************************
  ls_fieldcat-fieldname      =      'ETIME'.
  ls_fieldcat-ref_tabname    =      'REC'.
  ls_fieldcat-ref_fieldname  =      'ETIME'.
  ls_fieldcat-seltext_s      =      'ET      '.
  ls_fieldcat-seltext_m      =      'Et Tm           '.
  ls_fieldcat-seltext_l      =   'End Time             '.
  append ls_fieldcat to pt_fieldcat.
*****************************************************
  ls_fieldcat-fieldname      =                'HOURS'.
  ls_fieldcat-ref_tabname    =                'PC2BF'.
  ls_fieldcat-ref_fieldname  =                'ANZHL'.
  ls_fieldcat-seltext_s      =                'Hrs    '.
  ls_fieldcat-seltext_m      =                'Hors '.
  ls_fieldcat-seltext_l      =                'Hours'.
  ls_fieldcat-decimals_out = 2.
  ls_fieldcat-no_zero = 'X'.
  ls_fieldcat-datatype = 'DEC'.
  ls_fieldcat-do_sum = 'X'.
  append ls_fieldcat to pt_fieldcat.
  ls_fieldcat-no_zero = ''.
  ls_fieldcat-datatype = ''.
  ls_fieldcat-outputlen = ''.
  ls_fieldcat-do_sum = ''.
  ls_fieldcat-decimals_out = ''.
  ls_fieldcat-fieldname = ''.
******************************************************
  ls_fieldcat-fieldname      =                'PNUMB'.
  ls_fieldcat-ref_tabname    =                'PC20E'.
  ls_fieldcat-ref_fieldname  =                'PRAKN'.
  ls_fieldcat-seltext_s      =                'P#     '.
  ls_fieldcat-seltext_m      =     'Pre #       '.
  ls_fieldcat-seltext_l      =   'Premium #           '.
  ls_fieldcat-datatype       =                'NUMC'.
  append ls_fieldcat to pt_fieldcat.
  ls_fieldcat-datatype       = ''.
*************************************************

The column with Hours is showing NUMBER with the total sum but the column before and after that shows correctly.

I have tried taken out the

<b> ls_fieldcat-do_sum = 'X'.</b>

Then its shows correctly but i need it to do the sum.

Is there anything i need to do in order to show the columns correctly?

Please help. <b><REMOVED BY MODERATOR></b>. thanks

Message was edited by:

Anwarul Kabir

Message was edited by:

Anwarul Kabir

Message was edited by:

Alvaro Tejada Galindo

1 ACCEPTED SOLUTION

Former Member
0 Kudos
199

How are generating your field catalog? Are you using function module - REUSE_ALV_FIELDCATALOG_MERGE?

ashish

28 REPLIES 28

Former Member
0 Kudos
200

How are generating your field catalog? Are you using function module - REUSE_ALV_FIELDCATALOG_MERGE?

ashish

0 Kudos
199

No actually that's all what i am doing to build the catalog. I add each column to append ls_fieldcat to pt_fieldcat and pass that.


*************************************************
* BUILD_FIELD_CATALOG
************************************************
form build_field_catalog USING pt_fieldcat type
                               slis_t_fieldcat_alv.
  data:  ls_fieldcat type slis_fieldcat_alv.
  clear: fieldcat, pt_fieldcat[].

Message was edited by:

Anwarul Kabir

0 Kudos
199

Why don't you use the function module instead of populating field catalog manually?

0 Kudos
199

hmm because i don't know that's how i found a code and i am following that...

DO you have an example code so that in future i can follow that.

Thanks

0 Kudos
199

It is very simple -

I am also attaching sample code. But here are the steps.

Suppose Your final internal table name is IT_FINAL. Make sure that all fields are declared as LIKE and not TYPE when you are referring to a database field

For eg : EBELN LIKE EKKO-EBELN & it should not be like EBELN TYPE EKKO-EBELN.

Then call fm REUSE_ALV_FIELDCATALOG_MERGE

  • To build the Field Catlog.

data : l_tabname type slis_tabname. " Table Name

l_tabname = 'TB_FINAL'.

refresh : tb_fieldcat.

clear : tb_fieldcat.

call function 'REUSE_ALV_FIELDCATALOG_MERGE'

exporting

i_program_name = g_repid

i_internal_tabname = l_tabname

i_inclname = g_repid

changing

ct_fieldcat = tb_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.

TB_FIELDCAT declaration :

data: tb_fieldcat type slis_t_fieldcat_alv, " Field Catalog

TB_FIELDCAT will contain the fieldcatalog for the internal table TB_FINAL. This you can pass to ALV report.

You can modify the field catalog to add DO_SUM parameters:

  • Getting the Header Text for the Coloumns

loop at tb_fieldcat into x_fieldcat.

clear l_tabix.

l_tabix = sy-tabix.

case x_fieldcat-fieldname.

  • Sales Org

when 'VKORG'.

x_fieldcat-seltext_l = 'Sales Org'(001).

x_fieldcat-ddictxt = l_ddictxt.

x_fieldcat-key = c_x.

  • Channel

when 'MENGE'.

x_fieldcat-do_sum = c_x.

endcase.

modify tb_fieldcat from x_fieldcat index l_tabix.

endloop.

Also check this link -

Hope this helps.

ashish

0 Kudos
199

thanks for the code. I will certainly try it next time. But i think for this report it won't work as i have some TYPE columns. and One of them is the hours which is giving me the problem...

0 Kudos
199

Can you change the declaration of column HOURS from TYPE to LIKE? How did you declare this field in your final internal table?

Please change once and see. It should work. I am not sure why but TYPE declaration does not work in ALV (when you declare fields using TYPE and data dictionary reference)

ashish

0 Kudos
199

Well actually i changed it because of the SUM_DO thing. I guess i can change back to its original field and see in your way weather it works or not.

I don't have enough time to do so today i will start that tomorow and will let you know how it went...

0 Kudos
199

hi

I was working on anew report and decided to do in your way. but its giving me Run time error.

Here is my code:


DATA: BEGIN OF REC OCCURS 0,
  PERNR TYPE TEVEN-PERNR,
  LDATE TYPE TEVEN-LDATE,
  LTIME TYPE TEVEN-LTIME,
  SATZA TYPE TEVEN-SATZA,
  TERID TYPE TEVEN-TERID,
  PLANS TYPE TEVEN-PLANS.


DATA: END OF REC.

...
*************************************************
*  CALL_ALV
**************************************************
form call_alv.

  perform build_field_catalog using field_tab[].
  perform build_eventtab      using events[].
  perform comment_build       using header_alv[].
  perform build_sorttab       using gt_sort[].
  perform build_layout.
* Call ABAP List Viewer
  call function 'REUSE_ALV_GRID_DISPLAY'
    exporting
      i_callback_program      = v_repid
      i_callback_user_command = 'ALV_USER_COMMAND'
      i_structure_name        = 'REC'
      it_fieldcat             = field_tab[]
      it_special_groups       = gt_sp_group[]
      it_sort                 = gt_sort[]
      i_save                  = v_save
      is_variant              = v_variant
      it_events               = events[]
      is_layout               = gd_layout
    tables
      t_outtab                 = REC
    exceptions
      program_error            = 1
      others                   = 2.

endform.                    "call_alv

*********************************************
* BUILD_FIELD_CATALOG
*****************************************
form build_field_catalog USING pt_fieldcat type
                               slis_t_fieldcat_alv.
  data:  ls_fieldcat type slis_fieldcat_alv.
  clear: fieldcat, pt_fieldcat[].

  call function 'REUSE_ALV_FIELDCATALOG_MERGE'
    exporting
      i_program_name = v_repid
      i_internal_tabname = REC
      i_inclname = v_repid
    changing
      ct_fieldcat = ls_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.
 else.
    append ls_fieldcat to pt_fieldcat.
  endif.


endform.                    "build_field_catalog

Please Help

Message was edited by:

Anwarul Kabir

0 Kudos
199

Hi,

Change declaration of REC from TYPE to LIKE.

DATA: BEGIN OF REC OCCURS 0,

PERNR LIKE TEVEN-PERNR,

LDATE LIKE TEVEN-LDATE,

LTIME LIKE TEVEN-LTIME,

SATZA LIKE TEVEN-SATZA,

TERID LIKE TEVEN-TERID,

PLANS LIKE TEVEN-PLANS.

DATA: END OF REC.

In field catalog merge function module, keep a break point and check if field catalog is generated after the function call.

ashish

0 Kudos
199

ok changed it but as soon as i hit F5 on the call function it breaks.

One thing i want to mention here not all the fields have data. but that shouldn't be a reason the error should it?

Message was edited by:

Anwarul Kabir

0 Kudos
199

Change declaration of ls_fieldcat. Also it should be declared as a global variable as you are going to use this in the display function module.

data: tb_fieldcat type slis_t_fieldcat_alv. " Field Catalog

ashish

PS: Change your display function module call parameters -

  • Call ABAP List Viewer

call function 'REUSE_ALV_GRID_DISPLAY'

exporting

i_callback_program = v_repid

i_callback_user_command = 'ALV_USER_COMMAND'

i_structure_name = 'REC'

it_fieldcat = field_tab

it_special_groups = gt_sp_group

it_sort = gt_sort

i_save = v_save

is_variant = v_variant

it_events = events

is_layout = gd_layout

tables

t_outtab = REC

exceptions

program_error = 1

others = 2.

Message was edited by:

Ashish Gundawar

0 Kudos
199

here is what i have done so far

Changed declaraion of REC from TYPE to LIKE,

changed ls_fieldcat type slis_t_fieldcat_alv

and made it global.

Still the same error.

0 Kudos
199

What is the error you are getting? Did you try to debug the code? Also check the dump analysis, it helps to fix the problem. I believe as the dump occurs on function call, you might not have declared parameters passed to function module correctly. There is type conflict.

ashish

0 Kudos
199

Ok i have also chaged my

call function 'REUSE_ALV_GRID_DISPLAY'

But its not even going that far.

I also found the in the merge function when i was passing the table name i didn't use ' ' now i have done that and it still errors out. here what its says

READ_REPORT_LINE_TOO_LONG

the current ABAP application program "SAPLSKBH" had to be terminated because one of the statements could not be executed

0 Kudos
199

Hi,

Have you made changes to function module ?

call function 'REUSE_ALV_FIELDCATALOG_MERGE'

exporting

i_program_name = v_repid (Should be declared LIKE SY-REPID)

i_internal_tabname = REC (a variable should be declared LIKE SLIS_TABNAME, and pass value of REC to this variable)

i_inclname = v_repid

changing

ct_fieldcat = ls_fieldcat (Ihave already told you about this one)

exceptions

inconsistent_interface = 1

program_error = 2

others = 3.

ashish

0 Kudos
199

no i didn't made any changes tot he function it self...

v_repid is declared as sy-Repid and it holds the report name (i debuged it)

REC is declared as an internal table. so i should just declare a Variable as slis_tabname and move all data from rec to that variable and pass that as i_internal_tabname?

0 Kudos
199

If you see parameter i_internal_tabname, it is a character variable which will hold table name.

When you need to generate field catalog, you need to pass internal table NAME for whom you want to generate field catalog (we are not talking about data here). So declare a variable of type slis_tabname and pas svalue of REC to this variable.

DATA: V_TABNAME TYPE slis_tabname.

V_TABNAME = 'REC'.

Now pass V_TABNAME to the function module.

ashish

0 Kudos
199

here is the whole program. you can upload this run it for your self if that helps in any way...


*&---------------------------*
*& Report  ZHEADCOUNT       *
*&              *


REPORT  ZHEADCOUNT no standard page 
heading message-id zw line-size 255.
*--------------------------------------------
*       Dictionary tables/structures
*--------------------------------------------
tables: teven,
        ZSHIFTS,
        ZHEADCT.
* Global ALV Data Declarations
type-pools slis.

include: rpcxB200, RPTBAL01.

DATA: BEGIN OF REC OCCURS 0,
  PERNR LIKE TEVEN-PERNR,
  LDATE LIKE TEVEN-LDATE,
  LTIME LIKE TEVEN-LTIME,
  SATZA LIKE TEVEN-SATZA,
  TERID LIKE TEVEN-TERID,
  PLANS LIKE TEVEN-PLANS.


DATA: END OF REC.

data:
  begin of x_sortinfo_alv occurs 0,
      spos                  like alvdynp-sortpos,
      fieldname             type slis_fieldname,
      tabname               type slis_fieldname,
      up                    like alvdynp-sortup,
      down                  like alvdynp-sortdown,
      group                 like alvdynp-grouplevel,
      subtot                like alvdynp-subtotals,
      comp(1)               type c,
      expa(1)               type c,
      obligatory(1)         type c,
    end   of x_sortinfo_alv,
    d                like scal-indicator,   
    v_variant        like disvariant,
    v_repid          like sy-repid,
    v_save(1)        type c,
    lv_sortseq       type i,
    s_title(20),     
    fieldcat         type slis_t_fieldcat_alv,
    ls_line          type slis_listheader,
    gd_layout        type slis_layout_alv,
    gt_sp_group      type slis_t_sp_group_alv,
    gt_sort          type slis_t_sortinfo_alv,
    ls_sort          type slis_sortinfo_alv,
    events           type slis_t_event,
    list_top_of_page type slis_t_listheader,
    top_of_page      type slis_formname value 'TOP_OF_PAGE',
    v_exit(1)        type c,
    v_pdsnr like assob-pdsnr,
    ls_fieldcat type slis_t_fieldcat_alv.

constants:
  alv_slis_formname       type slis_formname value 'ALV_USER_COMMAND',
  c_yes                   like space value 'X',
  c_no                    like space value space,
  c_dev LIKE  sy-sysid VALUE 'DEV',
  c_device(4) TYPE c   VALUE 'LOCL'.
*********************************
* define selection screen
*********************************
selection-screen begin of block elmo with frame title text-001.
selection-screen begin of line.
selection-screen comment 1(30) text-002.
select-options  p_terid for TEVEN-TERID.
selection-screen end of line.

selection-screen begin of line.
selection-screen comment 1(30) text-003.
select-options p_shift for ZSHIFTS-DWS.
selection-screen end of line.
selection-screen end of block elmo.

selection-screen begin of block blk2 with frame title text-004.
PARAMETERS: p_vari like disvariant-variant.
selection-screen end   of block blk2.

******************
*  Form  Initialization
**************************
initialization.
  v_repid = sy-repid.
  v_save = 'A'.
  clear v_variant.
  v_variant-report = v_repid.

* Get default variant
  alv_variant = v_variant.
  call function 'REUSE_ALV_VARIANT_DEFAULT_GET'
    EXPORTING
      i_save     = v_save
    CHANGING
      cs_variant = alv_variant
    EXCEPTIONS
      not_found  = 2.
  if sy-subrc = 0.
    p_vari = alv_variant-variant.
  endif.
*------------------------------------
*  At Selection-Screen event (value help)
*-----------------------------------
at selection-screen on value-request for p_vari.
  perform f4_for_variant.
*--------------------------
*  At Selection-Screen event (check input data)
*----------------------------------------
at selection-screen on p_vari.
  if p_vari <> space.
    v_variant-report  = v_repid.
    v_variant-variant = p_vari.
    call function 'REUSE_ALV_VARIANT_SELECT'
      EXPORTING
        i_dialog            = c_no
        it_default_fieldcat = field_tab[]
        i_layout            = gs_layout
      CHANGING
        cs_variant          = v_variant.
    if sy-subrc <> 0.
      call function 'REUSE_ALV_VARIANT_SELECT'
        EXPORTING
          i_dialog            = c_yes
          it_default_fieldcat = field_tab[]
          i_layout            = gs_layout
        CHANGING
          cs_variant          = v_variant.
    endif.
  endif.
*------------------------------------
*                       main logic
*------------------------------------
TOP-OF-PAGE.

START-OF-SELECTION.

GET PERNR.
  RP-PROVIDE-FROM-LAST P0001 SPACE PNPBEGDA PNPENDDA.
* process the data according to the payroll area
  IF PERNR-WERKS EQ P0001-WERKS AND PERNR-BTRTL EQ P0001-BTRTL
     AND PERNR-KOSTL EQ P0001-KOSTL AND PERNR-BUKRS EQ P0001-BUKRS
     AND PERNR-ABKRS EQ P0001-ABKRS AND PERNR-KOKRS EQ P0001-KOKRS.
    PERFORM RETRIEVE_Time.
  ENDIF.

END-OF-SELECTION.
  Perform call_alv.
*==================================*
*                   *
*=================================*
FORM RETRIEVE_Time.

 Clear: REC.

       Select * from teven where PERNR EQ PERNR-PERNR
                             AND TERID IN p_terid
                             AND LDATE >= PNPBEGDA
                             AND LDATE <= PNPENDDA.
            MOVE:
                 TEVEN-PERNR TO REC-PERNR,
                 TEVEN-LDATE TO REC-LDATE,
                 TEVEN-LTIME TO REC-LTIME,
                 TEVEN-SATZA TO REC-SATZA,
                 TEVEN-TERID TO REC-TERID,
                 TEVEN-PLANS TO REC-PLANS.

            APPEND REC.
       endselect.
ENDFORM.                            " RETRIEVE_PAYROLL

*********************************
*  CALL_ALV
******************************
form call_alv.

  perform build_field_catalog using field_tab[].
  perform build_eventtab      using events[].
  perform comment_build       using header_alv[].
  perform build_sorttab       using gt_sort[].
  perform build_layout.
* Call ABAP List Viewer
  call function 'REUSE_ALV_GRID_DISPLAY'
    exporting
      i_callback_program      = v_repid
      i_callback_user_command = 'ALV_USER_COMMAND'
      i_structure_name        = 'REC'
      it_fieldcat             = field_tab
      it_special_groups       = gt_sp_group
      it_sort                 = gt_sort
      i_save                  = v_save
      is_variant              = v_variant
      it_events               = events
      is_layout               = gd_layout
    tables
      t_outtab                 = REC
    exceptions
      program_error            = 1
      others                   = 2.

endform.                    "call_alv
************************************
* BUILD_FIELD_CATALOG
*********************************
form build_field_catalog USING pt_fieldcat type
                               slis_t_fieldcat_alv.
*  data:  ls_fieldcat type slis_fieldcat_alv.
  clear: fieldcat, pt_fieldcat[].

  data : l_tabname type slis_tabname. " Table Name
   l_tabname = 'REC'.


  call function 'REUSE_ALV_FIELDCATALOG_MERGE'
    exporting
      i_program_name = v_repid
      i_internal_tabname = l_tabname
      i_inclname = v_repid
    changing
      ct_fieldcat = ls_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.
  else.
*    append ls_fieldcat to pt_fieldcat.
  endif.


endform.                    "build_field_catalog
********************************
* BUILD_EVENTTAB
**************************
form build_eventtab using events type slis_t_event.
* Registration of events to happen during list display
  data: tmp_event type slis_alv_event.
  call function 'REUSE_ALV_EVENTS_GET'
    EXPORTING
      i_list_type = 0
    IMPORTING
      et_events   = events.
  read table events with key name = slis_ev_top_of_page into tmp_event.

  if sy-subrc = 0.
    move top_of_page to tmp_event-form.
    append tmp_event to events.
  endif.
endform.                    "build_eventtab
*************************************
* COMMENT_BUILD
***********************************
form comment_build using pt_top_of_page type slis_t_listheader.
  data: v_head_string(255) value space, d1(2), m1(2), y1(2), d2(2), m2(2), y2(2).
  clear: ls_line, pt_top_of_page.
  ls_line-typ  = 'H'.
  data pnpfrom(10).
  data pnpto(10).
  data: print_date(10).
  data: print_time(10).
  d1 = PNPBEGDA+6(2).          d2 = PNPENDDA+6(2).
  m1 = PNPBEGDA+4(2).          m2 = PNPENDDA+4(2).
  y1 = PNPBEGDA+2(2).          y2 = PNPENDDA+2(2).
  concatenate m1 '/' d1 '/' y1 into pnpfrom.
  concatenate m2 '/' d2 '/' y2 into pnpto.
***********************************
  ls_line-info = sy-repid.
  append ls_line to pt_top_of_page.
********************************
  concatenate 'Printed by:' sy-uname 'on' print_date 'at' print_time
  into ls_line-info separated by space.
  append ls_line to pt_top_of_page.
**********************************
  ls_line-info = 'BGM INDUSTRIES, INC.'.
  append ls_line to pt_top_of_page.
*********************************
  concatenate 'Period:' pnpfrom 'to' pnpto
  into ls_line-info separated by space.
  append ls_line to pt_top_of_page.
********************************
endform.                    "comment_build
************************************
*       Build layout for ALV grid report
********************************
form build_layout.
  gd_layout-no_input          = 'X'.
  gd_layout-colwidth_optimize = 'X'.
*  gd_layout-totals_text       = 'Totals'(255).
*  gd_layout-info_fieldname    = 'LINE_COLOR'.
endform.                    " BUILD_LAYOUT
**********************************
* TOP_OF_PAGE
**********************************
form top_of_page.
  call function 'REUSE_ALV_COMMENTARY_WRITE'
    EXPORTING
      i_logo             = 'Z_BGLOGO'
      it_list_commentary = header_alv.
endform.                    "top_of_page
*&---------------------------------
*&      Form  build_sorttab
*&-----------------------------------
*       Set up the sorting for the report.
*---------------------------------------
form build_sorttab using pt_sort type slis_t_sortinfo_alv.
  clear lv_sortseq.
* ******************************
  perform build_sort tables pt_sort changing ls_sort.
  ls_sort-fieldname = 'PERNR'.
  ls_sort-subtot    = 'X'.
endform.                    " build_sorttab
*******************************
*  Use to add another sort field.
*********************************
form build_sort
  tables   pt_sort
  changing ls_sort structure x_sortinfo_alv.
  clear ls_sort.
  add 1 to lv_sortseq.
  ls_sort-spos = lv_sortseq.
  ls_sort-up = 'X'.
  ls_sort-tabname = 'REC'.
endform.                    "build_sort


*&-----------------------------------
*&      Form  f4_for_variant
*&----------------------------------
form f4_for_variant.
  call function 'REUSE_ALV_VARIANT_F4'
    EXPORTING
      is_variant = v_variant
      i_save     = v_save
    IMPORTING
      e_exit     = v_exit
      es_variant = alv_variant
    EXCEPTIONS
      not_found  = 2.
  if sy-subrc = 2.
    message id sy-msgid type 'S' number sy-msgno
            with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  else.
    if v_exit = space.
      p_vari = alv_variant-variant.
    endif.
  endif.
endform.


Message was edited by:

Anwarul Kabir

0 Kudos
199

Hi,

As your program contains Z tables, i am not able to run this one. Also what is the logical database you have assigned in the program attributes? And are you still getting error in the execution?

I see TOP-OF-PAGE before start of selection. As you are using ALV, this is not required, so you can remove that.

ashish

0 Kudos
199

Oh ok i will remove that line.

The report will do much more than what's it doing now. I have used TEVEN so far. so you should be able to run it. just take out those z tables from the declaration.

SO far it is using only TEVEN to get some data. And i was trying to see if I can get it to show the ALV by using your code.

Yeah i am still getting teh same error.

0 Kudos
199

I am debugging the function to pin point where its breaking and looks like its trying to get a i_structure name which we are not passing here.

0 Kudos
199

Hi,

I got the dump in the beginning - error was "READ REPORT LINE TOO LONG"

If you are getting same error - do this. Got to program in CHANGE mode, click on Utilities --> Settings. Go to Editor tab and select checkbox for DOWNLOAD-COMP LINE. It will insert line breaks in the program. Activate program.

Goto your code -

call function 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = v_repid

i_callback_user_command = 'ALV_USER_COMMAND'

i_structure_name = 'REC'

it_fieldcat = field_tab

it_special_groups = gt_sp_group

it_sort = gt_sort

i_save = v_save

is_variant = v_variant

it_events = events

is_layout = gd_layout

TABLES

t_outtab = REC

EXCEPTIONS

program_error = 1

others = 2.

Change it_fieldcat = field_tab to

it_fieldcat = ls_fieldcat.

This should work.

All the best.

ashish

0 Kudos
199

Ok that did the trick. I have rewarded you points. but can you explain to me what did you or we did here that fixed it?

0 Kudos
199

Thanks for that and glad it is working.

First problem was while extracting field catalog. Function module reads code line by line and each line width is 72 characters. In the program there were some lines which were more than 72 characters long so it was giving dump and we fixed it using setting from Utilities menu.

Second was easier - you were populating field catalog in the internal table and were passing different internal table reference so it was giving a dump.

Hope this is clear and you will be able to build more ALVs.

ashish

0 Kudos
199

Hi

I am doing this part now


loop at tb_fieldcat into x_fieldcat.
clear l_tabix.
l_tabix = sy-tabix.

case x_fieldcat-fieldname.

* Sales Org
when 'VKORG'.
x_fieldcat-seltext_l = 'Sales Org'(001).
x_fieldcat-ddictxt = l_ddictxt.
x_fieldcat-key = c_x.
* Channel
when 'MENGE'.
x_fieldcat-do_sum = c_x.
endcase.
modify tb_fieldcat from x_fieldcat index l_tabix.
endloop.


Can you tell me what should i declare x_fieldcat AS?

0 Kudos
199

never mind I declared it as

data: x_fieldcat type slis_t_fieldcat_alv with header line,

l_tabix type sy-tabix.

Former Member
0 Kudos
199

I wonder why there is the restriction for 72 characters. I think it is pretty unreasonable to have a limit of 72 characters!