Skip to Content
0
Former Member
Apr 19, 2007 at 12:01 PM

Reg :Alv report

24 Views

Hi experts,

after clicking of check box i want to insert the data in database(Y00_MM_ISSUE_DAT) table with check boxes

i had written some code but it came errors

how to write that code ,send me mail with code check my code.

plz send me reply.

REPORT Y00_MM_PICK_PUT_LIST.

TYPE-POOLS: slis.

TABLES:MSEG,MARD,MKPF.

TYPES:BEGIN OF tp_data,

mblnr LIKE mseg-mblnr,

matnr LIKE mseg-matnr,

werks LIKE mard-werks,

lgort LIKE mard-lgort,

lgpbe LIKE mard-lgpbe,

charg LIKE mseg-charg,

bwart LIKE mseg-bwart,

budat LIKE mkpf-budat,

menge LIKE mseg-menge,

meins LIKE mseg-meins,

kostl LIKE mseg-kostl,

aufnr LIKE mseg-aufnr,

rsnum LIKE mseg-rsnum,

ENDKZ,

END OF tp_data,

tp_tbl_data TYPE STANDARD TABLE OF tp_data.

  • Report data to be shown.

DATA: it_data TYPE STANDARD TABLE OF tp_data.

  • Heading of the report.

DATA: t_heading TYPE slis_t_listheader.

========================== Selection Screen ==========================

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

SELECT-OPTIONS:smblnr FOR mseg-mblnr MODIF ID m1,

smatnr FOR mseg-matnr MODIF ID m2,

swerks FOR mard-werks MODIF ID m3,

slgort FOR mard-lgort MODIF ID m4,

slgpbe FOR mard-lgpbe MODIF ID m5,

scharg FOR mseg-charg MODIF ID m6,

sbwart FOR mseg-bwart MODIF ID m7,

skostl FOR mseg-kostl MODIF ID m8,

saufnr FOR mseg-aufnr MODIF ID m9,

srsnum FOR mseg-rsnum MODIF ID m10.

SELECTION-SCREEN END OF BLOCK b1.

SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-002.

PARAMETERS:pre RADIOBUTTON GROUP radi USER-COMMAND ucomm DEFAULT 'X',

pse RADIOBUTTON GROUP radi,

bps RADIOBUTTON GROUP radi.

SELECTION-SCREEN END OF BLOCK b2.

SELECTION-SCREEN BEGIN OF BLOCK b3 WITH FRAME TITLE text-003.

PARAMETER:lay TYPE i.

SELECTION-SCREEN END OF BLOCK b3.

=========================== Event Blocks =============================

AT SELECTION-SCREEN.

START-OF-SELECTION.

PERFORM get_data USING it_data.

END-OF-SELECTION.

PERFORM build_alv USING it_data t_heading.

=========================== Subroutines ==============================

&----


*& Form get_data

&----


  • Gets the information to be shown in the report.

----


FORM get_data USING t_data TYPE tp_tbl_data.

SELECT mseg~mblnr

mseg~matnr

mard~werks

mard~lgort

mard~lgpbe

mseg~charg

mseg~bwart

mkpf~budat

mseg~menge

mseg~meins

mseg~kostl

mseg~aufnr

mseg~rsnum

INTO CORRESPONDING FIELDS OF TABLE t_data

FROM mseg

jOIN mard ON mardmatnr EQ msegmatnr

JOIN mkpf ON msegmblnr EQ mkpfmblnr

WHERE mseg~matnr IN smatnr.

ENDFORM. "get_data

&----


*& Form build_alv

&----


  • Builds and display the ALV Grid.

----


FORM build_alv USING t_data TYPE tp_tbl_data

t_heading TYPE slis_t_listheader.

  • ALV required data objects.

DATA: w_title TYPE lvc_title,

w_comm TYPE slis_formname,

w_status TYPE slis_formname,

  • x_layout TYPE slis_layout_alv,

  • t_event TYPE slis_t_event,

t_fieldcat TYPE slis_t_fieldcat_alv,

t_sort TYPE slis_t_sortinfo_alv.

REFRESH t_fieldcat.

  • REFRESH t_event.

REFRESH t_sort.

  • CLEAR x_layout.

CLEAR w_title.

  • Field Catalog

PERFORM set_fieldcat2 USING:

1 'MBLNR' 'MBLNR' 'MSEG' space space space space space space space space space space space space t_fieldcat ,

2 'MATNR' 'MATNR' 'MSEG' space space space space space space space space space space space space t_fieldcat ,

3 'WERKS' 'WERKS' 'MARD' space space space space space space space space space space space space t_fieldcat,

4 'LGORT' 'LGORT' 'MARD' space space space space space space space space space space space space t_fieldcat ,

5 'LGPBE' 'LGPBE' 'MARD' space space space space space space space space space space space space t_fieldcat ,

6 'CHARG' 'CHARG' 'MSEG' space space space space space space space space space space space space t_fieldcat ,

7 'BWART' 'BWART' 'MSEG' space space space space space space space space space space space space t_fieldcat ,

8 'BUDAT' 'BUDAT' 'MKPF' space space space space space space space space space space space space t_fieldcat ,

9 'MENGE' 'MENGE' 'MSEG' space space space space space space space space space space space space t_fieldcat ,

10 'MEINS' 'MEINS' 'MSEG' space space space space space space space space space space space space t_fieldcat ,

11 'KOSTL' 'KOSTL' 'MSEG' space space space space space space space space space space space space t_fieldcat ,

12 'AUFNR' 'AUFNR' 'MSEG' space space space space space space space space space space space space t_fieldcat ,

13 'RSNUM' 'RSNUM' 'MSEG' space space space space space space space space space space space space t_fieldcat ,

14 'ENDKZ' 'ENDKZ' space space space 'Select' 'Select this row' 'Sel' 'Select this row' space space space 'X' 'X' space t_fieldcat.

  • GUI Status

w_status = ''.

  • User commands

w_comm = 'USER_COMMAND'.

  • Order

  • Example

  • PERFORM set_order USING '<field>' 'IT_DATA' 'X' space space t_sort.

PERFORM set_order USING 'MATNR' 'IT_DATA' 'X' space 'X' t_sort.

PERFORM set_order USING 'MBLNR' 'IT_DATA' 'X' space 'X' t_sort.

PERFORM set_order USING 'WERKS' 'IT_DATA' 'X' space space t_sort.

  • Displays the ALV grid

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = sy-repid

it_fieldcat = t_fieldcat

  • is_layout = x_layout

it_sort = t_sort

i_callback_pf_status_set = w_status

i_callback_user_command = w_comm

i_save = 'X'

  • it_events = t_event

i_grid_title = w_title

TABLES

t_outtab = t_data

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. " build_alv.

&----


*& Form set_order

&----


  • Adds an entry to the order table.

----


FORM set_order USING p_fieldname p_tabname p_up p_down p_subtot

t_sort TYPE slis_t_sortinfo_alv.

DATA: x_sort TYPE slis_sortinfo_alv.

CLEAR x_sort.

x_sort-fieldname = p_fieldname.

x_sort-tabname = p_tabname.

x_sort-UP = p_up.

x_sort-down = p_down.

x_sort-subtot = p_subtot.

APPEND x_sort TO t_sort.

ENDFORM. "set_order

&----


*& Form set_fieldcat2

&----


  • Adds an entry to the field catalog.

----


FORM set_fieldcat2 USING p_colpos p_fieldname p_ref_fieldname p_ref_tabname

p_outputlen p_noout

p_seltext_m p_seltext_l p_seltext_s p_reptext_ddic p_ddictxt

p_hotspot p_showasicon p_checkbox p_edit

p_dosum

t_fieldcat TYPE slis_t_fieldcat_alv.

DATA: wa_fieldcat TYPE slis_fieldcat_alv.

CLEAR wa_fieldcat.

  • General settings

wa_fieldcat-fieldname = p_fieldname.

wa_fieldcat-col_pos = p_colpos.

wa_fieldcat-no_out = p_noout.

wa_fieldcat-HOTSPOT = p_hotspot.

wa_fieldcat-CHECKBOX = p_checkbox.

wa_fieldcat-ICON = p_showasicon.

wa_fieldcat-do_sum = p_dosum.

  • Set reference fieldname, tablenam and rollname.

  • If p_ref_tabname is not given, the ref_fieldname given is a data element.

  • If p_ref_tabname is given, the ref_fieldname given is a field of a table.

  • In case ref_fieldname is not given, it is copied from the fieldname.

IF p_ref_tabname IS INITIAL.

wa_fieldcat-rollname = p_ref_fieldname.

ELSE.

wa_fieldcat-ref_tabname = p_ref_tabname.

IF p_ref_fieldname EQ space.

wa_fieldcat-ref_fieldname = wa_fieldcat-fieldname.

ELSE.

wa_fieldcat-ref_fieldname = p_ref_fieldname.

ENDIF.

ENDIF.

  • Set output length.

IF NOT p_outputlen IS INITIAL.

wa_fieldcat-outputlen = p_outputlen.

ENDIF.

  • Set text headers.

IF NOT p_seltext_m IS INITIAL.

wa_fieldcat-seltext_m = p_seltext_m.

ENDIF.

IF NOT p_seltext_l IS INITIAL.

wa_fieldcat-seltext_l = p_seltext_l.

ENDIF.

IF NOT p_seltext_s IS INITIAL.

wa_fieldcat-seltext_s = p_seltext_s.

ENDIF.

IF NOT p_reptext_ddic IS INITIAL.

wa_fieldcat-reptext_ddic = p_reptext_ddic.

ENDIF.

IF NOT p_ddictxt IS INITIAL.

wa_fieldcat-ddictxt = p_ddictxt.

ENDIF.

  • Set as editable or not.

IF p_edit IS NOT INITIAL.

wa_fieldcat-INPUT = 'X'.

wa_fieldcat-EDIT = 'X'.

ENDIF.

APPEND wa_fieldcat TO t_fieldcat.

ENDFORM. "set_fieldcat2

&----


*& Form user_command

&----


  • Called on user_command ALV event.

  • Executes custom commands.

----


FORM user_command USING r_ucomm LIKE sy-ucomm

rs_selfield TYPE slis_selfield

t_data TYPE tp_tbl_data.

tables:Y00_MM_ISSUE_DAT.

Y00_MM_ISSUE_DAT-mblnr = t_data-mblnr.

Y00_MM_ISSUE_DAT-matnr = t_data-matnr.

Y00_MM_ISSUE_DAT-ENDKZ = t_data-endkz.

INSERT Y00_MM_ISSUE_DAT from table t_data.

ENDFORM. "user_command

Y00_MM_ISSUE_DAT it is database table with mblnr,matnr,enkz

endkz

Thanks,

Ramesh...