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: 

Reg ALV report

Former Member
0 Kudos

Hi,

i have coded the below ALV report in which i get the output where i should be able to EDIT the MATNR (Material Number) field in the ALV output.

how can i edit the MATNR field in my code?

Below is my code

Report ztest.

tables : ekpo.

----


  • Includes *

----


INCLUDE:

*--- Standard header and footer routines

zsrepthd,

*--- ALV Routines

zvsdi_alv_routines_ver3,

*--- Authorization Check

z_selection_auth_check.

----


  • Types Declarations

----


TYPES: BEGIN OF ty_ekpo,

EBELN(18) TYPE C,

EBELP(22) TYPE C,

MATNR(18) TYPE C,

WERKS(11) TYPE C,

END OF ty_ekpo.

*-Output field name

TYPES: BEGIN OF ty_out,

EBELN(18) TYPE C,

EBELP(22) TYPE C,

MATNR(18) TYPE C,

WERKS(11) TYPE C,

END OF ty_out.

*-Output field name

TYPES: BEGIN OF ty_fields,

fname(60) TYPE c,

END OF ty_fields.

----


  • Table Declarations

----


DATA: it_ekpo TYPE STANDARD TABLE OF ty_ekpo,

*--- Alv parameters

it_out_alvp TYPE typ_alv_form_params. "for alv parameters

**--To store output for ekpo data

DATA: BEGIN OF it_out occurs 0,

EBELN(18) TYPE C,

EBELP(22) TYPE C,

MATNR(18) TYPE C,

WERKS(11) TYPE C,

END OF it_out.

----


  • Data Declarations

----


data: v_ebeln TYPE ekpo-ebeln,

v_ebelp TYPE ekpo-ebelp,

v_matnr TYPE ekpo-matnr,

v_werks TYPE ekpo-werks.

----


  • Constants Declarations

----


CONSTANTS:

c_0 TYPE i VALUE 0,

c_x TYPE char1 VALUE 'X',

c_i TYPE char1 VALUE 'I',

c_l TYPE char1 VALUE 'L',

c_h TYPE char1 VALUE 'H',

c_s TYPE char1 VALUE 'S',

c_eq TYPE char2 VALUE 'EQ',

c_icon TYPE char4 VALUE 'ICON',

c_exit TYPE char4 VALUE 'EXIT',

c_ekpo TYPE char4 VALUE 'EKPO',

c_matnr TYPE char5 VALUE 'MATNR',

c_ebeln TYPE char5 VALUE 'EBELN',

c_ebelp TYPE char5 VALUE 'EBELP',

c_werks TYPE char5 VALUE 'WERKS',

c_hyfn TYPE char1 VALUE '-',

c_it_out TYPE char6 VALUE 'IT_OUT'.

----


  • Work areas Declarations

----


DATA: x_out_ekpo type ty_out,

x_ekpo type ty_ekpo.

----


  • Selection Screen

----


SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-f01.

SELECT-OPTIONS:

s_ebeln FOR v_ebeln OBLIGATORY,

s_ebelp FOR v_ebelp,

s_matnr FOR v_matnr,

s_werks FOR v_werks.

SELECTION-SCREEN END OF BLOCK b1.

----


  • At Selection Screen

----


AT SELECTION-SCREEN.

----


  • Start of Selection

----


START-OF-SELECTION.

*Fetch table data

PERFORM fetch_status_pp.

----


  • End of Selection

----


END-OF-SELECTION.

*Download data to final internal table.

PERFORM data_output.

IF NOT it_out[] IS INITIAL.

*--- Fill the structure for calling the ALV form

PERFORM initialize_alv_params.

*--- Display ALV Report

PERFORM setup_and_display_alv_ver2

USING

it_out_alvp "Parameter structure

it_out[] "Internal Data table(header table)

it_out[]. "Dummy table for Hierarchical ALV!!(item table)

ENDIF.

IF it_out[] IS INITIAL.

MESSAGE i999(zi) WITH 'No data found for selection'(i02).

ENDIF.

----


  • Form FETCH_STATUS_PP

----


*Get data from ekpo table

----


FORM FETCH_STATUS_PP .

*-Fetch PP Data from ekpo table

REFRESH it_ekpo.

SELECT EBELN

EBELP

MATNR

WERKS

FROM ekpo

INTO TABLE it_ekpo

WHERE ebeln IN s_ebeln

AND ebelp IN s_ebelp.

IF sy-subrc = c_0.

SORT it_ekpo BY ebeln ebelp.

ENDIF.

ENDFORM. " FETCH_STATUS_PP

----


  • FORM it_out_alv_fieldcat_before *

----


  • Description : Form to initialize Field catalog *

----


FORM it_out_alv_fieldcat_before

CHANGING

fcat TYPE slis_t_fieldcat_alv

alvp TYPE typ_alv_form_params.

**--- Icon

  • PERFORM f_fill_fcat USING c_icon

  • text-t01

  • space

  • c_it_out

  • CHANGING fcat.

*--- Purchasing Doc No

PERFORM f_fill_fcat USING c_ebeln

text-t02

space

c_it_out

CHANGING fcat.

*--- Item No Purchasing Doc

PERFORM f_fill_fcat USING c_ebelp

text-t03

space

c_it_out

CHANGING fcat.

*---Material No

PERFORM f_fill_fcat USING c_matnr

text-t04

space

c_it_out

CHANGING fcat.

*--- Supply plant

PERFORM f_fill_fcat USING c_werks

text-t05

space

c_it_out

CHANGING fcat.

ENDFORM. " it_out_alv_fieldcat_before

&----


*& Form F_FILL_FCAT

&----


  • To fill the Alv Fieldcatalog

----


  • -->P_FNAME type slis_fieldcat_alv-fieldname

  • -->P_TEXT type slis_fieldcat_alv-seltext_l

  • -->P_OUT type char1

  • -->P_TAB type char6

  • <--P_FCAT type slis_t_fieldcat_alv

----


FORM f_fill_fcat USING p_fname

p_text

p_out

p_tab

CHANGING p_fcat TYPE slis_t_fieldcat_alv.

DATA: lx_fcat TYPE slis_fieldcat_alv.

CLEAR lx_fcat.

lx_fcat-tabname = p_tab.

lx_fcat-fieldname = p_fname.

lx_fcat-ddictxt = c_l.

lx_fcat-no_out = p_out.

lx_fcat-seltext_l = p_text.

APPEND lx_fcat TO p_fcat.

ENDFORM. " F_FILL_FCAT

&----


*& Form f_top_of_page

&----


*This is to write the top of page

----


FORM top_of_page.

DATA: lt_list TYPE slis_t_listheader,

lx_list TYPE slis_listheader.

*--- Company name

CLEAR lx_list.

lx_list-typ = c_h.

lx_list-key = space.

lx_list-info = 'Testing Program'(h02).

APPEND lx_list TO lt_list.

*--- Title name

CLEAR lx_list.

lx_list-typ = c_s.

lx_list-key = 'Title name'(t13).

lx_list-info = sy-title.

APPEND lx_list TO lt_list.

IF NOT lt_list IS INITIAL.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

it_list_commentary = lt_list.

ENDIF.

ENDFORM. "top_of_page

&----


*& Form init_page_head

&----


  • Description : This subroutine initializes the fields in table BHDGD *

  • for printing the report heading. *

----


FORM init_page_head.

bhdgd-line1 = 'Test Program'(h02).

bhdgd-line2 = sy-title.

bhdgd-lines = sy-linsz.

bhdgd-fcpyrt = sy-uline.

bhdgd-inifl = '0'.

ENDFORM. "init_page_head

----


  • FORM it_out_init_events *

----


  • -->this is form is to modify the events

----


FORM it_out_init_events

CHANGING

alevnts TYPE slis_t_event.

FIELD-SYMBOLS <alevnt> TYPE slis_alv_event.

LOOP AT alevnts ASSIGNING <alevnt>.

CASE <alevnt>-name.

WHEN slis_ev_top_of_page.

MOVE 'TOP_OF_PAGE' TO <alevnt>-form.

ENDCASE.

ENDLOOP.

ENDFORM. "it_out_init_events

----


  • FORM it_out_user_command *

----


  • Description : Handling user commands

----


FORM it_out_user_command

USING

ucmd TYPE sy-ucomm " SY-UCOMM value

fieldinfo TYPE slis_selfield " Current ALV Cell & ALV Info

alv_fcat_dtel TYPE typ_t_fcat_dtel. " Table utilized by std ucmd

fieldinfo-refresh = c_x.

*--- User-commands

CASE ucmd.

WHEN 'SAVE'.

perform save_data.

WHEN c_exit.

LEAVE PROGRAM.

ENDCASE.

ENDFORM. "it_out_user_command

----


  • FORM it_out_pfstatus *

----


  • Description : Form to set PF status

----


FORM it_out_pfstatus USING rt_extab TYPE slis_t_extab.

DATA : lt_extab TYPE slis_t_extab,

lx_extab LIKE LINE OF lt_extab.

REFRESH lt_extab.

SET PF-STATUS 'ALV_MAIN' EXCLUDING lt_extab.

ENDFORM. " it_out_pfstatus

&----


*& Form initialize_alv_params

&----


  • Description : Form to initialize ALV Params

----


FORM initialize_alv_params.

CONSTANTS: lc_u TYPE char1 VALUE 'U'.

MOVE: c_it_out TO it_out_alvp-tablname,

sy-repid TO it_out_alvp-repid,

c_alv_grid TO it_out_alvp-alvtype,

c_x TO it_out_alvp-bringdefaultvar,

lc_u TO it_out_alvp-variantsavetype,

c_x TO it_out_alvp-userpfstatflag.

ENDFORM. " initialize_alv_params

&----


*& Form DATA_OUTPUT

&----


*Download data to final internal table

----


FORM DATA_OUTPUT .

loop at it_ekpo into x_ekpo.

x_out_ekpo-ebeln = x_ekpo-ebeln.

x_out_ekpo-ebelp = x_ekpo-ebelp.

x_out_ekpo-matnr = x_ekpo-matnr.

x_out_ekpo-werks = x_ekpo-werks.

append x_out_ekpo to it_out.

endloop.

ENDFORM. " DATA_OUTPUT

*&----


*

*& Form SAVE_DATA

*&----


*

  • text

*----


*

  • --> p1 text

  • <-- p2 text

*----


*

FORM SAVE_DATA .

data: lv_answer type c.

CALL FUNCTION 'POPUP_TO_CONFIRM'

EXPORTING

  • TITLEBAR = ' '

  • DIAGNOSE_OBJECT = ' '

TEXT_QUESTION = 'Do you want to save'

TEXT_BUTTON_1 = 'Yes'(007)

  • ICON_BUTTON_1 = ' '

TEXT_BUTTON_2 = 'No'(008)

  • ICON_BUTTON_2 = ' '

  • DEFAULT_BUTTON = '1'

  • DISPLAY_CANCEL_BUTTON = 'X'

  • USERDEFINED_F1_HELP = ' '

  • START_COLUMN = 25

  • START_ROW = 6

  • POPUP_TYPE =

  • IV_QUICKINFO_BUTTON_1 = ' '

  • IV_QUICKINFO_BUTTON_2 = ' '

IMPORTING

ANSWER = lv_answer

  • TABLES

  • PARAMETER =

EXCEPTIONS

TEXT_NOT_FOUND = 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.

if lv_answer = '1'.

modify it_out.

endif.

ENDFORM. " SAVE_DATA

regards,

reddy

Edited by: reddy reddy on Oct 15, 2008 8:35 AM

Edited by: reddy reddy on Oct 15, 2008 10:38 AM

Edited by: reddy reddy on Oct 15, 2008 10:39 AM

5 REPLIES 5

Former Member
0 Kudos

Hi Reddy,

Please check the below thread(s),

Best Regards.

Former Member
0 Kudos

HAI,

PASS wa_fieldcat-edit = 'X'. IN FIELDCATLOG.

FORM f_fill_fcat USING p_fname

p_text

p_out

p_tab

CHANGING p_fcat TYPE slis_t_fieldcat_alv.

DATA: lx_fcat TYPE slis_fieldcat_alv.

CLEAR lx_fcat.

lx_fcat-tabname = p_tab.

lx_fcat-fieldname = p_fname.

lx_fcat-ddictxt = c_l.

lx_fcat-no_out = p_out.

lx_fcat-seltext_l = p_text.

APPEND lx_fcat TO p_fcat.

ENDFORM. " F_FILL_FCAT

SHAN.

Edited by: shan palani on Oct 15, 2008 2:19 PM

Former Member
0 Kudos

Add-

field_catalog-edit = 'X'.

for that particular field.

Regards,

Aparna

Former Member
0 Kudos

Hi,

I know that i should put the EDIT as 'X'.

but in my code where should i place this?

Regards,

reddy

Former Member
0 Kudos

Find the code below for a similar requirement.

TYPE-POOLS: slis.

DATA: it_fcat TYPE slis_t_fieldcat_alv,

      wa_fcat LIKE LINE OF it_fcat.


DATA: it_data TYPE vbap_t.


SELECT *

  FROM VBAP

  INTO TABLE it_data

  UP TO 20 ROWS.



wa_fcat-fieldname = 'VBELN'.

wa_fcat-tabname  = 'IT_DATA'.

wa_fcat-outputlen = 5.

wa_fcat-edit = 'X'.

wa_fcat-input = 'X'.

wa_fcat-ref_fieldname = 'VBELN'.

wa_fcat-ref_tabname = 'VBAK'.

wa_fcat-seltext_l = 'Sales Order'.

APPEND wa_fcat TO it_fcat.

clear wa_fcat .



wa_fcat-fieldname = 'POSNR'.

wa_fcat-tabname  = 'IT_DATA'.

wa_fcat-outputlen = 5.

wa_fcat-seltext_l = 'Item'.

APPEND wa_fcat TO it_fcat.



PERFORM display_data.


*&---------------------------------------------------------------------*

*&      Form  user_command

*&---------------------------------------------------------------------*

FORM user_command USING ucomm TYPE sy-ucomm

            selfield TYPE slis_selfield.

  DATA: gd_repid LIKE sy-repid, "Exists

  ref_grid TYPE REF TO cl_gui_alv_grid.

  IF ref_grid IS INITIAL.

    CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'

      IMPORTING

        e_grid = ref_grid.

  ENDIF.

  IF NOT ref_grid IS INITIAL.

    CALL METHOD ref_grid->check_changed_data .

  ENDIF.

  CASE ucomm.

    WHEN '&DATA_SAVE'.

     *"Update the Data base here*

      selfield-refresh = 'X'.

  ENDCASE.

ENDFORM.                    "user_command

*&---------------------------------------------------------------------*

*&      Form  display_data

*&---------------------------------------------------------------------*

FORM display_data.

  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

    EXPORTING

      i_interface_check       = sy-repid

      it_fieldcat             = it_fcat

      i_callback_user_command = 'USER_COMMAND'

    TABLES

      t_outtab                = it_data

    EXCEPTIONS

      program_error           = 1.

ENDFORM.                    "display_data

Cheers,

Murthy.

Edited by: pr murthy on Oct 15, 2008 11:07 AM