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 field in alv

Former Member
0 Kudos
1,051

hi please see code below

i am trying to use both editable field and hierarchical record in alv and the editable doesn't work

TYPE-POOLS: slis. " ALV Global types

*----


CONSTANTS :

c_x VALUE 'X',

c_gt_vbap TYPE SLIS_TABNAME VALUE 'GT_VBAP',

c_gt_vbak TYPE SLIS_TABNAME VALUE 'GT_VBAK'.

*----


SELECTION-SCREEN :

SKIP, BEGIN OF LINE,COMMENT 5(27) v_1 FOR FIELD p_max. "#EC NEEDED

PARAMETERS p_max(02) TYPE n DEFAULT '10' OBLIGATORY.

SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN :

SKIP, BEGIN OF LINE,COMMENT 5(27) v_2 FOR FIELD p_expand. "#EC NEEDED

PARAMETERS p_expand AS CHECKBOX DEFAULT c_x.

SELECTION-SCREEN END OF LINE.

*----


TYPES :

  • * 1st Table

BEGIN OF ty_vbak,

vbeln TYPE vbak-vbeln, " Sales document

kunnr TYPE vbak-kunnr, " Sold-to party

netwr TYPE vbak-netwr, " Net Value of the Sales Order

erdat TYPE vbak-erdat, " Creation date

waerk TYPE vbak-waerk, " SD document currency

expand TYPE xfeld,

END OF ty_vbak,

  • * 2nd Table

BEGIN OF ty_vbap,

vbeln TYPE vbap-vbeln, " Sales document

posnr TYPE vbap-posnr, " Sales document

matnr TYPE vbap-matnr, " Material number

netwr TYPE vbap-netwr, " Net Value of the Sales Order

waerk TYPE vbap-waerk, " SD document currency

END OF ty_vbap.

*----


DATA :

gt_vbak TYPE TABLE OF ty_vbak,

gt_vbap TYPE TABLE OF ty_vbap.

DATA: i_fieldcat TYPE slis_t_fieldcat_alv,

wa_fieldcat like line of i_fieldcat.

*----


INITIALIZATION.

v_1 = 'Maximum of records to read'.

v_2 = 'With ''EXPAND'' field'.

*----


START-OF-SELECTION.

  • * Read Sales Document: Header Data

SELECT vbeln kunnr netwr waerk erdat

FROM vbak

UP TO p_max ROWS

INTO CORRESPONDING FIELDS OF TABLE gt_vbak.

IF NOT gt_vbak[] IS INITIAL.

  • * Read Sales Document: Item Data

SELECT vbeln posnr matnr netwr waerk

FROM vbap

INTO CORRESPONDING FIELDS OF TABLE gt_vbap

FOR ALL ENTRIES IN gt_vbak

WHERE vbeln = gt_vbak-vbeln.

ENDIF.

PERFORM f_display.

*----


*

  • * Form F_DISPLAY

*

*----


FORM f_display.

DEFINE m_sort.

ls_sort-tabname = &1.

ls_sort-fieldname = &2.

ls_sort-up = c_x.

append ls_sort to lt_sort.

END-OF-DEFINITION.

DATA:

ls_layout TYPE slis_layout_alv,

ls_keyinfo TYPE slis_keyinfo_alv,

ls_sort TYPE slis_sortinfo_alv,

lt_sort TYPE slis_t_sortinfo_alv," Sort table

ls_fieldcat TYPE slis_fieldcat_alv,

lt_fieldcat TYPE slis_t_fieldcat_alv." Field catalog

ls_layout-group_change_edit = c_x.

ls_layout-colwidth_optimize = c_x.

ls_layout-zebra = c_x.

ls_layout-detail_popup = c_x.

ls_layout-get_selinfos = c_x.

IF p_expand = c_x.

ls_layout-expand_fieldname = 'EXPAND'.

ENDIF.

m_sort c_gt_vbak 'KUNNR'.

m_sort c_gt_vbap 'NETWR'.

ls_keyinfo-header01 = 'VBELN'.

ls_keyinfo-item01 = 'VBELN'.

ls_keyinfo-item02 = 'POSNR'.

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

EXPORTING

  • I_PROGRAM_NAME =

I_INTERNAL_TABNAME = 'GT_VBAK'

I_STRUCTURE_NAME = 'ZVBAK'

CHANGING

ct_fieldcat = i_fieldcat

EXCEPTIONS

INCONSISTENT_INTERFACE = 1

PROGRAM_ERROR = 2

OTHERS = 3

.

IF sy-subrc <> 0.

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

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

ENDIF.

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

EXPORTING

  • I_PROGRAM_NAME =

I_INTERNAL_TABNAME = 'GT_VBAP'

I_STRUCTURE_NAME = 'ZVBAP'

CHANGING

ct_fieldcat = i_fieldcat

EXCEPTIONS

INCONSISTENT_INTERFACE = 1

PROGRAM_ERROR = 2

OTHERS = 3

.

IF sy-subrc <> 0.

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

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

ENDIF.

LOOP AT i_fieldcat into wa_fieldcat.

CASE wa_fieldcat-fieldname .

WHEN 'VBELN' .

*wa_fieldcat-outpulen = '10' .

*wa_fieldcat-coltext = 'VBELN' .

wa_fieldcat-edit = 'X'.

MODIFY i_fieldcat FROM wa_fieldcat .

WHEN 'POSNR' .

wa_fieldcat-no_out = 'X' .

wa_fieldcat-edit = 'X'.

MODIFY i_fieldcat FROM wa_fieldcat.

ENDCASE .

ENDLOOP.

  • * Dipslay Hierarchical list

CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'

EXPORTING

i_callback_program = sy-cprog

i_callback_user_command = 'USER_COMMAND'

is_layout = ls_layout

it_fieldcat = i_fieldcat

it_sort = lt_sort

i_tabname_header = c_gt_vbak

i_tabname_item = c_gt_vbap

i_structure_name_header = 'ZVBAK'

i_structure_name_item = 'ZVBAP'

is_keyinfo = ls_keyinfo

TABLES

t_outtab_header = gt_vbak

t_outtab_item = gt_vbap

EXCEPTIONS

program_error = 1

OTHERS = 2.

*IF sy-subrc EQ 0.

*MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

*WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

*ENDIF.

ENDFORM. " F_LIST_DISPLAY

*----


*

  • * Form USER_COMMAND *

*

*----


FORM user_command USING i_ucomm TYPE sy-ucomm

is_selfield TYPE slis_selfield. "#EC CALLED

DATA ls_vbak TYPE ty_vbak.

CASE i_ucomm.

WHEN '&IC1'. " Pick

CASE is_selfield-tabname.

WHEN c_gt_vbap.

WHEN c_gt_vbak.

READ TABLE gt_vbak INDEX is_selfield-tabindex INTO ls_vbak.

IF sy-subrc EQ 0.

  • * Sales order number

SET PARAMETER ID 'AUN' FIELD ls_vbak-vbeln.

  • * Display Sales Order

CALL TRANSACTION 'VA03' AND SKIP FIRST SCREEN.

ENDIF.

ENDCASE.

ENDCASE.

ENDFORM. " USER_COMMAND

4 REPLIES 4

Former Member
0 Kudos
112

Hi

The follow program demonstrates how to make individual fields of an ALV grid editable (NetPR greater than 10).

Changes required from a basic ALV grid include adding a new field to ALV grid data table(it_ekko), Populating this

field with style attribute and adding an entry to layout control table. Also from the previous examples used on

this website you will also need to change the data type of the fieldcatalog, the layout and use a different function

module for displaying the report.

REPORT ZDEMO_ALVGRID_EDIT .

TABLES: ekko.

TYPE-POOLS: slis. "ALV Declarations

*Data Declaration

*----


TYPES: BEGIN OF t_ekko,

ebeln TYPE ekpo-ebeln,

ebelp TYPE ekpo-ebelp,

statu TYPE ekpo-statu,

aedat TYPE ekpo-aedat,

matnr TYPE ekpo-matnr,

menge TYPE ekpo-menge,

meins TYPE ekpo-meins,

netpr TYPE ekpo-netpr,

peinh TYPE ekpo-peinh,

field_style TYPE lvc_t_styl, "FOR DISABLE

END OF t_ekko.

DATA: it_ekko TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,

wa_ekko TYPE t_ekko.

*ALV data declarations

DATA: fieldcatalog TYPE slis_t_fieldcat_alv WITH HEADER LINE.

DATA: it_fieldcat TYPE lvc_t_fcat, "slis_t_fieldcat_alv WITH HEADER LINE,

wa_fieldcat TYPE lvc_s_fcat,

gd_tab_group TYPE slis_t_sp_group_alv,

gd_layout TYPE lvc_s_layo, "slis_layout_alv,

gd_repid LIKE sy-repid.

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

*Start-of-selection.

START-OF-SELECTION.

PERFORM data_retrieval.

PERFORM set_specific_field_attributes.

PERFORM build_fieldcatalog.

PERFORM build_layout.

PERFORM display_alv_report.

&----


*& Form BUILD_FIELDCATALOG

&----


  • Build Fieldcatalog for ALV Report

----


FORM build_fieldcatalog.

wa_fieldcat-fieldname = 'EBELN'.

wa_fieldcat-scrtext_m = 'Purchase Order'.

wa_fieldcat-col_pos = 0.

wa_fieldcat-outputlen = 10.

wa_fieldcat-emphasize = 'X'.

wa_fieldcat-key = 'X'.

APPEND wa_fieldcat TO it_fieldcat.

CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'EBELP'.

wa_fieldcat-scrtext_m = 'PO Item'.

wa_fieldcat-col_pos = 1.

APPEND wa_fieldcat TO it_fieldcat.

CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'STATU'.

wa_fieldcat-scrtext_m = 'Status'.

wa_fieldcat-col_pos = 2.

APPEND wa_fieldcat TO it_fieldcat.

CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'AEDAT'.

wa_fieldcat-scrtext_m = 'Item change date'.

wa_fieldcat-col_pos = 3.

APPEND wa_fieldcat TO it_fieldcat.

CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'MATNR'.

wa_fieldcat-scrtext_m = 'Material Number'.

wa_fieldcat-col_pos = 4.

APPEND wa_fieldcat TO it_fieldcat.

CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'MENGE'.

wa_fieldcat-scrtext_m = 'PO quantity'.

wa_fieldcat-col_pos = 5.

APPEND wa_fieldcat TO it_fieldcat.

CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'MEINS'.

wa_fieldcat-scrtext_m = 'Order Unit'.

wa_fieldcat-col_pos = 6.

APPEND wa_fieldcat TO it_fieldcat.

CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'NETPR'.

wa_fieldcat-scrtext_m = 'Net Price'.

wa_fieldcat-edit = 'X'. "sets whole column to be editable

wa_fieldcat-col_pos = 7.

wa_fieldcat-outputlen = 15.

wa_fieldcat-datatype = 'CURR'.

APPEND wa_fieldcat TO it_fieldcat.

CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'PEINH'.

wa_fieldcat-scrtext_m = 'Price Unit'.

wa_fieldcat-col_pos = 8.

APPEND wa_fieldcat TO it_fieldcat.

CLEAR wa_fieldcat.

ENDFORM. " BUILD_FIELDCATALOG

&----


*& Form BUILD_LAYOUT

&----


  • Build layout for ALV grid report

----


FORM build_layout.

  • Set layout field for field attributes(i.e. input/output)

gd_layout-stylefname = 'FIELD_STYLE'.

gd_layout-zebra = 'X'.

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'

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'

EXPORTING

i_callback_program = gd_repid

  • i_callback_user_command = 'USER_COMMAND'

is_layout_lvc = gd_layout

it_fieldcat_lvc = it_fieldcat

i_save = 'X'

TABLES

t_outtab = it_ekko

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 ebeln ebelp statu aedat matnr menge meins netpr peinh

UP TO 10 ROWS

FROM ekpo

INTO CORRESPONDING FIELDS OF TABLE it_ekko.

ENDFORM. " DATA_RETRIEVAL

&----


*& Form set_specific_field_attributes

&----


  • populate FIELD_STYLE table with specific field attributes

----


form set_specific_field_attributes .

DATA ls_stylerow TYPE lvc_s_styl .

DATA lt_styletab TYPE lvc_t_styl .

  • Populate style variable (FIELD_STYLE) with style properties

*

  • The NETPR field/column has been set to editable in the fieldcatalog...

  • The following code sets it to be disabled(display only) if 'NETPR'

  • is gt than 10.

LOOP AT it_ekko INTO wa_ekko.

IF wa_ekko-netpr GT 10.

ls_stylerow-fieldname = 'NETPR' .

ls_stylerow-style = cl_gui_alv_grid=>mc_style_disabled.

"set field to disabled

APPEND ls_stylerow TO wa_ekko-field_style.

MODIFY it_ekko FROM wa_ekko.

ENDIF.

ENDLOOP.

endform. " set_specific_field_attributes

0 Kudos
112

i need an example that make use of

CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'

and field catalog merge since my table contain at least 50 fields

Former Member
0 Kudos
112

Following this program is edit block alv report.

REPORT YMS_EDITBLOCKALV.

TABLES : rmmg1,MCHB, mkpf.

DATA: BEGIN OF t_mseg OCCURS 0,

zeile LIKE mseg-zeile,

menge LIKE mseg-menge,

meins LIKE mseg-meins,

matnr LIKE mseg-matnr,

werks LIKE mseg-werks,

charg LIKE mseg-charg,

bwart LIKE mseg-bwart,

END OF t_mseg.

DATA:BEGIN OF t_mchb OCCURS 0.

INCLUDE STRUCTURE mchb.

data flag type c.

matnr LIKE mchb-matnr,

charg LIKE mchb-charg,

werks LIKE mchb-werks,

clabs LIKE mchb-clabs,

DATA END OF t_mchb.

TYPE-POOLS slis.

data: progname like sy-repid,

fieldcattab TYPE slis_t_fieldcat_alv WITH HEADER LINE.

data tabindex type i.

data wa_matnr LIKE mchb-matnr.

progname = sy-repid.

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

SELECT-OPTIONS s_docno FOR mkpf-mblnr. " OBLIGATORY.

PARAMETERS p_docyr LIKE mkpf-mjahr. " OBLIGATORY.

SELECTION-SCREEN END OF BLOCK b_b1.

START-OF-SELECTION.

SELECT zeile

menge

meins

matnr

werks

charg

bwart

FROM mseg

INTO TABLE t_mseg

WHERE mblnr IN s_docno AND mjahr = p_docyr.

CLEAR fieldcattab.

fieldcattab-col_pos = 1.

fieldcattab-fieldname = 'ZEILE'.

fieldcattab-tabname = 'T_MSEG'.

fieldcattab-fix_column = 'X'.

fieldcattab-seltext_l = 'Item'.

APPEND fieldcattab.

CLEAR fieldcattab.

fieldcattab-col_pos = 2.

fieldcattab-fieldname = 'MENGE'.

fieldcattab-tabname = 'T_MSEG'.

fieldcattab-seltext_l = 'Quantity'.

APPEND fieldcattab.

CLEAR fieldcattab.

fieldcattab-col_pos = 3.

fieldcattab-fieldname = 'MEINS'.

fieldcattab-tabname = 'T_MSEG'.

fieldcattab-seltext_l = 'Unit'.

APPEND fieldcattab.

CLEAR fieldcattab.

fieldcattab-col_pos = 4.

fieldcattab-fieldname = 'MATNR'.

fieldcattab-tabname = 'T_MSEG'.

fieldcattab-seltext_l = 'Material'.

APPEND fieldcattab.

CLEAR fieldcattab.

fieldcattab-col_pos = 5.

fieldcattab-fieldname = 'WERKS'.

fieldcattab-tabname = 'T_MSEG'.

fieldcattab-seltext_l = 'Plant'.

APPEND fieldcattab.

CLEAR fieldcattab.

fieldcattab-col_pos = 6.

fieldcattab-fieldname = 'CHARG'.

fieldcattab-tabname = 'T_MSEG'.

fieldcattab-seltext_l = 'Batch No'.

APPEND fieldcattab.

CLEAR fieldcattab.

fieldcattab-col_pos = 7.

fieldcattab-fieldname = 'BWART'.

fieldcattab-tabname = 'T_MSEG'.

fieldcattab-seltext_l = 'Inventory'.

fieldcattab-hotspot = 'X'.

APPEND fieldcattab.

end-of-selection.

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

EXPORTING

I_INTERFACE_CHECK = ' '

I_BYPASSING_BUFFER =

I_BUFFER_ACTIVE = ' '

I_CALLBACK_PROGRAM = PROGNAME

I_CALLBACK_PF_STATUS_SET = ' '

I_CALLBACK_USER_COMMAND = 'USERCOMMAND1'

I_CALLBACK_TOP_OF_PAGE = ' '

I_CALLBACK_HTML_TOP_OF_PAGE = ' '

I_CALLBACK_HTML_END_OF_LIST = ' '

I_STRUCTURE_NAME =

I_BACKGROUND_ID = ' '

I_GRID_TITLE =

I_GRID_SETTINGS =

IS_LAYOUT =

IT_FIELDCAT = fieldcattab[]

IT_EXCLUDING =

IT_SPECIAL_GROUPS =

IT_SORT =

IT_FILTER =

IS_SEL_HIDE =

I_DEFAULT = 'X'

I_SAVE = ' '

IS_VARIANT =

IT_EVENTS =

IT_EVENT_EXIT =

IS_PRINT =

IS_REPREP_ID =

I_SCREEN_START_COLUMN = 0

I_SCREEN_START_LINE = 0

I_SCREEN_END_COLUMN = 0

I_SCREEN_END_LINE = 0

IT_ALV_GRAPHICS =

IT_ADD_FIELDCAT = fieldcattab

IT_HYPERLINK =

IMPORTING

E_EXIT_CAUSED_BY_CALLER =

ES_EXIT_CAUSED_BY_USER =

TABLES

t_outtab = t_mseg

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.

FORM usercommand1 USING r_ucomm LIKE sy-ucomm rs_selfield TYPE

slis_selfield.

CASE r_ucomm.

WHEN '&IC1'.

tabindex = rs_selfield-tabindex.

read table t_mseg INDEX tabindex.

select * from mchb into table t_mchb where matnr = t_mseg-matnr.

clear fieldcattab.

CLEAR fieldcattab[].

fieldcattab-col_pos = 1.

fieldcattab-fieldname = 'FLAG'.

fieldcattab-tabname = 'T_MCHB'.

fieldcattab-fix_column = 'X'.

fieldcattab-seltext_l = 'Check Box'.

fieldcattab-input = 'X'.

fieldcattab-edit = 'X'.

fieldcattab-checkbox = 'X'.

APPEND fieldcattab.

clear fieldcattab.

fieldcattab-col_pos = 2.

fieldcattab-fieldname = 'MATNR'.

fieldcattab-tabname = 'T_MCHB'.

fieldcattab-fix_column = 'X'.

fieldcattab-seltext_l = 'Material'.

fieldcattab-emphasize = 'C1'.

fieldcattab-input = 'X'.

fieldcattab-edit = 'X'.

fieldcattab-checkbox = 'X'.

APPEND fieldcattab.

clear fieldcattab.

fieldcattab-col_pos = 3.

fieldcattab-fieldname = 'CHARG'.

fieldcattab-tabname = 'T_MCHB'.

fieldcattab-seltext_l = 'Batch No'.

fieldcattab-emphasize = 'C2'.

fieldcattab-input = 'X'.

fieldcattab-edit = 'X'.

APPEND fieldcattab.

clear fieldcattab.

fieldcattab-col_pos = 4.

fieldcattab-fieldname = 'WERKS'.

fieldcattab-tabname = 'T_MCHB'.

fieldcattab-seltext_l = 'Plant'.

fieldcattab-emphasize = 'C30'.

fieldcattab-input = 'X'.

fieldcattab-edit = 'X'.

APPEND fieldcattab.

clear fieldcattab.

fieldcattab-col_pos = 5.

fieldcattab-fieldname = 'CLABS'.

fieldcattab-tabname = 'T_MCHB'.

fieldcattab-seltext_l = 'Stock'.

fieldcattab-emphasize = 'C601'.

fieldcattab-input = 'X'.

fieldcattab-edit = 'X'.

APPEND fieldcattab.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

I_INTERFACE_CHECK = ' '

I_BYPASSING_BUFFER =

I_BUFFER_ACTIVE = ' '

I_CALLBACK_PROGRAM = PROGNAME

I_CALLBACK_PF_STATUS_SET = ' '

I_CALLBACK_USER_COMMAND = 'USERCOMMAND2'

I_CALLBACK_TOP_OF_PAGE = ' '

I_CALLBACK_HTML_TOP_OF_PAGE = ' '

I_CALLBACK_HTML_END_OF_LIST = ' '

I_STRUCTURE_NAME =

I_BACKGROUND_ID = ' '

I_GRID_TITLE =

I_GRID_SETTINGS =

IS_LAYOUT =

IT_FIELDCAT = FIELDCATTAB[]

IT_EXCLUDING =

IT_SPECIAL_GROUPS =

IT_SORT =

IT_FILTER =

IS_SEL_HIDE =

I_DEFAULT = 'X'

I_SAVE = ' '

IS_VARIANT =

IT_EVENTS =

IT_EVENT_EXIT =

IS_PRINT =

IS_REPREP_ID =

I_SCREEN_START_COLUMN = 0

I_SCREEN_START_LINE = 0

I_SCREEN_END_COLUMN = 0

I_SCREEN_END_LINE = 0

IT_ALV_GRAPHICS =

IT_ADD_FIELDCAT =

IT_HYPERLINK =

IMPORTING

E_EXIT_CAUSED_BY_CALLER =

ES_EXIT_CAUSED_BY_USER =

TABLES

t_outtab = t_mchb

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.

endcase.

endform.

FORM usercommand2 USING r_ucomm LIKE sy-ucomm rs_selfield TYPE

slis_selfield.

CASE r_ucomm.

WHEN '&IC1'.

IF rs_selfield-sel_tab_field = 'T_MCHB-MATNR'.

CALL FUNCTION 'ZALV2'

EXPORTING

CTU = 'X'

MODE = 'E'

UPDATE = 'A'

GROUP =

USER =

KEEP =

HOLDDATE =

NODATA = '/'

MATNR_001 = '200-200'

KZSEL_01_002 = 'X'

IMPORTING

SUBRC =

TABLES

MESSTAB =

.

**

SET PARAMETER ID 'RID' FIELD RMMG1-MATNR.

CALL TRANSACTION 'MM03' and skip first screen.

ENDIF.

ENDCASE.

*

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = progname

i_callback_user_command = 'USERCOMMAND3'

it_fieldcat = fieldcattab[]

TABLES

t_outtab = t_mchb

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.

endcase.

ENDFORM.

Former Member
0 Kudos
112

solve