‎2008 Aug 11 1:10 PM
Hi experts!
I've a doubt, I have to create an ALV with differents types of data one of them must be a check, when the user has the ALV he can chose wich of the data want to generate the Batch Input and after this, make the Batch Input process, does anybody have an idea of how make this?
thanks a lot
Regards,
Rebeca
‎2008 Aug 11 1:43 PM
when you are working with input fields or check boxes
You need use the Function module in the user command to get the updated content to the internal table.
GET_GLOBALS_FROM_SLVC_FULLSCR
follow the sample code.
REPORT ZTEST_ALV_CHECK MESSAGE-ID ZZ .
TYPE-POOLS: SLIS.
DATA: X_FIELDCAT TYPE SLIS_FIELDCAT_ALV,
IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
L_LAYOUT TYPE SLIS_LAYOUT_ALV,
X_EVENTS TYPE SLIS_ALV_EVENT,
IT_EVENTS TYPE SLIS_T_EVENT.
DATA: BEGIN OF ITAB OCCURS 0,
VBELN LIKE VBAK-VBELN,
POSNR LIKE VBAP-POSNR,
CHK(1),
color(4),
END OF ITAB.
SELECT VBELN
POSNR
FROM VBAP
UP TO 20 ROWS
INTO TABLE ITAB.
X_FIELDCAT-FIELDNAME = 'CHK'.
X_FIELDCAT-TABNAME = 'ITAB'.
X_FIELDCAT-COL_POS = 1.
X_FIELDCAT-INPUT = 'X'.
X_FIELDCAT-EDIT = 'X'.
X_FIELDCAT-CHECKBOX = 'X'.
APPEND X_FIELDCAT TO IT_FIELDCAT.
CLEAR X_FIELDCAT.
X_FIELDCAT-FIELDNAME = 'VBELN'.
X_FIELDCAT-SELTEXT_L = 'VBELN'.
X_FIELDCAT-HOTSPOT = 'X'.
X_FIELDCAT-TABNAME = 'ITAB'.
X_FIELDCAT-COL_POS = 2.
APPEND X_FIELDCAT TO IT_FIELDCAT.
CLEAR X_FIELDCAT.
X_FIELDCAT-FIELDNAME = 'POSNR'.
X_FIELDCAT-SELTEXT_L = 'POSNR'.
X_FIELDCAT-TABNAME = 'ITAB'.
X_FIELDCAT-COL_POS = 3.
APPEND X_FIELDCAT TO IT_FIELDCAT.
CLEAR X_FIELDCAT.
L_LAYOUT-info_fieldname = 'COLOR'.
*L_LAYOUT-ZEBRA = 'X'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
IS_LAYOUT = L_LAYOUT
I_CALLBACK_PF_STATUS_SET = 'STATUS'
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
IT_FIELDCAT = IT_FIELDCAT
TABLES
T_OUTTAB = ITAB
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.
&---------------------------------------------------------------------
*& Form STATUS
&---------------------------------------------------------------------
text
----------------------------------------------------------------------
-->P_EXTAB text
----------------------------------------------------------------------
FORM STATUS USING P_EXTAB TYPE SLIS_T_EXTAB.
Pf status
SET PF-STATUS 'STATUS'.
ENDFORM. " STATUS
&---------------------------------------------------------------------
*& Form USER_COMMAND
&---------------------------------------------------------------------
text
----------------------------------------------------------------------
-->R_UCOMM text
-->RS_SELFIELD text
----------------------------------------------------------------------
FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
RS_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.
"Read the current record which you selected using the
"RS_SELFIELD-TABINDEX and using the values
"populate BDCDATA
"here you can send the records for BDC/BAPI and update the DB
RS_SELFIELD-refresh = 'X'.
break-point.
ENDFORM. "USER_COMMANDRegards
Vijay Babu Dudla
‎2008 Aug 12 7:51 AM
To create ALV ,
data: begin of t_vendor occurs 5, "Internal table of the ALV
box type c ,
lifnr like lfa1-lifnr,
name1 like lfa1-name1, " Add the other required fields
end of t_vendor,
data: t_layout type lvc_s_layo, "ALV Layout
t_field type lvc_t_fcat with header line, "ALV Field catalogue
ref1 type ref to cl_gui_alv_grid, "Object for alv
ref1 type ref to cl_gui_alv_grid, "Object for alv
answer type c ,
valid type c,
flag type i,
i type i.
perform build_catalogue using :
'BOX' 'Check box' 'T_VENDOR' 1 'X' 'X',
'LIFNR' 'Vendor number ' 'T_VENDOR' 2 ' ' ' ',
'NAME1' 'Vendor name ' 'T_VENDOR' 3 ' ' ' ', "Add the required fields
form build_catalogue using f_field f_reptext
f_tabname f_col_pos
f_checkbox f_edit.
clear t_field.
t_field-fieldname = f_field.
t_field-tabname = f_tabname .
t_field-reptext = f_reptext .
t_field-col_pos = f_col_pos .
t_field-checkbox = f_checkbox .
t_field-edit = f_edit.
append t_field to t_field.
endform. "build_catalogue
call function 'REUSE_ALV_GRID_DISPLAY_LVC'
exporting
i_callback_program = sy-repid
i_callback_pf_status_set = 'SUB_PF_STATUS_SET'
i_callback_user_command = 'SUB_EVENT'
it_fieldcat_lvc = t_field[]
i_save = 'X'
tables
t_outtab = t_vendor.
form sub_event using r_ucomm like sy-ucomm
rs_selfield type slis_selfield.
call function 'GET_GLOBALS_FROM_SLVC_FULLSCR'
importing
e_grid = ref1.
call method ref1->check_changed_data. "checking the alv grid for changed data
loop at t_vendor where box = 'X'.
valid = 'X'.
exit.
endloop.
case r_ucomm.
when '&DEACT'.
if valid = 'X'.
call function 'POPUP_TO_CONFIRM'
exporting
titlebar = 'Confirmation Dialog '
text_question = 'Are you sure to carry out BDC ?'
text_button_1 = 'Yes'
text_button_2 = 'No'
default_button = '1'
display_cancel_button = ' '
start_column = 25
start_row = 6
importing
answer = answer.
if answer = '1'.
perform bdc. "Contains the code to do bdc.
endif.
endif.
endcase.
valid = ' '.
endform. "sub_event
Do the bdc and record it . modify the code as per requirements .Copy and paste the code into this sub routine .