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

regarding normal ALVs

Former Member
0 Likes
707

Hi friends,

I have developed a report in alv .it's working .

1) when I tried to add some additional flds it's not working properly

here iam giving my codig.I addeded matkl,arktx. it's giving wrong data of these 2flds.

can any body help me to get this.

2)

when i tried to change from grid list to normal list it's working

after addition of fields it's not work out. plz let me know the solution.

Thanks in advance

REPORT Z_ALV.

TABLES: vbak,vbap.

select-options:s_vbeln for vbak-vbeln.

TYPE-POOLS: slis. "ALV Declarations

*Data Declaration

*----


TYPES: BEGIN OF t_final,

vbeln LIKE vbak-vbeln,

erdat LIKE vbak-erdat,

matnr LIKE vbap-matnr,

posnr LIKE vbap-posnr,

matkl LIKE vbap-matkl,

arktx LIKE vbap-arktx,

END OF t_final.

DATA: i_final TYPE STANDARD TABLE OF t_final initial size 0,

wa_final TYPE t_final.

*ALV data declarations

DATA: fieldcatalog TYPE slis_t_fieldcat_alv,

wa_fieldcatalog type slis_fieldcat_alv,

*gd_tab_group TYPE slis_t_sp_group_alv,

gd_layout TYPE slis_layout_alv,

gd_repid LIKE sy-repid.

*Start-of-selection.

START-OF-SELECTION.

PERFORM data_retrieval.

PERFORM build_fieldcatalog.

PERFORM build_layout.

PERFORM display_alv_report.

*&----


*& Form BUILD_FIELDCATALOG

*&----


*• Build Fieldcatalog for ALV Report

*----


FORM build_fieldcatalog.

wa_fieldcatalog-fieldname = 'VBELN'.

wa_fieldcatalog-seltext_m = 'sales order'.

wa_fieldcatalog-col_pos = 0.

APPEND wa_fieldcatalog TO fieldcatalog.

CLEAR wa_fieldcatalog.

wa_fieldcatalog-fieldname = 'ERDAT'.

wa_fieldcatalog-seltext_m = 'date'.

wa_fieldcatalog-col_pos = 1.

APPEND wa_fieldcatalog TO fieldcatalog.

CLEAR wa_fieldcatalog.

wa_fieldcatalog-fieldname = 'MATNR'.

wa_fieldcatalog-seltext_m = 'material no.'.

wa_fieldcatalog-col_pos = 2.

APPEND wa_fieldcatalog TO fieldcatalog.

CLEAR wa_fieldcatalog.

wa_fieldcatalog-fieldname = 'POSNR'.

wa_fieldcatalog-seltext_m = 'line item no.'.

wa_fieldcatalog-col_pos = 3.

APPEND wa_fieldcatalog TO fieldcatalog.

CLEAR wa_fieldcatalog.

wa_fieldcatalog-fieldname = 'matkl'.

wa_fieldcatalog-seltext_m = 'mat grp.'.

wa_fieldcatalog-col_pos = 4.

APPEND wa_fieldcatalog TO fieldcatalog.

CLEAR wa_fieldcatalog.

wa_fieldcatalog-fieldname = 'arktx'.

wa_fieldcatalog-seltext_m = 'short txt'.

wa_fieldcatalog-col_pos = 5.

append wa_fieldcatalog TO fieldcatalog.

CLEAR wa_fieldcatalog.

ENDFORM. " BUILD_FIELDCATALOG

*&----


*& Form BUILD_LAYOUT

*&----


*• Build layout for ALV grid report

*----


FORM build_layout.

*gd_layout-no_input = 'X'.

*gd_layout-colwidth_optimize = 'X'.

*gd_layout-totals_text = 'Totals'(201).

**• gd_layout-totals_only = 'X'.

**• gd_layout-f2code = 'DISP'. "Sets fcode for when double

**• "click(press f2)

    • gd_layout-zebra = 'X'.

**• gd_layout-group_change_edit = 'X'.

  • gd_layout-header_text = 'helllllo'.

ENDFORM. " BUILD_LAYOUT

*&----


*& Form DISPLAY_ALV_REPORT

*&----


*• Display report using ALV grid

*----


FORM display_alv_report.

gd_repid = sy-repid.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = gd_repid

*• i_callback_top_of_page = 'TOP-OF-PAGE' "see FORM

i_callback_user_command = 'USER_COMMAND'

*• i_grid_title = outtext

is_layout = gd_layout

it_fieldcat = fieldcatalog[]

*• it_special_groups = gd_tabgroup

*• IT_EVENTS = GT_XEVENTS

i_save = 'X'

*• is_variant = z_template

TABLES

t_outtab = i_final

EXCEPTIONS

program_error = 1

OTHERS = 2.

IF sy-subrc ne 0.

message ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

ENDFORM. " DISPLAY_ALV_REPORT

*&----


*& Form DATA_RETRIEVAL

*&----


*• Retrieve data form EKPO table and populate itab it_ekko

*----


FORM data_retrieval.

SELECT avbeln aerdat bmatnr bposnr bmatkl barktx FROM vbak AS a

INNER JOIN vbap AS b ON avbeln = bvbeln

INTO TABLE i_final WHERE a~vbeln in s_vbeln.

ENDFORM. " DATA_RETRIEVAL

when i chabged from grid to list.

I addeded some extra fields in my outputlist. with this it goes to runtime error.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
691

Hi,

Please mention the field names in Upper Case.

as in...


* wa_fieldcatalog-fieldname = 'matkl'.
wa_fieldcatalog-fieldname = 'MATKL'.
wa_fieldcatalog-seltext_m = 'mat grp.'.
wa_fieldcatalog-col_pos = 4.
APPEND wa_fieldcatalog TO fieldcatalog.
CLEAR wa_fieldcatalog.

*wa_fieldcatalog-fieldname = 'arktx'.
wa_fieldcatalog-fieldname = 'ARKTX'.
wa_fieldcatalog-seltext_m = 'short txt'.
wa_fieldcatalog-col_pos = 5.
append wa_fieldcatalog TO fieldcatalog.
CLEAR wa_fieldcatalog.

Reward points inorder to say thanks and encourage us,

Kiran

6 REPLIES 6
Read only

Former Member
0 Likes
692

Hi,

Please mention the field names in Upper Case.

as in...


* wa_fieldcatalog-fieldname = 'matkl'.
wa_fieldcatalog-fieldname = 'MATKL'.
wa_fieldcatalog-seltext_m = 'mat grp.'.
wa_fieldcatalog-col_pos = 4.
APPEND wa_fieldcatalog TO fieldcatalog.
CLEAR wa_fieldcatalog.

*wa_fieldcatalog-fieldname = 'arktx'.
wa_fieldcatalog-fieldname = 'ARKTX'.
wa_fieldcatalog-seltext_m = 'short txt'.
wa_fieldcatalog-col_pos = 5.
append wa_fieldcatalog TO fieldcatalog.
CLEAR wa_fieldcatalog.

Reward points inorder to say thanks and encourage us,

Kiran

Read only

Former Member
0 Likes
691

while preparing the fieldcatalog u have written field name in lower case so make them like

wa_fieldcatalog-fieldname = 'MATKL'.

&

wa_fieldcatalog-fieldname = 'ARKTX'.

reward if helpful

Read only

Former Member
0 Likes
691

Hi Frd

the fields MATKL & ARKTX should in upper case in ALV.

wa_fieldcatalog-fieldname = 'MATKL'.

wa_fieldcatalog-seltext_m = 'mat grp.'.

wa_fieldcatalog-col_pos = 4.

APPEND wa_fieldcatalog TO fieldcatalog.

CLEAR wa_fieldcatalog.

wa_fieldcatalog-fieldname = 'ARKTX'.

wa_fieldcatalog-seltext_m = 'short txt'.

wa_fieldcatalog-col_pos = 5.

append wa_fieldcatalog TO fieldcatalog.

CLEAR wa_fieldcatalog.

Reward Me Points

BY

Pari

Read only

Former Member
0 Likes
691

Hi,

In ur field catalog perform u forgot include one more step.

i.e

wa_fieldcat-tabname = I_FINAL.

First u should add ur fields to t_final structure and then append.

what ever values u retrieve into i_final will display in the output.

Regards,

kk.

Read only

Former Member
0 Likes
691

Hi,

When you create fieldcatalog the fieldname should be in capital letters.

You have to pass MATKL and ARKTX in capital letters.

I think it is useful for you.

Read only

Former Member
0 Likes
691

Thank you