Group Quantity field in ALV GRID
hi all,
how to group the Quantity fileds in ALV grid output here fldcat-group = 'X' is not useful.
ex : in my for a order qty column values are 10.00,10.00,10.00,10.00 for a given sales order then i have to display only one 10.00 instead of 4 times.
any idea..?
Regards
Ashok P
Hi Ashok,
If can you check this using Onchange of in a loop statement.
Regards,
Prashanth
Similar Messages
-
Regarding Editable Quantity field in ALV Grid
Hi Experts,
I need your advice in this 2 scenarios.
1.I have a scenario where quantity field in output is editable and the user wants the quantity field printed without thousand separator. If i take a char field and display the field is editable then user may mistakenly type a,bcd...z/ special characters which it should not capture. Is there any char data type data element which accepts only integers. Because after that i need to save that value in z database table quantity field.
2. when there i raised an error message after validation of that editable field in alv output(by events), the user wants all other rows in that grid as uneditable except the row which has got error till this error is solved. Is this possible. If yes how.
Please share your valuable suggestions.Hi abilash n
as in dictionary, all quantity fields should have a reference to the unit field which then defines the number of decimals.
The rest is done automatically as long as you do it standard way. In field catalog you have to set the fcat-qfieldname to the name of the field that has the unit.
If you do so, also totals will be grouped by unit.
SAP has really done a great thing by inventing units for quantities (and currency keys for currency amounts). Only developers do not understand and thus refuse to use it.
Regards,
Clemens -
I am using KWMENG data element in my ALV grid which is a quantity field. In normal dialog programming this field does not allows entering characters in editable cells. But in ALV grid I am not able to restrict it from entering characters.
Eg: In VA01 if we try to enter any character "ABC...Z" then it wouldn't be typed in the screen. But when using the same data element in ALV grid iot allows to enter alphanumeric values. Since it's a quantity field so character value gives a short dump. I know I can restrict the dump by using "NA" in comparing string but I want to knw is there a way by which I restrict character field entry in alv grid, the same way this field works in VA01. I checked with a simple dialog prog and in that also it doesn not allows character typing in editable fields.simple solution
mention the ref_fieldname and ref_tablename in the fieldcatalog for that column.
ex:
fieldcat-ref_fieldname = 'KWMENG'.
fieldcat-ref_tablename = 'VBAP'. -
How can we sort up currency field in alv grid??
Hi GUrus,
Can any one suggest me how to sort the currency field in alv grid...Please help me out of this issue..
Thanks in advance!!!
regards,
Kranthi.hii,
SAP provides a set of ALV (ABAP List Viewer) & function modules, which can be used to enhance the readability and functionality of any report output.
ALV is a flexible tool used for displaying lists.The tool provides common list functions & can be enhanced by self-defined options.
so u will get the option for sorting in your alv report.
Thanks -
Total for a Numeric field in ALV Grid display
Hi all,
I am not getting the Total for a Numeric field in ALV Grid output. What might be the problem.
Regards,
Balavardhan.KCheck this code for subtotals and totals..
REPORT ZYFI_REPT007
NO STANDARD PAGE HEADING
LINE-SIZE 300
LINE-COUNT 50
MESSAGE-ID ZYFI.
TABLES : COOI, " Commitments Management: Line Items
LFA1, " Vendor master (general section)
VBEP,
RKPLN.
TABLE TYPES AND INTERNAL TABLES *
DATA : BEGIN OF TYP_COOI ,
OBJNR LIKE COOI-OBJNR,
SAKTO LIKE COOI-SAKTO,
MEGBTR LIKE COOI-MEGBTR,
MEINH LIKE COOI-MEINH,
WKGBTR LIKE COOI-WKGBTR,
REFBN LIKE COOI-REFBN,
RFPOS LIKE COOI-RFPOS,
SGTXT LIKE COOI-SGTXT,
BUDAT LIKE COOI-BUDAT,
LIFNR LIKE COOI-LIFNR,
END OF TYP_COOI.
DATA : BEGIN OF TYP_LFA1 ,
LIFNR LIKE LFA1-LIFNR,
NAME1 LIKE LFA1-NAME1,
END OF TYP_LFA1.
DATA : BEGIN OF IT_OUTTAB OCCURS 0,
OBJNR LIKE COOI-OBJNR,
SAKTO LIKE COOI-SAKTO,
MEGBTR LIKE COOI-MEGBTR,
MEINH LIKE COOI-MEINH,
WKGBTR LIKE COOI-WKGBTR,
REFBN LIKE COOI-REFBN,
RFPOS LIKE COOI-RFPOS,
SGTXT LIKE COOI-SGTXT,
BUDAT LIKE COOI-BUDAT,
LIFNR LIKE COOI-LIFNR,
NAME1 LIKE LFA1-NAME1,
END OF IT_OUTTAB.
DATA : IT_COOI LIKE TYP_COOI OCCURS 0 WITH HEADER LINE,
IT_LFA1 LIKE TYP_LFA1 OCCURS 0 WITH HEADER LINE.
*-- ALV Declarations
TYPE-POOLS SLIS.
DATA: IT_EVENTS TYPE SLIS_T_EVENT,
GS_EVENT TYPE SLIS_ALV_EVENT,
wa_fldcat type slis_fieldcat_alv.
DATA: S_LAYOUT TYPE SLIS_LAYOUT_ALV,
GT_PRINT TYPE SLIS_PRINT_ALV.
DATA: IT_FLDCAT TYPE SLIS_T_FIELDCAT_ALV.
DATA: IT_SORT TYPE SLIS_T_SORTINFO_ALV.
DATA: V_REPID LIKE SY-REPID.
SELECTION SCREEN *
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS : S_KOKRS FOR COOI-KOKRS NO-EXTENSION NO INTERVALS,
" Controlling Area
S_BUKRS FOR COOI-BUKRS NO-EXTENSION NO INTERVALS,
" Company code
S_GJAHR FOR COOI-GJAHR NO-EXTENSION NO INTERVALS,
" Fiscal Year
S_OBJNR FOR RKPLN-AUFNR MATCHCODE OBJECT ORDE,
" Internal order
S_SAKTO FOR COOI-SAKTO MATCHCODE OBJECT KART,
" Cost Element
S_BUDAT FOR COOI-BUDAT, " Debit Date
S_LIFNR FOR COOI-LIFNR. " Vendor
SELECTION-SCREEN END OF BLOCK B1.
S T A R T O F S E L E C T I O N *
START-OF-SELECTION.
*-- Read data
PERFORM GET_DATA.
E N D O F S E L E C T I O N *
END-OF-SELECTION.
*-- Process the data and prepare the output data
PERFORM CALCULATE_FINAL_INFO.
*--Display Report output
PERFORM DISPLAY_REPORT.
FORM CALCULATE_FINAL_INFO *
Process the data and prepare final internal table *
FORM CALCULATE_FINAL_INFO.
DATA : L_OBJNR LIKE COOI-OBJNR.
SORT IT_LFA1 BY LIFNR.
DELETE ADJACENT DUPLICATES FROM IT_LFA1 COMPARING LIFNR.
LOOP AT IT_COOI.
L_OBJNR = IT_COOI-OBJNR+2(20).
SHIFT L_OBJNR LEFT DELETING LEADING '0'.
IF L_OBJNR IN S_OBJNR.
READ TABLE IT_LFA1 WITH KEY LIFNR = IT_COOI-LIFNR.
IF SY-SUBRC EQ 0.
IT_OUTTAB-NAME1 = IT_LFA1-NAME1.
ENDIF.
MOVE-CORRESPONDING IT_COOI TO IT_OUTTAB.
CLEAR IT_OUTTAB-OBJNR.
IT_OUTTAB-OBJNR = L_OBJNR.
APPEND IT_OUTTAB.
CLEAR IT_OUTTAB.
CLEAR IT_LFA1.
CLEAR L_OBJNR.
ENDIF.
ENDLOOP.
ENDFORM.
*& Form GET_DATA
Fetch the Data from the table COOI and LFA1
FORM GET_DATA.
SELECT OBJNR
SAKTO
MEGBTR
MEINH
WKGBTR
REFBN
RFPOS
SGTXT
BUDAT
LIFNR
FROM COOI
INTO TABLE IT_COOI
WHERE BUDAT IN S_BUDAT
AND LIFNR IN S_LIFNR
AND KOKRS IN S_KOKRS
AND BUKRS IN S_BUKRS
AND GJAHR IN S_GJAHR
AND SAKTO IN S_SAKTO.
IF SY-SUBRC EQ 0 .
Get the Vendor name from LFA1
SELECT LIFNR
NAME1
FROM LFA1
INTO TABLE IT_LFA1
FOR ALL ENTRIES IN IT_COOI
WHERE LIFNR EQ IT_COOI-LIFNR.
ELSE.
MESSAGE I999 WITH TEXT-013.
ENDIF.
ENDFORM. " GET_DATA
*& Form DISPLAY_REPORT
Display the output
FORM DISPLAY_REPORT.
PERFORM BUILD_CATALOG.
PERFORM FRM_PREPARE_EVENT_LIST TABLES IT_EVENTS.
IF NOT IT_OUTTAB[] IS INITIAL.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = V_REPID
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
IT_FIELDCAT = IT_FLDCAT
IT_SORT = IT_SORT
IT_EVENTS = IT_EVENTS
TABLES
T_OUTTAB = IT_OUTTAB
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
ELSE.
MESSAGE I999 WITH TEXT-013.
ENDIF.
ENDFORM. " DISPLAY_REPORT
*& Form BUILD_CATALOG
Build the Field catalog for the ALV Report
FORM BUILD_CATALOG.
DATA: V_INDEX LIKE SY-TABIX.
V_REPID = SY-REPID.
DATA: LS_SORT TYPE SLIS_SORTINFO_ALV.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = V_REPID
I_INTERNAL_TABNAME = 'IT_OUTTAB'
I_INCLNAME = V_REPID
CHANGING
CT_FIELDCAT = IT_FLDCAT
EXCEPTIONS
INCONSISTENT_INTERFACE = 1
PROGRAM_ERROR = 2
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.
READ TABLE IT_FLDCAT WITH KEY FIELDNAME = 'WKGBTR'
TABNAME = 'IT_OUTTAB' INTO WA_FLDCAT.
IF SY-SUBRC EQ 0.
WA_FLDCAT-DO_SUM = 'X'.
MODIFY IT_FLDCAT FROM WA_FLDCAT INDEX SY-TABIX.
ENDIF.
READ TABLE IT_FLDCAT WITH KEY FIELDNAME = 'OBJNR'
TABNAME = 'IT_OUTTAB' INTO WA_FLDCAT.
IF SY-SUBRC EQ 0.
WA_FLDCAT-SELTEXT_L = 'Order'.
WA_FLDCAT-COL_POS = 1.
WA_FLDCAT-DDICTXT = 'L'.
MODIFY IT_FLDCAT FROM WA_FLDCAT INDEX SY-TABIX.
ENDIF.
LS_SORT-FIELDNAME = 'OBJNR'.
LS_SORT-SPOS = 1.
LS_SORT-UP = 'X'.
LS_SORT-SUBTOT = 'X'.
APPEND LS_SORT TO IT_SORT.
ENDFORM. " BUILD_CATALOG
*& Form FRM_PREPARE_EVENT_LIST
Build the Events
FORM FRM_PREPARE_EVENT_LIST TABLES IT_EVENTS TYPE SLIS_T_EVENT.
CLEAR GS_EVENT.
GS_EVENT-NAME = SLIS_EV_TOP_OF_PAGE.
GS_EVENT-FORM = 'TOP_OF_PAGE_REPORT'.
APPEND GS_EVENT TO IT_EVENTS.
ENDFORM. " FRM_PREPARE_EVENT_LIST
TOP OF PAGE
FORM TOP_OF_PAGE_REPORT.
CALL FUNCTION 'Z_YREPORT_HEADER'
EXPORTING
DL_TITLE = SY-TITLE
DL_REPID = SY-CPROG
DL_LINSZ = SY-LINSZ
EXCEPTIONS
OTHERS = 1.
ENDFORM. " FRM_TOP_OF_PAGE_REPORT
*& Form USER_COMMAND
Drill Down Functionality to Call the Transaction ME23
FORM USER_COMMAND USING P_UCOMM LIKE SY-UCOMM
P_SELFIELD TYPE SLIS_SELFIELD.
DATA : L_INDEX LIKE SY-INDEX,
L_REFBN LIKE COOI-REFBN.
L_INDEX = P_SELFIELD-TABINDEX. " holds the selected table index
CLEAR L_REFBN.
CASE P_UCOMM.
*-- On Double Click
WHEN '&IC1'.
CLEAR L_REFBN.
*-- Read the Current Line
READ TABLE IT_OUTTAB INDEX L_INDEX.
IF SY-SUBRC EQ 0.
L_REFBN = IT_OUTTAB-REFBN.
IF NOT L_REFBN IS INITIAL.
*-- Set the BES Paramater Id to the Current line Purchase Order Number
SET PARAMETER ID 'BES' FIELD L_REFBN.
*-- Call the Transaction Purchase Order Display with the above PO Number
CALL TRANSACTION 'ME23' AND SKIP FIRST SCREEN.
ENDIF.
ELSE.
MESSAGE E999 WITH TEXT-014.
ENDIF.
ENDCASE.
ENDFORM. " USER_COMMAND -
Add List box for one field in ALV GRID
Hi All,
I need to add drop down list box for one field in ALV Grid.
If any body knows, please help.
Thanks in advance.
Regards
MangleshHi,
Here is the ex where i have used for date parameter in the sel screen
type-pools: vrm.
data: name type vrm_id,
list type vrm_values,
value like line of list.
parameters : p_date like p_date2
as listbox visible length 15.
at selection-screen output.
name = 'P_DATE'.
value-key = '1'.
value-text = 'Today'.
append value to list.
value-key = '2'.
value-text = 'Last 7 days'.
append value to list.
value-key = '3'.
value-text = 'Last 30 days'.
append value to list.
value-key = '4'.
value-text = 'Last 90 days'.
append value to list.
value-key = '5'.
value-text = 'Last year'.
append value to list.
Call the ''VRM_SET_VALUES' to display the values in Listbox
call function 'VRM_SET_VALUES'
exporting
id = name
values = list.
at selection-screen.
if sy-ucomm = 'CLI1'.
sscrfields-ucomm = 'ONLI'(001).
endif.
if p_date = '1'.
p_date11 = sy-datum .
elseif p_date = '2'.
p_date11 = ( sy-datum - 7 ).
elseif p_date = '3'.
p_date11 = ( sy-datum - 30 ).
elseif p_date = '4'.
p_date11 = ( sy-datum - 90 ).
elseif p_date = '5'.
p_date11 = ( sy-datum - 365 ).
endif.
Hope this helps u..
Please reward points if useful.
Regards,
Sreenivas -
F4 - Help for field in ALV Grid Output
Hi,
I generated a report which gives output in ALV Grid output.
In the output, 1 of the field is editable.Here, for this field I need to have my own F4-Help.
I think the procedure to be followed is:--
Create a Search Help in SE11.
Link the Search Help to the editable field.
Please let me know if its the correct procedure.
I f yes, how can I link user defined Search Help to the editable field?
Thanks,
Shivaa........Hi siva,
you can also do that way.
while filling the fieldcatalog use the parameter F4AVAILABL
for more info check
F4 help in ALV Grid...
f4 help for a field in alv grid
hope it helps you
Thanks!
Edited by: Prasanth on Mar 6, 2009 3:59 PM -
F4 help for field in ALV grid control (using ABAP objects)
Hi All,
I have created a z table ZTAB which is a master table( with single column X). field X should be a input field in ALV Grid through F4 key. I have created searchelp and assigned it to data element of X feild, and in domain level I have assigned ZTAB as value table.
And in ALV field catalog wrote ls_fcat-ref_tab = 'ZTAB'. But still I'm not getting list of values when I press F4.
Can anyone help me to understand what is missing here? How to call standardard F4 help?
This is very urgent..
Regards
Jaker.u can refer to this standard program :BCALV_EDIT_08
also u wont get the list of values automatically..
declare a class :
CLASS LCL_EVENT_HANDLER DEFINITION.
PUBLIC SECTION.
METHODS :
handle_on_f4 for event onf4 of cl_gui_alv_grid
importing e_fieldname es_row_no er_event_data,
ENDCLASS. "LCL_EVENT_HANDLER
implementation of class
here u pass ur internal table what u want to display as pop up for f4 help.
*& Class (Implementation) LCL_EVENT_HANDLER
Text
CLASS LCL_EVENT_HANDLER IMPLEMENTATION.
*Method to handle F4 click.
Method handle_on_f4.
Function to create a popup and passing the values of internal table in it.
CALL FUNCTION 'POPUP_WITH_TABLE'
EXPORTING
ENDPOS_COL = 60
ENDPOS_ROW = 60
STARTPOS_COL = 5
STARTPOS_ROW = 5
TITLETEXT = 'pop up'
IMPORTING
CHOICE = wa_grid-zfield
TABLES
VALUETAB = ITAB
EXCEPTIONS
BREAK_OFF = 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.
RETURN.
ENDIF.
endmethod. "handle_on_f4
ENDCLASS. "LCL_EVENT_HANDLER
hope this gives u some idea. -
How to make a field of ALV Grid to use a Search Help?
Hi;
I have a ALV grid with a field catalog. Say the field is 'USR000'.
F4availabl = 'X' . for the field in the field catalog.
I have prepared search help named ZEV_PROTYPE that uses tha table ZEV_PROTYPES.(two fields in the table :ProType and Text).
Is it possible to make the field in ALV grid to use this search help if F4 is pressed on the field. ?
Which structure of the ALV must be used for that ? Is it Field Catalog ?
Would you please help me ?
erk.Hi,
If you have a Z data element and the search help is attached to it, you can just give the reference table and field in the field catalog for the editable ALV field, and the search help should appear.
Regards,
Sagar -
How to add F1 help for a field on ALV grid
Hi All,
When we execute a program, the output is displayed using ALV grid.
on the ALV grid, if we press F1 on a field, it should popup the help document.
How to add F1 help for a field on ALV grid.
Thank you all in advance.fill field LVC_S_FCAT-ROLLNAME of your fieldcatalog in method SET_TABLE_FOR_FIRST_DISPLAY
A. -
F4 help for a field in alv grid
hello friends,
i want to make one of the fields of my alv grid as editable and i want f4 help option also available for it, can v do it, if yes how??? pls explain through code
thankscheck this example
REPORT ztest440.
TABLES : mara.
TYPES: BEGIN OF t_mara,
matnr TYPE mara-matnr,
lvorm TYPE mara-lvorm,
mtart TYPE mara-mtart,
mbrsh TYPE mara-mbrsh,
matkl TYPE mara-matkl,
meins TYPE mara-meins,
brgew TYPE mara-brgew,
ntgew TYPE mara-ntgew,
gewei TYPE mara-gewei,
END OF t_mara.
TYPES: BEGIN OF t_equk,
matnr TYPE equk-matnr,
werks TYPE equk-werks,
bdatu TYPE equk-bdatu,
vdatu TYPE equk-vdatu,
qunum TYPE equk-qunum,
END OF t_equk.
CLASS : lcl_alv_grid DEFINITION DEFERRED.
DATA : gi_mara TYPE STANDARD TABLE OF t_mara,
gi_equk TYPE STANDARD TABLE OF t_equk,
gs_mara TYPE t_mara,
gs_equk TYPE t_equk.
*-- Global data definitions for ALV
*--- ALV Grid instance reference
DATA : gw_alvgrid TYPE REF TO cl_gui_alv_grid,
gw_alvgrid1 TYPE REF TO cl_gui_alv_grid .
*--- Custom container instance reference
DATA gw_container TYPE REF TO cl_gui_custom_container.
DATA gw_event_handler TYPE REF TO lcl_alv_grid.
DATA gw_event_handler1 TYPE REF TO lcl_alv_grid.
DATA gw_container1 TYPE REF TO cl_gui_custom_container.
*--- Field catalog table
DATA : gi_fieldcat TYPE lvc_t_fcat,
gi_fieldcat1 TYPE lvc_t_fcat,
gs_fieldcat TYPE lvc_s_fcat,
gs_fieldcat1 TYPE lvc_s_fcat.
*--- Layout structure
DATA : gs_layout TYPE lvc_s_layo,
gs_layout1 TYPE lvc_s_layo.
CLASS lcl_alv_grid DEFINITION
CLASS lcl_alv_grid DEFINITION.
PUBLIC SECTION.
METHODS :
Handle_double_click
handle_double_click
FOR EVENT double_click OF cl_gui_alv_grid
IMPORTING e_row e_column,
Handle_double_click
handle_onf4
FOR EVENT onf4 OF cl_gui_alv_grid
IMPORTING e_fieldname,
Handle_double_click
handle_hotspot_click
FOR EVENT hotspot_click OF cl_gui_alv_grid
IMPORTING e_row_id.
PRIVATE SECTION.
ENDCLASS. " lcl_alv_grid DEFINITION
CLASS LCL_ALV_GRID IMPLEMENTATION *
CLASS lcl_alv_grid IMPLEMENTATION.
METHOD handle_double_click *
METHOD handle_double_click.
READ TABLE gi_mara INTO gs_mara INDEX e_row.
IF sy-subrc = 0.
SELECT matnr
werks
bdatu
vdatu
qunum
FROM equk
INTO TABLE gi_equk
WHERE matnr = gs_mara-matnr.
IF sy-dbcnt NE 0.
SORT gi_equk BY matnr werks bdatu.
ENDIF.
CALL SCREEN 0002.
ENDIF.
ENDMETHOD. "handle_double_click
METHOD handle_onf4 *
METHOD handle_onf4.
PERFORM f4_help USING e_fieldname.
ENDMETHOD. "handle_double_click
METHOD handle_double_click *
METHOD handle_hotspot_click.
READ TABLE gi_mara INTO gs_mara INDEX e_row_id.
IF sy-subrc = 0.
SELECT matnr
werks
bdatu
vdatu
qunum
FROM equk
INTO TABLE gi_equk
WHERE matnr = gs_mara-matnr.
IF sy-dbcnt NE 0.
SORT gi_equk BY matnr werks bdatu.
ENDIF.
CALL SCREEN 0002.
ENDIF.
ENDMETHOD. "handle_hotspot_click
ENDCLASS. " lcl_alv_grid IMPLEMENTATION
SELECTION SCREEN DEFINITION *
SELECTION-SCREEN BEGIN OF BLOCK b1.
SELECT-OPTIONS : s_matnr FOR mara-matnr NO INTERVALS,
s_mtart FOR mara-mtart NO INTERVALS.
SELECTION-SCREEN END OF BLOCK b1.
START-OF-SELECTION *
START-OF-SELECTION.
SELECT matnr
lvorm
mtart
mbrsh
matkl
meins
brgew
ntgew
gewei
FROM mara
INTO TABLE gi_mara
WHERE matnr IN s_matnr
AND mtart IN s_mtart.
IF sy-dbcnt NE 0.
SORT gi_mara BY matnr.
ENDIF.
CALL SCREEN 0001.
*& Module STATUS_0001 OUTPUT
text
MODULE status_0001 OUTPUT.
SET PF-STATUS '0001'.
SET TITLEBAR '001'.
PERFORM build_alv_display.
ENDMODULE. " STATUS_0001 OUTPUT
*& Module USER_COMMAND_0001 INPUT
text
MODULE user_command_0001 INPUT.
CASE sy-ucomm.
WHEN 'EXIT'.
LEAVE TO SCREEN 0.
WHEN 'SAVE'.
LEAVE TO SCREEN 0.
ENDCASE.
ENDMODULE. " USER_COMMAND_0001 INPUT
*& Form build_alv_display
text
--> p1 text
<-- p2 text
FORM build_alv_display .
PERFORM build_fieldcat.
PERFORM build_layout.
PERFORM create_alv_grid.
PERFORM display_alv_grid.
ENDFORM. " build_alv_display
*& Form build_fieldcat
text
--> p1 text
<-- p2 text
FORM build_fieldcat .
CLEAR gs_fieldcat.
gs_fieldcat-fieldname = 'MATNR'.
gs_fieldcat-tabname = 'MARA'.
gs_fieldcat-coltext = 'Material Number'.
gs_fieldcat-outputlen = '18'.
gs_fieldcat-edit = ' '.
gs_fieldcat-just = 'C'.
gs_fieldcat-col_pos = '1'.
gs_fieldcat-hotspot = 'X'.
APPEND gs_fieldcat TO gi_fieldcat.
CLEAR gs_fieldcat.
gs_fieldcat-fieldname = 'LVORM'.
gs_fieldcat-tabname = 'MARA'.
gs_fieldcat-coltext = 'Deletion'.
gs_fieldcat-outputlen = '8'.
gs_fieldcat-edit = ' '.
gs_fieldcat-just = 'C'.
gs_fieldcat-col_pos = '2'.
gs_fieldcat-checkbox = 'X'.
APPEND gs_fieldcat TO gi_fieldcat.
CLEAR gs_fieldcat.
gs_fieldcat-fieldname = 'MTART'.
gs_fieldcat-tabname = 'MARA'.
gs_fieldcat-coltext = 'Material Type'.
gs_fieldcat-outputlen = '13'.
gs_fieldcat-edit = ' '.
gs_fieldcat-just = 'C'.
gs_fieldcat-col_pos = '3'.
APPEND gs_fieldcat TO gi_fieldcat.
CLEAR gs_fieldcat.
gs_fieldcat-fieldname = 'MBRSH'.
gs_fieldcat-tabname = 'MARA'.
gs_fieldcat-coltext = 'Industry sector'.
gs_fieldcat-outputlen = '15'.
gs_fieldcat-edit = ' '.
gs_fieldcat-just = 'C'.
gs_fieldcat-col_pos = '4'.
APPEND gs_fieldcat TO gi_fieldcat.
CLEAR gs_fieldcat.
gs_fieldcat-fieldname = 'MATKL'.
gs_fieldcat-tabname = 'MARA'.
gs_fieldcat-coltext = 'Material group'.
gs_fieldcat-outputlen = '14'.
gs_fieldcat-edit = ' '.
gs_fieldcat-just = 'C'.
gs_fieldcat-col_pos = '5'.
APPEND gs_fieldcat TO gi_fieldcat.
CLEAR gs_fieldcat.
gs_fieldcat-fieldname = 'MEINS'.
gs_fieldcat-tabname = 'MARA'.
gs_fieldcat-coltext = 'Base Unit of Measure'.
gs_fieldcat-outputlen = '20'.
gs_fieldcat-edit = ' '.
gs_fieldcat-just = 'C'.
gs_fieldcat-col_pos = '6'.
APPEND gs_fieldcat TO gi_fieldcat.
CLEAR gs_fieldcat.
gs_fieldcat-fieldname = 'BRGEW'.
gs_fieldcat-tabname = 'MARA'.
gs_fieldcat-coltext = 'Gross weight'.
gs_fieldcat-outputlen = '13'.
gs_fieldcat-edit = ' '.
gs_fieldcat-just = 'C'.
gs_fieldcat-col_pos = '7'.
APPEND gs_fieldcat TO gi_fieldcat.
CLEAR gs_fieldcat.
gs_fieldcat-fieldname = 'NTGEW'.
gs_fieldcat-tabname = 'MARA'.
gs_fieldcat-coltext = 'Net weight'.
gs_fieldcat-outputlen = '13'.
gs_fieldcat-edit = ' '.
gs_fieldcat-just = 'C'.
gs_fieldcat-col_pos = '8'.
APPEND gs_fieldcat TO gi_fieldcat.
CLEAR gs_fieldcat.
gs_fieldcat-fieldname = 'GEWEI'.
gs_fieldcat-tabname = 'MARA'.
gs_fieldcat-coltext = 'Weight Unit'.
gs_fieldcat-outputlen = '11'.
gs_fieldcat-edit = ' '.
gs_fieldcat-just = 'C'.
gs_fieldcat-col_pos = '9'.
APPEND gs_fieldcat TO gi_fieldcat.
ENDFORM. " build_fieldcat
*& Form build_layout
text
--> p1 text
<-- p2 text
FORM build_layout .
gs_layout-sel_mode = 'A'.
gs_layout-edit = ' '.
gs_layout-no_toolbar = ' '.
gs_layout-grid_title = 'Material Data'.
gs_layout-no_headers = ' '.
gs_layout-weblook = 'X'.
ENDFORM. " build_layout
*& Form create_alv_grid
text
--> p1 text
<-- p2 text
FORM create_alv_grid .
IF gw_container IS INITIAL.
CREATE OBJECT gw_container
EXPORTING
container_name = 'CC_ALV'.
Display ALV grid
IF gw_alvgrid IS INITIAL.
CREATE OBJECT gw_alvgrid
EXPORTING
i_parent = gw_container.
ENDIF.
ENDIF.
IF gw_event_handler IS INITIAL.
CREATE OBJECT gw_event_handler.
SET HANDLER gw_event_handler->handle_double_click
FOR gw_alvgrid.
SET HANDLER gw_event_handler->handle_onf4
FOR gw_alvgrid.
SET HANDLER gw_event_handler->handle_hotspot_click
FOR gw_alvgrid.
ENDIF.
ENDFORM. " create_alv_grid
*& Form display_alv_grid
text
--> p1 text
<-- p2 text
FORM display_alv_grid .
CALL METHOD gw_alvgrid->set_table_for_first_display
EXPORTING
i_buffer_active = ' '
i_bypassing_buffer = ' '
i_structure_name = 'T_MARA'
is_layout = gs_layout
CHANGING
it_outtab = gi_mara[]
it_fieldcatalog = gi_fieldcat[]
EXCEPTIONS
OTHERS = 0.
ENDFORM. " display_alv_grid
*& Module STATUS_0002 OUTPUT
text
MODULE status_0002 OUTPUT.
SET PF-STATUS '0002'.
SET TITLEBAR '002'.
PERFORM build_alv_display1.
ENDMODULE. " STATUS_0002 OUTPUT
*& Module USER_COMMAND_0002 INPUT
text
MODULE user_command_0002 INPUT.
CASE sy-ucomm.
WHEN 'EXIT'.
LEAVE TO SCREEN 0.
ENDCASE.
ENDMODULE. " USER_COMMAND_0002 INPUT
*& Form build_alv_display1
text
--> p1 text
<-- p2 text
FORM build_alv_display1 .
PERFORM build_fieldcat1.
PERFORM build_layout1.
PERFORM create_alv_grid1.
PERFORM display_alv_grid1.
ENDFORM. " build_alv_display1
*& Form build_fieldcat2
text
--> p1 text
<-- p2 text
FORM build_fieldcat1.
CLEAR gs_fieldcat.
gs_fieldcat-fieldname = 'MATNR'.
gs_fieldcat-tabname = 'EQUK'.
gs_fieldcat-coltext = 'Material Number'.
gs_fieldcat-outputlen = '18'.
gs_fieldcat-edit = ' '.
gs_fieldcat-just = 'C'.
gs_fieldcat-col_pos = '1'.
gs_fieldcat-f4availabl = 'X'.
APPEND gs_fieldcat TO gi_fieldcat1.
CLEAR gs_fieldcat.
gs_fieldcat-fieldname = 'WERKS'.
gs_fieldcat-tabname = 'EQUK'.
gs_fieldcat-coltext = 'Plant'.
gs_fieldcat-outputlen = '4'.
gs_fieldcat-edit = ' '.
gs_fieldcat-just = 'C'.
gs_fieldcat-col_pos = '2'.
APPEND gs_fieldcat TO gi_fieldcat1.
CLEAR gs_fieldcat.
gs_fieldcat-fieldname = 'BDATU'.
gs_fieldcat-tabname = 'EQUK'.
gs_fieldcat-coltext = 'Valid Untill'.
gs_fieldcat-outputlen = '12'.
gs_fieldcat-edit = ' '.
gs_fieldcat-just = 'C'.
gs_fieldcat-col_pos = '3'.
APPEND gs_fieldcat TO gi_fieldcat1.
CLEAR gs_fieldcat.
gs_fieldcat-fieldname = 'VDATU'.
gs_fieldcat-tabname = 'EQUK'.
gs_fieldcat-coltext = 'Valid From'.
gs_fieldcat-outputlen = '10'.
gs_fieldcat-edit = ' '.
gs_fieldcat-just = 'C'.
gs_fieldcat-col_pos = '4'.
APPEND gs_fieldcat TO gi_fieldcat1.
CLEAR gs_fieldcat.
gs_fieldcat-fieldname = 'QUNUM'.
gs_fieldcat-tabname = 'EQUK'.
gs_fieldcat-coltext = 'Quota'.
gs_fieldcat-outputlen = '10'.
gs_fieldcat-edit = ' '.
gs_fieldcat-just = 'C'.
gs_fieldcat-col_pos = '5'.
APPEND gs_fieldcat TO gi_fieldcat1.
ENDFORM. " build_fieldcat2
*& Form build_layout2
text
--> p1 text
<-- p2 text
FORM build_layout1.
gs_layout1-sel_mode = 'A'.
gs_layout1-edit = ' '.
gs_layout1-no_toolbar = ' '.
gs_layout1-grid_title = 'Quota Header Data'.
gs_layout1-no_headers = ' '.
ENDFORM. " build_layout1
*& Form create_alv_grid2
text
--> p1 text
<-- p2 text
FORM create_alv_grid1.
IF gw_container1 IS INITIAL.
CREATE OBJECT gw_container1
EXPORTING
container_name = 'CC_ALV1'.
Display ALV grid
IF gw_alvgrid1 IS INITIAL.
CREATE OBJECT gw_alvgrid1
EXPORTING
i_parent = gw_container1.
ENDIF.
ENDIF.
IF gw_event_handler1 IS INITIAL.
CREATE OBJECT gw_event_handler1.
SET HANDLER gw_event_handler1->handle_onf4
FOR gw_alvgrid1.
ENDIF.
ENDFORM. " create_alv_grid1
*& Form display_alv_grid2
text
--> p1 text
<-- p2 text
FORM display_alv_grid1 .
DATA : li_f4 TYPE lvc_t_f4,
ls_f4 TYPE lvc_s_f4.
CALL METHOD gw_alvgrid1->set_table_for_first_display
EXPORTING
i_buffer_active = ' '
i_bypassing_buffer = ' '
i_structure_name = 'T_EQUK'
is_layout = gs_layout1
CHANGING
it_outtab = gi_equk[]
it_fieldcatalog = gi_fieldcat1[]
EXCEPTIONS
OTHERS = 0.
IF li_f4[] IS INITIAL.
MOVE 'MATNR' TO ls_f4-fieldname.
MOVE 'X' TO ls_f4-register.
MOVE 'X' TO ls_f4-getbefore.
APPEND ls_f4 TO li_f4.
CLEAR ls_f4.
CALL METHOD gw_alvgrid1->register_f4_for_fields
EXPORTING
it_f4 = li_f4.
ENDIF.
ENDFORM. " display_alv_grid1
*& Form f4_help
text
-->P_FIELDNAME text
FORM f4_help USING p_fieldname.
TYPES : BEGIN OF t_values,
matnr TYPE mara-matnr,
END OF t_values.
DATA : li_fields TYPE TABLE OF dfies,
li_select_values TYPE TABLE OF ddshretval,
li_values TYPE TABLE OF t_values,
ls_fields TYPE dfies,
ls_values TYPE t_values.
REFRESH : li_fields,
li_select_values.
SELECT matnr
FROM equk
INTO TABLE li_values.
CASE p_fieldname.
WHEN 'MATNR'.
ls_fields-tabname = 'EQUK'.
ls_fields-fieldname = 'MATNR'.
APPEND ls_fields TO li_fields.
CLEAR ls_fields.
SORT li_values BY matnr.
DELETE ADJACENT DUPLICATES FROM li_values COMPARING matnr.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield = 'MATNR'
TABLES
value_tab = li_values
field_tab = li_fields
return_tab = li_select_values.
IF sy-subrc = 0.
LOOP AT li_select_values WHERE fieldname = 'MATNR'.
clear gs_mara.
gs_mara in
ENDIF.
ENDCASE.
ENDFORM. " f4_help -
Problem in data format of quantity in edittable alv grid
Hi All,
In edittable alv grid,I have a quantity field which has been specified as type p in program code.
In table i have taken datatype as dec and 4 decimal palces.
when i put value in edittable grid as 255.It changes it to .0255
Also if i take value as 2.58,it gives error and it changes it to .0258
Please help me to solve my query.
Thanks and Regards,
AmanHi..
I have taken the field as type char and then taken it in p with dec 4.It is working correct.But it should take 5 char only.whereas if i put more than 5 decimals it is also working fine which is an error.
Please help em to solve my query.
Regards,
Aman -
hi
can i make the fields of one of the columns of one of the rows as editable in ALV_GRID FM..?
if so pls guide me how do i do it..
after the user edits the data in the field, can i save that in another variable or another internal table? or modify the same internal table?
pls send me an example code also...
thanks in advance
srinihi,
editable alv:
chk this link.
http://www.sapdevelopment.co.uk/reporting/alv/alvgrid_editable.htm
then u can capture the events in USER COMMAND.
http://www.sapdevelopment.co.uk/reporting/alv/alvgrid_ucomm.htm
See these threads
Re: Making selected alv rows editable
Re: selective edit in ALV grid
REPORT ZSRI_REPORT6 NO STANDARD PAGE HEADING
MESSAGE-ID ZZ
LINE-SIZE 132
LINE-COUNT 65 .
TABLES: MARA.
TYPE-POOLS: SLIS.
TYPES: BEGIN OF T_MARA,
MATNR TYPE MARA-MATNR, "Material Number
ERSDA TYPE MARA-ERSDA, "Creation date
BRGEW TYPE MARA-BRGEW, "Gross weight
NTGEW TYPE MARA-NTGEW, "Net weight
MTART TYPE MARA-MTART, "Material type
MBRSH TYPE MARA-MBRSH, "Industry Sector
REC_SEL TYPE C , "checkbox
END OF T_MARA.
V A R I A B L E S
DATA: V_REPID LIKE SY-REPID,
V_FLAG(1) TYPE C.
CONSTANTS :
C_X(1) TYPE C VALUE 'X',
C_PF_STATUS TYPE SLIS_FORMNAME VALUE 'F_SET_PF_STATUS',
C_FC_DELETE(6) TYPE C VALUE 'DELETE',
C_FC_MODIFY(6) TYPE C VALUE 'MODIFY',
C_USER_COMMAND TYPE SLIS_FORMNAME VALUE 'F_USER_COMMAND',
C_USER_COMMAND_MODIFY TYPE SLIS_FORMNAME
VALUE 'F_USER_COMMAND_MODIFY',
C_ICON_DELETE TYPE ICON-NAME VALUE 'ICON_DELETE', " Icon,Delete'
C_ICON_CANCEL TYPE ICON-NAME VALUE 'ICON_CANCEL', " Icon,Cancel'
C_FC_SAVE(4) TYPE C VALUE 'SAVE'.
*internal table declarations.
DATA: IT_MARA TYPE STANDARD TABLE OF T_MARA WITH HEADER LINE,
IT_MODIFY TYPE STANDARD TABLE OF T_MARA WITH HEADER LINE,
IT_TEMP TYPE STANDARD TABLE OF MARA WITH HEADER LINE,
*-ALV Internal Tables.
*--Field Catalog
IT_FIELDCAT TYPE STANDARD TABLE OF
SLIS_FIELDCAT_ALV WITH HEADER LINE,
*--Layout
WA_LAYOUT TYPE SLIS_LAYOUT_ALV,
*--Sort
IT_SORT TYPE SLIS_T_SORTINFO_ALV,
WA_SORT TYPE SLIS_SORTINFO_ALV ,
**-Structure for excluding function codes
WA_EXTAB TYPE SLIS_EXTAB,
**-To hold function codes to be excluded in ALV toolbar
IT_EXTAB TYPE SLIS_T_EXTAB.
*selection screen.
SELECTION-SCREEN: BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS: S_MATNR FOR MARA-MATNR,
S_ERSDA FOR MARA-ERSDA.
SELECTION-SCREEN: END OF BLOCK B1.
*--Radio buttons to select either Display/Delete/Modify
SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME
TITLE TEXT-002.
SELECTION-SCREEN : BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(20) TEXT-003.
PARAMETERS: P_DISP RADIOBUTTON GROUP RAD1 DEFAULT 'X'.
SELECTION-SCREEN : END OF LINE.
SELECTION-SCREEN : BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(20) TEXT-005.
PARAMETERS: P_UPD RADIOBUTTON GROUP RAD1.
SELECTION-SCREEN : END OF LINE.
SELECTION-SCREEN : BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(20) TEXT-004.
PARAMETERS: P_DEL RADIOBUTTON GROUP RAD1.
SELECTION-SCREEN : END OF LINE.
SELECTION-SCREEN END OF BLOCK B2 .
AT SELECTION-SCREEN.
PERFORM VALIDATE_SCREEN.
*start of selection
START-OF-SELECTION.
*clear the internal tables to be used.
CLEAR: IT_MARA,IT_MARA[],
V_FLAG.
*get the data
PERFORM GET_DATA.
*end of selection
END-OF-SELECTION.
IF IT_MARA[] IS INITIAL.
MESSAGE I000 WITH
'No Records found for the given Selection Criteria'(012).
ELSE.
*do alv process
V_REPID = SY-REPID.
*--Sort the Output Fields
PERFORM SORT_FIELDS.
*--Build Field catalog for the Output fields
PERFORM BUILD_FIELDCAT.
*--Set the Layout for ALV
PERFORM SET_LAYOUT.
IF P_DISP = C_X.
*--Exclude any Buttons on the Appn tool bar
perform change_default_pf_status.
MOVE C_FC_DELETE TO WA_EXTAB-FCODE. " DELETE button on ALV
APPEND WA_EXTAB TO IT_EXTAB.
MOVE C_FC_MODIFY TO WA_EXTAB-FCODE. " MODIFY button on ALV
APPEND WA_EXTAB TO IT_EXTAB.
ELSEIF P_UPD = C_X.
*--Exclude DELETE Button on the appn tool bar
MOVE C_FC_DELETE TO WA_EXTAB-FCODE. " DELETE button on ALV
APPEND WA_EXTAB TO IT_EXTAB.
ELSEIF P_DEL = C_X.
*--Exclude MODIFY button on appn tool bar
MOVE C_FC_MODIFY TO WA_EXTAB-FCODE. " MODIFY button on ALV
APPEND WA_EXTAB TO IT_EXTAB.
ENDIF.
*--Exclude SAVE button for all options
MOVE 'SAVE' TO WA_EXTAB-FCODE. " SAVE button on ALV
APPEND WA_EXTAB TO IT_EXTAB.
*--Display ALV output
PERFORM LIST_DISPLAY TABLES IT_MARA
USING C_USER_COMMAND.
ENDIF.
*& Form get_data
FORM GET_DATA .
SELECT MATNR
ERSDA
BRGEW
NTGEW
MTART
MBRSH
FROM MARA
INTO TABLE IT_MARA
WHERE MATNR IN S_MATNR
AND ERSDA IN S_ERSDA.
IF SY-SUBRC <> 0.
*no records selected leave processing
STOP.
ENDIF.
SORT IT_MARA.
ENDFORM. " get_data
*& Form sort_fields
text
--> p1 text
<-- p2 text
FORM SORT_FIELDS .
CLEAR WA_SORT.
WA_SORT-FIELDNAME = 'MATNR'.
WA_SORT-SPOS = '1'.
WA_SORT-UP = 'X'.
APPEND WA_SORT TO IT_SORT.
CLEAR WA_SORT.
WA_SORT-FIELDNAME = 'ERSDA'.
WA_SORT-SPOS = '2'.
WA_SORT-UP = 'X'.
APPEND WA_SORT TO IT_SORT.
ENDFORM. " sort_fields
*& Form build_fieldcat
text
--> p1 text
<-- p2 text
FORM BUILD_FIELDCAT .
IT_FIELDCAT-COL_POS = '1'.
IT_FIELDCAT-FIELDNAME = 'MATNR'.
IT_FIELDCAT-KEY = 'X'.
IT_FIELDCAT-OUTPUTLEN = '15'.
IT_FIELDCAT-SELTEXT_L = 'Material number'(022).
APPEND IT_FIELDCAT.
CLEAR IT_FIELDCAT.
IT_FIELDCAT-COL_POS = '2'.
IT_FIELDCAT-FIELDNAME = 'ERSDA'.
IT_FIELDCAT-KEY = 'X'.
IT_FIELDCAT-OUTPUTLEN = '10'.
IT_FIELDCAT-SELTEXT_L = 'Created on'(023).
APPEND IT_FIELDCAT.
CLEAR IT_FIELDCAT.
IT_FIELDCAT-COL_POS = '3'.
IT_FIELDCAT-FIELDNAME = 'BRGEW'.
IT_FIELDCAT-OUTPUTLEN = '10'.
IT_FIELDCAT-SELTEXT_L = 'GROSS WEIGHT'(024).
APPEND IT_FIELDCAT.
CLEAR IT_FIELDCAT.
IT_FIELDCAT-COL_POS = '4'.
IT_FIELDCAT-FIELDNAME = 'NTGEW'.
IT_FIELDCAT-OUTPUTLEN = '15'.
IT_FIELDCAT-SELTEXT_L = 'NET WEIGHT'(025).
APPEND IT_FIELDCAT.
CLEAR IT_FIELDCAT.
IT_FIELDCAT-COL_POS = '5'.
IT_FIELDCAT-FIELDNAME = 'MTART'.
IT_FIELDCAT-OUTPUTLEN = '3'.
IT_FIELDCAT-SELTEXT_L = 'Material type'(026).
APPEND IT_FIELDCAT.
CLEAR IT_FIELDCAT.
IT_FIELDCAT-COL_POS = '6'.
IT_FIELDCAT-FIELDNAME = 'MBRSH'.
IT_FIELDCAT-OUTPUTLEN = '25'.
IT_FIELDCAT-SELTEXT_L = 'Industry sector'(027).
APPEND IT_FIELDCAT.
CLEAR IT_FIELDCAT.
IT_FIELDCAT-FIELDNAME = 'REC_SEL'.
IT_FIELDCAT-NO_OUT = C_X.
APPEND IT_FIELDCAT.
CLEAR IT_FIELDCAT.
ENDFORM. " build_fieldcat
*& Form list_display
text
-->P_IT_MARA text
-->P_C_USER_COMMAND text
FORM LIST_DISPLAY TABLES P_IT_MARA
USING P_USER_COMMAND TYPE SLIS_FORMNAME.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = V_REPID
I_CALLBACK_PF_STATUS_SET = C_PF_STATUS
I_CALLBACK_USER_COMMAND = P_USER_COMMAND
IS_LAYOUT = WA_LAYOUT
IT_FIELDCAT = IT_FIELDCAT[]
IT_EXCLUDING = IT_EXTAB[]
IT_SORT = IT_SORT[]
TABLES
T_OUTTAB = P_IT_MARA
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. " list_display
*& Form F_SET_PF_STATUS
Set PF_STATUS STANDARD modifying the standard toolbar
by excluding some buttons
-->P_IT_EXTAB -- TABLE OF EXCLUDING FUNCTIONS
FORM F_SET_PF_STATUS USING RT_EXTAB TYPE SLIS_T_EXTAB.
CLEAR : WA_EXTAB,
IT_EXTAB.
*--Set the Modified PF status for the ALV.
SET PF-STATUS 'ALV_STATUS_01' EXCLUDING RT_EXTAB.
ENDFORM. " SET_PF_STATUS
*& Form f_user_command
Handle user action on ALV toolbar
FORM F_USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
RS_SELFIELD TYPE SLIS_SELFIELD.
RS_SELFIELD-REFRESH = C_X.
IF R_UCOMM = C_FC_DELETE.
*--User Selected DELETE button.
PERFORM DELETE_SELECTED_RECORDS.
ELSEIF R_UCOMM = C_FC_MODIFY.
*--If user selects MODIFY button.
PERFORM CHANGE_RECORDS.
ENDIF.
ENDFORM. "F_USER_COMMAND
*& Form POP_UP_CONFIRMATION
text
<--P_ANSWER text
FORM POP_UP_CONFIRMATION
CHANGING P_ANSWER TYPE C.
DATA:
L_TITLE(14) TYPE C, " Title of pop-up
L_TXT_QUESTION(52) TYPE C, " Text displayed in pop-up
L_DISP_CANCEL TYPE C, " Display 'Cancel' button?
L_BTN1 TYPE ICON-NAME, " Icon on button 1
L_BTN2 TYPE ICON-NAME. " Icon on button 2
L_TITLE = 'Delete'(017). " delete
L_TXT_QUESTION = 'Are you sure to delete?'(018).
L_BTN1 = C_ICON_DELETE.
L_BTN2 = C_ICON_CANCEL.
**-Display pop-up asking user for confirmation
CALL FUNCTION 'POPUP_TO_CONFIRM'
EXPORTING
TITLEBAR = L_TITLE
TEXT_QUESTION = L_TXT_QUESTION
TEXT_BUTTON_1 = 'Yes'
ICON_BUTTON_1 = L_BTN1
TEXT_BUTTON_2 = 'No'
ICON_BUTTON_2 = L_BTN2
DEFAULT_BUTTON = '2'
DISPLAY_CANCEL_BUTTON = 'X'
IMPORTING
ANSWER = P_ANSWER
EXCEPTIONS
TEXT_NOT_FOUND = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
MESSAGE E000 WITH 'Error executing function module:'(019)
'POPUP_TO_CONFIRM'.
ENDIF.
ENDFORM. "pop_up_confirmation
*& Form set_layout
text
--> p1 text
<-- p2 text
FORM SET_LAYOUT .
IF P_DEL = C_X OR P_UPD = C_X.
*--Allow Input only if user choose 'UPDATE'/ 'DELETE' radio buttons
WA_LAYOUT-BOX_FIELDNAME = 'REC_SEL'.
WA_LAYOUT-BOX_TABNAME = 'IT_MARA'.
ENDIF.
*--Display Header based on the user selection
IF P_DISP = C_X.
WA_LAYOUT-WINDOW_TITLEBAR =
'Display '(036).
ELSEIF P_DEL = C_X.
WA_LAYOUT-WINDOW_TITLEBAR =
'Delete '(037).
ELSEIF P_UPD = C_X.
WA_LAYOUT-WINDOW_TITLEBAR =
'Change '(038).
ENDIF.
ENDFORM. " set_layout
*& Form change_default_pf_status
text
--> p1 text
<-- p2 text
FORM CHANGE_DEFAULT_PF_STATUS .
MOVE C_FC_DELETE TO WA_EXTAB-FCODE. " DELETE button on ALV
APPEND WA_EXTAB TO IT_EXTAB.
MOVE C_FC_MODIFY TO WA_EXTAB-FCODE. " MODIFY button on ALV
APPEND WA_EXTAB TO IT_EXTAB.
ENDFORM. " change_default_pf_status
*& Form f_user_command
Handle user action on ALV toolbar
FORM F_USER_COMMAND_MODIFY USING R_UCOMM LIKE SY-UCOMM "#EC *
RS_SELFIELD TYPE SLIS_SELFIELD.
DATA : L_ANSWER TYPE C. "#EC *
IF R_UCOMM = C_FC_SAVE.
*user selected save button
READ TABLE IT_MODIFY WITH KEY REC_SEL = 'X'.
*check if user selected atleast one line.
IF SY-SUBRC <> 0.
MESSAGE I000 WITH 'No record(s) Selected to Modify'(016).
EXIT.
ENDIF.
LOOP AT IT_MODIFY WHERE REC_SEL = 'X'.
*--Check the entered values are valid or not.
IF NOT ( it_modify-status = 'A' OR
it_modify-status = 'C' OR
it_modify-status = 'E' ).
*--User Entered invalid value for STATUS field,so Display Error Msg
CLEAR R_UCOMM.
MESSAGE e000 WITH 'Invalid value '''(031)
'' for Status in the Record # '(032)
sy-tabix.
ENDIF.
ENDLOOP.
CLEAR: IT_TEMP,
IT_TEMP[].
LOOP AT IT_MODIFY WHERE REC_SEL = 'X'.
MOVE-CORRESPONDING IT_MODIFY TO IT_TEMP.
APPEND IT_TEMP.
CLEAR IT_TEMP.
ENDLOOP.
*--start new code
DATA : IT_TEMP2 LIKE STANDARD TABLE OF MARA WITH HEADER LINE.
SELECT * FROM MARA
INTO TABLE IT_TEMP2
FOR ALL ENTRIES IN IT_TEMP
WHERE MATNR = IT_TEMP-MATNR.
IF SY-SUBRC = 0.
LOOP AT IT_MODIFY WHERE REC_SEL = 'X'.
READ TABLE IT_TEMP2 WITH KEY MATNR = IT_MODIFY-MATNR.
IF SY-SUBRC = 0.
IT_TEMP2-NTGEW = IT_MODIFY-NTGEW.
IT_TEMP2-BRGEW = IT_MODIFY-BRGEW.
MODIFY IT_TEMP2 INDEX SY-TABIX.
ENDIF.
ENDLOOP.
ENDIF.
*modify mara table with the changed values
MODIFY MARA FROM TABLE IT_TEMP2 .
*--end new code
IF SY-SUBRC = 0.
COMMIT WORK AND WAIT.
*--Display message with Success in Updating database
MESSAGE I000 WITH SY-DBCNT
' Record(s) has been Updated'(020).
CLEAR :
IT_MARA,
IT_MARA[].
*get-data again from database.
PERFORM GET_DATA.
RS_SELFIELD-REFRESH = C_X.
ELSE.
*--Error occurred
MESSAGE I000 WITH 'Error occured in Modifying the database'(021).
ENDIF.
ENDIF.
ENDFORM. "f_user_command_modify
*& Form validate_screen
text
--> p1 text
<-- p2 text
FORM VALIDATE_SCREEN .
DATA : LV_MATNR LIKE MARA-MATNR.
*--validate product
IF NOT S_MATNR[] IS INITIAL.
SELECT MATNR
INTO MARA-MATNR
FROM MARA
WHERE MATNR IN S_MATNR.
ENDSELECT.
IF SY-SUBRC <> 0.
*--Error
MESSAGE E000 WITH 'Invalid Material'(034).
ENDIF.
ENDIF.
ENDFORM. " validate_screen
*& Form delete_records
text
--> p1 text
<-- p2 text
FORM DELETE_RECORDS .
LOOP AT IT_MARA.
MOVE-CORRESPONDING IT_MARA TO IT_TEMP.
APPEND IT_TEMP.
CLEAR IT_TEMP.
ENDLOOP.
DELETE MARA FROM TABLE IT_TEMP.
IF SY-SUBRC = 0.
*--Successfully selected records Deleted.
COMMIT WORK AND WAIT.
*--Display Success Message to the user
MESSAGE I000 WITH SY-DBCNT
' Record(s) deleted Successfully'(010).
ELSE.
*--Error occured in deletion
MESSAGE I000 WITH 'Error occured in Deleting the Record(s)'(011).
ENDIF.
CLEAR: IT_MARA,
IT_MARA[],
IT_TEMP,
IT_TEMP[].
V_FLAG = C_X.
STOP.
ENDFORM. " delete_records
*& Form delete_selected_records
text
--> p1 text
<-- p2 text
FORM DELETE_SELECTED_RECORDS .
DATA : L_ANSWER(1) TYPE C.
READ TABLE IT_MARA WITH KEY REC_SEL = C_X.
IF SY-SUBRC <> 0.
MESSAGE I000 WITH 'No record(s) Selected to Delete'(013).
EXIT.
ELSE.
*--Ask for delete confirmation
PERFORM POP_UP_CONFIRMATION
CHANGING L_ANSWER.
IF L_ANSWER = '1'. " 'Yes'
CLEAR: IT_TEMP,
IT_TEMP[].
LOOP AT IT_MARA WHERE REC_SEL = 'X'.
MOVE-CORRESPONDING IT_MARA TO IT_TEMP.
APPEND IT_TEMP.
CLEAR IT_TEMP.
ENDLOOP.
DELETE MARA FROM TABLE IT_TEMP.
IF SY-SUBRC = 0.
*--Successfully selected records Deleted.
COMMIT WORK AND WAIT.
*--Display completed work information to the user
MESSAGE I000 WITH SY-DBCNT
' Record(s) deleted Successfully'(014).
*--Clear the Internal tables
CLEAR: IT_MARA,
IT_MARA[].
*--Reselects entries from Database again & display in ALV
PERFORM GET_DATA.
ELSE.
*--Error occured
MESSAGE I000 WITH
'Error occured in Deleting the Record(s)'(015).
ENDIF.
ENDIF.
ENDIF.
ENDFORM. " delete_selected_records
*& Form change_records
text
--> p1 text
<-- p2 text
FORM CHANGE_RECORDS .
READ TABLE IT_MARA WITH KEY REC_SEL = 'X'.
*--check user selected at least 1 record to MODIFY or not
IF SY-SUBRC <> 0.
MESSAGE I000 WITH 'No record(s) Selected to Modify'(016).
EXIT.
ELSE.
CLEAR : IT_MODIFY,
IT_MODIFY[].
LOOP AT IT_MARA WHERE REC_SEL = 'X'.
IT_MODIFY = IT_MARA.
APPEND IT_MODIFY.
CLEAR IT_MODIFY.
ENDLOOP.
*--Change PF status for this new ALV list.
PERFORM CHANGE_PF_STATUS_AGAIN.
*--Change Field Catalog to make INPUT enabled.
READ TABLE IT_FIELDCAT WITH KEY FIELDNAME = 'NTGEW'.
IT_FIELDCAT-INPUT = C_X.
MODIFY IT_FIELDCAT INDEX SY-TABIX.
*--Call ALV LIST DISPLAY with this new values.
PERFORM LIST_DISPLAY TABLES IT_MODIFY
USING C_USER_COMMAND_MODIFY.
ENDIF.
ENDFORM. " change_records
*& Form change_pf_status_again
text
--> p1 text
<-- p2 text
FORM CHANGE_PF_STATUS_AGAIN .
MOVE C_FC_DELETE TO WA_EXTAB-FCODE. " DELETE button on ALV
APPEND WA_EXTAB TO IT_EXTAB.
MOVE C_FC_MODIFY TO WA_EXTAB-FCODE. " MODIFY button on ALV
APPEND WA_EXTAB TO IT_EXTAB.
ENDFORM. " change_pf_status_again -
Color change of a field in ALV Grid Control
Hi,
One small help needed....
My req is explained below:
I have 3 fields empno, ename and deptno. and the records of these fields would be displayed in ALV grid control.
When I hover the mouse on ename field, the color of the complete field should change to other color, say "RED".
How do I get this. Are there any Mouse events in SAP?
KalyanHi,
Once i changed the color of a field in a alv (not grid alv), i suspose that the same in alv grid. Also i used an mouse event.
To manage the color:
TYPE-POOLS : SLIS, and check this type: SLIS_T_SPECIALCOL_ALV.
when you call the function to display the alv, there is a parameter in which you should pass an internal table that references the type SLIS_T_SPECIALCOL_ALV.
To manage the mouse:
1.- You should add the event user command:
for example:
DATA: I_EVENT TYPE SLIS_ALV_EVENT.
Llamo al la función que obtiene los eventos validos para el ALV
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 0
IMPORTING
ET_EVENTS = P_EVENTS
EXCEPTIONS
LIST_TYPE_WRONG = 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.
ELSE.
agrega evento user command
READ TABLE P_EVENTS INTO I_EVENT
WITH KEY NAME = SLIS_EV_USER_COMMAND.
IF SY-SUBRC EQ 0.
I_EVENT-FORM = SLIS_EV_USER_COMMAND.
MODIFY P_EVENTS FROM I_EVENT INDEX SY-TABIX.
ENDIF.
ENDIF.
2.- you work with the user command event:
FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
RS_SELFIELD TYPE SLIS_SELFIELD .
CASE R_UCOMM.
WHEN C_DOBLE_CLICK.
here you do the things that you need when the mouse * bottom it's pressed
PERFORM xxxxxxx.
ENDCASE.
ENDFORM.
3.- you can change the form of the mouse, but i don't remember exactly how to do that... try to check that, it's helpfull in order to display the fields that can execute a funtion in your alv.
I hope this help you, and sorry for my english.
Albio.- -
Currency field in alv grid display
Hi,
I am using alv grid display.I am having one currency field netprice.I want it to be displayed as blank when i am not passing any value.But it gives 0.00 when it is not having any value.How to make it blank instead of 0.00.
Points will be rewarded.
Regards,
Sowmya.HI,
If itab-curr = '0.00' .
itab-curr = ''.
modify itab.
endif.
Maybe you are looking for
-
What is happening in this code
Hello guys import java.util.*; public class nip{ public static void main(String args[]){ Random rn=new Random(); int array1[]=new int[7]; for(int counter=1;counter<50;counter++){ ++array1[1+rn.nextInt
-
Can't uninstall iTunes program due to missing itunes.msi file.
I am having trouble updating my iTunes on my netbook PC. This is the error message I get when trying to unistall iTunes - the feature you are trying to use is on a network resource that is unavailable. Click ok or try again or enter an alternate path
-
Adding an attachment to a BPEL process instance
Hi Is it possible to add an attachment (say a word/pdf doc) to an instance, where the document is obtained from a webservice (say as a binary content in web service)? Thanks SAtinder
-
Jms settings and correlation settings in jms adapter
hi expects, what is use of jms settings and correlation settings in jms adapter.
-
Where's the "Open Panel Vi"?
Hi, I am looking for the �Open Panel Vi', which I found described in Help->Online Reference. I know that it existed in Labview 4.1, but after upgrading to 5.0 I can't find it anymore. So, can anybody tell me where it is located. Is there anybody who