How to get subtotal value in ALV list display
Hi all,
How to give condition on the value of subtotal line in ALV list display,
i.e.if value of subtotal of plan quantity = actual quantity (in red oval) it should show the message
'ON TIME DELIVERY' else it should not show messagee.In my case(shown in red oval) its
showing for each subtotal value. I know how to change the subtotal text but i want to change
with respect to value of the subtotal.(plz refer attachment)
Any input regard to this will be achieved great.
Many thanks in advance.
samadhan shinde.
Hi Samadhan,
I am awaiting for solution for this problem.....but as i think dynamically displaying sub total based on
matching actual quantity and planned quantity is bit complicated.
My idea is to display matched quantities in one block and unmatched quantities in another. I mean using blocked list.
awaiting suggestions.
regards,
Similar Messages
-
How to get actual value from LOV list
Like Subject says: How to get actual value from LOV list. Any help will be appreciated.
Thanks.Thanks Shay, I did it with bind variable because I'm not using JSF. Is there any chance to post solution using standard JSTL or HTML expression. I have something like this: LOV displays some Companies names:
<html:select property="UserJobCompanyId"
disabled="${!bindings[\'UserJobCompanyId\'].updateable}"
onchange="submitform();">
<html:optionsCollection label="prompt" value="index" property="UserJobCompanyId.displayData"/>
</html:select>and I want to get CompanyID of selected Company.
Thanks, again. -
How to get multiple values from the list
I've a list of an item which I queried it from the database. I also created a button that will takes a selected items from the list when it was clicked. I used javabean to get the data from database.
<% // clicked on Select District Button
Vector vselectedDistrict = new Vector();
Vector vdistrictID = new Vector();
String tmpSelectDistrict = "";
tmpSelectDistrict = request.getParameter("bSelectDistrict");
if(tmpSelectDistrict != null)
// get multiple values from the list
String[] selectedDistrict = request.getParameterValues("usrTDistrict");
vselectedDistrict.clear();
vdistrictID.clear();
if((selectedDistrict != null) && (selectedDistrict.length != 0))
for(int i=0;i<selectedDistrict.length;i++)
vselectedDistrict.addElement(selectedDistrict);
vdistrictID = dbaseInfo.getcurrentDistrictID(nstate,vselectedDistrict);
for(int i=0;i<vdistrictID.size();i++)
out.println("district = " + selectedDistrict[i]); out.println("district ID= " + vdistrictID.get(i).toString());
%>
// get vdistrict from the database here......
<select name="usrTDistrict" size="5" multiple>
<% for(int i = 0; i< vdistrict.size(); i++)
%>
<option value="<%=vdistrict.get(i).toString()%>"><%=vdistrict.get(i).toString()%></option>
<%
%>
</select>
<input type="submit" name="bSelectDistrict" value="Select District">
Lets say the item that i selected from the list is 'Xplace' and I clicked on the Select District button,
what I got is this error message:
org.apache.jasper.JasperException: Unable to convert string 'Xplace' to class java.util.Vector for attribute usrTDistrict: java.lang.IllegalArgumentException: Property Editor not registered with the PropertyEditorManager
So where is going wrong and what the message means?. Any help very much appreciated. ThanksThese are just guesses that might hopefully steer you in directions you haven't looked in yet.
I presume you used triangle brackets (< >) to avoid having the Jive Forum think it was the "italics" tag?
Are you certain this: dbaseInfo.getcurrentDistrictID(nstate,vselectedDistrict);
expects a Vector as its second parameter? And returns a Vector?
I don't believe you've shown how you use the javabean, or its code? Perhaps it should be rewritten to accept an array of strings instead of a Vector? -
How to edit particular field in alv list display-urgent
HI ALL,
my requirement is i am displaying output using alv list display. now my rewuirement :
i am displaying out in edit mode only. when user clicks one particular field
for example record is like
runrate a01 maheed -> if user clicks on a01 this field should be editable. i have a following code
w_field-edit = w_edit.
w_field-input = 'X'. -> using this code i can able to display entire colomn in edit mode. this not suits my requirement.anybody can send me the sample code please.
thanks,
maheedhar.tCan you please send me the sample code plz.
i am sending my code below.
type-pools : slis.
tables : zuser_secobjects.
data : t_header1 like zuser_secobjects.
data : begin of it_secobjects occurs 0.
include structure t_header1.
data : checkbox type c value 'X',
action type c,
end of it_secobjects.
data : begin of it_secobjects1 occurs 0.
include structure ZUSER_SECOBJECTS.
data : checkbox type c VALUE 'X',
end of it_secobjects1.
data : wa_ita like line of it_secobjects.
data : i_field type slis_t_fieldcat_alv with header line.
data : w_field like line of i_field.
data : i_sort type slis_t_sortinfo_alv.
data : w_sort like line of i_sort.
data : it_filt1 type slis_t_filter_alv with header line.
data:
i_tabname type tabname,
i_repid like sy-repid,
is_lout type slis_layout_alv.
data : it_filt type slis_t_filter_alv with header line,
it_evts type slis_t_event with header line.
DATA : is_vari type disvariant.
constants : c_default_vari value 'X',
c_save_vari value 'U',
c_checkfield type slis_fieldname value 'ACTION',
c_f2code type sy-ucomm value '&ETA'.
data : chk_box type slis_fieldname.
selection-screen: begin of block b1 with frame title text-t01.
parameters : p_appln type zuser_secobjects-appln.
parameters : p_user type usr02-bname, "zuser_secobjects-appln_user,
p_partnr type zuser_secobjects-appln_partner,
p_ptype type zuser_secobjects-partner_type default '02',
p_upostn type zuser_secobjects-user_position,
p_sdate like likp-erdat default sy-datum,
p_edate(10) default '12/31/9999',
p_revnum type zuser_secobjects-revnum,
p_cted type zuser_secobjects-created_by,
p_cdate type zuser_secobjects-creation_date,
p_ctime type zuser_secobjects-creation_time,
p_chnby type zuser_secobjects-changed_by,
p_cdate1 type zuser_secobjects-changed_date,
p_ctime1 type zuser_secobjects-changed_time.
selection-screen: end of block b1.
form user_command using p_ucomm like sy-ucomm
rs_selfield type slis_selfield.
case p_ucomm.
when 'SELECT_ALL'. " SELALL is the FCODE of ur push button
loop at it_secobjects into wa_ita.
wa_ita-checkbox = 'X'.
modify it_secobjects from wa_ita.
endloop.
rs_selfield-refresh = 'X'. "<- ADD THIS
when 'DESLCT_ALL'.
loop at it_secobjects into wa_ita.
wa_ita-checkbox = ' '.
modify it_secobjects from wa_ita.
endloop.
rs_selfield-refresh = 'X'. "<- ADD THIS
is_lout-f2code = c_f2code.
is_lout-box_fieldname = c_checkfield.
is_lout-get_selinfos = 'X'.
is_lout-detail_popup = 'X'.
is_lout-detail_initial_lines = 'X'.
maheed-start.
*when 'SAVE'.
*LOOP AT IT_SECOBJECTS WHERE CHECKBOX = 'X'.
MOVE-CORRESPONDING IT_SECOBJECTS TO IT_SECOBJECTS1.
APPEND IT_SECOBJECTS1.
CLEAR IT_SECOBJECTS1.
DELETE IT_SECOBJECTS.
*ENDLOOP.
*DELETE ZUSER_SECOBJECTS FROM TABLE IT_SECOBJECTS1.
WHEN 'DELETE'.
loop at it_SECOBJECTS where checkbox eq 'X'.
delete it_SECOBJECTS.
endloop.
*RS_SELFIELD-REFRESH = 'X'.
maheed-end.
maheed-start. apr 13
WHEN 'DELETE'.
loop at it_SECOBJECTS where checkbox eq 'X'.
MOVE-CORRESPONDING IT_SECOBJECTS TO IT_SECOBJECTS1.
APPEND IT_SECOBJECTS1.
delete it_SECOBJECTS.
endloop.
RS_SELFIELD-REFRESH = 'X'.
when 'SAVE'.
DELETE ZUSER_SECOBJECTS FROM TABLE IT_SECOBJECTS1.
commit work.
refresh :IT_SECOBJECTS1.
maheed-end. apr 13
*when 'SAVE'.
*LOOP AT IT_SECOBJECTS WHERE CHECKBOX = 'X'.
MOVE-CORRESPONDING IT_SECOBJECTS TO IT_SECOBJECTS1.
APPEND IT_SECOBJECTS1.
CLEAR IT_SECOBJECTS1.
DELETE IT_SECOBJECTS.
*ENDLOOP.
*DELETE ZUSER_SECOBJECTS FROM TABLE IT_SECOBJECTS1.
ENDCASE.
endform.
*& Form delete
form delete.
data : begin of is_secobjects occurs 0.
include structure zuser_secobjects.
data : checkbox type c.
data : end of is_secobjects.
is_secobjects-checkbox = 'X'.
modify is_secobjects
from it_secobjects
transporting checkbox
where checkbox = 'X'.
endform.
*& Form get_data
form get_data.
select * from zuser_secobjects
into table it_secobjects.
endform. " get_data
*& Form prepare_fieldcatalog
text
--> p1 text
<-- p2 text
form prepare_fieldcatalog." USING w_edit TYPE any.
data : w_edit type c.
clear w_edit.
clear: w_field,i_field.
refresh:i_field.
i_field-key = 'X'.
i_field-col_pos = 1.
i_field-ddictxt = 'S'.
i_field-seltext_s = '@11@'.
i_field-checkbox = 'X'.
i_field-input = 'X'.
i_field-fieldname = 'HEADER'.
i_field-outputlen = 0.
append i_field.
clear i_field.
w_field-fieldname = 'APPLN'.
w_field-tabname = 'IT_SECOBJECTS'.
w_field-seltext_l = text-m01.
w_field-outputlen = '10'.
w_field-EDIT = 'X'. "maheed
w_field-col_pos = 1.
append w_field to i_field.
clear w_field.
w_field-fieldname = 'APPLN_USER'.
w_field-tabname = 'IT_SECOBJECTS'.
w_field-just = 'C'.
w_field-seltext_l = text-m02.
w_field-outputlen = '7'.
w_field-col_pos = 2.
append w_field to i_field.
clear w_field.
w_field-fieldname = 'APPLN_PARTNER'.
w_field-tabname = 'IT_SECOBJECTS'.
w_field-just = 'C'.
w_field-seltext_l = text-m03.
w_field-edit = w_edit.
w_field-input = 'X'.
w_field-outputlen = '7'.
w_field-col_pos = 2.
append w_field to i_field.
clear w_field.
w_field-fieldname = 'INACTIVE'.
w_field-tabname = 'IT_SECOBJECTS'.
w_field-just = 'C'.
w_field-seltext_l = text-m02.
w_field-outputlen = '7'.
w_field-col_pos = 3.
append w_field to i_field.
clear w_field.
endform. " prepare_fieldcatalog
*& Form ALV_LIST_DISPLAY
text
--> p1 text
<-- p2 text
form alv_list_display.
DATA : LC_GLAY TYPE LVC_S_GLAY.
LC_GLAY-EDT_CLL_CB = 'X'.
i_repid = sy-repid.
is_lout-box_fieldname = 'CHECKBOX'.
it_filt-fieldname = 'ACTION'.
call function 'REUSE_ALV_LIST_DISPLAY'
exporting
i_callback_program = i_repid
i_callback_pf_status_set = 'PF_STATUS_SET'
i_callback_user_command = 'USER_COMMAND'
is_layout = is_lout
it_fieldcat = i_field[]
it_filter = it_filt[]
it_events = it_evts[]
i_default = c_default_vari
i_save = c_save_vari
is_variant = is_vari
tables
t_outtab = it_secobjects.
endform. " ALV_LIST_DISPLAY
*& Form display
text
-->P_I_OBJECT text
form display using object.
case object.
ENDCASE.
endform. " display
thanks,
maheedhar.t -
How to read green light from ALV list display during BDC
Hi,
I am currently writing a BDC on CK11 transaction, after the user enters all the data he has to check log for any errors. The log is shown using ALV LIST DISPLAY and the errors are identified by RED lights on ALV LIST DISPLAY. At this point in BDC i have to either save or exit depending the status lights shown on the screen.
Does anybody has any idea on how to read these lights from the screen ?
thanks
UdaiHi,
I agree with Rich here. Never seen this done before (and I'm pretty sure you can't do it), but if someone has a funky way of doing it please share!
Cheers,
Pat. -
How to edit particular field in alv list display
hi,
i am displaying output using alv list display. my as follows.
runrate maheed a01.
here if i click a01 it has to show iin edit mode earlier it has to show display mode only. when i select by that time it has to show edit mode there i will change into a02 and i will click save button this is my requirement.
anybody can send me the sample code please.
thanks,
maheedhar.tfollowing is my field cata log
w_field-fieldname = 'APPLN'.
w_field-tabname = 'IT_SECOBJECTS'.
w_field-seltext_l = text-m01.
w_field-outputlen = '10'.
w_field-col_pos = 1.
append w_field to i_field.
clear w_field.
now i am writng like this
w_field-fieldname = 'APPLN'.
w_field-tabname = 'IT_SECOBJECTS'.
w_field-seltext_l = text-m01.
w_field-EDIT = 'X'. "maheed
w_field-outputlen = '10'.
w_field-col_pos = 1.
append w_field to i_field.
clear w_field.
eventhough it is not allowing me to edit the field when i click that field in the output.
thanks,
maheedhar.t -
How to get the value from select list to text box
Hi,
I have a select list i want to retrieve the value from select list to text box.
How can i do that???
Regards,
Sakthi.Hi Sakthi,
Yo can use the Java script for that..
Dynamically the value will come into text box.
Use the below script.
<script type="text/javascript">
function disFormItems()
var lReturn = $v(here your select list name)
alert(lReturn);
document.getElementById(here your text box name).value =lReturn; }
</script>Cheers,
Shan -
How to get sub totals in alv list
Hi all,
i have a data in internal table which need to display by alv lis display, but i need to display
sub totals, like sub total by customer, subtotal by state, and complete total amount. In alv we have standard function
buttons , by i need by default it is displayed when i exe my report, hope to achieve that.
Please help me to know.
thanks,
rajeshhi Rajesh,
Check these threads out
http://www.sap-basis-abap.com/sapalv.htm
http://help.sap.com/saphelp_nw04/helpdata/en/ee/b99d37e188a049e10000009b38f8cf/content.htm
http://www.sapfans.com/forums/viewtopic.php?t=20386
http://www.sapfans.com/forums/viewtopic.php?t=85191
http://www.sapfans.com/forums/viewtopic.php?t=88401
http://www.sapfans.com/forums/viewtopic.php?t=17335
DATA SORTING AND SUBTOTAL
DATA: GS_SORT TYPE SLIS_SORTINFO_ALV.
CLEAR GS_SORT.
GS_SORT-FIELDNAME = 'FIELD1'.
GS_SORT-SPOS = 1.
GS_SORT-UP = 'X'.
<b>GS_SORT-SUBTOT = 'X'.</b>
APPEND GS_SORT TO GT_SORT.
CLEAR GS_SORT.
GS_SORT-FIELDNAME = 'FIELD2'.
GS_SORT-SPOS = 2.
GS_SORT-UP = 'X'.
*GS_SORT-SUBTOT = 'X'.
APPEND GS_SORT TO GT_SORT.
Regards,
Santosh -
How to delete particular row in ALV list display
Hi All,
My requirement is :
I am displaying ouput using lav list dispplay befor the first colomn i am displaying check box. i defined my own pf status here . in pf status i have 3 buttons .
1 select all
2 deselect all
3 delete.
First two options are working fine when i click select all it is selecting all the rown in a program(selectiong all the check boxex) like working fine for deselecting all.
3 optioin Delete when i click delete option it has to delete partcular row in a list display and at the same time this entry should delete from the table. this is my requirement. for the third point(delete) option i dont have any logic. anybody can suggest me or send me the sameple code. i am sending my code below.if possible please modify the code and resend it to me.
type-pools : slis.
tables : zuser_secobjects.
data : t_header1 like zuser_secobjects.
data : begin of it_secobjects occurs 0.
include structure t_header1.
*data : box,
input(1) type c,
data : checkbox type c,
flag type c,
end of it_secobjects.
data : wa_ita like line of it_secobjects.
*data : it_secobjects like zuser_secobjects occurs 0 with header line.
data : i_field type slis_t_fieldcat_alv with header line.
data : w_field like line of i_field.
data : i_sort type slis_t_sortinfo_alv.
data : w_sort like line of i_sort.
data : it_filt1 type slis_t_filter_alv with header line.
data:
i_tabname type tabname,
i_repid like sy-repid,
is_lout type slis_layout_alv.
data : it_filt type slis_t_filter_alv with header line,
it_evts type slis_t_event with header line.
DATA : is_vari type disvariant.
constants : c_default_vari value 'X',
c_save_vari value 'U',
c_checkfield type slis_fieldname value 'ACTION',
c_f2code type sy-ucomm value '&ETA'.
data : chk_box type slis_fieldname.
selection-screen: begin of block b1 with frame title text-t01.
parameters : p_appln type zuser_secobjects-appln.
parameters : p_user type usr02-bname, "zuser_secobjects-appln_user,
p_partnr type zuser_secobjects-appln_partner,
p_ptype type zuser_secobjects-partner_type default '02',
p_upostn type zuser_secobjects-user_position,
p_sdate like likp-erdat default sy-datum,
p_edate(10) default '12/31/9999',
p_revnum type zuser_secobjects-revnum,
p_cted type zuser_secobjects-created_by,
p_cdate type zuser_secobjects-creation_date,
p_ctime type zuser_secobjects-creation_time,
p_chnby type zuser_secobjects-changed_by,
p_cdate1 type zuser_secobjects-changed_date,
p_ctime1 type zuser_secobjects-changed_time.
selection-screen: end of block b1.
form user_command using p_ucomm like sy-ucomm
rs_selfield type slis_selfield.
*DATA : it_filt type slis_t_filter_alv with header line.
case p_ucomm.
when 'SELECT_ALL'. " SELALL is the FCODE of ur push button
loop at it_secobjects into wa_ita.
wa_ita-checkbox = 'X'.
modify it_secobjects from wa_ita.
endloop.
rs_selfield-refresh = 'X'. "<- ADD THIS
when 'DESLCT_ALL'.
loop at it_secobjects into wa_ita.
wa_ita-checkbox = ' '.
modify it_secobjects from wa_ita.
endloop.
rs_selfield-refresh = 'X'. "<- ADD THIS
is_lout-f2code = c_f2code.
is_lout-box_fieldname = c_checkfield.
is_lout-get_selinfos = 'X'.
is_lout-detail_popup = 'X'.
is_lout-detail_initial_lines = 'X'.
when 'HIDE_DEL'.
rs_selfield-exit = 'X'.
it_filt-fieldname = 'ACTION'.
it_filt-tabname = '1'.
it_filt-valuf = 'X'.
it_filt-intlen = '1'.
it_filt-inttype = 'C'.
it_filt-datatype = 'CHAR'.
it_filt-valuf_int = 'X'.
it_filt-sign0 = 'E'.
it_filt-optio = 'EQ'.
if it_filt[] is initial.
append it_filt.
else.
modify it_filt index 1.
endif.
perform display using i_object.
PERForm ALV_LIST_DISPLAY.
WHEN 'SHOW_DEL'.
rs_selfield-exit = 'X'.
free it_filt.
PERForm ALV_LIST_DISPLAY.
when 'SAVE1'.
select * from zuser_secobjects where
appln = zuser_secobjects-appln
and appln_partner = zuser_secobjects-appln_partner
and partner_type = zuser_secobjects-partner_type
and start_date = zuser_secobjects-start_date
and end_date = zuser_secobjects-end_date.
endselect.
if sy-subrc eq 0.
message e000(ZV) with 'Duplicate Entry'.
endif.
endcase.
endform.
*& Form delete
form delete.
data : begin of is_secobjects occurs 0.
include structure zuser_secobjects.
data : checkbox type c.
data : end of is_secobjects.
is_secobjects-checkbox = 'X'.
modify is_secobjects
from it_secobjects
transporting checkbox
where checkbox = 'X'.
endform.
*& Form get_data
form get_data.
select * from zuser_secobjects
into table it_secobjects.
endform. " get_data
*& Form prepare_fieldcatalog
text
--> p1 text
<-- p2 text
form prepare_fieldcatalog.
clear: w_field,i_field.
refresh:i_field.
i_field-key = 'X'.
i_field-col_pos = 1.
i_field-ddictxt = 'S'.
i_field-seltext_s = '@11@'.
i_field-checkbox = 'X'.
i_field-input = 'X'.
i_field-fieldname = 'HEADER'.
i_field-outputlen = 0.
append i_field.
clear i_field.
w_field-fieldname = 'APPLN'.
w_field-tabname = 'IT_SECOBJECTS'.
w_field-seltext_l = text-m01.
w_field-outputlen = '10'.
w_field-col_pos = 1.
append w_field to i_field.
clear w_field.
w_field-fieldname = 'APPLN_USER'.
w_field-tabname = 'IT_SECOBJECTS'.
w_field-just = 'C'.
w_field-seltext_l = text-m02.
w_field-outputlen = '7'.
w_field-col_pos = 2.
append w_field to i_field.
clear w_field.
endform. " prepare_fieldcatalog
*& Form ALV_LIST_DISPLAY
text
--> p1 text
<-- p2 text
form alv_list_display.
i_repid = sy-repid.
is_lout-box_fieldname = 'CHECKBOX'.
it_filt-fieldname = 'ACTION'.
call function 'REUSE_ALV_LIST_DISPLAY'
exporting
i_callback_program = i_repid
i_callback_pf_status_set = 'PF_STATUS_SET'
i_callback_user_command = 'USER_COMMAND'
is_layout = is_lout
it_fieldcat = i_field[]
it_filter = it_filt[]
it_events = it_evts[]
i_default = c_default_vari
i_save = c_save_vari
is_variant = is_vari
tables
t_outtab = it_secobjects.
endform. " ALV_LIST_DISPLAY
*& Form display
text
-->P_I_OBJECT text
form display using object.
case object.
ENDCASE.
endform. " display
thanks,
maheedhar.tHI
In my program checkbox(before the record is displayed)
I used following lines to display checkbox .
i_field-key = 'X'.
i_field-col_pos = 1.
i_field-ddictxt = 'S'.
i_field-seltext_s = '@11@'.
i_field-checkbox = 'X'. <- Using this command i am getting checkbox
i_field-input = 'X'.
when i select this checkbox i press delete option then this entry will remove from internal table and refresh the screen and at the same time i will click on save button this ztable has to update according to that action.
this is my requirement.
thanks,
maheedhar. -
How to print check box in ALV list display and how to pick selected ones
Hi
i am displaying one ALV list dispaly. for that im adding one check box fields by filling the fieldcat as below:
wa_fldcat-checkbox = 'X'.
wa_fldcat-edit = 'X'.
but the check box is showing disable mode only. i want to display that check box and if i select that check box i want pick that records. for ALV grid i found one FM to pick records of selectedones as below.
DATA 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 ref_grid IS NOT INITIAL.
CALL METHOD ref_grid->check_changed_data.
ENDIF.
but how can i do for list display to pick those selected one records.
Can any one sugget regarding this.
Thanks in advance.
Rahul.Hi,
Thanks. now it's enabled. but how can we pick the records from that list whichever i selected through that check box.
i found this one for ALV grid:
DATA 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 ref_grid IS NOT INITIAL.
CALL METHOD ref_grid->check_changed_data.
ENDIF.
but how for ALV normal list display.
Thanks.
rahul -
How to get total value from checkbox list?
I have a list of checkbox items - all number values. I want to then get the total value from all of the check items and add that value to the database. Can this be done?
Also, anyone know of one source where I can get detailed information on how to best use Web Apps and all of it's possibilities and limitations? Most of the tutorials that I have seen so far say that you can do most anything with Web Apps; however, the tutorial examples leave a lot of questions unanswered. I saw that Adobe has an article that shows how to build a basic web app and that it is "part 1" in a series. Anyone know where to find parts 2, 3, etc?
Thanks,Hi there,
Good day, i hope this will give you some ideas
for example this is your html
<input type="checkbox" name="test" value="1">1
<input type="checkbox" name="test" value="2">2
<input type="checkbox" name="test" value="3">3
<input type="checkbox" name="test" value="4">4
and this is your jquery script
<script type="text/javascript">
jQuery("input@[name='test']").click(function() {
var istrue = jQuery(this).is(":checked");
if(istrue == true) {
var urvalue = jQuery(this).val();
alert(urvalue);
</script>
hope this helps you -
How to get distinct values from a list and display in a ListView webpart.
Hi,
I have a requirement in which I need to pull unique/distinct values from a custom list and then display it via a listview webpart. Can any one suggest how this can be done.
If possible please share the CAMEL query to fetch distinct values from a custom list.
Thanks,
AnkitHi Ankit,
Is there any particular reason that the values need to be shown in a list view web part? Are you going to use that web part for filtering via web part connections?
I ask because the enterprise site collection features include the SharePoint List Filter web part, which may accomplish what you're looking for.
If you just need to display the values in a grid view, you might have more luck with the JavaScript Client Object Model. Try putting the following in a text file:
<style>
.CustomTableClass{display:table;table-layout:fixed}
.CustomRowClass{display:table-row;}
</style>
<div id="distinct_values_div" class="CustomTableClass">
<img src="/_layouts/loading.gif" />
</div>
<script language="JavaScript" type="text/JavaScript">
var siteUrl = '/sitecollection/web'; //use the actual subsite URL here
var listName = 'mylist'; // use the actual list name here
var field = "Title" // use the actual field you want to display here
var divToUpdate = document.getElementById("distinct_values_div");
var rowClass = "CustomRowClass";
ExecuteOrDelayUntilScriptLoaded(function(){
var clientContext = new SP.ClientContext(siteUrl);
var web = clientContext.get_web();
var lists = web.get_lists();
var list = lists.getByTitle(listName);
var camlQuery = new SP.CamlQuery();
camlQuery.set_viewXml('<View><Query></Query><RowLimit>500</RowLimit></View>');
this.collListItem = list.getItems(camlQuery);
clientContext.load(collListItem,"Include ("+field+")");
clientContext.executeQueryAsync(
Function.createDelegate(this, this.onQuerySucceeded),
Function.createDelegate(this, this.onQueryFailed));
},"sp.js");
function onQueryFailed(sender, args){
divToUpdate.innerHTML = 'Unable to retrieve values: '+args.get_message());
function onQuerySucceeded(sender, args){
var allValues = [];
var listItemEnumerator = collListItem.getEnumerator();
divToUpdate.innerHTML = "";
while(listItemEnumerator.moveNext()){
var listItem = listItemEnumerator.get_current();
if(!containsString(allValues,listItem.get_item(field)){
var value = listItem.get_item(field);
allValues.push(value);
var newDiv = document.createElement("div");
newDiv.className = rowClass;
newDiv.innerHTML = value;
divToUpdate.appendChild(newDiv);
function containsString(strArray, text){
var contains = false;
for (var i=0; i<strArray.length; i++){
if(strArray[i]==text){contains = true; break;}
return contains;
</script>
Upload the text file to a library on the site, then add a content editor web part to a page where you want the distinct values to appear. In the content editor web part's properties, edit the Content Link so that it links directly to the text file. This
will cause the JavaScript to run on the page. -
How to get Date value from database and display them in a drop down list?
Hello.
In my Customers table, I have a column with Date data type. I want to create a form in JSP, where visitors can filter Customers list by year and month.
All I know is this piece of SQL that is convert the date to the dd-mm-yyyy format:
SELECT TO_CHAR(reg_date,'dd-mm-yyyy') from CustomersAny ideas of how this filtering possible? In my effort not to sound like a newbie wanting to be spoonfed, you can provide me link to external notes and resources, I'll really appreciate it.
Thanks,
Rightbrainer.Hi
What part is your biggest problem?? I am not experienced in getting data out of a database, but the way to get a variable amount of data to show in a drop down menu, i have just messed around with for some time and heres how i solved it... In my app, what i needed was, a initial empty drop down list, and then using input from a text-field, users could add elements to a Vector that was passed to a JComboBox. Heres how.
package jcombobox;
import java.awt.*;
import java.awt.event.*;
import java.util.Vector;
import javax.swing.*;
public class Main extends JApplet implements ActionListener {
private Vector<SomeClass> list = new Vector<SomeClass>();
private JComboBox dropDownList = new JComboBox(list);
private JButton addButton = new JButton("add");
private JButton remove = new JButton("remove");
private JTextField input = new JTextField(10);
private JPanel buttons = new JPanel();
public Main() {
addButton.addActionListener(this);
remove.addActionListener(this);
input.addActionListener(this);
buttons.setLayout(new FlowLayout());
buttons.add(addButton);
buttons.add(remove);
add(dropDownList, "North");
add(input, "Center");
add(buttons, "South");
public void actionPerformed(ActionEvent e) {
if (e.getSource() == addButton) {
list.addElement(new SomeClass(input.getText()));
input.setText("");
} else if (e.getSource() == remove) {
int selected = dropDownList.getSelectedIndex();
dropDownList.removeItemAt(selected);
public void init(String[] args) {
setSize(400,300);
getContentPane().setLayout(new BorderLayout());
getContentPane().add(new Main());
}And that "SomeClass" is show here
package jcombobox;
public class SomeClass {
private String text;
public SomeClass(String input) {
text = input;
public String toString() {
return text;
}One of the things i struggled a lot with was to get the dropdown menu to show some usefull result. If the list just contains class references it will show the memory code that points to that class. Thats where the toString cones in handy. But it took me some time to figure that one out, a laugh here is welcome as it should have been obvious :-)
When the app is as simple as this one, using a <String> vector would have been easier, but this is just to demonstrate how to place classes in a vector and get some usefull info out of it, hope this answered some of your question :-)
The layout might have been easier to write, than using the toppanel created by the JApplet and then the two additional JPanels, but it was just a small app brewed together in 15 minutes. Please comments on my faults, so that i can learn of it.
If you need any of the code specified more, please let me know. Ill be glad to, -
How to get Subtotal text in ALV using OOPS
hi,
Can any one pls help me out getting <b>subtotals text</b> in ALV using OOPS concepts....Pls provide me if any of u have sample code for that......
my code:
data:gr_grid_d0100 type ref to cl_gui_alv_grid.
data : gr_events_d0100 type ref to lcl_events_d0100.
classes**********
class lcl_events_d0100 definition.
public section.
methods:
subtotal_text for event subtotal_text
of cl_gui_alv_grid
importing es_subtottxt_info
ep_subtot_line
e_event_data.
endclass.
class lcl_events_d0100 implementation.
method subtotal_text.
perform d0100_event_subtotal_text using es_subtottxt_info
ep_subtot_line
e_event_data.
endmethod. "subtotal_text
endclass.
data : gr_event_handler type ref to lcl_events_d0100.
SET HANDLER gr_event_handler->subtotal_text FOR wcl_alv_grid_request
FORM d0100_event_subtotal_text USING
es_subtottxt_info TYPE LVC_S_STXT
ep_subtot_line TYPE REF TO data
e_event_data TYPE REF TO cl_alv_event_data.
DATA: l_text TYPE string.
l_text = es_subtottxt_info.
FIELD-SYMBOLS: <fs> TYPE ANY.
ASSIGN e_event_data->m_data->* TO <fs>.
<fs> = text-007.hi vijay
check this code
if you want to use field symbols.
data: total type ref to data,
subtotal1 type ref to data.
field-symbols <total> like gt_sflight.
field-symbols <subtotal1> like gt_sflight.
call method grid1->get_subtotals
importing
ep_collect00 = total
ep_collect01 = subtotal1.
assign total->* to <total>.
assign subtotal1->* to <subtotal1>.
or u can use
U have to do the subtotal column wise.In the field catalog specify the following in addition to the corresponding field name(i.e. Column)
DATA ls_fcat TYPE lvc_s_fcat.
ls_fcat-do_sum = 'X'.
Hope this helps u out.
Thanks & Regards,
naveen -
How to get checkboxes in dynamic ALV list generation
hi ,
below is the code in which two lists we wll be displayed in one layout dynamically(i.e after entering the table name two lists wll be displayed in one layout) from two different clients(i.e. source and target).
TYPE-POOLS *
TYPE-POOLS: slis.
*-- Tables Declaration
TABLES: dd02l, t000.
*-- Constants Declaration
CONSTANTS: lc_z TYPE char1 VALUE 'Z',
lc_y TYPE char1 VALUE 'Y'.
DATA: ok_code TYPE sy-ucomm.
*--Internal table and Work Area Declaration
DATA: lines LIKE sy-dbcnt VALUE 0.
DATA: icursor TYPE cursor.
*DATA: icursor1 TYPE cursor.
DATA: lv_count TYPE i.
DATA: lv_table_var1 TYPE char1.
DATA: lv_ans TYPE char1.
DATA : gd_tabname TYPE tabname.
*for check boxes
DATA:l_pos TYPE i VALUE 1.
*field catalog for source client
DATA: c_cont1 TYPE REF TO cl_gui_custom_container,
c_alv1 TYPE REF TO cl_gui_alv_grid,
it_fieldcat1 TYPE lvc_t_fcat ,
ty_fieldcat1 TYPE lvc_s_fcat ,
struc_desc1 TYPE REF TO cl_abap_structdescr,
ls_fieldcatalogue1 TYPE slis_fieldcat_alv,
lt_fieldcatalogue1 TYPE slis_t_fieldcat_alv,
l_structure1 TYPE REF TO data,
l_table1 TYPE REF TO data.
for check boxes for source client
DATA: ls_edit TYPE lvc_s_styl,
lt_edit TYPE lvc_t_styl.
*field catalog for target client
DATA: c_cont2 TYPE REF TO cl_gui_custom_container,
c_alv2 TYPE REF TO cl_gui_alv_grid,
it_fieldcat2 TYPE lvc_t_fcat ,
ty_fieldcat2 TYPE lvc_s_fcat ,
struc_desc2 TYPE REF TO cl_abap_structdescr,
ls_fieldcatalogue2 TYPE slis_fieldcat_alv,
lt_fieldcatalogue2 TYPE slis_t_fieldcat_alv,
l_structure2 TYPE REF TO data,
l_table2 TYPE REF TO data.
*for source client
TYPES: BEGIN OF itab,
t_name TYPE tabname,
t_ref TYPE REF TO data,
*for checkboxes.
check(1),
style TYPE lvc_t_styl,
END OF itab.
*for target client
TYPES: BEGIN OF itab1,
t_name1 TYPE tabname,
t_ref1 TYPE REF TO data,
END OF itab1.
*-- Field Symbol declaration for Dynamic Internal Table for source client
FIELD-SYMBOLS: <tab> TYPE table.
FIELD-SYMBOLS: <tab1> TYPE ANY.
FIELD-SYMBOLS: <l_mandt>.
FIELD-SYMBOLS: <str_comp1> TYPE abap_compdescr,
<dyn_str1> TYPE ANY.
*--Field Symbol declaration for Dynamic Internal Table for target client
FIELD-SYMBOLS <tab2> TYPE table.
FIELD-SYMBOLS <tab3> TYPE ANY.
FIELD-SYMBOLS: <l_mandt1>.
FIELD-SYMBOLS: <str_comp2> TYPE abap_compdescr,
<dyn_str2> TYPE ANY.
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME.
PARAMETERS: p_table LIKE dd02l-tabname,
p_mdt_fm LIKE t000-mandt DEFAULT sy-mandt,
p_mdt_to LIKE t000-mandt DEFAULT '910'.
SELECTION-SCREEN END OF BLOCK b1.
AT SELECTION-SCREEN ON p_table.
lv_table_var1 = p_table+0(1).
*-- Validation for Standard tables
IF ( lv_table_var1 NE lc_z ) AND ( lv_table_var1 NE lc_y ).
MESSAGE e001(00) WITH text-002.
ENDIF.
*-- Start of Selection
START-OF-SELECTION.
--for source client--
DATA itab2 TYPE itab.
DATA t_ref1 TYPE REF TO data.
itab2-t_name = p_table.
--for target client--
DATA itab3 TYPE itab1.
DATA t_ref2 TYPE REF TO data.
itab3-t_name1 = p_table.
*-- Create Dynamic Internal table for source client
CREATE DATA itab2-t_ref TYPE TABLE OF (itab2-t_name) .
ASSIGN itab2-t_ref->* TO <tab>.
CREATE DATA t_ref1 LIKE LINE OF <tab>.
ASSIGN t_ref1->* TO <tab1>.
*-- Create Dynamic Internal table for target client
CREATE DATA itab3-t_ref1 TYPE TABLE OF (itab3-t_name1) .
ASSIGN itab3-t_ref1->* TO <tab2>.
CREATE DATA t_ref2 LIKE LINE OF <tab2>.
ASSIGN t_ref2->* TO <tab3>.
*-- get the number of entries in table
SELECT COUNT(*) FROM dd03l INTO lv_count
WHERE tabname = p_table
AND fieldname = 'MANDT'.
Check MANDT field the the table, if not exists through an error message
IF lv_count = 0.
MESSAGE i000(8i) WITH text-001 space space.
EXIT.
ELSE.
*-- Delete the Table Entries in the target system
DELETE FROM (p_table) CLIENT SPECIFIED
WHERE mandt = p_mdt_to.
COMMIT WORK.
*-- Open cursor
OPEN CURSOR WITH HOLD icursor FOR
SELECT * FROM (p_table) CLIENT SPECIFIED
WHERE mandt = p_mdt_fm.
IF sy-subrc <> 0.
MESSAGE e000(8i) WITH text-001.
ENDIF.
DO.
FETCH NEXT CURSOR icursor INTO TABLE <tab> PACKAGE SIZE 1000.
IF sy-subrc <> 0.
CLOSE CURSOR icursor.
EXIT.
ENDIF.
*-- Modify Field 'MANDT' with the Target Client no.
LOOP AT <tab> ASSIGNING <tab1>.
ASSIGN COMPONENT: 'MANDT' OF STRUCTURE <tab1> TO <l_mandt>.
<l_mandt> = p_mdt_to.
MODIFY <tab> FROM <tab1>.
lines = lines + 1.
ENDLOOP.
*-- Insert records into target table
INSERT (p_table) CLIENT SPECIFIED FROM TABLE <tab>.
*-- Close the cursor
CALL FUNCTION 'DB_COMMIT'.
ENDDO.
ENDIF.
for target client
*-- Open cursor
OPEN CURSOR WITH HOLD icursor FOR
SELECT * FROM (p_table) CLIENT SPECIFIED
WHERE mandt = p_mdt_to.
IF sy-subrc <> 0.
MESSAGE e000(8i) WITH text-001.
ENDIF.
DO.
FETCH NEXT CURSOR icursor INTO TABLE <tab2> PACKAGE SIZE 1000.
IF sy-subrc <> 0.
CLOSE CURSOR icursor.
EXIT.
ENDIF.
*-- Close the cursor
CALL FUNCTION 'DB_COMMIT'.
ENDDO.
ENDIF.
CALL SCREEN 3000.
*& Module STATUS_3000 OUTPUT
text
MODULE status_3000 OUTPUT.
SET PF-STATUS 'ZTESTMENU'.
SET TITLEBAR 'xxx'.
For Source client
IF c_alv1 IS INITIAL.
CREATE OBJECT c_cont1
EXPORTING
container_name = 'CONTAINER_SOURCE'.
IF sy-subrc = 0.
CREATE OBJECT c_alv1
EXPORTING
i_parent = c_cont1.
ENDIF.
IF sy-subrc EQ 0.
PERFORM field_cat1.
ENDIF.
CALL METHOD c_alv1->set_table_for_first_display
EXPORTING
i_buffer_active =
i_bypassing_buffer =
i_consistency_check =
i_structure_name =
is_variant =
i_save =
i_default = 'x'
is_layout =
is_print =
it_special_groups =
it_toolbar_excluding =
it_hyperlink =
it_alv_graphics =
it_except_qinfo =
ir_salv_adapter =
CHANGING
it_outtab = <tab>
it_fieldcatalog = it_fieldcat1
it_sort =
it_filter =
EXCEPTIONS
valid_parameter_combination = 1
program_error = 2
too_many_lines = 3
others = 4
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDIF.
For Target client
IF c_alv2 IS INITIAL.
CREATE OBJECT c_cont2
EXPORTING
container_name = 'CONTAINER_TARGET'.
IF sy-subrc = 0.
CREATE OBJECT c_alv2
EXPORTING
i_parent = c_cont2.
ENDIF.
IF sy-subrc EQ 0.
PERFORM field_cat2.
ENDIF.
CALL METHOD c_alv2->set_table_for_first_display
EXPORTING
i_buffer_active =
i_bypassing_buffer =
i_consistency_check =
i_structure_name =
is_variant =
i_save =
i_default = 'x'
is_layout =
is_print =
it_special_groups =
it_toolbar_excluding =
it_hyperlink =
it_alv_graphics =
it_except_qinfo =
ir_salv_adapter =
CHANGING
it_outtab = <tab2>
it_fieldcatalog = it_fieldcat2
it_sort =
it_filter =
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
others = 4
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDIF.
ENDMODULE. " STATUS_3000 OUTPUT
*& Module USER_COMMAND_3000 INPUT
text
MODULE user_command_3000 INPUT.
CASE ok_code.
WHEN 'BACK'.
LEAVE PROGRAM.
ENDCASE.
ENDMODULE. " USER_COMMAND_3000 INPUT
*& Form field_cat1
text
--> p1 text
<-- p2 text
FORM field_cat1 .
Dynamic creation of a structure
CREATE DATA l_structure1 TYPE (p_table).
ASSIGN l_structure1->* TO <dyn_str1>.
Fields Structure
struc_desc1 ?= cl_abap_typedescr=>describe_by_data( <dyn_str1> ).
LOOP AT struc_desc1->components ASSIGNING <str_comp1>.
Build Fieldcatalog
ty_fieldcat1-fieldname = <str_comp1>-name.
ty_fieldcat1-ref_table = p_table.
CLEAR: l_pos.
*l_pos = l_pos + 1.
*ty_fieldcat1-seltext = 'CHECK'.
*ty_fieldcat1-fieldname = 'CHECK'.
*ty_fieldcat1-tabname = 'ITAB'.
*ty_fieldcat1-col_pos = l_pos.
*ty_fieldcat1-checkbox = 'X'.
*ty_fieldcat1-edit = 'X'.
*ty_fieldcat1-outputlen = '5'.
APPEND ty_fieldcat1 TO it_fieldcat1.
Build Fieldcatalog
ls_fieldcatalogue1-fieldname = <str_comp1>-name.
ls_fieldcatalogue1-ref_tabname = p_table.
APPEND ls_fieldcatalogue1 TO lt_fieldcatalogue1.
ENDLOOP.
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
i_style_table =
it_fieldcatalog = it_fieldcat1
i_length_in_byte =
IMPORTING
ep_table = l_table1
e_style_fname =
EXCEPTIONS
generate_subpool_dir_full = 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.
ASSIGN l_table1->* TO <tab>.
Read data from the table selected.
SELECT * FROM (p_table)
CLIENT SPECIFIED
INTO CORRESPONDING FIELDS OF TABLE <tab>
WHERE mandt = p_mdt_fm.
ENDFORM. " field_cat1
*& Form field_cat2
text
--> p1 text
<-- p2 text
FORM field_cat2 .
CREATE DATA l_structure2 TYPE (p_table).
ASSIGN l_structure2->* TO <dyn_str2>.
Fields Structure
struc_desc2 ?= cl_abap_typedescr=>describe_by_data( <dyn_str2> ).
LOOP AT struc_desc2->components ASSIGNING <str_comp2>.
Build Fieldcatalog
ty_fieldcat2-fieldname = <str_comp2>-name.
ty_fieldcat2-ref_table = p_table.
APPEND ty_fieldcat2 TO it_fieldcat2.
Build Fieldcatalog
ls_fieldcatalogue2-fieldname = <str_comp2>-name.
ls_fieldcatalogue2-ref_tabname = p_table.
APPEND ls_fieldcatalogue2 TO lt_fieldcatalogue2.
ENDLOOP.
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
i_style_table =
it_fieldcatalog = it_fieldcat2
i_length_in_byte =
IMPORTING
ep_table = l_table2
e_style_fname =
EXCEPTIONS
generate_subpool_dir_full = 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.
ASSIGN l_table2->* TO <tab2>.
Read data from the table selected.
SELECT * FROM (p_table) CLIENT SPECIFIED
INTO CORRESPONDING FIELDS OF TABLE <tab2>
WHERE mandt = p_mdt_to.
ENDFORM. " field_cat2
*FOR THE ABOVE CODE I NEED CHECKBOXES IN THE FIRST LIST AND I HAVE TRIED MANY WAYS BUT I HAVENT GOT THE SOLUTION. SO, PLZ CAN U EXPLAIN BY MENTIONING THE PIECE OF CODE IN ABOVE CODE.
PLZ DO THE NEED FUL.
thanks in advance.hi ,
below is the code in which two lists we wll be displayed in one layout dynamically(i.e after entering the table name two lists wll be displayed in one layout) from two different clients(i.e. source and target).
TYPE-POOLS *
TYPE-POOLS: slis.
*-- Tables Declaration
TABLES: dd02l, t000.
*-- Constants Declaration
CONSTANTS: lc_z TYPE char1 VALUE 'Z',
lc_y TYPE char1 VALUE 'Y'.
DATA: ok_code TYPE sy-ucomm.
*--Internal table and Work Area Declaration
DATA: lines LIKE sy-dbcnt VALUE 0.
DATA: icursor TYPE cursor.
*DATA: icursor1 TYPE cursor.
DATA: lv_count TYPE i.
DATA: lv_table_var1 TYPE char1.
DATA: lv_ans TYPE char1.
DATA : gd_tabname TYPE tabname.
*for check boxes
DATA:l_pos TYPE i VALUE 1.
*field catalog for source client
DATA: c_cont1 TYPE REF TO cl_gui_custom_container,
c_alv1 TYPE REF TO cl_gui_alv_grid,
it_fieldcat1 TYPE lvc_t_fcat ,
ty_fieldcat1 TYPE lvc_s_fcat ,
struc_desc1 TYPE REF TO cl_abap_structdescr,
ls_fieldcatalogue1 TYPE slis_fieldcat_alv,
lt_fieldcatalogue1 TYPE slis_t_fieldcat_alv,
l_structure1 TYPE REF TO data,
l_table1 TYPE REF TO data.
for check boxes for source client
DATA: ls_edit TYPE lvc_s_styl,
lt_edit TYPE lvc_t_styl.
*field catalog for target client
DATA: c_cont2 TYPE REF TO cl_gui_custom_container,
c_alv2 TYPE REF TO cl_gui_alv_grid,
it_fieldcat2 TYPE lvc_t_fcat ,
ty_fieldcat2 TYPE lvc_s_fcat ,
struc_desc2 TYPE REF TO cl_abap_structdescr,
ls_fieldcatalogue2 TYPE slis_fieldcat_alv,
lt_fieldcatalogue2 TYPE slis_t_fieldcat_alv,
l_structure2 TYPE REF TO data,
l_table2 TYPE REF TO data.
*for source client
TYPES: BEGIN OF itab,
t_name TYPE tabname,
t_ref TYPE REF TO data,
*for checkboxes.
check(1),
style TYPE lvc_t_styl,
END OF itab.
*for target client
TYPES: BEGIN OF itab1,
t_name1 TYPE tabname,
t_ref1 TYPE REF TO data,
END OF itab1.
*-- Field Symbol declaration for Dynamic Internal Table for source client
FIELD-SYMBOLS: <tab> TYPE table.
FIELD-SYMBOLS: <tab1> TYPE ANY.
FIELD-SYMBOLS: <l_mandt>.
FIELD-SYMBOLS: <str_comp1> TYPE abap_compdescr,
<dyn_str1> TYPE ANY.
*--Field Symbol declaration for Dynamic Internal Table for target client
FIELD-SYMBOLS <tab2> TYPE table.
FIELD-SYMBOLS <tab3> TYPE ANY.
FIELD-SYMBOLS: <l_mandt1>.
FIELD-SYMBOLS: <str_comp2> TYPE abap_compdescr,
<dyn_str2> TYPE ANY.
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME.
PARAMETERS: p_table LIKE dd02l-tabname,
p_mdt_fm LIKE t000-mandt DEFAULT sy-mandt,
p_mdt_to LIKE t000-mandt DEFAULT '910'.
SELECTION-SCREEN END OF BLOCK b1.
AT SELECTION-SCREEN ON p_table.
lv_table_var1 = p_table+0(1).
*-- Validation for Standard tables
IF ( lv_table_var1 NE lc_z ) AND ( lv_table_var1 NE lc_y ).
MESSAGE e001(00) WITH text-002.
ENDIF.
*-- Start of Selection
START-OF-SELECTION.
--for source client--
DATA itab2 TYPE itab.
DATA t_ref1 TYPE REF TO data.
itab2-t_name = p_table.
--for target client--
DATA itab3 TYPE itab1.
DATA t_ref2 TYPE REF TO data.
itab3-t_name1 = p_table.
*-- Create Dynamic Internal table for source client
CREATE DATA itab2-t_ref TYPE TABLE OF (itab2-t_name) .
ASSIGN itab2-t_ref->* TO <tab>.
CREATE DATA t_ref1 LIKE LINE OF <tab>.
ASSIGN t_ref1->* TO <tab1>.
*-- Create Dynamic Internal table for target client
CREATE DATA itab3-t_ref1 TYPE TABLE OF (itab3-t_name1) .
ASSIGN itab3-t_ref1->* TO <tab2>.
CREATE DATA t_ref2 LIKE LINE OF <tab2>.
ASSIGN t_ref2->* TO <tab3>.
*-- get the number of entries in table
SELECT COUNT(*) FROM dd03l INTO lv_count
WHERE tabname = p_table
AND fieldname = 'MANDT'.
Check MANDT field the the table, if not exists through an error message
IF lv_count = 0.
MESSAGE i000(8i) WITH text-001 space space.
EXIT.
ELSE.
*-- Delete the Table Entries in the target system
DELETE FROM (p_table) CLIENT SPECIFIED
WHERE mandt = p_mdt_to.
COMMIT WORK.
*-- Open cursor
OPEN CURSOR WITH HOLD icursor FOR
SELECT * FROM (p_table) CLIENT SPECIFIED
WHERE mandt = p_mdt_fm.
IF sy-subrc <> 0.
MESSAGE e000(8i) WITH text-001.
ENDIF.
DO.
FETCH NEXT CURSOR icursor INTO TABLE <tab> PACKAGE SIZE 1000.
IF sy-subrc <> 0.
CLOSE CURSOR icursor.
EXIT.
ENDIF.
*-- Modify Field 'MANDT' with the Target Client no.
LOOP AT <tab> ASSIGNING <tab1>.
ASSIGN COMPONENT: 'MANDT' OF STRUCTURE <tab1> TO <l_mandt>.
<l_mandt> = p_mdt_to.
MODIFY <tab> FROM <tab1>.
lines = lines + 1.
ENDLOOP.
*-- Insert records into target table
INSERT (p_table) CLIENT SPECIFIED FROM TABLE <tab>.
*-- Close the cursor
CALL FUNCTION 'DB_COMMIT'.
ENDDO.
ENDIF.
for target client
*-- Open cursor
OPEN CURSOR WITH HOLD icursor FOR
SELECT * FROM (p_table) CLIENT SPECIFIED
WHERE mandt = p_mdt_to.
IF sy-subrc <> 0.
MESSAGE e000(8i) WITH text-001.
ENDIF.
DO.
FETCH NEXT CURSOR icursor INTO TABLE <tab2> PACKAGE SIZE 1000.
IF sy-subrc <> 0.
CLOSE CURSOR icursor.
EXIT.
ENDIF.
*-- Close the cursor
CALL FUNCTION 'DB_COMMIT'.
ENDDO.
ENDIF.
CALL SCREEN 3000.
*& Module STATUS_3000 OUTPUT
text
MODULE status_3000 OUTPUT.
SET PF-STATUS 'ZTESTMENU'.
SET TITLEBAR 'xxx'.
For Source client
IF c_alv1 IS INITIAL.
CREATE OBJECT c_cont1
EXPORTING
container_name = 'CONTAINER_SOURCE'.
IF sy-subrc = 0.
CREATE OBJECT c_alv1
EXPORTING
i_parent = c_cont1.
ENDIF.
IF sy-subrc EQ 0.
PERFORM field_cat1.
ENDIF.
CALL METHOD c_alv1->set_table_for_first_display
EXPORTING
i_buffer_active =
i_bypassing_buffer =
i_consistency_check =
i_structure_name =
is_variant =
i_save =
i_default = 'x'
is_layout =
is_print =
it_special_groups =
it_toolbar_excluding =
it_hyperlink =
it_alv_graphics =
it_except_qinfo =
ir_salv_adapter =
CHANGING
it_outtab = <tab>
it_fieldcatalog = it_fieldcat1
it_sort =
it_filter =
EXCEPTIONS
valid_parameter_combination = 1
program_error = 2
too_many_lines = 3
others = 4
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDIF.
For Target client
IF c_alv2 IS INITIAL.
CREATE OBJECT c_cont2
EXPORTING
container_name = 'CONTAINER_TARGET'.
IF sy-subrc = 0.
CREATE OBJECT c_alv2
EXPORTING
i_parent = c_cont2.
ENDIF.
IF sy-subrc EQ 0.
PERFORM field_cat2.
ENDIF.
CALL METHOD c_alv2->set_table_for_first_display
EXPORTING
i_buffer_active =
i_bypassing_buffer =
i_consistency_check =
i_structure_name =
is_variant =
i_save =
i_default = 'x'
is_layout =
is_print =
it_special_groups =
it_toolbar_excluding =
it_hyperlink =
it_alv_graphics =
it_except_qinfo =
ir_salv_adapter =
CHANGING
it_outtab = <tab2>
it_fieldcatalog = it_fieldcat2
it_sort =
it_filter =
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
others = 4
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDIF.
ENDMODULE. " STATUS_3000 OUTPUT
*& Module USER_COMMAND_3000 INPUT
text
MODULE user_command_3000 INPUT.
CASE ok_code.
WHEN 'BACK'.
LEAVE PROGRAM.
ENDCASE.
ENDMODULE. " USER_COMMAND_3000 INPUT
*& Form field_cat1
text
--> p1 text
<-- p2 text
FORM field_cat1 .
Dynamic creation of a structure
CREATE DATA l_structure1 TYPE (p_table).
ASSIGN l_structure1->* TO <dyn_str1>.
Fields Structure
struc_desc1 ?= cl_abap_typedescr=>describe_by_data( <dyn_str1> ).
LOOP AT struc_desc1->components ASSIGNING <str_comp1>.
Build Fieldcatalog
ty_fieldcat1-fieldname = <str_comp1>-name.
ty_fieldcat1-ref_table = p_table.
CLEAR: l_pos.
*l_pos = l_pos + 1.
*ty_fieldcat1-seltext = 'CHECK'.
*ty_fieldcat1-fieldname = 'CHECK'.
*ty_fieldcat1-tabname = 'ITAB'.
*ty_fieldcat1-col_pos = l_pos.
*ty_fieldcat1-checkbox = 'X'.
*ty_fieldcat1-edit = 'X'.
*ty_fieldcat1-outputlen = '5'.
APPEND ty_fieldcat1 TO it_fieldcat1.
Build Fieldcatalog
ls_fieldcatalogue1-fieldname = <str_comp1>-name.
ls_fieldcatalogue1-ref_tabname = p_table.
APPEND ls_fieldcatalogue1 TO lt_fieldcatalogue1.
ENDLOOP.
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
i_style_table =
it_fieldcatalog = it_fieldcat1
i_length_in_byte =
IMPORTING
ep_table = l_table1
e_style_fname =
EXCEPTIONS
generate_subpool_dir_full = 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.
ASSIGN l_table1->* TO <tab>.
Read data from the table selected.
SELECT * FROM (p_table)
CLIENT SPECIFIED
INTO CORRESPONDING FIELDS OF TABLE <tab>
WHERE mandt = p_mdt_fm.
ENDFORM. " field_cat1
*& Form field_cat2
text
--> p1 text
<-- p2 text
FORM field_cat2 .
CREATE DATA l_structure2 TYPE (p_table).
ASSIGN l_structure2->* TO <dyn_str2>.
Fields Structure
struc_desc2 ?= cl_abap_typedescr=>describe_by_data( <dyn_str2> ).
LOOP AT struc_desc2->components ASSIGNING <str_comp2>.
Build Fieldcatalog
ty_fieldcat2-fieldname = <str_comp2>-name.
ty_fieldcat2-ref_table = p_table.
APPEND ty_fieldcat2 TO it_fieldcat2.
Build Fieldcatalog
ls_fieldcatalogue2-fieldname = <str_comp2>-name.
ls_fieldcatalogue2-ref_tabname = p_table.
APPEND ls_fieldcatalogue2 TO lt_fieldcatalogue2.
ENDLOOP.
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
i_style_table =
it_fieldcatalog = it_fieldcat2
i_length_in_byte =
IMPORTING
ep_table = l_table2
e_style_fname =
EXCEPTIONS
generate_subpool_dir_full = 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.
ASSIGN l_table2->* TO <tab2>.
Read data from the table selected.
SELECT * FROM (p_table) CLIENT SPECIFIED
INTO CORRESPONDING FIELDS OF TABLE <tab2>
WHERE mandt = p_mdt_to.
ENDFORM. " field_cat2
*FOR THE ABOVE CODE I NEED CHECKBOXES IN THE FIRST LIST AND I HAVE TRIED MANY WAYS BUT I HAVENT GOT THE SOLUTION. SO, PLZ CAN U EXPLAIN BY MENTIONING THE PIECE OF CODE IN ABOVE CODE.
PLZ DO THE NEED FUL.
thanks in advance.
Maybe you are looking for
-
I have a brand new macbook with microsoft office loaded. I set outlook as the default mail. i would rather go back to mac mail but can't figure out how to do it. any ideas? Thanks for any help Lou
-
I installed ios 7.0.2 on my i-pads and now want to delete the pass code, which I originally put in. I no longer want the hassle of the pass code, but cannot figure out how to delete it. I do not want the additional security.
-
Is it possible to Load External SWF files into Flex Mobile projects?
Hi Guys, I'm trying to load an external asset in this cse (a SWF file) into my flex project (Apple IOS IPAD), don't get any luck. Can any one suggest a solution ?
-
EHP5 Stack File is invalid: component 'EA-HR' (stack release 600 source .
Hi all . . . Attempting to install EHP5 on ERP ABAP stack. Currently on EHP4 SPS5. During the configuration roadmap step, the Stack configuration overview told me that "for the following components, a Component Upgrade/Installation and/or Support Pac
-
Different layout and wallpaper on start up
Hi, I'm a self proclaimed moron so if this is a stupid question please be kind enough to point me in the right direct anyway, thanks. So, for the past week, every time I start up my Pavilion p7-1179c, a completely different wallpaper and layout are o