Update GS_STYLE in ALV
Hi,
i have a problem for update STYLE, i have an ALV with checkbox and i have specific lines where the CHECKBOX is desactivate. But when i want to update my style for enable or disable style i have problem for insert new value (sy-subrc = 4 )
types: begin of gs_outtab.
types: checkbox type c.
"Zone de style qui permet d'activer l'edition des celulles ou non.
types: celltab type lvc_t_styl.
include structure zpvprevmaj.
types: end of gs_outtab.
form checkbox_lock.
break epetrini.
LOOP AT gt_outtab.
IF gt_outtab-KSCHL = 'PR00'.
GS_STYLE-FIELDNAME = 'CHECKBOX'.
GS_STYLE-STYLE = CL_GUI_ALV_GRID=>MC_STYLE_ENABLED.
else.
GS_STYLE-FIELDNAME = 'CHECKBOX'.
GS_STYLE-STYLE = CL_GUI_ALV_GRID=>MC_STYLE_DISABLED.
endif.
INSERT GS_STYLE INTO TABLE gt_outtab-celltab.
MODIFY gt_outtab INDEX SY-TABIX TRANSPORTING CELLTAB.
endloop.
Here the code for the update when i do INSERT GS_STYLE INTO TABLE gt_outtab-celltab.
my sy-surbc = 4 i want to replace this piece of code by MODIFY GS_STYLE ....
endform. "checkbox_lock
form checkbox_lock_update.
break epetrini.
LOOP AT gt_outtab.
IF gt_outtab-KSCHL = 'PR00'.
GS_STYLE-FIELDNAME = 'CHECKBOX'.
GS_STYLE-STYLE = CL_GUI_ALV_GRID=>MC_STYLE_ENABLED.
else.
GS_STYLE-FIELDNAME = 'CHECKBOX'.
GS_STYLE-STYLE = CL_GUI_ALV_GRID=>MC_STYLE_DISABLED.
endif.
"Here my problem, i search instruction for update GS_STYLE INTO TABLE gt_outtab-celltab because the INSERT return a sy-subrc = 4
INSERT GS_STYLE INTO TABLE gt_outtab-celltab.
MODIFY gt_outtab INDEX SY-TABIX TRANSPORTING CELLTAB.
endloop.
endform.
Edited by: Emilien P. on Dec 8, 2010 11:23 AM
Edited by: Emilien P. on Dec 8, 2010 11:27 AM
Edited by: Emilien P. on Dec 8, 2010 11:28 AM
Hi,
i have a problem for update STYLE, i have an ALV with checkbox and i have specific lines where the CHECKBOX is desactivate. But when i want to update my style for enable or disable style i have problem for insert new value (sy-subrc = 4 )
types: begin of gs_outtab.
types: checkbox type c.
"Zone de style qui permet d'activer l'edition des celulles ou non.
types: celltab type lvc_t_styl.
include structure zpvprevmaj.
types: end of gs_outtab.
form checkbox_lock.
break epetrini.
LOOP AT gt_outtab.
IF gt_outtab-KSCHL = 'PR00'.
GS_STYLE-FIELDNAME = 'CHECKBOX'.
GS_STYLE-STYLE = CL_GUI_ALV_GRID=>MC_STYLE_ENABLED.
else.
GS_STYLE-FIELDNAME = 'CHECKBOX'.
GS_STYLE-STYLE = CL_GUI_ALV_GRID=>MC_STYLE_DISABLED.
endif.
INSERT GS_STYLE INTO TABLE gt_outtab-celltab.
MODIFY gt_outtab INDEX SY-TABIX TRANSPORTING CELLTAB.
endloop.
Here the code for the update when i do INSERT GS_STYLE INTO TABLE gt_outtab-celltab.
my sy-surbc = 4 i want to replace this piece of code by MODIFY GS_STYLE ....
endform. "checkbox_lock
form checkbox_lock_update.
break epetrini.
LOOP AT gt_outtab.
IF gt_outtab-KSCHL = 'PR00'.
GS_STYLE-FIELDNAME = 'CHECKBOX'.
GS_STYLE-STYLE = CL_GUI_ALV_GRID=>MC_STYLE_ENABLED.
else.
GS_STYLE-FIELDNAME = 'CHECKBOX'.
GS_STYLE-STYLE = CL_GUI_ALV_GRID=>MC_STYLE_DISABLED.
endif.
"Here my problem, i search instruction for update GS_STYLE INTO TABLE gt_outtab-celltab because the INSERT return a sy-subrc = 4
INSERT GS_STYLE INTO TABLE gt_outtab-celltab.
MODIFY gt_outtab INDEX SY-TABIX TRANSPORTING CELLTAB.
endloop.
endform.
Edited by: Emilien P. on Dec 8, 2010 11:23 AM
Edited by: Emilien P. on Dec 8, 2010 11:27 AM
Edited by: Emilien P. on Dec 8, 2010 11:28 AM
Similar Messages
-
Update values in AlV grid display after entering value
Hi,
I have an issue in ALV grid display.
Let me explain.
i have 8 fields to display in which one is editiable.
Fields are: date
material,
material Description,
Opening Stock,
Closing stock- ( this field is editiable)
Closing stock,
Received Stock,
Actual production.
Actual production = Closing stock + removal stock
- receipt stock - opening stock.
when i change the value of closing stock and press enter, actual production should get update, the new values should display.
Thany you in advance.Hi,
Please refer the code below:
REPORT z_demo_alv_jg.*******************************************************************
* TYPE-POOLS *
TYPE-POOLS: slis. *******************************************************************
* INTERNAL TABLES/WORK AREAS/VARIABLES *
DATA: i_fieldcat TYPE slis_t_fieldcat_alv,
i_index TYPE STANDARD TABLE OF i WITH HEADER LINE,
w_field TYPE slis_fieldcat_alv,
p_table LIKE dd02l-tabname,
dy_table TYPE REF TO data,
dy_tab TYPE REF TO data,
dy_line TYPE REF TO data.*******************************************************************
* FIELD-SYMBOLS *
FIELD-SYMBOLS: <dyn_table> TYPE STANDARD TABLE,
<dyn_wa> TYPE ANY,
<dyn_field> TYPE ANY,
<dyn_tab_temp> TYPE STANDARD TABLE.*******************************************************************
* SELECTION SCREEN *
PARAMETERS: tabname(30) TYPE c,
lines(5) TYPE n.*******************************************************************
* START-OF-SELECTION *
START-OF-SELECTION.* Storing table name
p_table = tabname.* Create internal table dynamically with the stucture of table name
* entered in the selection screen
CREATE DATA dy_table TYPE STANDARD TABLE OF (p_table).
ASSIGN dy_table->* TO <dyn_table>.
IF sy-subrc <> 0.
MESSAGE i000(z_zzz_ca_messages) WITH ' No table found'. LEAVE TO LIST-PROCESSING.
ENDIF.
* Create workarea for the table
CREATE DATA dy_line LIKE LINE OF <dyn_table>.
ASSIGN dy_line->* TO <dyn_wa>.* Create another temp. table
CREATE DATA dy_tab TYPE STANDARD TABLE OF (p_table).
ASSIGN dy_tab->* TO <dyn_tab_temp>. SORT i_fieldcat BY col_pos.* Select data from table
SELECT * FROM (p_table)
INTO TABLE <dyn_table>
UP TO lines ROWS. REFRESH <dyn_tab_temp>.* Display report
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_program = sy-repid
i_structure_name = p_table
i_callback_user_command = 'USER_COMMAND'
i_callback_pf_status_set = 'SET_PF_STATUS'
TABLES
t_outtab = <dyn_table>
EXCEPTIONS
program_error = 1
OTHERS = 2. IF sy-subrc <> 0. ENDIF.*&-----------------------------------------------------------------*
*& Form SET_PF_STATUS
* Setting custom PF-Status
* -->RT_EXTAB Excluding table
FORM set_pf_status USING rt_extab TYPE slis_t_extab. SET PF-STATUS 'Z_STANDARD'.ENDFORM. "SET_PF_STATUS*&----------------------------------------------------------------*
*& Form user_command
* Handling custom function codes
* -->R_UCOMM Function code value
* -->RS_SELFIELD Info. of cursor position in ALV
FORM user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.* Local data declaration
DATA: li_tab TYPE REF TO data,
l_line TYPE REF TO data.* Local field-symbols
FIELD-SYMBOLS:<l_tab> TYPE table,
<l_wa> TYPE ANY.* Create table
CREATE DATA li_tab TYPE STANDARD TABLE OF (p_table).
ASSIGN li_tab->* TO <l_tab>.* Create workarea
CREATE DATA l_line LIKE LINE OF <l_tab>.
ASSIGN l_line->* TO <l_wa>. CASE r_ucomm.* When a record is selected
WHEN '&IC1'.* Read the selected record
READ TABLE <dyn_table> ASSIGNING <dyn_wa> INDEX
rs_selfield-tabindex. IF sy-subrc = 0.* Store the record in an internal table
APPEND <dyn_wa> TO <l_tab>.* Fetch the field catalog info
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = 'Z_DEMO_PDF_JG'
i_structure_name = p_table
CHANGING
ct_fieldcat = i_fieldcat
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
IF sy-subrc = 0.* Make all the fields input enabled except key fields
w_field-input = 'X'. MODIFY i_fieldcat FROM w_field TRANSPORTING input
WHERE key IS INITIAL. ENDIF.* Display the record for editing purpose
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_program = sy-repid
i_structure_name = p_table
it_fieldcat = i_fieldcat
i_screen_start_column = 10
i_screen_start_line = 15
i_screen_end_column = 200
i_screen_end_line = 20
TABLES
t_outtab = <l_tab>
EXCEPTIONS
program_error = 1
OTHERS = 2. IF sy-subrc = 0.* Read the modified data
READ TABLE <l_tab> INDEX 1 INTO <l_wa>.* If the record is changed then track its index no.
* and populate it in an internal table for future
* action
IF sy-subrc = 0 AND <dyn_wa> <> <l_wa>.
<dyn_wa> = <l_wa>.
i_index = rs_selfield-tabindex.
APPEND i_index.
ENDIF.
ENDIF. ENDIF.* When save button is pressed
WHEN 'SAVE'.* Sort the index table
SORT i_index.* Delete all duplicate records
DELETE ADJACENT DUPLICATES FROM i_index. LOOP AT i_index.* Find out the changes in the internal table
* and populate these changes in another internal table
READ TABLE <dyn_table> ASSIGNING <dyn_wa> INDEX i_index.
IF sy-subrc = 0.
APPEND <dyn_wa> TO <dyn_tab_temp>.
ENDIF. ENDLOOP.* Lock the table
CALL FUNCTION 'ENQUEUE_E_TABLE'
EXPORTING
mode_rstable = 'E'
tabname = p_table
EXCEPTIONS
foreign_lock = 1
system_failure = 2
OTHERS = 3. IF sy-subrc = 0.* Modify the database table with these changes
MODIFY (p_table) FROM TABLE <dyn_tab_temp>. REFRESH <dyn_tab_temp>.* Unlock the table
CALL FUNCTION 'DEQUEUE_E_TABLE'
EXPORTING
mode_rstable = 'E'
tabname = p_table. ENDIF.
ENDCASE. rs_selfield-refresh = 'X'.ENDFORM. "user_command
Thanks,
Sriram Ponna. -
How to update/modify the ALV internal table once it is displayed
Hi All,
I have a alv grid report using fm reuse_alv_grid_dispaly. My requirement is to create sales order using bapi (up to here it is working fine) and once the SO is created update the function module tables field with the created sales order.
Example:
My alv grid display before creating SO:
Customer Material SalesOrder
1000001 material1
My alv grid display after creating SO:
Customer Material SalesOrder
1000001 material1 3025642
How can I achieve this functionality. Because the field catalog is already displayed, how can I modify/update it by adding the sales order number to it. Experts, suggest me.
Thanks.FORM callback_ucomm USING ucomm LIKE sy-ucomm
selfield TYPE slis_selfield.
CASE ucomm.
WHEN 'CRE'.
* Logic to create sales order here...
* Show the Sales order column
CALL FUNCTION 'REUSE_ALV_GRID_LAYOUT_INFO_GET'
IMPORTING
et_fieldcat = gt_fieldcat
EXCEPTIONS
no_infos = 1
program_error = 2
OTHERS = 3.
if sy-subrc eq 0.
read table gt_fieldcat into gs_fieldcat with key fieldname = 'VBELN'.
if sy-subrc eq 0.
gs_fieldcat-no_out = space.
gs_fieldcat-tech = space.
modify gt_fieldcat from gs_fieldcat index sy-tabix transporting no_out tech.
endif.
CALL FUNCTION 'REUSE_ALV_GRID_LAYOUT_INFO_SET'
EXPORTING
it_fieldcat = gt_fieldcat[].
endif.
ENDFORM. -
How I can update data in ALV GRID?
Hi all,
I have to update data in an ALV GRID and only one column is editable. I've exclude insert and delete row pushbutton, and I inserted a save pushbutton.
What I have to write under the "save function" to update my internal table displayed in ALV GRID?
Thanks advance
Christian
Message was edited by: Christian MarchiolREPORT ZTESTDFALV1 .
*Data Declaration
DATA: BEGIN OF T_EKKO,
EBELN TYPE EKPO-EBELN,
EBELP TYPE EKPO-EBELP,
END OF T_EKKO.
DATA: BEGIN OF IT_EKKO OCCURS 0.
INCLUDE STRUCTURE T_EKKO.
DATA: END OF IT_EKKO.
DATA: BEGIN OF IT_BACKUP OCCURS 0.
INCLUDE STRUCTURE T_EKKO.
DATA: END OF IT_BACKUP.
*ALV data declarations
TYPE-POOLS: SLIS. "ALV Declarations
DATA: FIELDCATALOG TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE,
GD_LAYOUT TYPE SLIS_LAYOUT_ALV,
GD_REPID LIKE SY-REPID.
*Start-of-selection.
START-OF-SELECTION.
PERFORM DATA_RETRIEVAL.
PERFORM BUILD_FIELDCATALOG.
PERFORM BUILD_LAYOUT.
IT_BACKUP[] = IT_EKKO[].
PERFORM DISPLAY_ALV_REPORT.
*& Form build_fieldcatalog
* text
FORM BUILD_FIELDCATALOG.
REFRESH FIELDCATALOG.
CLEAR FIELDCATALOG.
FIELDCATALOG-FIELDNAME = 'EBELN'.
FIELDCATALOG-SELTEXT_M = 'Purchase Order'.
FIELDCATALOG-INPUT = 'X'.
FIELDCATALOG-EDIT = 'X'.
FIELDCATALOG-COL_POS = 2.
APPEND FIELDCATALOG.
CLEAR FIELDCATALOG.
FIELDCATALOG-FIELDNAME = 'EBELP'.
FIELDCATALOG-SELTEXT_M = 'PO Item'.
FIELDCATALOG-COL_POS = 3.
APPEND FIELDCATALOG.
CLEAR FIELDCATALOG.
ENDFORM. " BUILD_FIELDCATALOG
*& Form BUILD_LAYOUT
* Build layout for ALV grid report
FORM BUILD_LAYOUT.
"Permet d'ajuster les colonnes au text
* gd_layout-colwidth_optimize = 'X'.
GD_LAYOUT-TOTALS_TEXT = 'Totals'(201).
* gd_layout-box_fieldname = 'SELECT'.
* gd_layout-box_tabname = 'IT_EKKO'.
ENDFORM. " BUILD_LAYOUT
*& Form DISPLAY_ALV_REPORT
* Display report using ALV grid
FORM DISPLAY_ALV_REPORT.
GD_REPID = SY-REPID.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = GD_REPID
* i_callback_top_of_page = 'TOP-OF-PAGE'
I_CALLBACK_PF_STATUS_SET = 'SET_PF_STATUS'
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
* i_grid_title = 'My Title'
IS_LAYOUT = GD_LAYOUT
IT_FIELDCAT = FIELDCATALOG[]
TABLES
T_OUTTAB = IT_EKKO
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
WRITE:/ SY-SUBRC.
ENDIF.
ENDFORM. " DISPLAY_ALV_REPORT
*& Form DATA_RETRIEVAL
* Retrieve data form EKPO table and populate itab it_ekko
FORM DATA_RETRIEVAL.
SELECT EBELN EBELP
UP TO 10 ROWS
FROM EKPO
INTO CORRESPONDING FIELDS OF TABLE IT_EKKO.
ENDFORM. " DATA_RETRIEVAL
* FORM SET_PF_STATUS *
FORM SET_PF_STATUS USING RT_EXTAB TYPE SLIS_T_EXTAB.
<b>SET PF-STATUS 'STANDARD_FULLSCREEN1' EXCLUDING RT_EXTAB.</b>
ENDFORM. "set_pf_status
*& Form user_command
* text
* -->R_UCOMM text
* -->RS_SELFIELDtext
FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
RS_SELFIELD TYPE SLIS_SELFIELD.
<b> DATA: GD_REPID LIKE SY-REPID, "Exists
REF_GRID TYPE REF TO CL_GUI_ALV_GRID. "new
</b>
*then insert the following code in your USER_COMMAND routine...
<b>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.</b>
CASE R_UCOMM.
WHEN '&IC1'.
CHECK RS_SELFIELD-TABINDEX > 0.
IF RS_SELFIELD-VALUE EQ '6000000001'.
CALL TRANSACTION 'ZDF2'.
ENDIF.
WHEN 'REFRESH'.
READ TABLE IT_EKKO INDEX RS_SELFIELD-TABINDEX.
IF SY-SUBRC = 0.
READ TABLE IT_BACKUP INDEX RS_SELFIELD-TABINDEX.
IF SY-SUBRC = 0.
IF IT_EKKO <> IT_BACKUP.
* then do your check
ENDIF.
ENDIF.
ENDIF.
PERFORM DATA_RETRIEVAL.
RS_SELFIELD-REFRESH = 'X'.
when 'SAVE'.
***do your save**
ENDCASE.
ENDFORM. "user_command
concentrate on Bold....
regards
vijay -
Automatically update totals in an ALV-grid
Hi there,
Is there a possibility to automatically update a totals-field in an ALV-grid?
At the moment the totals-field is only updated when the ALV-grid is refreshed (PBO). I want an immediate update when the user enters a value in the ALV.
Who can help me?
AngeloHi,
Subramanian has taken his time and effort to help you. if you wish to reward his effort SDN has got a way for that. Since you are new to SDN may i introduce you to the points system at SDN.
You assign points to the replies that you have found to be useful. It's a way to say "thanks" for the effort in the replies.
See: /people/mark.finnern/blog/2004/08/10/spread-the-love for directions.
Click on the Yellow Star icon in each reply.
You can give:
1 - 10 pointer (marks it as a solved problem)
2 - 6 pointers (very helpful)
Lots of 2 pointers (helpful)
Raja -
Using ALV OM to UPDATE (Change) Data
Hallo Dear Experts,
Would you give a Tip how to update Datas using ALV OM. Does any body now an Example program ?
Thank a lot
FissehaHi,
new ALV object model (class CL_SALV_TABLE and so on) does not support editable columns. Yoe need to use class CL_GUI_ALV_GRID to implement editable ALV. More info can be found [here|http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/e8a1d690-0201-0010-b7ad-d9719a415907].
Cheers -
What is the best way to update an ALV tree?
Hello all of you
What is the best way to update an ALV tree?
In my case, by double clicking on a branch, a table is updated and an icon should be updated in the alv tree.
I use the class CL_SALV_TREE
Thanks for your helpCall method REFRESH!
-
Update ALV screen - quantity field
Hi All,
Data: o_Ref_Grid Type Ref to cl_Gui_Alv_Grid.
Update the main ALV table with any changes made to the grid (ie check boxes)
Call Function 'GET_GLOBALS_FROM_SLVC_FULLSCR'
Importing
E_Grid = O_Ref_Grid.
Call Method O_Ref_Grid->Check_Changed_Data.
Am using the above code to get the values changed at ALV at runtime.
All changes values are reflecting except the quantity field.
Say I enter 6,000 in quantity (the fdata element in ALV structure is KWMENG) after the call method its becoming 0.006.
Pls suggest solution to solve this.
Thanks,
KausthubHi Kausthub Krish,
In SAP ABAP, currency fields are conneted to a CUKY currency ke field and quantity fields are connected to a UNIT field. This is enforced when creating a structure in data dictionary. If field catalog is created by REUSE_ALV_FIELDCATALOG_MERGE this relationship is transferred to ALV object and handled accordingly.
It is possible to create the relation of quantity to a unit in ALV, it is better to have both in the DDIC structure for the ALV display table.
Regards,
Clemens -
In ALV display model ,how to accept the ENTER key event?
Dear All,
I have used ALV by GRID DISPLAY model ,not class model.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid
i_callback_pf_status_set = 'SET_PF_STATUS'
i_callback_user_command = 'USER_COMMAND'
i_structure_name = 'T_ITAB'
is_layout = gs_layout
it_fieldcat = t_fieldcat[]
i_default = 'X'
i_save = 'A'
TABLES
t_outtab = t_itab
EXCEPTIONS
program_error = 1
OTHERS = 2.
For example :
IN ALV DISPLAY, there are two fields, one is MATNR, the other is MAKTX.
When user input the material value in MATNR field and press ENTER, then ALV can run my code to select the MAKTX into MAKTX field and display it synchronization.
Now I have realized update edit in ALV,but I found only I double click ALV row, then the MAKTX can update.
Please give me help,
Thanks
SunThis is the document written by me on Interactive ALV.. hope this maybe helpful for u..
When an Interactive Report is needed in Classical Display, we go for AT LINE-SELECTION. But when the same is needed in ALV Display, this method won't work. Instead, we need to use other way which is explained below:
We use REUSE_ALV_GRID_DISPLAY for ALV Display. Now, normally we call that FM in the following way:
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = 'PROGRAM_NAME'
it_fieldcat = tb_fieldcat
TABLES
t_outtab = tb_output.
When it is needed to get an Interactive ALV, call the same FM in the following manner:
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = 'ZTEST75599_1'
it_fieldcat = tb_fieldcat
i_callback_user_command = 'USER_COMMAND'
TABLES
t_outtab = tb_output.
Now, in the report, create a subroutine with the name USER_COMMAND as follows:
FORM user_command USING p_ucomm LIKE sy-ucomm
p_selfield TYPE slis_selfield.
CASE p_ucomm.
WHEN '&IC1'. " &IC1 - SAP standard code for double-clicking
Based on the requirement, write the logic *
ENDCASE.
ENDFORM.
No need to call the subroutine as PERFORM user_command. This will be takane care by REUSE_ALV_GRID_DISPLAY. We need to just write the subroutine in the report. That suffices.
Some more useful points for Interactive ALV:
1. If Hotspot is needed, then that should be done by declaring hotspot (one field in slis_t_fieldcat_alv) as 'X' in tb_fieldcat which is of type slis_t_fieldcat_alv. When hotspot is active, single click will be enough or else you should double click on the output data.
2. In Classical Display, when it is needed to read the record on which we double clicked, we do that in following way:
AT LINE-SELECTION.
GET CURSOR LINE wf_line. " wf_line gives the line number on which it has been clicked
READ LINE wf_line OF CURRENT PAGE.
But this won't work for ALV. Instead, the following logic can be used:
FORM user_command USING p_ucomm LIKE sy-ucomm
p_selfield TYPE slis_selfield.
CASE p_ucomm.
WHEN '&IC1'. " &IC1 - SAP standard code for double-clicking
READ TABLE tb_output INTO wa_output INDEX p_selfield-tabindex.
IF sy-subrc EQ 0.
Based on the requirement, write the logic *
ENDIF.
ENDCASE.
ENDFORM. -
Editing An ALV Grid and saving finally.
Hİ !
former Abap programmer I have modified CN47N as ZCN47N and made the some of the fields of the grid Editable.
The user changes some of the fields and then press Enter occasionally. When he wants to save he clicks a Save button.
If I use
call method g_d_grid->set_ready_for_input
exporting
i_ready_for_input = 1.
call method g_d_grid->register_edit_event
exporting
i_event_id = cl_gui_alv_grid=>mc_evt_enter
exceptions
error = 1
others = 2.
the "data_changed " event of the ALV grid is fired every time the user press Enter BUT CAPTURES ONLY THE LAST EDITS.
But I can update the neighboring cells of the editable cells immediately by this way.
If I disable the mc_evt_enter event , The user can save ALL of the changes with the firing of gr_grid->checked_changed_data which fires the data_changed event.
But by this way I can not update the neighboring cells of the editable cells with the explanation of the editable cells.
My Question:
1) Will data_changed_finished event suit better than data_changed_?
2) Is there a moderate way in which I can use the enter key and capture all the changes that have been made in the grid ?
thanks.
erkan.DATA_CHANGED triggers as soon as you enter the value and move away to different cell. Parameter ER_DATA_CHANGED of the handler method of DATA_CHANGED would have MT_GOOD_CELLS and MT_BED_CELLS. Based on this you can validate the values and update the Protocol table using the method ADD_PROTOCOL_ENTRY.
If you have to modify other cells based on the entered cells, you need to use this DATA_CHANGED method, because here you can get / change the data of the cell using the method GET_CELL_VALUE & MODIFY_CELL. in this method, the entered data is not yet visible in your ALV data table.
DATA_CHANGED_FINISHED triggers after the data has been updated in the ALV data table. So, if you wish to change the other cells it too late. You need to modify the table and call the refresh method to actually refresh the data.
Regards,
Naimesh Patel -
hi experts,
i have a requirement to create a alv grid report and in the output one column should be editable.(till here every thing is correct what i did)
i have to create a 'update' button to the tool bar of alv output screen so that if i enter my own data in the editable screen,and press 'update' button then my database table should be updated..
can anyone tell me how to create 'update' button and write code for that.
my code is as below:
TABLES: vbak,vbap.
TYPE-POOLS: slis. "ALV Declarations
*Data Declaration
TYPES: BEGIN OF t_final,
vbeln LIKE vbak-vbeln,
erdat LIKE vbak-erdat,
matnr LIKE vbap-matnr,
posnr LIKE vbap-posnr,
END OF t_final.
DATA: i_final TYPE STANDARD TABLE OF t_final INITIAL SIZE 0,
wa_final TYPE t_final.
*ALV data declarations
DATA: fieldcatalog TYPE slis_t_fieldcat_alv WITH HEADER LINE,
gd_tab_group TYPE slis_t_sp_group_alv,
gd_layout TYPE slis_layout_alv,
gd_repid LIKE sy-repid.
*Start-of-selection.
START-OF-SELECTION.
PERFORM data_retrieval.
PERFORM build_fieldcatalog.
PERFORM build_layout.
PERFORM display_alv_report.
*& Form BUILD_FIELDCATALOG
Build Fieldcatalog for ALV Report
FORM build_fieldcatalog.
fieldcatalog-fieldname = 'VBELN'.
fieldcatalog-seltext_m = 'sales order'.
fieldcatalog-col_pos = 0.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'ERDAT'.
fieldcatalog-seltext_m = 'date'.
fieldcatalog-col_pos = 1.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'MATNR'.
fieldcatalog-seltext_m = 'material no.'.
fieldcatalog-col_pos = 2.
fieldcatalog-edit = 'X'.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'POSNR'.
fieldcatalog-seltext_m = 'line item no.'.
fieldcatalog-col_pos = 3.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
ENDFORM. " BUILD_FIELDCATALOG
*& Form BUILD_LAYOUT
Build layout for ALV grid report
FORM build_layout.
gd_layout-no_input = 'X'.
gd_layout-colwidth_optimize = 'X'.
gd_layout-totals_text = 'Totals'(201).
gd_layout-totals_only = 'X'.
gd_layout-f2code = 'DISP'. "Sets fcode for when double
"click(press f2)
gd_layout-zebra = 'X'.
gd_layout-group_change_edit = 'X'.
gd_layout-header_text = 'helllllo'.
ENDFORM. " BUILD_LAYOUT
*& Form DISPLAY_ALV_REPORT
Display report using ALV grid
FORM display_alv_report.
gd_repid = sy-repid.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = gd_repid
i_callback_top_of_page = 'TOP-OF-PAGE' "see FORM
i_callback_user_command = 'USER_COMMAND'
i_grid_title = outtext
is_layout = gd_layout
it_fieldcat = fieldcatalog[]
it_special_groups = gd_tabgroup
IT_EVENTS = GT_XEVENTS
i_save = 'X'
is_variant = z_template
TABLES
t_outtab = I_FINAL
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. " DISPLAY_ALV_REPORT
*& Form DATA_RETRIEVAL
Retrieve data form EKPO table and populate itab it_ekko
FORM data_retrieval.
SELECT avbeln aerdat bmatnr bposnr FROM vbak AS a
INNER JOIN vbap AS b ON avbeln = bvbeln
INTO TABLE i_final WHERE avbeln = bvbeln.
ENDFORM. " DATA_RETRIEVAL
points will be rewarded.Hi Nani
TO add a button on alv tool bar and to handle it
u have to use object oriented approach
for this u have to define class and implement class in which u will write code inside the method to hadle particlur event
here is the code for it.
*& Class z_cl_9_u_EVENT_RECEIVER this class contains the definition
of methods for handling events
CLASS z_cl_9_u_event_receiver DEFINITION DEFERRED.
DATA : event_receiver TYPE REF TO z_cl_9_u_event_receiver.
*data: create object e1 type ref to cl_alv_event_toolbar_set.
*& Class z_cl_9_u_EVENT_RECEIVER this class contains the definition
of methods for handling events
CLASS z_cl_9_u_event_receiver DEFINITION.
PUBLIC SECTION.
METHODS:
handle_toolbar
FOR EVENT toolbar OF cl_gui_alv_grid
IMPORTING e_object e_interactive,
handle_user_command
FOR EVENT user_command OF cl_gui_alv_grid
IMPORTING e_ucomm.
ENDCLASS. "z_cl_9_u_EVENT_RECEIVER
CLASSES
CLASS lcl_event_receiver DEFINITION DEFERRED.
*& Class (Implementation) z_cl_9_u_EVENT_RECEIVER
Add a Update Button On ALV-Toolbar and put the logic
for handing that button
*& Class z_cl_9_u_EVENT_RECEIVER this class contains the implementation
of methods for handling events.
CLASS z_cl_9_u_event_receiver IMPLEMENTATION.
*& Method HANDLE_TOOLBAR is to handle toolbar.
In event handler method for event TOOLBAR: Append own functions
by using event parameter E_OBJECT.
METHOD handle_toolbar.
In event handler method for event TOOLBAR: Append own functions
by using event parameter E_OBJECT.
DATA: L_T_toolbar TYPE stb_button.
Append an icon to update tables if country is otherthan NZ.
IF g_flag = c_x AND g_back NE c_x.
CLEAR L_T_toolbar.
MOVE 0 TO L_T_toolbar-butn_type.
MOVE 'UPDATE' TO L_T_toolbar-function.
MOVE icon_modify TO L_T_toolbar-icon.
MOVE text-062 TO L_T_toolbar-quickinfo.
MOVE '' TO L_T_toolbar-text.
MOVE ' ' TO L_T_toolbar-disabled.
APPEND L_T_toolbar TO e_object->mt_toolbar.
In a self defined button, you can disable the button with option DISABLED = 'X'
ELSEIF g_back = c_x.
CLEAR L_T_toolbar.
L_T_toolbar-function = 'UPDATE'.
L_T_toolbar-butn_type = 0.
L_T_toolbar-icon = icon_modify.
L_T_toolbar-quickinfo = text-015.
L_T_toolbar-disabled = 'X'.
APPEND L_T_toolbar TO e_object->mt_toolbar.
CLEAR ok_code.
ENDIF.
ENDMETHOD. "handle_toolbar
*& Method HANDLE_USER_COMMAND does processing based on user inputs.
E_UCOMM has the user command.
METHOD handle_user_command.
In event handler method for event USER_COMMAND:
DATA: L_T_Rows TYPE lvc_t_row,
L_Size TYPE sy-tabix.
CASE e_ucomm.
WHEN 'UPDATE'.
REFRESH L_T_Rows.
CALL METHOD alv_grid->get_selected_rows
IMPORTING
et_index_rows = L_T_Rows.
CALL METHOD cl_gui_cfw=>flush.
DESCRIBE TABLE L_T_Rows LINES L_Size.
IF L_Size IS INITIAL.
MESSAGE i071.
ELSE.
Execute this subroutines to capture the changed data
in ALV and pass it to Ztables,
PERFORM f4700_update_table TABLES L_T_Rows.
PERFORM f4800_get_changed_data.
PERFORM f0500_get_analysis_details USING g_socnr g_matnr.
CALL METHOD alv_grid->refresh_table_display.
ENDIF.
ENDCASE.
ENDMETHOD. "handle_user_command
ENDCLASS.
now call these methods wher eever u r calling the alv like in PBO of screen.
IF g_custom_container IS INITIAL.
g_t_lvc_s_layo-info_fname = c_l_line_colour.
g_t_lvc_s_layo-no_keyfix = '1'. "
CREATE OBJECT g_custom_container
EXPORTING container_name = 'CONTAINER_DETAIL'.
CREATE OBJECT alv_grid
EXPORTING i_parent = g_custom_container.
CALL METHOD alv_grid->set_table_for_first_display
EXPORTING
i_structure_name = 'structre of table'
is_layout = g_t_lvc_s_layo
CHANGING
it_outtab = g_t_outtab[]
it_fieldcatalog = g_t_fieldcat.
*OLY EN01434 BEGIN
->Create Object to receive events and link them to handler methods.
CREATE OBJECT event_receiver.
SET HANDLER event_receiver->handle_user_command FOR alv_grid.
SET HANDLER event_receiver->handle_toolbar FOR alv_grid.
ELSE. "SUBSEQUENT ITERATIONS:
F g_custom_container IS INITIAL.
Layout field 'info-fname' points to the field/column in the
OUTTAB that controls the colour attribute. (OUTTAB is
maintained in function Y_DIP_METER_REC_CALCULATION).
g_t_lvc_s_layo-info_fname = c_l_line_colour.
g_t_lvc_s_layo-no_keyfix = '1'. "RSC18Sep02 - allow hor scroll
CREATE OBJECT g_custom_container
EXPORTING container_name = 'CONTAINER_DETAIL'.
CREATE OBJECT alv_grid
EXPORTING i_parent = g_custom_container.
CALL METHOD alv_grid->set_table_for_first_display
EXPORTING
i_structure_name = 'ZV9NDMRA'
is_layout = g_t_lvc_s_layo
CHANGING
it_outtab = g_t_outtab[]
it_fieldcatalog = g_t_fieldcat.
*OLY EN01434 BEGIN
->Create Object to receive events and link them to handler methods.
CREATE OBJECT event_receiver.
SET HANDLER event_receiver->handle_user_command FOR alv_grid.
SET HANDLER event_receiver->handle_toolbar FOR alv_grid.
ELSE. "SUBSEQUENT ITERATIONS:
*********SAVE IMPORT PARMAETER IS ADDED BY NEEC
PERFORM f4900_set_excluding_buttons." USING sy-dynnr.
CALL METHOD alv_grid->set_table_for_first_display
EXPORTING
i_structure_name = 'ZV9NDMRA'
is_layout = g_t_lvc_s_layo
it_toolbar_excluding = g_t_toolbar_excl
CHANGING
it_outtab = g_t_outtab[]
it_fieldcatalog = g_t_fieldcat.
CALL METHOD alv_grid->set_toolbar_interactive.
CALL METHOD alv_grid->refresh_table_display.
I hope it will help to sme extent
Rewards if helpful and if any help required reply back.....
CALL METHOD alv_grid->set_table_for_first_display
EXPORTING
i_structure_name = 'ZV9NDMRA'
is_layout = g_t_lvc_s_layo
it_toolbar_excluding = g_t_toolbar_excl
CHANGING
it_outtab = g_t_outtab[]
it_fieldcatalog = g_t_fieldcat.
CALL METHOD alv_grid->set_toolbar_interactive.
CALL METHOD alv_grid->refresh_table_display. -
Hi,
I have an ALV Tree report developed using the OOPS. In my ALV Tree output, I have some buttons which will update the database after clicking. The data is correctly updating in the database. But, it is not getting updated in the ALV Tree display. That means, it is not REFRESHing the ALV Tree display. We have to again execute the program in order to see the updated output.
Could anyone please suggest me how to Refresh the ALV Tree display..?
We can't use the method 'REFRESH_TABLE_DISPLAY' as it is a PRIVATE method is the class CL_GUI_ALV_TREE.
Please share your valuable thoughts.
Thanks & Regards,
Paddu.Hi paddu.
please check out the link mentioned below,this will help u.
How to Refresh data on ALV tree
Regards
Theres -
Dear All
I written a program using ALV in which i can get only 10 characters but i want all characters in the field what settings i should do in ALV or in anything else.
Thanks and Regards
Sureshhi Vasu
thanks for ur ealist reply
my coding following
wht i can change
REPORT z_gldetail_withoutpo LINE-SIZE 175 LINE-COUNT 30.
TABLES: ekko,
ekpo,
rbkp,
lfa1,
rseg,
skat,
bkpf,
bseg.
TYPE-POOLS slis.
DATA: BEGIN OF it_lfa OCCURS 0,
lifnr LIKE lfa1-lifnr,
name1 LIKE lfa1-name1,
ORT01 like lfa1-ORT01,
STRAS like lfa1-STRAS,
END OF it_lfa.
data: begin of it_cin occurs 0,
lifnr LIKE J_1IMOVEND-lifnr,
J_1ICSTNO like J_1IMOVEND-J_1ICSTNO,
J_1ILSTNO LIKE J_1IMOVEND-J_1ILSTNO,
end of it_cin.
for update all data - ALV use
data: begin of FinnalTbl,
belnr like bkpf-belnr,
bldat like bkpf-bldat,
bldat(10) type c ,
xblnr like bkpf-xblnr,
wrbtr like bseg-wrbtr,
dmbtr like bseg-dmbtr,
lifnr like bseg-lifnr,
MENGE like bseg-MENGE, qty
l_MEINS like bseg-MEINS, uom
land1 like LFA1-LAND1,
regio like LFA1-REGIO,
stceg like LFA1-stceg,
NAME1 like lfa1-NAME1,
count(5),
perval type p decimals 2,
vatamt type p decimals 2,
ttlval type p decimals 2,
linevalue type p decimals 2,
tgjAHR like bseg-gjAHR,
STRAS like LFA1-STRAS,
ORT01 like LFA1-ORT01,
BKTXT LIKE BKPF-BKTXT,
BilValue type p decimals 2,
VatPer type p decimals 2,
ZUONR like bseg-ZUONR, "Qty
holdtax type p decimals 2,
docdate like bkpf-bldat,
end of FinnalTbl.
DATA: fieldcatalog TYPE slis_t_fieldcat_alv WITH HEADER LINE,
ct_catalog TYPE slis_t_fieldcat_alv WITH HEADER LINE,
gd_tab_group TYPE slis_t_sp_group_alv,
gd_layout TYPE slis_layout_alv,
gd_repid LIKE sy-repid.
for new ALV
*TYPE-POOLS slis.
*DATA: afield TYPE slis_fieldcat_alv.
*DATA: fieldcat TYPE slis_t_fieldcat_alv.
*DATA: gd_layout TYPE slis_layout_alv.
DATA : BEGIN OF wa_ven_inv,
l_belnr like bkpf-belnr,
lifnr LIKE rbkp-lifnr,
name1 LIKE lfa1-name1,
ORT01 like lfa1-ORT01,
STRAS like lfa1-STRAS,
J_1ICSTNO like J_1IMOVEND-J_1ICSTNO,
J_1ILSTNO LIKE J_1IMOVEND-J_1ILSTNO,
kalsb like tmkkt-kalsb,
l_budat like bkpf-budat,
l_bldat like bkpf-bldat,
l_xblnr like bkpf-xblnr,
l_menge LIKE bseg-menge,
l_lifnr like bseg-lifnr,
l_hkont like bseg-hkont,
l_sgtxt like bseg-sgtxt,
l_wrbtr like bseg-wrbtr,
l_dmbtr like bseg-dmbtr,
l_matnr like bseg-matnr,
l_pswsl like bseg-pswsl,
l_vbel2 like bseg-vbel2,
l_MEINS like bseg-MEINS,
gldsc like skat-txt50,
ll_dmbtr like bseg-dmbtr,
ll_per type p decimals 2,
TotalV like bseg-dmbtr,
l_tmpcountryc like LFA1-LAND1,
l_tmpregc like LFA1-REGIO,
l_STCEG like LFA1-STCEG,
l_tmpcountry like T005T-LANDX50,
l_tmpreg like T005U-BEZEI,
l_tmpunitmea like rseg-BSTME,
l_BKTXT like bkpf-BKTXT,
l_GSBER like bseg-GSBER,
qsskz like bseg-qsskz, "With Holding Tax
END OF wa_ven_inv.
data: begin of wa_bkpf,
l_belnr like bkpf-belnr,
l_budat like bkpf-budat,
l_bldat like bkpf-bldat,
l_xblnr like bkpf-xblnr,
l_hkont like bseg-hkont,
l_sgtxt like bseg-sgtxt,
l_wrbtr like bseg-wrbtr,
l_dmbtr like bseg-dmbtr,
l_lifnr like bseg-lifnr,
l_matnr like bseg-matnr,
l_MENGE like bseg-MENGE,
l_pswsl like bseg-pswsl,
l_shkzg like bseg-shkzg,
l_bschl like bseg-bschl,
l_buzid like bseg-buzid,
l_vbel2 like bseg-vbel2,
l_MEINS like bseg-MEINS,
l_tmpcountryc like LFA1-LAND1,
l_tmpregc like LFA1-REGIO,
l_tmpcountry like T005T-LANDX50,
l_tmpreg like T005U-BEZEI,
l_tmpunitmea like rseg-BSTME,
l_BKTXT like bkpf-BKTXT,
l_GSBER like bseg-GSBER,
qsskz like bseg-qsskz, "With Holding Tax
tmpsisn like bseg-SHKZG,
tmpsisn1 like bseg-SHKZG,
postkey like bseg-bschl,
docdate(10) type c,
end of wa_bkpf.
data : gd_awkey type awkey,
gltxt type skat-txt50,
vetxt type lfa1-name1,
t_kalsk like lfm1-kalsk,
t_KALSB like tmkkt-kalsb,
podat(10),
glpdt(10),
glddt(10),
accno(15),
accyr(4),
tmpGlNum(15),
docvl type p decimals 2,
venam like bseg-lifnr,
gltot(15) type p decimals 2,
tebeln like bseg-ebeln,
tebelp like bseg-ebelp,
tgjahr like bseg-gjahr,
tbelnr like bkpf-belnr,
invnum like rbkp-belnr,
CSTNO like J_1IMOVEND-J_1ICSTNO,
LSTNO LIKE J_1IMOVEND-J_1ILSTNO,
HDMBTR like bseg-DMBTR,
balDMBTR like bseg-dmbtr,
peramt type p decimals 2,
Pamt type p decimals 2,
MENGE type bseg-MENGE,
MEINS type bseg-MEINS,
TMENGE type bseg-MENGE,
count(5),
VatPer type p decimals 2,
tempPer type p decimals 2,
perval type p decimals 2,
vatamt type p decimals 2,
ttlval type p decimals 2,
tmpsisn like bseg-SHKZG,
tmpsisn1 like bseg-SHKZG,
linevalue type p decimals 2.
DATA: it_sortcat TYPE slis_sortinfo_alv OCCURS 1,
wa_sort LIKE LINE OF it_sortcat.
data: it_bkpf like bkpf occurs 0 with header line,
it_bseg like bseg occurs 0 with header line,
it_rbkp like rbkp occurs 0 with header line.
DATA: in_bkpf like wa_bkpf occurs 0 with header line,
it_ven_inv LIKE wa_ven_inv OCCURS 0 WITH HEADER LINE,
finaltbl LIKE FinnalTbl OCCURS 0 WITH HEADER LINE.
SELECTION-SCREEN : BEGIN OF BLOCK B WITH FRAME TITLE text-002.
parameters : ekorg like LFM1-ekorg obligatory,
GJAHR like BKPF-GJAHR obligatory.
select-options : Dtype for RBKP-BLART.
SELECTION-SCREEN : END OF BLOCK B.
selection-screen : begin of block D with frame title text-004.
parameters : glnum like skat-saknr obligatory.
select-options : gldat for BKPF-budat,
dodat for BKPF-BLDAT.
selection-screen : end of block D.
tmpGlNum = glnum.
START-OF-SELECTION.
tmpglnum = tmpglnum+4(6).
count = 0.
Main Loop (Header Table) - ForGet Account Doc No
select belnr budat bldat xblnr BKTXT from bkpf
into (in_bkpf-l_belnr, in_bkpf-l_budat, in_bkpf-l_bldat,
in_bkpf-l_xblnr,in_bkpf-l_BKTXT)
where blart in dtype and bukrs eq 'NCCP'
and budat in gldat and BLDAT in dodat and
gjahr eq GJAHR order by belnr.
clear: vatamt, linevalue, in_bkpf-l_dmbtr, Finaltbl-BilValue,
finaltbl-holdtax, in_bkpf-l_lifnr.
Sub Loop - for get Values in Item Table
bschl is posting key
31 - for get bill value - RE & KR Regular entry
21 - for get bill value - RE Reverse entry
22 - for get bill value - KA (this KA is reversed entry key for KR.)
select GJAHR hkont menge dmbtr BUZID shkzg qsskz from bseg
into (tgjAHR, in_bkpf-l_hkont, in_bkpf-l_menge,
in_bkpf-l_dmbtr, in_bkpf-l_BUZID,
in_bkpf-l_shkzg, in_bkpf-qsskz)
where belnr = in_bkpf-l_belnr and
bukrs eq 'NCCP' and gjahr eq gjahr and
qsskz eq space and
( bschl ne '31' and bschl ne '21' and bschl ne '22' ).
for give negative symbol
if in_bkpf-l_shkzg = 'S'.
it_ven_inv-l_dmbtr = in_bkpf-l_dmbtr.
endif.
if in_bkpf-l_shkzg = 'H'.
it_ven_inv-l_dmbtr = - in_bkpf-l_dmbtr.
endif.
*for convert GL Account number in 6 charcter
in_bkpf-l_hkont = in_bkpf-l_hkont+4(6).
for get VAT & Line Value
if in_bkpf-l_hkont = tmpglnum.
vatamt = vatamt + it_ven_inv-l_dmbtr.
elseif in_bkpf-l_hkont ne tmpglnum.
linevalue = linevalue + it_ven_inv-l_dmbtr.
endif.
*for get withholding tax amount
*Sub Loop1A - For get Bill total value + withholding tax value
select dmbtr SHKZG from bseg into
(finaltbl-holdtax, in_bkpf-tmpsisn)
where belnr = in_bkpf-l_belnr and
bukrs eq 'NCCP' and gjahr eq gjahr and
qsskz ne space and
( bschl ne '31' or bschl ne '21' or bschl ne '22' ).
for give negative symbol to withholding tax Value
for display bill value in positive value here sigh changed
if in_bkpf-tmpsisn = 'S'.
Finaltbl-holdtax = - Finaltbl-holdtax .
endif.
if in_bkpf-tmpsisn = 'H'.
Finaltbl-holdtax = Finaltbl-holdtax .
endif.
endselect.
*sub Loop1A Ended
endselect.
*Sub Loop Ended
Sub Loop1 - For get Vendor Code
clear in_bkpf-postkey .
clear in_bkpf-l_lifnr.
select bschl from bseg into in_bkpf-postkey
where belnr = in_bkpf-l_belnr and bukrs eq 'NCCP'
and gjahr eq gjahr .
if in_bkpf-postkey = '31'.
select lifnr into in_bkpf-l_lifnr from bseg where
bschl = '31' and belnr = in_bkpf-l_belnr .
endselect.
endif.
if in_bkpf-postkey = '21'.
select lifnr into in_bkpf-l_lifnr from bseg where
bschl = '21' and belnr = in_bkpf-l_belnr .
endselect.
endif.
if in_bkpf-postkey = '22'.
select lifnr into in_bkpf-l_lifnr from bseg where
bschl = '22' and belnr = in_bkpf-l_belnr .
endselect.
endif.
endselect.
select lifnr into in_bkpf-l_lifnr from bseg where
( bschl = '31' or bschl = '21' or bschl = '22' )
and belnr = in_bkpf-l_belnr .
*Sub Loop2 - for select vendor details
if in_bkpf-l_lifnr ne space.
select regio stceg land1 NAME1 ORT01 STRAS into
(FinalTbl-regio, FinalTbl-stceg, FinalTbl-land1,
FinalTbl-name1, FinalTbl-ORT01, FinalTbl-STRAS)
from lfa1 where lifnr = in_bkpf-l_lifnr.
for get VAT percentage, VAT and Line Value Total
if vatamt ne 0 and linevalue ne 0 .
perval = vatamt / linevalue * 100.
ttlval = vatamt + linevalue.
endif .
*assign VAT Percentage 4 & 12.5 to check 100% value for VAT.
if perval >= 2 and perval <= 6.
tempPer = 4.
endif .
if perval >= 10 and perval <= 14 .
tempPer = 125 / 10.
endif .
if vatamt ne 0 and tempPer ne 0.
vatper = vatamt * ( 100 / tempPer ).
endif.
endselect.
endif.
Sub Loop2 Ended
endselect.
*Sub Loop1 Ended
*Sub Loop3 - For get Bill Value -
select dmbtr ZUONR SHKZG from bseg into
(Finaltbl-BilValue, Finaltbl-ZUONR, in_bkpf-tmpsisn1)
where belnr = in_bkpf-l_belnr and bukrs eq 'NCCP'
and gjahr eq gjahr and
( bschl = '31' or bschl = '21' or bschl = '22' ).
for assign negative symbol to Bill Value
for display bill value in positive value here sigh changed
if in_bkpf-tmpsisn1 = 'S'.
Finaltbl-BilValue = - Finaltbl-BilValue .
endif.
if in_bkpf-tmpsisn1 = 'H'.
Finaltbl-BilValue = Finaltbl-BilValue .
endif.
endselect.
*sub Loop3 Ended
Finaltbl-BilValue = Finaltbl-BilValue + Finaltbl-holdtax.
concatenate in_bkpf-l_bldat+6(2) '/'
in_bkpf-l_bldat+4(2) '/'
in_bkpf-l_bldat(4) into wa_bkpf-docdate.
*Move To Temp Table
if vatamt ne 0. " for avoid 0 values
count = count + 1.
FinalTbl-count = count.
FinalTbl-belnr = in_bkpf-l_belnr.
FinalTbl-bldat = in_bkpf-l_bldat.
FinalTbl-bldat = wa_bkpf-docdate.
FinalTbl-vatamt = vatamt.
FinalTbl-linevalue = linevalue.
FinalTbl-perval = perval.
FinalTbl-ttlval = ttlval.
FinalTbl-lifnr = in_bkpf-l_lifnr.
FinalTbl-regio = FinalTbl-regio.
FinalTbl-stceg = FinalTbl-stceg.
FinalTbl-land1 = FinalTbl-land1.
FinalTbl-name1 = FinalTbl-name1.
finaltbl-tgjAHR = tgjAHR.
FinalTbl-ORT01 = FinalTbl-ORT01.
FinalTbl-STRAS = FinalTbl-STRAS.
FinalTbl-xblnr = in_bkpf-l_xblnr.
FinalTbl-BKTXT = in_bkpf-l_BKTXT.
Finaltbl-BilValue = Finaltbl-BilValue.
Finaltbl-vatper = vatper.
Finaltbl-ZUONR = Finaltbl-ZUONR.
append finalTbl.
endif.
clear in_bkpf-l_lifnr.
clear FinalTbl-name1.
clear FinalTbl-STRAS.
clear: Finaltbl-BilValue.
endselect.
*Main Loop Ended
*coding for ALV
PERFORM build_sortcat.
PERFORM build_catalog.
PERFORM build_layout.
PERFORM disply.
*& Form TOP_OF_PAGE
LOGO
FORM TOP_OF_PAGE.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
I_LOGO = 'ENJOYSAP_LOGO'
IT_LIST_COMMENTARY = SLIS_EV_TOP_OF_PAGE.
ENDFORM.
*& Form Display_Header
text
FORM disply.
gd_repid = sy-repid.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = gd_repid
CHANGING
ct_fieldcat = ct_catalog[]
EXCEPTIONS
OTHERS = 3
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = gd_repid
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
is_layout = gd_layout
it_fieldcat = fieldcatalog[]
it_sort = it_sortcat[]
i_save = 'X'
TABLES
t_outtab = FinalTbl
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. "disply
*& Form build_layout
text
FORM build_layout.
gd_layout-no_input = 'X'.
gd_layout-colwidth_optimize = 'X'.
gd_layout-totals_text = 'Totals'(201).
ENDFORM. "build_layout
*& Form Build_catalog
text
FORM build_catalog.
fieldcatalog-col_pos = 1.
fieldcatalog-fieldname = 'COUNT'.
fieldcatalog-seltext_m = 'S.No'.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'LIFNR'.
fieldcatalog-seltext_m = 'Vendor Code'.
fieldcatalog-col_pos = 2.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'NAME1'.
fieldcatalog-seltext_m = 'Vendor Name'.
fieldcatalog-seltext_m = 'Vendor'.
lfa1
fieldcatalog-ref_fieldname = 'LFA1~NAME1'.
fieldcatalog-col_pos = 3.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'STRAS'.
fieldcatalog-seltext_m = 'Address'.
fieldcatalog-col_pos = 4.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'ORT01'.
fieldcatalog-seltext_m = 'Place'.
fieldcatalog-col_pos = 5.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'REGIO'.
fieldcatalog-seltext_m = 'State'.
fieldcatalog-col_pos = 6.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'STCEG'.
fieldcatalog-seltext_m = 'Tin No'.
fieldcatalog-col_pos = 7.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'LAND1'.
fieldcatalog-seltext_m = 'Country'.
fieldcatalog-col_pos = 8.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'BELNR'.
fieldcatalog-seltext_m = 'Doc Acc No'.
fieldcatalog-col_pos = 9.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'BLDAT'.
fieldcatalog-seltext_m = 'Doc Date'.
fieldcatalog-col_pos = 10.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'XBLNR'.
fieldcatalog-seltext_m = 'Doc Ref No'.
fieldcatalog-col_pos = 11.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'BKTXT'.
fieldcatalog-seltext_m = 'Material'.
fieldcatalog-col_pos = 12.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'ZUONR'.
fieldcatalog-seltext_m = 'Quantity/Uom'.
fieldcatalog-col_pos = 13.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'VATAMT'.
fieldcatalog-seltext_m = 'VAT'.
fieldcatalog-col_pos = 14.
fieldcatalog-do_sum = 'X'.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'LINEVALUE'.
fieldcatalog-seltext_m = 'Value'.
fieldcatalog-col_pos = 15.
fieldcatalog-do_sum = 'X'.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'PERVAL'.
fieldcatalog-seltext_m = '%'.
fieldcatalog-col_pos = 16.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'TTLVAL'.
fieldcatalog-seltext_m = 'Total Value'.
fieldcatalog-col_pos = 17.
fieldcatalog-do_sum = 'X'.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'BILVALUE'.
fieldcatalog-seltext_m = 'Bill Value'.
fieldcatalog-col_pos = 18.
fieldcatalog-do_sum = 'X'.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'VATPER'.
fieldcatalog-seltext_m = '100% Value'.
fieldcatalog-col_pos = 19.
fieldcatalog-do_sum = 'X'.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
ENDFORM. "Build_catalog
*& Form build_sortcat
text
FORM build_sortcat .
ENDFORM. " build_sortcat
*& Form USER_COMMAND
text
-->GUCOMM text
-->G_SELFIELD text
FORM user_command USING
gucomm TYPE sy-ucomm g_selfield TYPE slis_selfield.
READ TABLE FinalTbl INTO FinalTbl INDEX
g_selfield-tabindex.
case g_selfield-fieldname.
when 'BELNR'.
SET PARAMETER ID 'BLN' FIELD FinalTbl-belnr.
SET PARAMETER ID 'BUK' FIELD 'NCCP'.
SET PARAMETER ID 'GJR' FIELD FinalTbl-tGJAHR.
CALL TRANSACTION 'FB03' AND SKIP FIRST SCREEN.
ENDCASE.
ENDFORM. "USER_COMMAND -
Editable ALV -- OO -- Changed data capture
Hi,
I'm using an editable ALV to display the output. Output has a field for the user to enter comments. When the user enters the comments and presses "ENTER" key or clicks somewhere else on the ALV itself, the event DATA_CHANGED or DATA_CHANGED_FINISHED gets triggered and I'm able to capture the changed data and update the DB table.(I have a "SAVE" button on the menu bar which when pressed will update the ALV values into DB table.)
However, I need to capture this changed data even if the user does not press the "ENTER" key or clicks somewhere else on the ALV, but just presses the "SAVE" button. Please let me know if there is any way to do this.
Thanks,
Raj.Hi,
in your program check the user-command if 'SAVE' then write the following code in it
"Call the method check_changed_data to update the internal table with changed data.
DATA: lv_valid TYPE xfeld,
lv_refresh TYPE xfeld.
CALL METHOD gv_alv_grid->check_changed_data
IMPORTING
e_valid = lv_valid
CHANGING
c_refresh = lv_refresh.
" to refresh alv
CALL METHOD gv_alv_grid->refresh_table_display
EXCEPTIONS
finished = 1
OTHERS = 2.
by this way it the internal table will get the changed data and then you can update it in the DB and also after updating show the ALV since it is refreshed it will now show the changed data.
Hope it helps you,
Regards,
Abhijit G. Borkar -
Update the Billing orders after display/ modifiy in the Editable ALV
Hi Experts,
I have created one Editable ALV to display theBilling order with BP details,
Once user get the ALV output he can modify the content and same will be updated once he hits UPDATE button.
my requirement is after user hits the UPDATE button a background should be created and update of BO should happen also user user should able to see the status by checking the SPOOL.
currently i am using the FM crm_order_maintain to update, kindly guide me how to process this step in background for all the entries which are selected in ALV by user.
i think i can use SUBMIT with JOB_OPEN and JOB_CLOSE, but i need some same code & guidance.
Thanks in Advance.
Regards,
Pradeepproblem solved
Maybe you are looking for
-
Operational Issues vs Operator Error
The concept of the Android operational system got many rave reviews, and many positive comments regarding the many things an android phone can achieve. However, as a functionally smartphone to use in business to organize, file and utilize contacts,
-
How to Run a Report from Desktop in Oracle 10g without using Web
Hi Friends, I want to run a report from desktop (report which is developed in oracle report developer 10g), for that i have created shortcut. But when i double click on that shortcut it gives me followig error "Report name, database connection, and r
-
Re-formatting my Macbook Pro's System Drive.
I have upgraded to a new Mac Mini, which is a remarkable machine. Prior to that, I was running with a 2006 Macbook Pro and in the last couple of years, annoying things started to happen. Those that became a major annoyance were: Unable to write to th
-
MS SQL Server 2000 - Oracle 8.1.7 nvarchar problem.
Hello all, I move my database from MS SQL server 2000 to the Oracle 8.1.7 (W2K platform) and note, that Oracle Migration Workbench (ver 9.2.0.1.2 build 20020910) create wrong SQL Server model. In my SQL Server table I have one column with nvarchar ty
-
I just purchased a Marshall MS-2 micro amp to record electric guitar into Garageband. I plugged the headphone out into the line in on the Mac and nothing. No green level lights. I got no sound at all. I have used my regular Fender practice amp to rec