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: 

editable ALV grid program

Former Member
0 Kudos

hi experts,

i am new to sap learning reports.

my requirement is:

display a alv report with four fields vbeln(sales order),erdat,matnr,posnr using tables vbak and vbap using reuse_alv_grid display.when the output is displayed in grid format,and if we double click any sales order number it should take me to VA03(sales order display)transaction code with the sales order number i clicked and give the information abt that sales order number.

i know we should use 'at-user command' statement here to achieve this.

i need the exact code for at-user command.please can anyone help me with this?

the code what i wrote is....

TABLES: vbak,vbap.

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,

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 WITH HEADER LINE,

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.

fieldcatalog-fieldname = 'VBELN'.

fieldcatalog-seltext_m = 'sales order'.

fieldcatalog-col_pos = 0.

APPEND fieldcatalog TO fieldcatalog.

CLEAR fieldcatalog.

fieldcatalog-fieldname = 'ERDAT'.

fieldcatalog-seltext_m = 'date'.

fieldcatalog-col_pos = 1.

APPEND fieldcatalog TO fieldcatalog.

CLEAR fieldcatalog.

fieldcatalog-fieldname = 'MATNR'.

fieldcatalog-seltext_m = 'material no.'.

fieldcatalog-col_pos = 2.

APPEND fieldcatalog TO fieldcatalog.

CLEAR fieldcatalog.

fieldcatalog-fieldname = 'POSNR'.

fieldcatalog-seltext_m = 'line item no.'.

fieldcatalog-col_pos = 3.

APPEND fieldcatalog TO fieldcatalog.

CLEAR 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 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 FROM vbak AS a

INNER JOIN vbap AS b ON avbeln = bvbeln

INTO TABLE i_final WHERE avbeln = bvbeln.

ENDFORM. " DATA_RETRIEVAL

points will be rewarded.

thanks in advance.

2 REPLIES 2

Former Member
0 Kudos

Hi,

Try the following code:

FORM user_command USING r_ucomm TYPE sy-ucomm

rs_selfield TYPE slis_selfield.

CASE r_ucomm.

WHEN '&IC1'.

IF rs_selfield-sel_tab_field = 'I_FINAL-VBELN' .

SET PARAMETER ID 'AUN' FIELD gv_vbeln.

CALL TRANSACTION 'VA03'. " AND SKIP FIRST SCREEN (Optional).

IF sy-subrc NE 0 .

EXIT .

ENDIF .

ENDCASE.

ENDFORM. "user_command

Please Reward Full points if this helps fully.

0 Kudos

hi khalid ,

thank u for ur response.

i tried ur code and it is going to dump giving an error as too many parameters for perform.can u tell me y is it so?

thanks in advance.