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

ALV report problem. empty catalog.

Former Member
0 Likes
1,735

Hi everybody,

I'm having a lot of problems with the ALV displaying stuff, i can see no problems in the code but the alv doesnt display anything at all, the catalog is built but any data is displayed in the list, i even took the function call out of the perform and called REUSE_ALV_GRID_DISPLAY directly to avoid posting any parametres...but the list is still empty.

here i post the code, is really simple alv example. take info from it001, 002 and 006 and (try to )display that in a alv list.

If someone see something wrong i would really apreciate it.

Thanks in advance,

Ruben.

REPORT ZPRR3_12.

______________________________________________________________________

  • TYPE-POOLS

______________________________________________________________________

CONSTANTS: C_CHECK TYPE c VALUE 'X'.

DATA : v_rep_id TYPE sy-repid.

DATA: BEGIN OF t_employee OCCURS 0,

pernr TYPE persno,

begda TYPE begda,

endda TYPE endda,

bukrs TYPE bukrs,

werks TYPE persa,

persg TYPE persg,

persk TYPE persk,

orgeh TYPE orgeh,

plans TYPE plans,

stell TYPE stell,

nachn TYPE pad_nachn,

vorna TYPE pad_vorna,

gesch TYPE gesch,

gbdat TYPE gbdat,

pstlz TYPE pstlz_hr,

ort02 TYPE pad_ort02,

END OF t_employee.

" for alv functions.

TYPE-POOLS: slis, truxs.

DATA: gs_layout TYPE slis_layout_alv,

it_field TYPE slis_t_fieldcat_alv,

tt_fieldcat TYPE slis_fieldcat_alv.

TYPES: tt_fieldcat TYPE STANDARD TABLE OF slis_fieldcat_alv.

INITIALIZATION.

v_rep_id = sy-repid.

SELECTION-SCREEN BEGIN OF BLOCK parametres WITH FRAME TITLE text-001.

SELECT-OPTIONS: persnum FOR t_employee-pernr DEFAULT 000.

SELECT-OPTIONS: ccode FOR t_employee-bukrs DEFAULT 'ES01'.

SELECT-OPTIONS: date FOR sy-datum.

SELECTION-SCREEN END OF BLOCK parametres.

SELECTION-SCREEN BEGIN OF BLOCK options WITH FRAME TITLE text-002.

PARAMETERS:

op_alv TYPE c AS CHECKBOX,

op_excel TYPE c AS CHECKBOX.

SELECTION-SCREEN END OF BLOCK options.

INITIALIZATION.

"initialize select-options

op_alv = C_CHECK.

op_excel = ''.

START-OF-SELECTION.

PERFORM data_request.

END-OF-SELECTION.

IF op_excel EQ C_CHECK.

*PERFORM excel_save.

ENDIF.

IF op_alv EQ C_CHECK.

PERFORM display_alv.

ELSE.

PERFORM write_raw USING t_employee.

ENDIF.

**********************************************************************

  • FORMS

**********************************************************************

*&----


*

*& Form CHARGE_DATA

*&----


*

FORM data_request.

SELECT pa0001pernr pa0001begda pa0001endda pa0001bukrs pa0001~werks

pa0001persg pa0001persk pa0001orgeh pa0001plans pa0001~stell

pa0002nachn pa0002vorna pa0002gesch pa0002gbdat

pa0006pstlz pa0006ort02

INTO CORRESPONDING FIELDS OF t_employee

FROM pa0001 JOIN pa0002 ON pa0001pernr = pa0002pernr

JOIN pa0006 ON pa0002pernr = pa0006pernr

WHERE pa0001~pernr IN persnum AND

pa0001~bukrs IN ccode AND

pa0001~begda IN date.

ENDSELECT.

ENDFORM. " CHARGE_DATA

*&----


*

*& Form display_alv

*&----


*

FORM display_alv.

PERFORM build_header.

PERFORM build_layout.

write t_employee-pernr.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = 'g_repid'

is_layout = gs_layout

it_fieldcat = it_field

TABLES

t_outtab = t_employee

EXCEPTIONS

program_error = 1

OTHERS = 2

.

IF sy-subrc <> 0.

MESSAGE i799(cu) WITH 'Error creando el ALV'(008) 'Código'(009) sy-subrc.

ENDIF.

  • PERFORM call_alv using t_employee.

ENDFORM. "display_alv

*&----


*

*& Form build_HEADER

*&----


*

form build_header.

DATA: wa_field TYPE slis_fieldcat_alv. "work area for field catalog

wa_field-fieldname = 'pernr'. " name of field from internal table

wa_field-tabname = 't_employee'. " internal table name

wa_field-outputlen = 10. " output length on screen

wa_field-checkbox = c_check. " print as checkbox

wa_field-edit = c_check. " make field open for input

wa_field-seltext_l = text-006. " header information

APPEND wa_field TO it_field. " append field catalog internal table

CLEAR wa_field. " clear field catalog work area

wa_field-fieldname = 'begda'. " name of field from internal table

wa_field-tabname = 't_employee'. " internal table name

wa_field-outputlen = 12. " output length on screen

wa_field-seltext_l = text-003. " header information

APPEND wa_field TO it_field. " append field catalog internal table

CLEAR wa_field. " clear field catalog work area

wa_field-fieldname = 'endda'. " name of field from internal table

wa_field-tabname = 't_employee'. " internal table name

wa_field-outputlen = 12. " output length on screen

wa_field-seltext_l = text-004. " header information

APPEND wa_field TO it_field. " append field catalog internal table

CLEAR wa_field. " clear field catalog work area

wa_field-fieldname = 'bukrs'. " name of field from internal table

wa_field-tabname = 't_employee'. " internal table name

wa_field-outputlen = 12. " output length on screen

wa_field-seltext_l = text-005. " header information

APPEND wa_field TO it_field. " append field catalog internal table

CLEAR wa_field. " clear field catalog work area

wa_field-fieldname = 'werks'. " name of field from internal table

wa_field-tabname = 't_employee'. " internal table name

wa_field-outputlen = 12. " output length on screen

wa_field-seltext_l = text-007. " header information

APPEND wa_field TO it_field. " append field catalog internal table

CLEAR wa_field. " clear field catalog work area

wa_field-fieldname = 'persg'. " name of field from internal table

wa_field-tabname = 't_employee'. " internal table name

wa_field-outputlen = 12. " output length on screen

wa_field-seltext_l = text-008. " header information

APPEND wa_field TO it_field. " append field catalog internal table

CLEAR wa_field. " clear field catalog work area

wa_field-fieldname = 'persk'. " name of field from internal table

wa_field-tabname = 't_employee'. " internal table name

wa_field-outputlen = 12. " output length on screen

wa_field-seltext_l = text-009. " header information

APPEND wa_field TO it_field. " append field catalog internal table

CLEAR wa_field. " clear field catalog work area

wa_field-fieldname = 'orgeh'. " name of field from internal table

wa_field-tabname = 't_employee'. " internal table name

wa_field-outputlen = 12. " output length on screen

wa_field-seltext_l = text-010. " header information

APPEND wa_field TO it_field. " append field catalog internal table

CLEAR wa_field. " clear field catalog work area

wa_field-fieldname = 'plans'. " name of field from internal table

wa_field-tabname = 't_employee'. " internal table name

wa_field-outputlen = 12. " output length on screen

wa_field-seltext_l = text-011. " header information

APPEND wa_field TO it_field. " append field catalog internal table

CLEAR wa_field. " clear field catalog work area

wa_field-fieldname = 'stell'. " name of field from internal table

wa_field-tabname = 't_employee'. " internal table name

wa_field-outputlen = 12. " output length on screen

wa_field-seltext_l = text-012. " header information

APPEND wa_field TO it_field. " append field catalog internal table

CLEAR wa_field. " clear field catalog work area

wa_field-fieldname = 'nachn'. " name of field from internal table

wa_field-tabname = 't_employee'. " internal table name

wa_field-outputlen = 12. " output length on screen

wa_field-seltext_l = text-013. " header information

APPEND wa_field TO it_field. " append field catalog internal table

CLEAR wa_field. " clear field catalog work area

wa_field-fieldname = 'vorna'. " name of field from internal table

wa_field-tabname = 't_employee'. " internal table name

wa_field-outputlen = 12. " output length on screen

wa_field-seltext_l = text-014. " header information

APPEND wa_field TO it_field. " append field catalog internal table

CLEAR wa_field. " clear field catalog work area

wa_field-fieldname = 'gesch'. " name of field from internal table

wa_field-tabname = 't_employee'. " internal table name

wa_field-outputlen = 12. " output length on screen

wa_field-seltext_l = text-015. " header information

APPEND wa_field TO it_field. " append field catalog internal table

CLEAR wa_field. " clear field catalog work area

wa_field-fieldname = 'gbdat'. " name of field from internal table

wa_field-tabname = 't_employee'. " internal table name

wa_field-outputlen = 12. " output length on screen

wa_field-seltext_l = text-016. " header information

APPEND wa_field TO it_field. " append field catalog internal table

CLEAR wa_field. " clear field catalog work area

wa_field-fieldname = 'pstlz'. " name of field from internal table

wa_field-tabname = 't_employee'. " internal table name

wa_field-outputlen = 12. " output length on screen

wa_field-seltext_l = text-017. " header information

APPEND wa_field TO it_field. " append field catalog internal table

CLEAR wa_field. " clear field catalog work area

wa_field-fieldname = 'ort0z'. " name of field from internal table

wa_field-tabname = 't_employee'. " internal table name

wa_field-outputlen = 12. " output length on screen

wa_field-seltext_l = text-018. " header information

APPEND wa_field TO it_field. " append field catalog internal table

CLEAR wa_field. " clear field catalog work area

endform. " PREPARE_FIELD_CATALOG

*&----


*

*& Form build_layout

*&----


*

  • text

*----


*

FORM build_layout.

gs_layout-colwidth_optimize = 'X'. "Optimizar ancho del listado

gs_layout-zebra = 'X'. "Mostrar líneas tipo cebra.

gs_layout-detail_popup = 'X'. "Mostrar opción de información detalle

ENDFORM. "build_layout

*&----


*

*& Form call_alv

*&----


*

  • text

*----


*

  • -->ALV_EMPLOYEE text

*----


*

*FORM call_alv using alv_employee LIKE t_employee.

    • ABAP List Viewer

*

**WRITE: alv_employee-pernr.

*

*

  • CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

  • EXPORTING

  • i_callback_program = 'g_repid'

  • is_layout = gs_layout

  • it_fieldcat = it_field[]

  • TABLES

  • t_outtab = alv_employee

  • EXCEPTIONS

  • program_error = 1

  • OTHERS = 2

  • .

  • IF sy-subrc <> 0.

  • MESSAGE i799(cu) WITH 'Error creando el ALV'(008) 'Código'(009) sy-subrc.

  • ENDIF.

*

*ENDFORM. "CALL_ALV

FORM write_raw USING p_ta_employee LIKE t_employee.

WRITE: p_ta_employee-pernr,p_ta_employee-begda,p_ta_employee-endda,p_ta_employee-bukrs,p_ta_employee-werks,p_ta_employee-persg,

p_ta_employee-persk,p_ta_employee-orgeh,p_ta_employee-plans,p_ta_employee-stell,p_ta_employee-nachn,p_ta_employee-vorna,

p_ta_employee-gesch,p_ta_employee-gbdat,p_ta_employee-pstlz,p_ta_employee-ort02.

ENDFORM. " WRITE_RAW

1 ACCEPTED SOLUTION
Read only

former_member585060
Active Contributor
0 Likes
1,504

Hi,

Past the code in between code option <> so that every one can read it clearly.

1) Instead of using SELECT and ENDSELECT use below syntax,

SELECT  pa0001~pernr 
              pa0001~begda 
              pa0001~endda 
              pa0001~bukrs 
              pa0001~werks
              pa0001~persg 
               pa0001~persk 
              pa0001~orgeh 
              pa0001~plans 
              pa0001~stell
              pa0002~nachn 
              pa0002~vorna 
              pa0002~gesch 
              pa0002~gbdat
              pa0006~pstlz 
              pa0006~ort02
              INTO CORRESPONDING FIELDS OF TABLE t_employee   " use TABLE 
  FROM ( ( pa0001 inner JOIN pa0002 ON pa0001~pernr = pa0002~pernr )
  INNER JOIN pa0006 ON pa0002~pernr = pa0006~pernr )
  WHERE pa0001~pernr IN persnum AND
               pa0001~bukrs IN ccode AND
               pa0001~begda IN date.

2) In FM

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      i_callback_program = v_rep_id                 "you were using 'g_repid' which is not at all declared
      is_layout          = gs_layout
      it_fieldcat        = it_field
    TABLES
      t_outtab           = t_employee
    EXCEPTIONS
      program_error      = 1
      OTHERS             = 2.
  IF sy-subrc <> 0.
    MESSAGE i799(cu) WITH 'Error creando el ALV'(008) 'Código'(009) sy-subrc.
  ENDIF.

3) Check wether the Table t_employee is consisting any data or not, by keeping a BREAK-POINT after the SELECT statement.

4) If possible while filling the field catalog fill ROW_POS and COL_POS, and always use capital letters when ever you give any value in single quotes.

wa_field-row_pos = '1'.
  wa_field-col_pos = '1'.
  wa_field-fieldname = 'PERNR'. " name of field from internal table
  wa_field-tabname = 'T_EMPLOYEE'. " internal table name
  wa_field-outputlen = 10. " output length on screen
  wa_field-checkbox = c_check. " print as checkbox
  wa_field-edit = c_check. " make field open for input
  wa_field-seltext_l = text-006. " header information
  APPEND wa_field TO it_field. " append field catalog internal table
  CLEAR wa_field. " clear field catalog work area

Regards

Bala Krishna

7 REPLIES 7
Read only

Mohamed_Mukhtar
Active Contributor
0 Likes
1,504

hi,


wa_field-fieldname = 'PERNR'  "---> UPPERCASE when in quotes 'pernr'. " name of field from internal table
wa_field-tabname = 'T_EMPLOYEE' "---> UPPERCASE when in quotes 't_employee'. " internal table name
wa_field-outputlen = 10. " output length on screen
wa_field-checkbox = c_check. " print as checkbox
wa_field-edit = c_check. " make field open for input
wa_field-seltext_l = text-006. " header information
APPEND wa_field TO it_field. " append field catalog internal table
CLEAR wa_field. " clear field catalog work area

" do the changes in your fieldcat for every field..write in UPPER CASE.


Read only

Former Member
0 Likes
1,504

Hi

always when u use the catalag, u need to fill the "fieldname" and "tabname" values using UPPERCASE letters.

doing that ur problem will be solved.

Regards.

Read only

former_member585060
Active Contributor
0 Likes
1,505

Hi,

Past the code in between code option <> so that every one can read it clearly.

1) Instead of using SELECT and ENDSELECT use below syntax,

SELECT  pa0001~pernr 
              pa0001~begda 
              pa0001~endda 
              pa0001~bukrs 
              pa0001~werks
              pa0001~persg 
               pa0001~persk 
              pa0001~orgeh 
              pa0001~plans 
              pa0001~stell
              pa0002~nachn 
              pa0002~vorna 
              pa0002~gesch 
              pa0002~gbdat
              pa0006~pstlz 
              pa0006~ort02
              INTO CORRESPONDING FIELDS OF TABLE t_employee   " use TABLE 
  FROM ( ( pa0001 inner JOIN pa0002 ON pa0001~pernr = pa0002~pernr )
  INNER JOIN pa0006 ON pa0002~pernr = pa0006~pernr )
  WHERE pa0001~pernr IN persnum AND
               pa0001~bukrs IN ccode AND
               pa0001~begda IN date.

2) In FM

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      i_callback_program = v_rep_id                 "you were using 'g_repid' which is not at all declared
      is_layout          = gs_layout
      it_fieldcat        = it_field
    TABLES
      t_outtab           = t_employee
    EXCEPTIONS
      program_error      = 1
      OTHERS             = 2.
  IF sy-subrc <> 0.
    MESSAGE i799(cu) WITH 'Error creando el ALV'(008) 'Código'(009) sy-subrc.
  ENDIF.

3) Check wether the Table t_employee is consisting any data or not, by keeping a BREAK-POINT after the SELECT statement.

4) If possible while filling the field catalog fill ROW_POS and COL_POS, and always use capital letters when ever you give any value in single quotes.

wa_field-row_pos = '1'.
  wa_field-col_pos = '1'.
  wa_field-fieldname = 'PERNR'. " name of field from internal table
  wa_field-tabname = 'T_EMPLOYEE'. " internal table name
  wa_field-outputlen = 10. " output length on screen
  wa_field-checkbox = c_check. " print as checkbox
  wa_field-edit = c_check. " make field open for input
  wa_field-seltext_l = text-006. " header information
  APPEND wa_field TO it_field. " append field catalog internal table
  CLEAR wa_field. " clear field catalog work area

Regards

Bala Krishna

Read only

uwe_schieferstein
Active Contributor
0 Likes
1,504

Hello Ruben

There is almost no good reason around why one should create a fieldcatalog manually.

Apparently all your fields belongs to one or more DDIC structures. Therefore, just call the corresponding fm (in case of OO-based ALV it is LVC_FIELDCATALOG_MERGE) repeatedly for each of the structures and delete or inactivate fields you do not need, e.g.:

LVC_S_FCAT-TECH = 'X'.

And if you need some refinement of the fieldcatalog then do it after the automated generation.

Regards

Uwe

Read only

I355602
Product and Topic Expert
Product and Topic Expert
0 Likes
1,504

Hi,

Use this wiki by me to Learn to display data in ALV Grid

https://www.sdn.sap.com/irj/scn/wiki?path=/display/snippets/learn%252bto%252bdisplay%252bdata%252bin...

Hope this helps you.

Regards,

Tarun

Read only

Former Member
0 Likes
1,504

Hi,

First of all,thanks for all your replies, they where all very helpfull for me. I used all your solutions at once and now it works fine.

Thanks, Bala Krishna it´s my first post i didn´t know the ** option for codes, i´ll look into that for the next time.

Thanks, Uwe Schieferstein now that i i can set the catalog manually and display the data, i´ll try to do that using 'LVC_FIELDCATALOG_MERGE'. It was my first one , now i´ll keep working.

Best Regards,

Ruben.

Read only

kamesh_g
Contributor
0 Likes
1,504

hi

While doing ALV basic thing to remember always is .

While populating fieldcat except system fileds all fields should be passed in caps .

And internal table and fields sholud be quotes and caps .

try with this .

check r u appending all fields or not .

in debug check the data populating in internal table or not .