‎2008 Dec 01 7:28 AM
‎2008 Dec 01 8:34 AM
REPORT ZTEST_DATABASE .
type-pools: slis.
*Table declaration
tables: vbak,vbap.
*internal table
data: begin of i_sales occurs 0,
vbeln like vbak-vbeln,
erdat like vbak-erdat,
audat like vbak-audat,
kunnr like vbak-kunnr,
vkorg like vbak-vkorg,
matnr like vbap-matnr,
netpr like vbap-netpr,
check type c, "checkbox
end of i_sales.
data: begin of i_final occurs 0,
vbeln like vbak-vbeln,
erdat like vbak-erdat,
audat like vbak-audat,
kunnr like vbak-kunnr,
vkorg like vbak-vkorg,
matnr like vbap-matnr,
netpr like vbap-netpr,
end of i_final.
data: v_fieldcat type slis_fieldcat_alv,
gt_fieldcat type slis_t_fieldcat_alv,
gt_layout type slis_layout_alv,
gt_sort type slis_sortinfo_alv,
fieldcat like line of gt_fieldcat.
*Selection screen
parameters: p_vkorg like vbak-vkorg.
select-options: s_vbeln for vbak-vbeln.
*start of selection.
start-of-selection.
perform get_data.
perform fill_fieldcatalog.
perform write_data.
*----
get data
*----
FORM get_data .
select a~vbeln
a~erdat
a~audat
a~kunnr
a~vkorg
b~matnr
b~netpr
into corresponding fields of table i_sales
from vbak as a inner join vbap as b on avbeln = bvbeln
where a~vkorg = p_vkorg
and a~vbeln in s_vbeln.
ENDFORM. " get_data
*----
write_data
*----
FORM write_data .
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = sy-repid
I_CALLBACK_PF_STATUS_SET = 'GUI_SET'
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
IS_LAYOUT = gt_layout
IT_FIELDCAT = gt_fieldcat
TABLES
T_OUTTAB = i_sales .
ENDFORM. " write_data
*----
fill catalog
*----
FORM fill_fieldcatalog .
sort i_sales by vbeln.
clear v_fieldcat.
*for check box
v_fieldcat-col_pos = 1.
v_fieldcat-fieldname = 'CHECK'.
v_fieldcat-seltext_m = 'chek'.
v_fieldcat-checkbox = 'X'.
v_fieldcat-input = 'X'.
v_fieldcat-edit = 'X'.
append v_fieldcat to gt_fieldcat.
clear v_fieldcat.
v_fieldcat-col_pos = 2.
v_fieldcat-fieldname = 'VBELN'.
v_fieldcat-seltext_m = 'Sales Document'.
append v_fieldcat to gt_fieldcat.
clear v_fieldcat.
v_fieldcat-col_pos = 3.
v_fieldcat-fieldname = 'ERDAT'.
v_fieldcat-seltext_m = 'Creation Date'.
append v_fieldcat to gt_fieldcat.
clear v_fieldcat.
v_fieldcat-col_pos = 4.
v_fieldcat-fieldname = 'AUDAT'.
v_fieldcat-seltext_m = 'Document Date'.
append v_fieldcat to gt_fieldcat.
clear v_fieldcat.
v_fieldcat-col_pos = 5.
v_fieldcat-fieldname = 'KUNNR'.
v_fieldcat-seltext_m = 'Customer'.
append v_fieldcat to gt_fieldcat.
clear v_fieldcat.
v_fieldcat-col_pos = 6.
v_fieldcat-fieldname = 'VKORG'.
v_fieldcat-seltext_m = 'Sales Organization'.
append v_fieldcat to gt_fieldcat.
clear v_fieldcat.
v_fieldcat-col_pos = 7.
v_fieldcat-fieldname = 'MATNR'.
v_fieldcat-seltext_m = 'Material'.
append v_fieldcat to gt_fieldcat.
clear v_fieldcat.
v_fieldcat-col_pos = 8.
v_fieldcat-fieldname = 'NETPR'.
v_fieldcat-seltext_m = 'Net Value'.
append v_fieldcat to gt_fieldcat.
clear v_fieldcat.
endform.
&----
*& Form GUI_SET
&----
FORM GUI_SET USING RT_EXTAB TYPE SLIS_T_EXTAB .
SET PF-STATUS 'GETDATA' .
ENDFORM. "GUI_SET
&----
*& Form USER_COMMAND
&----
FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
R_SELFIELD TYPE SLIS_SELFIELD.
CASE R_UCOMM.
WHEN 'DATA'.
CLEAR I_FINAL.
CLEAR I_SALES.
REFRESH I_FINAL.
LOOP AT i_sales .
if i_sales-check = 'X'.
i_final-vbeln = i_sales-vbeln.
i_final-erdat = i_sales-erdat.
i_final-audat = i_sales-audat.
i_final-kunnr = i_sales-kunnr.
i_final-vkorg = i_sales-vkorg.
i_final-matnr = i_sales-matnr.
i_final-netpr = i_sales-netpr.
IF NOT I_FINAL-VBELN IS INITIAL.
append i_final .
ENDIF.
endif.
ENDLOOP.
PERFORM final_display.
endcase.
ENDFORM. "USER_COMMAND
&----
*& Form final_display
&----
text
-
--> p1 text
<-- p2 text
-
form final_display .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = sy-repid
IS_LAYOUT = gt_LAYOUT
IT_FIELDCAT = gt_fieldcat
TABLES
t_outtab = i_final .
endform. " final_display
after this do like this ...
loop at it_final .
dbtable-field1 = it_final-field1 .
dbtable-field2 = it_final-field2.
insert dbtable .
endloop .
‎2008 Dec 01 7:31 AM
hey,
Can you please make your question clear?your requirement?.
‎2008 Dec 01 9:19 AM
Hey,
My question is
I want to develop on user entry screen, on that one fields are Material Code, Name, Type and Rate.
Rate will be given by user individually. for that purpose i developed one push button , alv grid,
‎2008 Dec 01 10:29 AM
Hi ,
As per your Requirement , i feel that you are looking for a Basic Data Entry Form , Where users can Create, Edit & delete Rates of Materials , pls Correct me if i m Wrong .
Pls Follow the Steps
1.Create a Transparents Table With All Required Fields
2.Populate All the Fields into a ALV Grid From that Table
3.Create 3 Buttons at the ALv Header ( Create , Edit, delete)
4.Create a Screen with All feilds
5.When The user Click on Create Button System will go to Newly Created Screen and allow User to Do a New Entey
6.When User Selects an Entry in the ALV and Click on Edit , system will call the same Screen with Aloowing Only to Edit the Rate
7.Delete also same , it wil delete Selected Raw from the ALV
Hope this Flow is OK for your Requirement , feel free to contact if anything Needed
Thx & Br,
Dilum
‎2008 Dec 01 7:37 AM
insert your alv records from internal table to database dable using INSERT.
‎2008 Dec 01 7:53 AM
hi priya
1.)Take the backup and after the values changed
compare both the tables....
and find the records which are changed.....
and update them to database.
2.)Check the Program BCALV_GRID_EDIT in se38.
Thanks
‎2008 Dec 01 8:11 AM
Hi,
Purpose why we use ALV grid is to display the output,and Database can hold data in Transparent tables,so you can insert records in ALV grid to database in Tables but you can not insert Grid in database.I hope this answers your question,if you have some other requirement,then do let us know.
Regards,
Neha
‎2008 Dec 01 9:16 AM
Hi..
My purpose is
user will give the rates for individual material.
Give me suggestion. how to develop that one.
In my desiging total 4 columns are ther
one is Material Code,
Name,
Type
Rate.
Can u give how i can develop user entry screen
With Regards.
‎2008 Dec 01 8:18 AM
Hi,
I have one alv grid and one push button, my question is , whever the use press the push button then only my alv grid data store into the data base. How it is .
‎2008 Dec 01 8:34 AM
REPORT ZTEST_DATABASE .
type-pools: slis.
*Table declaration
tables: vbak,vbap.
*internal table
data: begin of i_sales occurs 0,
vbeln like vbak-vbeln,
erdat like vbak-erdat,
audat like vbak-audat,
kunnr like vbak-kunnr,
vkorg like vbak-vkorg,
matnr like vbap-matnr,
netpr like vbap-netpr,
check type c, "checkbox
end of i_sales.
data: begin of i_final occurs 0,
vbeln like vbak-vbeln,
erdat like vbak-erdat,
audat like vbak-audat,
kunnr like vbak-kunnr,
vkorg like vbak-vkorg,
matnr like vbap-matnr,
netpr like vbap-netpr,
end of i_final.
data: v_fieldcat type slis_fieldcat_alv,
gt_fieldcat type slis_t_fieldcat_alv,
gt_layout type slis_layout_alv,
gt_sort type slis_sortinfo_alv,
fieldcat like line of gt_fieldcat.
*Selection screen
parameters: p_vkorg like vbak-vkorg.
select-options: s_vbeln for vbak-vbeln.
*start of selection.
start-of-selection.
perform get_data.
perform fill_fieldcatalog.
perform write_data.
*----
get data
*----
FORM get_data .
select a~vbeln
a~erdat
a~audat
a~kunnr
a~vkorg
b~matnr
b~netpr
into corresponding fields of table i_sales
from vbak as a inner join vbap as b on avbeln = bvbeln
where a~vkorg = p_vkorg
and a~vbeln in s_vbeln.
ENDFORM. " get_data
*----
write_data
*----
FORM write_data .
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = sy-repid
I_CALLBACK_PF_STATUS_SET = 'GUI_SET'
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
IS_LAYOUT = gt_layout
IT_FIELDCAT = gt_fieldcat
TABLES
T_OUTTAB = i_sales .
ENDFORM. " write_data
*----
fill catalog
*----
FORM fill_fieldcatalog .
sort i_sales by vbeln.
clear v_fieldcat.
*for check box
v_fieldcat-col_pos = 1.
v_fieldcat-fieldname = 'CHECK'.
v_fieldcat-seltext_m = 'chek'.
v_fieldcat-checkbox = 'X'.
v_fieldcat-input = 'X'.
v_fieldcat-edit = 'X'.
append v_fieldcat to gt_fieldcat.
clear v_fieldcat.
v_fieldcat-col_pos = 2.
v_fieldcat-fieldname = 'VBELN'.
v_fieldcat-seltext_m = 'Sales Document'.
append v_fieldcat to gt_fieldcat.
clear v_fieldcat.
v_fieldcat-col_pos = 3.
v_fieldcat-fieldname = 'ERDAT'.
v_fieldcat-seltext_m = 'Creation Date'.
append v_fieldcat to gt_fieldcat.
clear v_fieldcat.
v_fieldcat-col_pos = 4.
v_fieldcat-fieldname = 'AUDAT'.
v_fieldcat-seltext_m = 'Document Date'.
append v_fieldcat to gt_fieldcat.
clear v_fieldcat.
v_fieldcat-col_pos = 5.
v_fieldcat-fieldname = 'KUNNR'.
v_fieldcat-seltext_m = 'Customer'.
append v_fieldcat to gt_fieldcat.
clear v_fieldcat.
v_fieldcat-col_pos = 6.
v_fieldcat-fieldname = 'VKORG'.
v_fieldcat-seltext_m = 'Sales Organization'.
append v_fieldcat to gt_fieldcat.
clear v_fieldcat.
v_fieldcat-col_pos = 7.
v_fieldcat-fieldname = 'MATNR'.
v_fieldcat-seltext_m = 'Material'.
append v_fieldcat to gt_fieldcat.
clear v_fieldcat.
v_fieldcat-col_pos = 8.
v_fieldcat-fieldname = 'NETPR'.
v_fieldcat-seltext_m = 'Net Value'.
append v_fieldcat to gt_fieldcat.
clear v_fieldcat.
endform.
&----
*& Form GUI_SET
&----
FORM GUI_SET USING RT_EXTAB TYPE SLIS_T_EXTAB .
SET PF-STATUS 'GETDATA' .
ENDFORM. "GUI_SET
&----
*& Form USER_COMMAND
&----
FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
R_SELFIELD TYPE SLIS_SELFIELD.
CASE R_UCOMM.
WHEN 'DATA'.
CLEAR I_FINAL.
CLEAR I_SALES.
REFRESH I_FINAL.
LOOP AT i_sales .
if i_sales-check = 'X'.
i_final-vbeln = i_sales-vbeln.
i_final-erdat = i_sales-erdat.
i_final-audat = i_sales-audat.
i_final-kunnr = i_sales-kunnr.
i_final-vkorg = i_sales-vkorg.
i_final-matnr = i_sales-matnr.
i_final-netpr = i_sales-netpr.
IF NOT I_FINAL-VBELN IS INITIAL.
append i_final .
ENDIF.
endif.
ENDLOOP.
PERFORM final_display.
endcase.
ENDFORM. "USER_COMMAND
&----
*& Form final_display
&----
text
-
--> p1 text
<-- p2 text
-
form final_display .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = sy-repid
IS_LAYOUT = gt_LAYOUT
IT_FIELDCAT = gt_fieldcat
TABLES
t_outtab = i_final .
endform. " final_display
after this do like this ...
loop at it_final .
dbtable-field1 = it_final-field1 .
dbtable-field2 = it_final-field2.
insert dbtable .
endloop .