‎2008 Aug 28 10:14 AM
Hi all,
I am having a checkbox for each field in the internal table.
and i only have to display the fields of the internal table which the user has selected based on the check boxes provided.
Could you plz help me out, how can i display the data of only those fields which the user has selected initially.....
Thanks,
anil.
‎2008 Aug 28 10:16 AM
hi anil reddy
Consider Your Internal table is ITAB and checkbox field is chk
Loop at itab where chk = 'X'.
Write "data"
Endloop.
Regards
Deva
‎2008 Aug 28 10:16 AM
Hi,
when you build your fieldcat, test the checkboxes and include only the fields your user has selected.
Regards
‎2008 Aug 28 10:19 AM
Try this way...
In ALV one can hide the fields based on condition.
while populating the field catalog check the condition which fields have been selected and in field catalog assignment check for condition...If condition fails hide the field...
‎2008 Aug 28 10:22 AM
Hi Dude,
We can do it using ALV. Please follow the below steps.
1.while creating Field catelog For the Fields,Use the Condition,
If Field1 = 'X'.
i_fcat-col_pos = 5.
i_fcat-fieldname = 'SPART'.
i_fcat-tabname = 'IT_VBAK'.
i_fcat-seltext_l = 'DIVISION'.
append i_fcat.
clear i_fcat.
Endif.
Hope This Helps U.
‎2008 Aug 28 10:26 AM
Hi Anil,
I didn't get your question. Checkboxes are on the output list or ALV?
‎2008 Aug 28 11:41 AM
Hi abijeet,
Actually i have to display the data of the internal table in the list not in ALV. and i have to display the data of only those
fields which the user has selected. For this i will provide a number of checkboxes based on the number of fields.
Lets assume in my internal table iam displaying KUNNR, LAND1, NAME1.
I will fetch data into these fields based on some select query.
and i will provide three check boxes for each of these fields.
If the user selects KUNNR check box i will display only that field data.
If the user selects KUNNR, and NAME1 checkboxes, i have to display these two fields data from the internal table.
And one more thing i should not use ALV here.
all the output should be in list itself.
Thanks,
Anil.
‎2008 Aug 28 11:52 AM
hi
Try this code
DO w_lines TIMES.
w_cu_line = sy-index + 4.
CLEAR: fs_spfli,
fs_sflight,
w_check.
READ LINE w_cu_line FIELD VALUE
w_check INTO w_check
fs_spfli-w_carrid INTO fs_spfli-w_carrid
fs_spfli-w_connid INTO fs_spfli-w_connid.
IF sy-subrc EQ 0.
IF w_check EQ 'X'.
Display the text here.Regerds
Sumit Agarwal
‎2008 Aug 28 12:09 PM
Hi Anil,
Try this logic
REPORT z_sdn.
PARAMETERS:
p_kunnr AS CHECKBOX DEFAULT 'X',
p_land1 AS CHECKBOX,
p_name1 AS CHECKBOX.
DATA:
BEGIN OF fs_tab,
kunnr TYPE kunnr,
land(10) TYPE c,
name(10) TYPE c,
END OF fs_tab.
DATA:
t_tab LIKE
TABLE OF
fs_tab.
START-OF-SELECTION.
CLEAR fs_tab.
fs_tab-kunnr = '001'.
fs_tab-land = 'Land1'.
fs_tab-name = 'Name1'.
APPEND fs_tab TO t_tab.
CLEAR fs_tab.
fs_tab-kunnr = '002'.
fs_tab-land = 'Land2'.
fs_tab-name = 'Name2'.
APPEND fs_tab TO t_tab.
IF p_kunnr = 'X'.
WRITE: / 'KUNNR:'.
LOOP AT t_tab INTO fs_tab.
WRITE: / fs_tab-kunnr.
ENDLOOP.
ENDIF.
IF p_land1 = 'X'.
WRITE: / 'LAND:'.
LOOP AT t_tab INTO fs_tab.
WRITE: / fs_tab-land.
ENDLOOP.
ENDIF.
IF p_name1 = 'X'.
WRITE: / 'NAME:'.
LOOP AT t_tab INTO fs_tab.
WRITE: / fs_tab-name.
ENDLOOP.
ENDIF.
Regards
Abhijeet
‎2008 Aug 28 12:19 PM
Hi Abhijeet,
Thanx for your reply.
This solution is diplaying data one after another.
But the data should be displayed as normal like
KUNNR LAND1 NAME1
10 IN x
20 CH Y
like it should display, but here it is displaying like
KUNNR
10
20
LAND1
IN
CH
like so....
Thanks,
Anil.
‎2008 Aug 28 12:21 PM
if its alv..
build the field catalouge for which the check box is selected.
if normal report..
just write it through "IF" Condition
Ex: if chk1 = 'X'.
alvfld-fieldname = 'MATNR'.
endif
‎2008 Aug 28 12:36 PM
Hi,
This is not the best solution but this can be one solution.
Check this code
REPORT z_sdn.
PARAMETERS:
p_kunnr AS CHECKBOX DEFAULT 'X',
p_land1 AS CHECKBOX,
p_name1 AS CHECKBOX.
DATA:
BEGIN OF fs_tab,
kunnr TYPE kunnr,
land(10) TYPE c,
name(10) TYPE c,
END OF fs_tab.
DATA:
t_tab LIKE
TABLE OF
fs_tab.
START-OF-SELECTION.
CLEAR fs_tab.
fs_tab-kunnr = '001'.
fs_tab-land = 'Land1'.
fs_tab-name = 'Name1'.
APPEND fs_tab TO t_tab.
CLEAR fs_tab.
fs_tab-kunnr = '002'.
fs_tab-land = 'Land2'.
fs_tab-name = 'Name2'.
APPEND fs_tab TO t_tab.
IF p_kunnr = 'X' AND p_land1 IS INITIAL AND p_name1 IS INITIAL.
WRITE: / 'KUNNR:'.
LOOP AT t_tab INTO fs_tab.
WRITE: / fs_tab-kunnr.
ENDLOOP.
ENDIF.
IF p_land1 = 'X' AND p_kunnr IS INITIAL AND p_name1 IS INITIAL.
WRITE: / 'LAND:'.
LOOP AT t_tab INTO fs_tab.
WRITE: / fs_tab-land.
ENDLOOP.
ENDIF.
IF p_name1 = 'X' AND p_kunnr IS INITIAL AND p_land1 IS INITIAL.
WRITE: / 'NAME:'.
LOOP AT t_tab INTO fs_tab.
WRITE: / fs_tab-name.
ENDLOOP.
ENDIF.
IF p_kunnr = 'X' AND p_land1 = 'X' AND p_name1 IS INITIAL.
WRITE: / 'KUNNR:',
'LAND'.
LOOP AT t_tab INTO fs_tab.
WRITE: / fs_tab-kunnr,
fs_tab-land.
ENDLOOP.
ENDIF.
IF p_kunnr = 'X' AND p_name1 = 'X' AND p_land1 IS INITIAL.
WRITE: / 'KUNNR:',
'NAME'.
LOOP AT t_tab INTO fs_tab.
WRITE: / fs_tab-kunnr,
fs_tab-name.
ENDLOOP.
ENDIF.
IF p_name1 = 'X' AND p_land1 = 'X' AND p_kunnr IS INITIAL.
WRITE: / 'LAND:',
'NAME:'.
LOOP AT t_tab INTO fs_tab.
WRITE: / fs_tab-land,
fs_tab-name.
ENDLOOP.
ENDIF.
IF p_name1 = 'X' AND p_land1 = 'X' AND p_kunnr = 'X'.
WRITE: / 'KUNNR',
'LAND:',
'NAME:'.
LOOP AT t_tab INTO fs_tab.
WRITE: / fs_tab-kunnr,
fs_tab-land,
fs_tab-name.
ENDLOOP.
ENDIF.
Regards
Abhijeet
‎2008 Aug 28 12:42 PM
Hi Abjijeet,
Thankyou for your replies.
It will work if there are limited fields to display.
but here i am having 9 fields to display. so , it will a bit tedious
to write IF conditions for all these fields.
thanks,
Anil.
‎2008 Aug 28 12:41 PM
Hello
PARAMETERS:
p_kunnr AS CHECKBOX,
p_land1 AS CHECKBOX,
p_name1 AS CHECKBOX.
DATA:
BEGIN OF itab,
kunnr like kna1-kunnr,
land1 like kna1-land1,
name1 like kna1-name1,
END OF itab.
loop at itab.
if p_kunnr = 'X'.
write: itab-kunnr.
endif.
if p_land1 = 'X'.
write: itab-land1.
endif.
if p_name1 = 'X'.
write: itab-name1.
endif.
new-line.
endloop.