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

Problem with ALV : fieldcatlog

Former Member
0 Likes
479

Hi,

I am trying to use 'REUSE_ALV_GRID_DISPLAY' to display a simple ITAB.

For some reason, its giving a runtime error.

Pls help me to indentify the problem. Am enclosing the code over here.

Thanks in advance

Hrishi

&----


*& Report ZTEST3

*&

&----


*&

*&

&----


REPORT ZTEST3 line-size 400.

TABLES: EKKO, LFA1, MAKT, EKET, EKPO, cdhdr.

*Data Declaration

*----


TYPES: BEGIN OF FINAL,

ebeln type ekko-ebeln,

BEDAT type ekko-bedat,

lifnr type ekko-lifnr,

ernam type ekko-ernam,

name1 type lfa1-name1,

matnr type ekpo-matnr,

eindt type eket-eindt,

MAKTX type MAKT-MAKTX,

MBLNR type MSEG-MBLNR,

eldat type eket-eldat,

end of FINAL.

DATA: ITAB TYPE STANDARD TABLE OF FINAL INITIAL SIZE 10 WITH HEADER LINE.

  • all ALV declarations

*----


type-pools: slis. "ALV Declarations

DATA: fieldcatalog TYPE slis_t_fieldcat_alv with header line,

G_REPID TYPE SY-REPID,

GS_PRINT TYPE SLIS_PRINT_ALV,

GT_LIST_TOP_OF_PAGE TYPE SLIS_T_LISTHEADER,

GT_EVENTS TYPE SLIS_T_EVENT,

GT_SORT TYPE SLIS_T_SORTINFO_ALV,

GS_LAYOUT TYPE SLIS_LAYOUT_ALV,

COL_POS TYPE I.

*----


  • -----------------SELECTION SCREEN----------------------

selection-screen begin of block b1 with frame title text-001.

select-options podate for EKKO-bedat.

selection-screen end of block b1.

*----


*................... GET DATA..................

SELECT EKKO~EBELN

EKKO~BEDAT

EKKO~LIFNR

EKKO~ERNAM

LFA1~NAME1

MAKT~MATNR

EKET~EINDT

MAKT~MAKTX

MSEG~MBLNR

eket~eldat

INTO CORRESPONDING FIELDS OF ITAB

FROM

( EKKO INNER JOIN LFA1

ON EKKO~LIFNR = LFA1~LIFNR

INNER JOIN MSEG

ON EKKO~EBELN = MSEG~EBELN

INNER JOIN MKPF

ON MSEG~MBLNR = MKPF~MBLNR

INNER JOIN EKPO

ON EKKO~EBELN = EKPO~EBELN

INNER JOIN MAKT

ON EKPO~MATNR = MAKT~MATNR

INNER JOIN EKET

ON EKKO~EBELN = EKET~EBELN

)

WHERE EKKO~BEDAT IN PODATE .

APPEND ITAB. CLEAR ITAB.

ENDSELECT.

*

*LOOP AT ITAB.

  • at first.

  • write: / 'VENDOR NO' color 6 INVERSE,' VENDOR NAME' COLOR 6

*INVERSE,48'MATERIAL NO' COLOR 6 INVERSE,67'MATERIAL DESCRIPTION' COLOR 6 INVERSE,108'PO.NUMBER' COLOR 6 INVERSE,119'DATE' COLOR 6 INVERSE,129'CREATED BY' COLOR 6 INVERSE,143'G R NO' COLOR 6 INVERSE, 154'GR DATE' COLOR 6 INVERSE,

*167'DELIVERY DATE PROMISED' COLOR 6 INVERSE.

  • ULINE.

  • endat.

*

*

*WRITE:/ ITAB-LIFNR,ITAB-NAME1,ITAB-MATNR,ITAB-MAKTX,ITAB-EBELN,ITAB-BEDAT,ITAB-ERNAM,ITAB-MBLNR, ITAB-ELDAT, ITAB-EINDT, itab-udate.

*

*ENDLOOP.

*

*

  • CDHDROBJECTCLAS AND CDHDRTCODE EQ 'ME28'.

*LOOP AT ITAB.

*

*

*SELECT * FROM CDHDR WHERE OBJECTid = ITAB-EBELN AND .

*

*ITAB-UDATE = CDHDR-UDATE.

*APPEND ITAB. CLEAR ITAB.

*ENDSELECT.

*ENDLOOP.

*

**----


fieldcatalog-fieldname = 'ebeln'.

fieldcatalog-seltext_m = 'po Number'.

fieldcatalog-col_pos = 0.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'bedat'.

fieldcatalog-seltext_m = 'po date'.

fieldcatalog-col_pos = 1.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'lifnr'.

fieldcatalog-seltext_m = 'vendor no'.

fieldcatalog-col_pos = 2.

fieldcatalog-outputlen = 15.

fieldcatalog-emphasize = 'X'.

fieldcatalog-key = 'X'.

  • fieldcatalog-do_sum = 'X'.

  • fieldcatalog-no_zero = 'X'.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'ernam'.

fieldcatalog-seltext_m = 'created by'.

fieldcatalog-col_pos = 3.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'name1'.

fieldcatalog-seltext_m = 'vendor name'.

fieldcatalog-col_pos = 4.

fieldcatalog-outputlen = 15.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'matnr'.

fieldcatalog-seltext_m = 'material number'.

fieldcatalog-col_pos = 5.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'eindt'.

fieldcatalog-seltext_m = 'date promised'.

fieldcatalog-col_pos = 6.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'maktx'.

fieldcatalog-seltext_m = 'material desc'.

fieldcatalog-col_pos = 7.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'mblnr'.

fieldcatalog-seltext_m = 'GR no'.

fieldcatalog-col_pos = 8.

fieldcatalog-outputlen = 15.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'eldat'.

fieldcatalog-seltext_m = 'gr date'.

fieldcatalog-col_pos = 9.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

*----


call function 'REUSE_ALV_GRID_DISPLAY'

exporting

i_callback_program = g_repid

it_fieldcat = fieldcatalog[]

is_layout = GS_layout

  • is_variant = z_template

tables

t_outtab = itab

exceptions

program_error = 1

others = 2.

*----


*

1 ACCEPTED SOLUTION
Read only

former_member214288
Participant
0 Likes
444

Hello Hrishi,

Change the field names within single quotes to CAPITAL Letters and it should solve the problem.

Change

fieldcatalog-fieldname = 'ebeln'

to

fieldcatalog-fieldname = 'EBELN'.

Change

fieldcatalog-fieldname = 'bedat'

to

fieldcatalog-fieldname = 'BEDAT'.

and so on for all the fields.

Do let me know if I can be of further assistance on this.

Do reward points if helpful and mark this question as 'Answered'.

Regards,

Ram

Hi,

I am trying to use 'REUSE_ALV_GRID_DISPLAY' to display a simple ITAB.

For some reason, its giving a runtime error.

Pls help me to indentify the problem. Am enclosing the code over here.

Thanks in advance

Hrishi

&----


*& Report ZTEST3

*&

&----


*&

*&

&----


REPORT ZTEST3 line-size 400.

TABLES: EKKO, LFA1, MAKT, EKET, EKPO, cdhdr.

*Data Declaration

*----


TYPES: BEGIN OF FINAL,

ebeln type ekko-ebeln,

BEDAT type ekko-bedat,

lifnr type ekko-lifnr,

ernam type ekko-ernam,

name1 type lfa1-name1,

matnr type ekpo-matnr,

eindt type eket-eindt,

MAKTX type MAKT-MAKTX,

MBLNR type MSEG-MBLNR,

eldat type eket-eldat,

end of FINAL.

DATA: ITAB TYPE STANDARD TABLE OF FINAL INITIAL SIZE 10 WITH HEADER LINE.

  • all ALV declarations

*----


type-pools: slis. "ALV Declarations

DATA: fieldcatalog TYPE slis_t_fieldcat_alv with header line,

G_REPID TYPE SY-REPID,

GS_PRINT TYPE SLIS_PRINT_ALV,

GT_LIST_TOP_OF_PAGE TYPE SLIS_T_LISTHEADER,

GT_EVENTS TYPE SLIS_T_EVENT,

GT_SORT TYPE SLIS_T_SORTINFO_ALV,

GS_LAYOUT TYPE SLIS_LAYOUT_ALV,

COL_POS TYPE I.

*----


  • -----------------SELECTION SCREEN----------------------

selection-screen begin of block b1 with frame title text-001.

select-options podate for EKKO-bedat.

selection-screen end of block b1.

*----


*................... GET DATA..................

SELECT EKKO~EBELN

EKKO~BEDAT

EKKO~LIFNR

EKKO~ERNAM

LFA1~NAME1

MAKT~MATNR

EKET~EINDT

MAKT~MAKTX

MSEG~MBLNR

eket~eldat

INTO CORRESPONDING FIELDS OF ITAB

FROM

( EKKO INNER JOIN LFA1

ON EKKO~LIFNR = LFA1~LIFNR

INNER JOIN MSEG

ON EKKO~EBELN = MSEG~EBELN

INNER JOIN MKPF

ON MSEG~MBLNR = MKPF~MBLNR

INNER JOIN EKPO

ON EKKO~EBELN = EKPO~EBELN

INNER JOIN MAKT

ON EKPO~MATNR = MAKT~MATNR

INNER JOIN EKET

ON EKKO~EBELN = EKET~EBELN

)

WHERE EKKO~BEDAT IN PODATE .

APPEND ITAB. CLEAR ITAB.

ENDSELECT.

*

*LOOP AT ITAB.

  • at first.

  • write: / 'VENDOR NO' color 6 INVERSE,' VENDOR NAME' COLOR 6

*INVERSE,48'MATERIAL NO' COLOR 6 INVERSE,67'MATERIAL DESCRIPTION' COLOR 6 INVERSE,108'PO.NUMBER' COLOR 6 INVERSE,119'DATE' COLOR 6 INVERSE,129'CREATED BY' COLOR 6 INVERSE,143'G R NO' COLOR 6 INVERSE, 154'GR DATE' COLOR 6 INVERSE,

*167'DELIVERY DATE PROMISED' COLOR 6 INVERSE.

  • ULINE.

  • endat.

*

*

*WRITE:/ ITAB-LIFNR,ITAB-NAME1,ITAB-MATNR,ITAB-MAKTX,ITAB-EBELN,ITAB-BEDAT,ITAB-ERNAM,ITAB-MBLNR, ITAB-ELDAT, ITAB-EINDT, itab-udate.

*

*ENDLOOP.

*

*

  • CDHDROBJECTCLAS AND CDHDRTCODE EQ 'ME28'.

*LOOP AT ITAB.

*

*

*SELECT * FROM CDHDR WHERE OBJECTid = ITAB-EBELN AND .

*

*ITAB-UDATE = CDHDR-UDATE.

*APPEND ITAB. CLEAR ITAB.

*ENDSELECT.

*ENDLOOP.

*

**----


fieldcatalog-fieldname = 'ebeln'.

fieldcatalog-seltext_m = 'po Number'.

fieldcatalog-col_pos = 0.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'bedat'.

fieldcatalog-seltext_m = 'po date'.

fieldcatalog-col_pos = 1.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'lifnr'.

fieldcatalog-seltext_m = 'vendor no'.

fieldcatalog-col_pos = 2.

fieldcatalog-outputlen = 15.

fieldcatalog-emphasize = 'X'.

fieldcatalog-key = 'X'.

  • fieldcatalog-do_sum = 'X'.

  • fieldcatalog-no_zero = 'X'.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'ernam'.

fieldcatalog-seltext_m = 'created by'.

fieldcatalog-col_pos = 3.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'name1'.

fieldcatalog-seltext_m = 'vendor name'.

fieldcatalog-col_pos = 4.

fieldcatalog-outputlen = 15.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'matnr'.

fieldcatalog-seltext_m = 'material number'.

fieldcatalog-col_pos = 5.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'eindt'.

fieldcatalog-seltext_m = 'date promised'.

fieldcatalog-col_pos = 6.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'maktx'.

fieldcatalog-seltext_m = 'material desc'.

fieldcatalog-col_pos = 7.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'mblnr'.

fieldcatalog-seltext_m = 'GR no'.

fieldcatalog-col_pos = 8.

fieldcatalog-outputlen = 15.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'eldat'.

fieldcatalog-seltext_m = 'gr date'.

fieldcatalog-col_pos = 9.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

*----


call function 'REUSE_ALV_GRID_DISPLAY'

exporting

i_callback_program = g_repid

it_fieldcat = fieldcatalog[]

is_layout = GS_layout

  • is_variant = z_template

tables

t_outtab = itab

exceptions

program_error = 1

others = 2.

*----


*

2 REPLIES 2
Read only

former_member214288
Participant
0 Likes
445

Hello Hrishi,

Change the field names within single quotes to CAPITAL Letters and it should solve the problem.

Change

fieldcatalog-fieldname = 'ebeln'

to

fieldcatalog-fieldname = 'EBELN'.

Change

fieldcatalog-fieldname = 'bedat'

to

fieldcatalog-fieldname = 'BEDAT'.

and so on for all the fields.

Do let me know if I can be of further assistance on this.

Do reward points if helpful and mark this question as 'Answered'.

Regards,

Ram

Read only

Former Member
0 Likes
444

Hi,

I just noticed that fieldcatalog-fieldnames are not capitalized.

Please see the following sample code:

PERFORM f_build USING:

'MATNR' text-003, "material

'MAKTX' text-004, "material description

'INVBEG' text-005, "inv beg

'INVAMT' text-006, "inv amount

'SOLD' text-007, "sold

'CANCEL' text-008, "cancelled

'INVEND' text-009. "inv end

&----


*& Form f_build

&----


  • Build ALV fieldcatalog

----


FORM f_build USING p_fieldname

p_fieldtext LIKE wa_fieldcatalog-seltext_l.

CLEAR wa_fieldcatalog.

wa_fieldcatalog-fieldname = p_fieldname.

wa_fieldcatalog-seltext_l = p_fieldtext.

APPEND wa_fieldcatalog TO it_fieldcatalog.

ENDFORM. " f_build