01-07-2009 8:43 AM
Hi Experts,
I have a problem with ALV Display. I am able to display the contents in output.
But my client requirement is, they need to insert 'check boxes' before each record.
I hope you understood. any way let me explain some thing...
I am displaying records in ALV, but they need check boxes before each record. Like.... you can see database tables. in database tables like MARA.. it will display
check box client field1 field2 field3.......................
Please help me in this regard.....
Thanks in Advance
Sai babu
01-07-2009 8:47 AM
Hi,
in the field catalog settings for checkbox field of type c length 1,
put wa_fcat-CHECKBOX = 'X'.
01-07-2009 8:48 AM
Hi,
Add first field as character in the internal table. for eg say "check".
Then will building fieldcatalog use this.
for eg itab has check as field..
in the fieldcat
wa_fcat-fieldname = 'CHECK'.
wa_fcat-tabname = 'ITAB'.
wa_fcat-checkbox = 'X'.
wa_fcat-edit = 'X'.
append wa_fcat to it_fcat.
regards,
Santosh Thorat
Code Formatted by: Alvaro Tejada Galindo on Jan 7, 2009 12:45 PM
01-07-2009 8:51 AM
Hi Sai,
Take a field as flag (type char, size 1) at the last of the internal table and work area(if using without header line).
Now when you define the field catalogs, use this code:-
wa_field-fieldname = 'FLAG'. " name of field from internal table
wa_field-tabname = 'IT_FINAL'. " internal table name
wa_field-outputlen = 2. " output length on screen
wa_field-checkbox = 'X' . " print as checkbox
wa_field-edit = 'X'. " make field open for input
wa_field-seltext_l = ' '. " header information
APPEND wa_field TO it_field. " append field catalog internal table
CLEAR wa_field. " clear field catalog work area
And use this field catalogs to pass in the FM.
Hope this solves your problem.
Thanks & Regards,
Tarun Gambhir
01-07-2009 8:51 AM
Hi,
Define one field in an internal table (final which u pass to alv FM)
eg: chk_box type c.
then build field catalog for this field in field catalog mention checkbox as 'X' and if u want that check box to be editable then pass parameter input of fieldcatalog as 'X'.
Code:
TYPES : BEGIN OF TY_DEL_ENT,
CHK_BOX(1) TYPE C, "Check Box
AUFNR TYPE AUFNR, "Order Number
END OF TY_DEL_ENT.
fieldcatalog
FS_FIELDCAT-TABNAME = WL_TABNAME.
FS_FIELDCAT-FIELDNAME = WL_FCAT_CHK.
FS_FIELDCAT-SELTEXT_L = TEXT-007.
FS_FIELDCAT-CHECKBOX = WL_X.
FS_FIELDCAT-INPUT = WL_X.
APPEND FS_FIELDCAT TO INT_FIELDCAT.
Code Formatted by: Alvaro Tejada Galindo on Jan 7, 2009 12:45 PM
01-07-2009 8:52 AM
Add a Column to the Final internal table with filed length as 1 and type a C.
Add the same in filed catelogue.
it will be displayed as a checkbox in alv.
01-07-2009 8:54 AM
HI.
Refer thic links.
http://born4abap.blogspot.com/2008/05/alv-check-boxes-sample-code.html
http://www.saptechies.com/checkbox-in-alv-grid/
Regards.
jay
01-07-2009 8:57 AM
Hi Sai Babu,
You can use the below mentioned method.
Data declaration:
TYPES: BEGIN OF struct_resb,
rsnum TYPE rsnum, " Number of Reservation
rspos TYPE rspos, " Item Number of Reservation
prvbe TYPE prvbe, " Supply Area
xwaok TYPE xwaok, " Goods movement for reser allowed
rgekz TYPE rgekz, " Indicator: Backflush
dbskz TYPE dbskz, " Direct procurement indicator
xloek TYPE xloek, " Item is deleted
bdmng TYPE bdmng, " Requirement Quantity
enmng TYPE enmng, " Quantity withdrawn
matnr TYPE matnr, " Material Number
bwart TYPE bwart, " Movement Type
werks TYPE werks_d," Plant
lgort TYPE lgort_d," Storage location
erfmg TYPE erfmg, " Quantity in unit of entry
erfme TYPE erfme, " Unit of entry
meins TYPE meins, " Base Unit of Measure
kzear TYPE kzear, " Final issue for this reservation
maktx TYPE maktx, " Material Description
open_qty(17) TYPE c, "Open Quantity
cb_box(1), " Check Box
color_line(4) TYPE c, " Column color
row TYPE c LENGTH 4, "FOR ROW COLOR
col TYPE slis_t_specialcol_alv, " for SLIS with color
comment(40) TYPE c,
END OF struct_resb.
DATA: wa_resb TYPE struct_resb,
t_resb TYPE STANDARD TABLE OF struct_resb,
t_fieldcatalog TYPE slis_t_fieldcat_alv, " for field catalog
PERFORM build_fieldcat USING t_fieldcatalog. " Prepare fieldcatalog
FORM build_fieldcat USING p_t_fieldcatalog TYPE slis_t_fieldcat_alv.
DATA: wl_fieldcat TYPE slis_fieldcat_alv. " Declaring Local Variable
CLEAR wl_fieldcat.
wl_fieldcat-col_pos = '1'. " POSITION OF THE COLUMN.
wl_fieldcat-fieldname = 'CB_BOX'.
wl_fieldcat-tabname = 'T_RESB'.
wl_fieldcat-checkbox = 'X'.
wl_fieldcat-seltext_l = text-013. " To issue
wl_fieldcat-seltext_m = text-014. " MEDIUM TEXT FOR HEADER.
wl_fieldcat-seltext_s = text-015. " SHORT TEXT FOR HEADER.
wl_fieldcat-outputlen = 10. " SET THE OUTPUT LENGTH.
wl_fieldcat-input = 'X'.
APPEND wl_fieldcat TO t_fieldcatalog.
By making the first column of filedcatalog as above, you will get the check boxes in the output for all records.
Best Regards,
Deepa Kulkarni
Code Formatted by: Alvaro Tejada Galindo on Jan 7, 2009 12:45 PM
01-07-2009 9:42 AM
Hi This is my code,
As of you people suggested me, i write like this.... but it is not working....
please guide me....
FORM SUB_DISP_REP .
PERFORM SUB_FIELD_DEF USING :
' ' '1' 'PERNR' 'Personnel Number' ' ' ' ' ' ' ,
' ' '2' 'STAT2' 'Employee Status' '' '' '' ,
' ' '3' 'STELL' 'Job Title' '' '' '' ,
' ' '4' 'VORNA' 'First Name' '' '' '' ,
' ' '5' 'NACHN' 'Last Name' '' '' '' ,
' ' '6' 'KTART' 'Absence Quota Type' '' '' '' ,
' ' '7' 'ANZHL' 'Number of Employee Time Quota' '' '' '' ,
' ' '8' 'KVERB' 'Deduction of Employee Time Quota' '' '' '' ,
' ' '9' 'QUONR' 'Counter for time quotas' '' '' '' ,
' ' '10' 'DESTA' 'Start Date for Quota Deduction' '' '' '' ,
' ' '11' 'DEEND' 'Quota Deduction to' '' '' '' .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
* I_INTERFACE_CHECK = ' '
* I_BYPASSING_BUFFER = ' '
* I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = SY-CPROG
* I_CALLBACK_PF_STATUS_SET = ' '
* I_CALLBACK_USER_COMMAND = ' '
I_CALLBACK_TOP_OF_PAGE = 'X'
* I_CALLBACK_HTML_TOP_OF_PAGE = ' '
* I_CALLBACK_HTML_END_OF_LIST = ' '
* I_STRUCTURE_NAME =
I_BACKGROUND_ID = 'TRVPICTURE08'
I_GRID_TITLE = 'EMPLOYEE ABSENCE QUOTA'
* I_GRID_SETTINGS =
* IS_LAYOUT =
IT_FIELDCAT = T_FCAT
* IT_EXCLUDING =
* IT_SPECIAL_GROUPS =
IT_SORT = T_SUBTOT
* 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_HYPERLINK =
* IT_ADD_FIELDCAT =
* IT_EXCEPT_QINFO =
* I_HTML_HEIGHT_TOP =
* I_HTML_HEIGHT_END =
* IMPORTING
* E_EXIT_CAUSED_BY_CALLER =
* ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB = T_OUTPUT
* 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. " SUB_DISP_REP
form SUB_FIELD_DEF using P_chk TYPE char1
P_COL TYPE CHAR2
P_NAME TYPE CHAR10
P_TEXT TYPE CHAR40
P_SUM TYPE CHAR1
P_EDIT TYPE CHAR1
P_OUT TYPE CHAR1.
W_FCAT-checkbox = 'X'.
W_FCAT-COL_POS = P_COL .
W_FCAT-FIELDNAME = P_NAME .
W_FCAT-SELTEXT_M = P_TEXT .
W_FCAT-DO_SUM = P_SUM .
W_FCAT-EDIT = P_EDIT .
W_FCAT-NO_OUT = P_OUT .
APPEND W_FCAT TO T_FCAT .
CLEAR W_FCAT .
endform. " SUB_FIELD_DEF
01-07-2009 10:04 AM
it shud be like dis...
in ur T_OUTPUT u shud enter one more field as first
FORM SUB_DISP_REP .
PERFORM SUB_FIELD_DEF USING :
'X' '1' 'CHECK' 'Checkbox' '' 'X' '',
' ' '2' 'PERNR' 'Personnel Number' ' ' ' ' ' ' ,
' ' '3' 'STAT2' 'Employee Status' '' '' '' ,
' ' '4' 'STELL' 'Job Title' '' '' '' ,
' ' '5' 'VORNA' 'First Name' '' '' '' ,
' ' '5' 'NACHN' 'Last Name' '' '' '' ,
' ' '6' 'KTART' 'Absence Quota Type' '' '' '' ,
' ' '7' 'ANZHL' 'Number of Employee Time Quota' '' '' '' ,
' ' '8' 'KVERB' 'Deduction of Employee Time Quota' '' '' '' ,
' ' '9' 'QUONR' 'Counter for time quotas' '' '' '' ,
' ' '10' 'DESTA' 'Start Date for Quota Deduction' '' '' '' ,
' ' '11' 'DEEND' 'Quota Deduction to' '' '' '' .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
* I_INTERFACE_CHECK = ' '
* I_BYPASSING_BUFFER = ' '
* I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = SY-CPROG
* I_CALLBACK_PF_STATUS_SET = ' '
* I_CALLBACK_USER_COMMAND = ' '
I_CALLBACK_TOP_OF_PAGE = 'X'
* I_CALLBACK_HTML_TOP_OF_PAGE = ' '
* I_CALLBACK_HTML_END_OF_LIST = ' '
* I_STRUCTURE_NAME =
I_BACKGROUND_ID = 'TRVPICTURE08'
I_GRID_TITLE = 'EMPLOYEE ABSENCE QUOTA'
* I_GRID_SETTINGS =
* IS_LAYOUT =
IT_FIELDCAT = T_FCAT
* IT_EXCLUDING =
* IT_SPECIAL_GROUPS =
IT_SORT = T_SUBTOT
* 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_HYPERLINK =
* IT_ADD_FIELDCAT =
* IT_EXCEPT_QINFO =
* I_HTML_HEIGHT_TOP =
* I_HTML_HEIGHT_END =
* IMPORTING
* E_EXIT_CAUSED_BY_CALLER =
* ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB = T_OUTPUT
* 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. " SUB_DISP_REP
form SUB_FIELD_DEF using P_chk TYPE char1
P_COL TYPE CHAR2
P_NAME TYPE CHAR10
P_TEXT TYPE CHAR40
P_SUM TYPE CHAR1
P_EDIT TYPE CHAR1
P_OUT TYPE CHAR1.
W_FCAT-checkbox = p_chk.
W_FCAT-COL_POS = P_COL .
W_FCAT-FIELDNAME = P_NAME .
W_FCAT-SELTEXT_M = P_TEXT .
W_FCAT-DO_SUM = P_SUM .
W_FCAT-EDIT = P_EDIT .
W_FCAT-NO_OUT = P_OUT .
APPEND W_FCAT TO T_FCAT .
CLEAR W_FCAT .
endform. " SUB_FIELD_DEF
Code Formatted by: Alvaro Tejada Galindo on Jan 7, 2009 12:44 PM
01-07-2009 8:57 AM
hi,
declare check box in your final table for alv display
types: chb type char1,
and then
CLEAR ls_fcat.
ls_fcat-fieldname = 'CHB'.
ls_fcat-CHECKBOX = 'X'.
ls_fcat-EDIT = 'X'.
ls_fcat-outputlen = 2.
APPEND ls_fcat TO lt_fct1.
thanks
Code Formatted by: Alvaro Tejada Galindo on Jan 7, 2009 12:46 PM
01-07-2009 9:38 AM
hi,
You want to have one field for Check Box and declare this as char.
Like
data: l_chkbox type c.
CLEAR ls_fcat.
ls_fieldcat-fieldname = 'L_CHKBOX'.
ls_fieldcat-checkbox = 'X'.
ls_fieldcat-edit = 'X'.
ls_fieldcat-outputlen = 2.
APPEND ls_fieldcat TO ps_fieldcat.
Regards,
Joan
Code Formatted by: Alvaro Tejada Galindo on Jan 7, 2009 12:46 PM
09-11-2009 4:55 PM