Add a New line to ALV Grid control
Hi experts,
My requirement is after filling ALV grid, user will select a + button from the menu, I need to add a new line next to the selected ALV line (Like in a table control). Does it posible to do this? If can any body tell me how I can do this.
Regards,
Venkat.
Hi Venkat...
I have tried this and it worked...
Just copy paste this program...
Note : U will have to create a new PF status for this... and give the Function code as given in my program... then only it will work...
*& Report Z_ALV_TRAINING_LIST_EVENTS
REPORT Z_ALV_TRAINING_LIST_EVENTS.
Tables *************
TABLES : T001.
Type Pools Used **********
TYPE-POOLS : SLIS.
Types Declared **********
Internal Tables Declare ************
DATA : IT_company TYPE STANDARD TABLE OF T001 INITIAL SIZE 0 WITH HEADER LINE,
IT_FIELD_CAT TYPE SLIS_T_FIELDCAT_ALV,
it_alv_event type SLIS_T_EVENT.
Select Data ***********
start-of-selection.
SELECT * FROM T001 INTO TABLE IT_company.
Make Field Catalog ******
PERFORM MAKE_FIELD_CATALOG.
get evente *****
perform get_alv_events.
Display ALV *********
end-of-selection.
PERFORM DISPLAY_ALV_LIST.
*& Form make_field_catalog
text
--> p1 text
<-- p2 text
FORM MAKE_FIELD_CATALOG .
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME =
I_INTERNAL_TABNAME =
I_STRUCTURE_NAME = 'T001'
I_CLIENT_NEVER_DISPLAY = 'X'
I_INCLNAME =
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE =
CHANGING
CT_FIELDCAT = it_field_cat
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.
ENDFORM. " make_field_catalog
*& Form display_alv_list
text
--> p1 text
<-- p2 text
FORM DISPLAY_ALV_LIST .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = sy-repid
I_CALLBACK_PF_STATUS_SET = 'SET_MY_PF_STATUS'
I_CALLBACK_USER_COMMAND = ' '
I_STRUCTURE_NAME =
IS_LAYOUT = fl_layout
IT_FIELDCAT = it_field_cat[]
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = 'X'
IS_VARIANT = '/TEST_VV'
IT_EVENTS = it_alv_event
IT_EVENT_EXIT =
IS_PRINT =
IS_REPREP_ID =
I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
IR_SALV_LIST_ADAPTER =
IT_EXCEPT_QINFO =
I_SUPPRESS_EMPTY_DATA = ABAP_FALSE
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB = it_company
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_list
*& Form get_alv_events
text
--> p1 text
<-- p2 text
FORM get_alv_events .
data : wa type slis_alv_event.
wa-name = 'USER_COMMAND'.
wa-form = 'SUB_MY_PF_EVENT'.
append wa to it_alv_event.
ENDFORM. " get_alv_events
*& Form sub_my_pf_event
text
--> p1 text
<-- p2 text
FORM sub_my_pf_event using p_comm type sy-ucomm p_sEL_FIELD TYPE SLIS_SELFIELD.
data : wa type t001.
case p_comm.
when 'BACK'.
leave program.
when 'EXIT'.
leave program.
when 'NEW'.
clear wa.
insert wa into it_company[] index p_sel_field-tabindex.
PERFORM DISPLAY_ALV_LIST.
endcase.
ENDFORM. " sub_my_pf_event
*& Form SET_MY_PF_STATUS
text
--> p1 text
<-- p2 text
FORM SET_MY_PF_STATUS USING p_rt_extab TYPE slis_t_extab.
SET PF-STATUS 'ZALV_STATUS'.
ENDFORM. " SET_MY_PF_STATUS
Plz award points if this was helpful....
Similar Messages
-
Color a line in ALV Grid Control
<<Do not ask for or offer points>>
Hi all,
How to color a line in ALV Grid Control using OOPs.
The appropriate replies will be rewarded.
regards,
S Philip
Edited by: Matt on Dec 22, 2008 11:05 AM<<Points unassigned - cut and paste not allowed. http://sgstocks.tripod.com/alvgrid_control.htm>>
Hi,
To color a line, the structure of the table must include a Char4 field for color properties
TYPES: BEGIN OF st_sflight.
INCLUDE STRUCTURE zsflight.
Field for line color
types: line_color(4) type c.
TYPES: END OF st_sflight.
TYPES: tt_sflight TYPE STANDARD TABLE OF st_sflight.
DATA: gi_sflight TYPE tt_sflight.
Loop trough the table to set the color properties of each line. The color properties field is
Char 4 and the characters is set as follows:
Char 1 = C = This is a color property
Char 2 = 6 = Color code (1 - 7)
Char 3 = Intensified on/of = 1 = on
Char 4 = Inverse display = 0 = of
LOOP AT gi_sflight INTO g_wa_sflight.
IF g_wa_sflight-paymentsum < 100000.
g_wa_sflight-line_color = 'C610'.
ENDIF.
MODIFY gi_sflight FROM g_wa_sflight.
ENDLOOP.
Name of the color field
gs_layout-info_fname = 'LINE_COLOR'.
Grid setup for first display
CALL METHOD go_grid->set_table_for_first_display
EXPORTING i_structure_name = 'SFLIGHT'
is_layout = gs_layout
CHANGING it_outtab = gi_sflight.
Regards,
John
Edited by: Matt on Dec 22, 2008 11:18 AM -
Appending a new line to ALV Grid
Hi,
I have created an editable ALV grid wherein the first 2 columns are key fields and hence non-editable and the rest are editable.
Now I try to append or create a row on the ALV Grid by using the standard toolbar buttons. By doing so, it adds a new line that has the first 2 columns (key fields) as non-editable and the rest as editable. I would like to open those key fields for edit mode when I try to append or insert a new row.
I overwrote the code for append and insert with my code like this
METHOD handle_toolbar.
DATA: ls_toolbar TYPE stb_button.
READ TABLE e_object->mt_toolbar INTO ls_toolbar
WITH KEY function = '&LOCAL&APPEND'.
IF sy-subrc = 0.
ls_toolbar-function = 'MY_APPEND'.
MODIFY e_object->mt_toolbar FROM ls_toolbar INDEX sy-tabix.
ENDIF.
ENDMETHOD.
METHOD handle_user_command.
DATA: ls_table TYPE ztable.
CASE e_ucomm.
WHEN 'MY_APPEND'.
APPEND ls_table TO gt_table. "append an initial line
PERFORM modify_alv TABLES gt_table.
CALL METHOD gref_alv->refresh_table_display.
ENDCASE.
ENDMETHOD.
FORM modify_alv TABLES xt_lt_table STRUCTURE ztable.
LOOP AT xt_lt_table INTO ls_table.
REFRESH lt_cell_style.
IF NOT ls_table IS INITIAL.
ls_cell_style-fieldname = 'FIELD1'.
ls_cell_style-style = cl_gui_alv_grid=>mc_style_disabled.
INSERT ls_cell_style INTO TABLE lt_cell_style.
ELSE.
ls_cell_style-fieldname = 'FIELD1'.
ls_cell_style-style = cl_gui_alv_grid=>mc_style_enabled.
INSERT ls_cell_style INTO TABLE lt_cell_style.
ENDIF.
INSERT LINES OF lt_cell_style
INTO TABLE ls_table-gt_cell_style .
MODIFY xt_lt_table FROM ls_table.
CLEAR: ls_cell_style.
ENDLOOP.
CALL METHOD gref_alv->set_ready_for_input
EXPORTING
i_ready_for_input = 1.
ENDFORM.
I used a field catalog to set my ALV for first display where I set the edit field to space for the first 2 columns. I used the modify_alv subroutine to overwrite the editability property of the fields inside the handle_user_command method.
But when I try to append a row, I don't see a switch to edit mode for the key fields.
I have tried searching through but couldn't find anything helpful. Please help me.
Edited by: Nitwick on Jul 13, 2010 4:46 PMHi,
Made a silly error in the code while populating the gs_layout.
My declaration had the cell style table to be 'GT_CELL_STYLE'. I have populated it with a local cell style table. So ideally it had to be
gs_layout-stylefname = 'GT_CELL_STYLE'. -
How to add a new server to the grid control
Hi ,
OEM 10g grid control has already bee installed n our site . But I don't know how a add /configure a new sever / database into that . Do I need to install the agent software on the destination machine OR is there any way to add the new sever from the 10g grid control itself ... Please help me out . You can also revert me back on my id [email protected]
redgs
RAHULthnx for replying .
Could you please tell me the patch number that I need to download for OEM grid control 10.2.0.3 . Actually I searched for lot of docs . But didn't found doc regarding installation of oem agent and agent PATCH number .
So , Please revert back with necessary Patch number and all the steps that I need to be follow . Thanx in advance
regds
RAHUL -
Populating Constant value to a column while inserting new lines to ALV Grid
Hi all,
I need to know how to populate a column in an ALV grid with a constant value , whenever a new line is inserted in the ALV.
Regards,
VijayakumarHi Arun,
g_t_alv is my Internal table. I am inseritng a button in the field name ICON.Now all my records in the ALV will contain a button in the field ICON. But when i create a new line in the ALV the field ICON is containing an empty space.
loop at g_t_alv into g_r_alv.
ls_edit-fieldname = 'ICON'.
ls_edit-style = cl_gui_alv_grid=>mc_style_button.
INSERT ls_edit INTO TABLE lt_edit.
INSERT LINES OF lt_edit INTO TABLE g_r_alv-handle_style.
MODIFY g_t_alv FROM g_r_alv.
endloop. -
Problem with alv grid control editable
Hello all. I ask your help with this question because I did not find the answer in the forum. Sorry for my pour english.
I have an alv grid control (OO) with the standards buttons 'insert a line', 'delete a line', 'copy a line'.
My problem is I want to catch the event of these buttons, because after I register the events mc_evt_enter y mc_evt_modifies, when I push the button to insert a new line the alv grid show the new line and then get a dump with error: Field symbol has not yet been assigned.
My problem is that no event is launched when I push the button. I tried to catch the event before command but it does not happen.
It is like these standard buttons works apart and it is not possible to find out what they are doing.
I have read the manual easy reference for alv grid control, and I created the class lcl_event_handler exactly equal.
I have tried to debug the code in order to find the error but I can find out where it has been done.
Thank you in advance. If anybody needs to see my code I will send you or post you.David,
What you need to do for that is to enable the editing field by field. You will have to add a field STYLE type LVC_T_STYL to the DATA table. This nested internal table will hold the information for each field of the row, whether the column is editable or not. So, if you have 5 columns, then the nested internal table will have 5 rows for each row of the main internal table.
Once this is done, you will have to append a blank row to the table, making all the fields editable and REFRESH the display.
Regards,
Ravi
Note: Please mark the answers as helpful if they help. -
ALV Grid Control - Modifiy data in total and subtotal lines
Hello all,
I´am creating a report using ALV Grid Control. This report calculates (using delivered and returned materials) for each vendor/material-combination the return quote.
Using the totals and subtotals function for different characteristics I want to calculate the return quote for the selected characteristic. Example:
Material delivered returned quote
..4711 . . . 500 . . . 5 . . . . 1 (=returned*100/delivered)
..4711 . . . 400 . . . 10 . . . . 2,5
. SUM . . . 900 . . . 15 . . . . 3,5 <-- 3,5 is the sum but I want display the calculated value 1,667
Is there a possibility to modify data in the total and subtotal lines.
Thank you for your answer
Best regards
Thomasyou said instead of 3.5 you want to show 1,667 ..
how is it possible...
3,5 become 1,667
i thought you are doing any conversions...
vijay -
Add new line in ALV report on click of button...
Dear All,
How to add a new line for input in ALV report at runtime, on click of a button.
Waiting for early and favorable reply.
Regards,
Dharmesh VyasHi,
First of all u have to Create ur own PF-status and Assign Fcode e.g 'INSERTROW'.
So, whenevr you will click Insertrow button it will be triggered in your User Command and then just Append the blank line in your Final Internal Table.
And Refresh Icon will be there by default...
To Trigger it You have to write rs_selfield-refresh = 'X'
You can also follow the below link...
Try it.
Link:[http://wiki.sdn.sap.com/wiki/display/ABAP/ALVeasytutorial].
Regards
Arbind -
Add new line in ALV report and Refresh button
How to add a new line in a ALV report?
How to add a refresh button in a report?Hi,
First of all u have to Create ur own PF-status and Assign Fcode e.g 'INSERTROW'.
So, whenevr you will click Insertrow button it will be triggered in your User Command and then just Append the blank line in your Final Internal Table.
And Refresh Icon will be there by default...
To Trigger it You have to write rs_selfield-refresh = 'X'
You can also follow the below link...
Try it.
Link:[http://wiki.sdn.sap.com/wiki/display/ABAP/ALVeasytutorial].
Regards
Arbind -
Can we add page numbers to ALV Grid Control.
Hi All,
1.My requirement is to display page numbers when we down load the list in to EXCEL.
Can we do this in ALV Grid Control.
2.Can we display the page numbers in the SAP Query,when we down load the out put list in to the EXCEL.
Thanks & Regards,
Seshadri GHi Seshadri,
No, it is not possible to print the page number when you download the list to EXCEL. Because in ALV grid the report output is display as table contorl and this data can not be divided into page when you download to EXCEL.
Regards,
Satya. -
Hi Everyone,
I am working on ALV Grid Control, where i am facing a problem with adding new buttons and writing the new code for the button, for placing the (display) button i used the method <b>handle_tool_bar</b>, But i want to know how to write the code for this particular button (display).
Kindly give me the solution for thishttp://www.abap4.it/download/ALV.pdf
Add the handle so we get user command control (ie Refresh)
perform add_handle using 'USER_COMMAND' 'PAI_USER_COMMAND'.
Colour and hotspot the project id column
w_fieldcat-fieldname = 'PROJECT_ID'.
w_fieldcat-emphasize = 'C400'.
w_fieldcat-hotspot = 'X'.
append w_fieldcat to t_fieldcat.
Iconify and set the length of the icon column
clear w_fieldcat.
w_fieldcat-fieldname = 'ZEXCEPTION'.
w_fieldcat-icon = 'X'.
w_fieldcat-outputlen = g_light_length.
append w_fieldcat to t_fieldcat.
Intensify every other line, improves readability
t_layout-zebra = 'X'.
Set up an exit on the refresh event, so it gets passed back to us
wa_event_exit-ucomm = '&REFRESH'. " Refresh
wa_event_exit-after = 'X'.
append wa_event_exit to t_event_exit.
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = 'ZGER_PROJECT_ID' " **CHANGE** !
i_callback_pf_status_set = 'SET_PF_STATUS'
i_structure_name = 'ZPROJECT_DATA'
i_grid_title = 'Project list'
it_event_exit = t_event_exit
i_default = 'X'
it_fieldcat = t_fieldcat
is_layout = t_layout
i_save = 'A'
it_events = t_events
tables
t_outtab = t_main
exceptions
program_error = 1
others = 2. -
Event for the List Box in ALV Grid Control
Hello,
I have the below urgent requirment.
I have an ALV Grid Control built using ABAP Objects. In the grid, I have few fields and one of these fields is a List Box. Depending on the values selected, I need to enable or disable some fields. So, is there any event for the List box in ALV Grid Control.
For ex: I have 2 Fields, Designation and Commission. The designation field is a List Box field having 'Software Engineer' and 'Manager' as values. When I select 'Software Engineer', the commission field should be disabled. When I select 'Manager', the comission field should be enabled.
Early reply is hightly appreciated.
PriyaREPORT ZTEST1234 MESSAGE-ID ZZ .
DATA: G_GRID TYPE REF TO CL_GUI_ALV_GRID.
DATA: L_VALID TYPE C,
V_FLAG,
V_DATA_CHANGE,
V_ROW TYPE LVC_S_ROW,
V_COLUMN TYPE LVC_S_COL,
V_ROW_NUM TYPE LVC_S_ROID.
DATA: OK_CODE LIKE SY-UCOMM,
SAVE_OK LIKE SY-UCOMM,
G_CONTAINER1 TYPE SCRFNAME VALUE 'TEST',
GS_LAYOUT TYPE LVC_S_LAYO.
DATA:BEGIN OF ITAB OCCURS 0,
VBELN LIKE LIKP-VBELN,
POSNR LIKE LIPS-POSNR,
COMISN(10),
CELLCOLOR TYPE LVC_T_SCOL, "required for color
DROP(20),
<b> HANDLE_STYLE TYPE LVC_T_STYL,</b>
END OF ITAB.
* CLASS lcl_event_handler DEFINITION
CLASS LCL_EVENT_HANDLER DEFINITION .
PUBLIC SECTION .
METHODS:
**Hot spot Handler
HANDLE_HOTSPOT_CLICK FOR EVENT HOTSPOT_CLICK OF CL_GUI_ALV_GRID
IMPORTING E_ROW_ID E_COLUMN_ID ES_ROW_NO,
<b>**Handler to Check the Data Change
HANDLE_DATA_CHANGED FOR EVENT DATA_CHANGED
OF CL_GUI_ALV_GRID
IMPORTING ER_DATA_CHANGED
E_ONF4
E_ONF4_BEFORE
E_ONF4_AFTER,</b>
**Double Click Handler
HANDLE_DOUBLE_CLICK FOR EVENT DOUBLE_CLICK OF CL_GUI_ALV_GRID
IMPORTING E_ROW E_COLUMN ES_ROW_NO.
ENDCLASS. "lcl_event_handler DEFINITION
* CLASS lcl_event_handler IMPLEMENTATION
CLASS LCL_EVENT_HANDLER IMPLEMENTATION.
*Handle Hotspot Click
METHOD HANDLE_HOTSPOT_CLICK .
CLEAR: V_ROW,V_COLUMN,V_ROW_NUM.
V_ROW = E_ROW_ID.
V_COLUMN = E_COLUMN_ID.
V_ROW_NUM = ES_ROW_NO.
MESSAGE I000 WITH V_ROW 'clicked'.
ENDMETHOD. "lcl_event_handler
*Handle Double Click
METHOD HANDLE_DOUBLE_CLICK.
ENDMETHOD. "handle_double_click
<b>**Handle Data Change
METHOD HANDLE_DATA_CHANGED.
DATA: X_CHANGE TYPE LVC_S_MODI,
X_FINAL TYPE ITAB,
L_FLAG,
LS_OUTTAB LIKE LINE OF ITAB.
DATA: LS_EDIT TYPE LVC_S_STYL,
LT_EDIT TYPE LVC_T_STYL.
LOOP AT ER_DATA_CHANGED->MT_GOOD_CELLS INTO X_CHANGE.
IF X_CHANGE-FIELDNAME = 'DROP' AND X_CHANGE-VALUE = 'S/W ENGINEER'.
LS_EDIT-FIELDNAME = 'COMISN'.
LS_EDIT-STYLE = CL_GUI_ALV_GRID=>MC_STYLE_DISABLED.
LS_EDIT-STYLE2 = SPACE.
LS_EDIT-STYLE3 = SPACE.
LS_EDIT-STYLE4 = SPACE.
LS_EDIT-MAXLEN = 8.
INSERT LS_EDIT INTO TABLE LT_EDIT.
INSERT LINES OF LT_EDIT INTO TABLE LS_OUTTAB-HANDLE_STYLE.
MODIFY ITAB INDEX X_CHANGE-ROW_ID FROM LS_OUTTAB TRANSPORTING
HANDLE_STYLE .
else.
LS_EDIT-FIELDNAME = 'COMISN'.
LS_EDIT-STYLE = CL_GUI_ALV_GRID=>MC_STYLE_ENABLED.
LS_EDIT-STYLE2 = SPACE.
LS_EDIT-STYLE3 = SPACE.
LS_EDIT-STYLE4 = SPACE.
LS_EDIT-MAXLEN = 8.
INSERT LS_EDIT INTO TABLE LT_EDIT.
INSERT LINES OF LT_EDIT INTO TABLE LS_OUTTAB-HANDLE_STYLE.
MODIFY ITAB INDEX X_CHANGE-ROW_ID FROM LS_OUTTAB TRANSPORTING
HANDLE_STYLE .
ENDIF.
ENDLOOP.
CALL METHOD G_GRID->REFRESH_TABLE_DISPLAY
EXCEPTIONS
FINISHED = 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.
ENDMETHOD. "HANDLE_DATA_CHANGED</b>
ENDCLASS. "LCL_EVENT_HANDLER IMPLEMENTATION
*& Global Definitions
DATA: G_CUSTOM_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER,"Container1
G_HANDLER TYPE REF TO LCL_EVENT_HANDLER. "handler
*- Fieldcatalog for First and second Report
DATA: IT_FIELDCAT TYPE LVC_T_FCAT,
X_FIELDCAT TYPE LVC_S_FCAT,
LS_VARI TYPE DISVARIANT.
* START-OF_SELECTION
START-OF-SELECTION.
SELECT VBELN
POSNR
FROM LIPS
UP TO 20 ROWS
INTO CORRESPONDING FIELDS OF TABLE ITAB.
END-OF-SELECTION.
IF NOT ITAB[] IS INITIAL.
CALL SCREEN 100.
ELSE.
MESSAGE I002 WITH 'NO DATA FOR THE SELECTION'(004).
ENDIF.
*& Form CREATE_AND_INIT_ALV
* text
FORM CREATE_AND_INIT_ALV .
DATA: LT_EXCLUDE TYPE UI_FUNCTIONS.
CREATE OBJECT G_CUSTOM_CONTAINER
EXPORTING CONTAINER_NAME = G_CONTAINER1.
CREATE OBJECT G_GRID
EXPORTING I_PARENT = G_CUSTOM_CONTAINER.
* Set a titlebar for the grid control
CLEAR GS_LAYOUT.
GS_LAYOUT-GRID_TITLE = TEXT-003.
<b>GS_LAYOUT-STYLEFNAME = 'HANDLE_STYLE'.</b>
GS_LAYOUT-ZEBRA = SPACE.
GS_LAYOUT-CWIDTH_OPT = 'X'.
GS_LAYOUT-NO_ROWMARK = 'X'.
GS_LAYOUT-CTAB_FNAME = 'CELLCOLOR'.
<b> CALL METHOD G_GRID->REGISTER_EDIT_EVENT
EXPORTING
I_EVENT_ID = CL_GUI_ALV_GRID=>MC_EVT_MODIFIED.</b>
CREATE OBJECT G_HANDLER.
SET HANDLER G_HANDLER->HANDLE_DOUBLE_CLICK FOR G_GRID.
SET HANDLER G_HANDLER->HANDLE_HOTSPOT_CLICK FOR G_GRID.
<b> SET HANDLER G_HANDLER->HANDLE_DATA_CHANGED FOR G_GRID.</b>
DATA: LS_CELLCOLOR TYPE LVC_S_SCOL. "required for color
DATA: L_INDEX TYPE SY-TABIX.
"Here i am changing the color of line 1,5,10...
"so you can change the color of font conditionally
LOOP AT ITAB.
L_INDEX = SY-TABIX.
IF L_INDEX = 1 OR L_INDEX = 5 OR L_INDEX = 10.
LS_CELLCOLOR-FNAME = 'VBELN'.
LS_CELLCOLOR-COLOR-COL = '6'.
LS_CELLCOLOR-COLOR-INT = '0'.
LS_CELLCOLOR-COLOR-INV = '1'.
APPEND LS_CELLCOLOR TO ITAB-CELLCOLOR.
MODIFY ITAB INDEX L_INDEX TRANSPORTING CELLCOLOR.
LS_CELLCOLOR-FNAME = 'POSNR'.
LS_CELLCOLOR-COLOR-COL = '6'.
LS_CELLCOLOR-COLOR-INT = '0'.
LS_CELLCOLOR-COLOR-INV = '1'.
APPEND LS_CELLCOLOR TO ITAB-CELLCOLOR.
MODIFY ITAB INDEX L_INDEX TRANSPORTING CELLCOLOR.
ENDIF.
ENDLOOP.
* setting focus for created grid control
CALL METHOD CL_GUI_CONTROL=>SET_FOCUS
EXPORTING
CONTROL = G_GRID.
* Build fieldcat and set editable for date and reason code
* edit enabled. Assign a handle for the dropdown listbox.
PERFORM BUILD_FIELDCAT.
PERFORM SET_DRDN_TABLE.
* Optionally restrict generic functions to 'change only'.
* (The user shall not be able to add new lines).
PERFORM EXCLUDE_TB_FUNCTIONS CHANGING LT_EXCLUDE.
**Vaiant to save the layout
LS_VARI-REPORT = SY-REPID.
LS_VARI-HANDLE = SPACE.
LS_VARI-LOG_GROUP = SPACE.
LS_VARI-USERNAME = SPACE.
LS_VARI-VARIANT = SPACE.
LS_VARI-TEXT = SPACE.
LS_VARI-DEPENDVARS = SPACE.
CALL METHOD G_GRID->REGISTER_EDIT_EVENT
EXPORTING
I_EVENT_ID = CL_GUI_ALV_GRID=>MC_EVT_MODIFIED.
**Calling the Method for ALV output
CALL METHOD G_GRID->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
IT_TOOLBAR_EXCLUDING = LT_EXCLUDE
IS_VARIANT = LS_VARI
IS_LAYOUT = GS_LAYOUT
I_SAVE = 'A'
CHANGING
IT_FIELDCATALOG = IT_FIELDCAT
IT_OUTTAB = ITAB[].
* Set editable cells to ready for input initially
CALL METHOD G_GRID->SET_READY_FOR_INPUT
EXPORTING
I_READY_FOR_INPUT = 1.
ENDFORM. "CREATE_AND_INIT_ALV
*& Form EXCLUDE_TB_FUNCTIONS
* text
* -->PT_EXCLUDE text
FORM EXCLUDE_TB_FUNCTIONS CHANGING PT_EXCLUDE TYPE UI_FUNCTIONS.
* Only allow to change data not to create new entries (exclude
* generic functions).
DATA LS_EXCLUDE TYPE UI_FUNC.
LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_COPY_ROW.
APPEND LS_EXCLUDE TO PT_EXCLUDE.
LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_DELETE_ROW.
APPEND LS_EXCLUDE TO PT_EXCLUDE.
LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_APPEND_ROW.
APPEND LS_EXCLUDE TO PT_EXCLUDE.
LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_INSERT_ROW.
APPEND LS_EXCLUDE TO PT_EXCLUDE.
LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_MOVE_ROW.
APPEND LS_EXCLUDE TO PT_EXCLUDE.
LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_COPY.
APPEND LS_EXCLUDE TO PT_EXCLUDE.
LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_CUT.
APPEND LS_EXCLUDE TO PT_EXCLUDE.
LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_PASTE.
APPEND LS_EXCLUDE TO PT_EXCLUDE.
LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_PASTE_NEW_ROW.
APPEND LS_EXCLUDE TO PT_EXCLUDE.
LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_UNDO.
APPEND LS_EXCLUDE TO PT_EXCLUDE.
ENDFORM. " EXCLUDE_TB_FUNCTIONS
*& Form build_fieldcat
* Fieldcatalog
FORM BUILD_FIELDCAT .
DATA: L_POS TYPE I.
L_POS = L_POS + 1.
X_FIELDCAT-SCRTEXT_M = 'Delivery'(024).
X_FIELDCAT-FIELDNAME = 'VBELN'.
X_FIELDCAT-TABNAME = 'ITAB'.
X_FIELDCAT-COL_POS = L_POS.
X_FIELDCAT-NO_ZERO = 'X'.
X_FIELDCAT-OUTPUTLEN = '10'.
X_FIELDCAT-HOTSPOT = 'X'.
APPEND X_FIELDCAT TO IT_FIELDCAT.
CLEAR X_FIELDCAT.
L_POS = L_POS + 1.
X_FIELDCAT-SCRTEXT_M = 'Item'(025).
X_FIELDCAT-FIELDNAME = 'POSNR'.
X_FIELDCAT-TABNAME = 'ITAB'.
X_FIELDCAT-COL_POS = L_POS.
X_FIELDCAT-OUTPUTLEN = '5'.
APPEND X_FIELDCAT TO IT_FIELDCAT.
CLEAR X_FIELDCAT.
L_POS = L_POS + 1.
X_FIELDCAT-SCRTEXT_M = 'Drop'(025).
X_FIELDCAT-FIELDNAME = 'DROP'.
X_FIELDCAT-TABNAME = 'ITAB'.
X_FIELDCAT-COL_POS = L_POS.
X_FIELDCAT-OUTPUTLEN = '5'.
X_FIELDCAT-EDIT = 'X'.
X_FIELDCAT-DRDN_HNDL = '1'.
X_FIELDCAT-DRDN_ALIAS = 'X'.
APPEND X_FIELDCAT TO IT_FIELDCAT.
CLEAR X_FIELDCAT.
L_POS = L_POS + 1.
X_FIELDCAT-SCRTEXT_M = 'Comissn'(025).
X_FIELDCAT-FIELDNAME = 'COMISN'.
X_FIELDCAT-TABNAME = 'ITAB'.
X_FIELDCAT-COL_POS = L_POS.
X_FIELDCAT-OUTPUTLEN = '10'.
X_FIELDCAT-EDIT = 'X'.
APPEND X_FIELDCAT TO IT_FIELDCAT.
CLEAR X_FIELDCAT.
ENDFORM. " build_fieldcat
*& Module STATUS_0100 OUTPUT
* text
MODULE STATUS_0100 OUTPUT.
SET PF-STATUS 'MAIN100'.
SET TITLEBAR 'MAIN100'.
IF G_CUSTOM_CONTAINER IS INITIAL.
**Initializing the grid and calling the fm to Display the O/P
PERFORM CREATE_AND_INIT_ALV.
ENDIF.
ENDMODULE. " STATUS_0100 OUTPUT
*& Module USER_COMMAND_0100 INPUT
* text
MODULE USER_COMMAND_0100 INPUT.
CASE SY-UCOMM.
WHEN 'BACK'.
LEAVE TO SCREEN 0.
ENDCASE.
ENDMODULE. " USER_COMMAND_0100 INPUT
*& Form SET_DRDN_TABLE
* text
FORM SET_DRDN_TABLE.
DATA:LT_DRAL TYPE LVC_T_DRAL,
LS_DRAL TYPE LVC_S_DRAL.
LS_DRAL-HANDLE = '1'.
LS_DRAL-VALUE = 'S/W Engineer'.
LS_DRAL-INT_VALUE = 'S/W Engineer'.
APPEND LS_DRAL TO LT_DRAL.
LS_DRAL-HANDLE = '1'.
LS_DRAL-VALUE = 'Manager'.
LS_DRAL-INT_VALUE = 'Manager'.
APPEND LS_DRAL TO LT_DRAL.
**Setting the Drop down table for Reason Code
CALL METHOD G_GRID->SET_DROP_DOWN_TABLE
EXPORTING
IT_DROP_DOWN_ALIAS = LT_DRAL.
ENDFORM. " set_drdn_table
Regards
vijay -
Unwanted field validation when adding new line to ALV (ABAP OO)
Hi,
We are using OO Controls to create an editable ALV grid, whose structure contains debit/credit indicator.
When we click on the standard add new line button, a new line is added but an error message appears telling the user to enter a valid credit/ debit indicator (of course it is blank in the new line).
This is annoying for users - is there any way to suppress this when....but just when a new line is being created?
Thanks,
TristanDebug and find out what is the sy-ucomm when you add a new line in the ALV. And then In the validation of "enter a valid credit/ debit indicator " put a IF condition to check the if the SY-ucomm is not for inseting new line.
Hope this helps.
Fran -
How do you gracefully error/exit an ALV Grid Controls
I have a report that uses ALV grid controls. Inside the screens, I am opening a file, and need to give an error if the file does not successfully open. I do not have any problem doing this, BUT when I error, it takes me totally out of the program, and I really just want to get back to the report selection screen. I have not been successful in finding out how to do this. Any help is very much appreciated!! Thanks!
Here is how some of the code looks....this is the initial call into the first screen of the ALV grid. From the screen 100 of the ALV Grid, I want to be able to hit the green back arrow button and go back to the report selection criteria so that the user can easily change a file name in case they entered it wrong, etc. Here is the code:
START-OF-SELECTION.
IF NOT p_ofile IS INITIAL.
CONCATENATE p_opath p_ofile INTO p_ofile.
ENDIF.
IF NOT p_sfile IS INITIAL.
CONCATENATE p_spath p_sfile INTO p_sfile.
ENDIF.
IF NOT p_ifile IS INITIAL.
CONCATENATE p_ipath p_ifile INTO p_ifile.
ENDIF.
IF NOT p_ofile2 IS INITIAL.
CONCATENATE p_opath p_ofile2 INTO p_ofile2.
ENDIF.
IF NOT p_sfile2 IS INITIAL.
CONCATENATE p_spath p_sfile2 INTO p_sfile2.
ENDIF.
IF NOT p_ifile2 IS INITIAL.
CONCATENATE p_ipath p_ifile2 INTO p_ifile2.
ENDIF.
IF NOT p_ofile3 IS INITIAL.
CONCATENATE p_opath p_ofile3 INTO p_ofile3.
ENDIF.
IF NOT p_sfile3 IS INITIAL.
CONCATENATE p_spath p_sfile3 INTO p_sfile3.
ENDIF.
IF NOT p_ofile4 IS INITIAL.
CONCATENATE p_opath p_ofile4 INTO p_ofile4.
ENDIF.
IF NOT p_sfile4 IS INITIAL.
CONCATENATE p_spath p_sfile4 INTO p_sfile4.
ENDIF.
IF NOT p_ofile5 IS INITIAL.
CONCATENATE p_opath p_ofile5 INTO p_ofile5.
ENDIF.
IF NOT p_ofile6 IS INITIAL.
CONCATENATE p_opath p_ofile6 INTO p_ofile6.
ENDIF.
IF NOT p_ofile7 IS INITIAL.
CONCATENATE p_opath p_ofile7 INTO p_ofile7.
ENDIF.
IF NOT p_ofile8 IS INITIAL.
CONCATENATE p_opath p_ofile8 INTO p_ofile8.
ENDIF.
SELECT * FROM zgedwsostmg INTO TABLE xzgedwsostmg.
SELECT SINGLE delimiter_hex FROM zgedwflcnfg
INTO g_delimiter_hex
WHERE kappl = 'V1'.
g_hex_value = g_delimiter_hex.
END-OF-SELECTION.
PERFORM load_header_table.
SET SCREEN 100.
Screen 100 Code
PROCESS BEFORE OUTPUT.
MODULE status_0100.
MODULE create_objects.
PROCESS AFTER INPUT.
MODULE pai_100 at exit-command.
MODULE pai_100 INPUT.
CASE ok_code.
WHEN 'BACK'.
g_back = 'X'.
PERFORM exit_program.
exit.
WHEN 'EXIT'.
PERFORM exit_program.
WHEN 'CANC'.
PERFORM exit_program.
ENDCASE.
CLEAR ok_code.
ENDMODULE. " PAI INPUT
FORM exit_program.
CALL METHOD g_custom_container1->free.
IF NOT g_custom_container2 IS INITIAL.
CALL METHOD g_custom_container2->free.
ENDIF.
CALL METHOD cl_gui_cfw=>flush.
IF sy-subrc NE 0.
add your handling, for example
CALL FUNCTION 'POPUP_TO_INFORM'
EXPORTING
titel = g_repid
txt2 = sy-subrc
txt1 = 'Error in Flush'(500).
ENDIF.
LEAVE PROGRAM.
set screen 0.
leave screen.
leave screen.
leave to screen 1000.
CALL SELECTION-SCREEN 1000.
leave to list-processing.
exit.
leave to screen 0.
ENDFORM. " exit_program
As you can see by all the commented lines, I have tried several ways to make this work, but without success. Thanks again for any help!! -
I need model program for alv grid control
hi all,
i need example program and detailed description of alv grid control . what is the features of alv grid control over normal alv.Hi,
Check out the below sample code.I have pasted even the include programs, u can copy the program.
SAP-User : BWR2KOR *
Author (name) : Bharadwaja R *
Created on/in : 07.02.2006 *
Description : Report for Listing IDOC-Informations for the given *
segment on the selection screen *
Changes: - for each change: add chapter *
- changes get a changes number (ascending) *
- source code has to be marked with SAP-user-name *
change date and number *
Change number : *
Enhance/Change numer: 90xxxx (900001-909999) -> /RB11/YBF_MODIF *
SAP-User : *
Author (name) : *
Created on/in : *
Reason for the change: *
REPORT Y16S_VIEW_IDOC_CONTENT LINE-SIZE 230
NO STANDARD PAGE HEADING.
Data declarations
INCLUDE Y16S_VIEW_IDOC_CONTENT_D01I.
Selection screen
INCLUDE Y16S_VIEW_IDOC_CONTENT_S01I.
Events
INCLUDE Y16S_VIEW_IDOC_CONTENT_E01I.
Routines for program
INCLUDE Y16S_VIEW_IDOC_CONTENT_F01I.
START-OF-SELECTION.
Get the fieldcatalog
PERFORM get_fcat.
**Method for getting the reference for the structure
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING it_fieldcatalog = g_t_fieldcat
IMPORTING ep_table = dref.
**Passing the reference of the structure to field-symbol of type table
ASSIGN dref->* TO .
Fill IDoc data
PERFORM fill_data.
Display ALV
perform display_grid.
INCLUDE Y16S_VIEW_IDOC_CONTENT_D01I *
Data declaration : Tables used *
TABLES : edidd, "Data record (IDoc)
edidc, "Control record (IDoc)
edid4, "IDoc Data Records from 4.0 onwards
dd03d, "Dynpro fields for table fields
edsappl, "EDI: IDoc Segment Application Structure
int_seg, "Data record details display
dd03l, "Table Fields
edisegment. "IDoc Development : IDoc Segment
Name of segment
DATA : g_f_segment LIKE dntab-tabname.
*--Data Declaration.
FIELD-SYMBOLS : TYPE ANY.
DATA : BEGIN OF g_t_edid OCCURS 0,
docnum LIKE edid4-docnum,
segnum LIKE edid4-segnum,
sdata LIKE edid4-sdata,
END OF g_t_edid.
*DATA : g_t_edid LIKE edid4 OCCURS 0 WITH HEADER LINE.
DATA : BEGIN OF g_t_edidc OCCURS 0,
docnum LIKE edidc-docnum,
credat LIKE edidc-credat,
mestyp LIKE edidc-mestyp,
END OF g_t_edidc.
DATA : BEGIN OF g_t_appl OCCURS 0,
fieldname LIKE edsappl-fieldname,
END OF g_t_appl.
DATA : g_v_tabix LIKE sy-tabix.
ALV Declarations
*Declaration of type groups
TYPE-POOLS :
slis. "Globale Typen für generische Listbausteine
DATA: g_f_okcode LIKE sy-ucomm,
g_container TYPE scrfname VALUE 'G_C_ALV',
grid1 TYPE REF TO cl_gui_alv_grid,
g_custom_container TYPE REF TO cl_gui_custom_container.
FIELD-SYMBOLS: .
Class
CLASS: g_cl_event DEFINITION DEFERRED.
Alv Grid Constants
DATA : g_c_handle(4) TYPE c VALUE '0100',
g_c_save(1) TYPE c VALUE 'A',
g_c_exit(4) TYPE c VALUE 'EXIT'.
DATA: g_v_layout TYPE lvc_s_layo,
g_f_print TYPE lvc_s_prnt,
g_f_variant TYPE disvariant,
g_v_recv TYPE REF TO g_cl_event.
CONSTANTS : gc_ucomm_sel_criteria(12) VALUE 'SEL_CRITERIA'.
CLASS G_Cl_EVENT DEFINITION
Class to handle GRID Events *
CLASS g_cl_event DEFINITION.
PUBLIC SECTION.
METHODS:
constructor IMPORTING value(grid_name) TYPE REF TO
cl_gui_alv_grid,
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.
PRIVATE SECTION.
DATA: g_v_alv TYPE REF TO cl_gui_alv_grid.
ENDCLASS. "g_cl_event DEFINITION
CLASS g_cl_events IMPLEMENTATION
Class to handle GRID Events *
CLASS g_cl_event IMPLEMENTATION.
Handling methods
METHOD constructor.
g_v_alv = grid_name.
ENDMETHOD. "constructor
Tool bar
METHOD handle_toolbar.
CONSTANTS:
lc_quickinfo_sel_criteria(111) VALUE 'Show Selection Criteria'.
DATA:
l_toolbar TYPE stb_button.
CLEAR l_toolbar.
MOVE 0 TO l_toolbar-butn_type.
MOVE gc_ucomm_sel_criteria TO l_toolbar-function.
MOVE icon_select_with_condition TO l_toolbar-icon.
MOVE lc_quickinfo_sel_criteria TO l_toolbar-quickinfo.
MOVE space TO l_toolbar-disabled.
APPEND l_toolbar TO e_object->mt_toolbar.
ENDMETHOD. "handle_toolbar
User Command
METHOD handle_user_command.
CASE e_ucomm.
When Exit button is used
WHEN 'EXIT'.
PERFORM exit_program.
WHEN OTHERS.
ENDCASE.
ENDMETHOD. "handle_user_command
ENDCLASS. "g_cl_event IMPLEMENTATION
INCLUDE Y16S_VIEW_IDOC_CONTENT_S01I *
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME.
Creation Date of IDoc
SELECT-OPTIONS : s_date FOR edidc-credat.
IDoc Number
SELECT-OPTIONS : s_idocnm FOR edidc-docnum.
Basic IDoc type
SELECT-OPTIONS : s_idoctp FOR edidc-idoctp.
*Message type
SELECT-OPTIONS : s_mestyp FOR edidc-mestyp.
Segment name
PARAMETERS : p_segnam LIKE edisegment-segtyp OBLIGATORY.
Field name
SELECT-OPTIONS : s_fldnam FOR dd03d-fieldname NO INTERVALS.
SELECTION-SCREEN END OF BLOCK b1.
SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME.
Field name
PARAMETERS : p_fldnam LIKE dd03d-fieldname.
Field contents of a field of an IDoc segment
SELECT-OPTIONS : s_fldval FOR int_seg-string.
SELECTION-SCREEN END OF BLOCK b2.
INCLUDE Y16S_VIEW_IDOC_CONTENT_E01I *
Check for IDoc number on selection screen
AT SELECTION-SCREEN ON s_idocnm.
IF NOT s_idocnm IS INITIAL.
Data fetch : Control record (IDoc)
SELECT COUNT( * ) FROM edidc
WHERE docnum IN s_idocnm.
IF sy-subrc NE 0.
MESSAGE e429(mo).
ENDIF.
ELSE.
message for required entry.
MESSAGE e055(00).
ENDIF.
Check for segment name on selection screen
AT SELECTION-SCREEN ON p_segnam.
Check segment name is an input on selection screen
IF NOT p_segnam IS INITIAL.
Data fetch : Table Fields
SELECT SINGLE * FROM dd03l
WHERE tabname EQ p_segnam.
IF sy-subrc NE 0.
MESSAGE e429(mo).
ENDIF.
ENDIF.
F4 help for fieldname
AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_fldnam-low.
DATA : l_rc LIKE sy-subrc.
Check segment name on selection screen is not empty
IF NOT p_segnam IS INITIAL.
PERFORM get_f4help USING l_rc.
IF l_rc = 0.
Fill the selected field name
READ TABLE g_t_appl INDEX g_v_tabix.
CHECK sy-subrc = 0.
s_fldnam-low = g_t_appl-fieldname.
s_fldnam-sign = 'I'.
s_fldnam-option = 'EQ'.
APPEND s_fldnam.
ENDIF.
ENDIF.
Check for field name on selection screen
AT SELECTION-SCREEN ON s_fldnam.
IF NOT p_fldnam IS INITIAL.
Data fetch : Table Fields
SELECT SINGLE * FROM dd03l
WHERE tabname EQ p_segnam
AND fieldname IN s_fldnam.
IF sy-subrc NE 0.
MESSAGE e429(mo).
ENDIF.
ENDIF.
F4 help for fieldname
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_fldnam.
DATA : l_rc LIKE sy-subrc.
Check segment name on selection screen is not empty
IF NOT p_segnam IS INITIAL.
F4 Help for fieldname
PERFORM get_f4help USING l_rc.
IF l_rc = 0.
Fill the selected field name
READ TABLE g_t_appl INDEX g_v_tabix.
CHECK sy-subrc = 0.
p_fldnam = g_t_appl-fieldname.
ENDIF.
ENDIF.
Check for field name on selection screen
AT SELECTION-SCREEN ON p_fldnam.
IF NOT p_fldnam IS INITIAL.
Data fetch : Table Fields
SELECT SINGLE * FROM dd03l
WHERE tabname EQ p_segnam
AND fieldname EQ p_fldnam.
IF sy-subrc NE 0.
MESSAGE e429(mo).
ENDIF.
ENDIF.
Check for field name on selection screen
AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_fldval-low.
Check field name is an input on selection screen
IF NOT p_fldnam IS INITIAL.
Get the domain values as F4 help
PERFORM get_domain_value.
ENDIF.
*Check for Message type on selection screen
AT SELECTION-SCREEN ON s_mestyp.
IF NOT s_mestyp IS INITIAL.
Data fetch : Logical message types
SELECT COUNT( * ) FROM edmsg
WHERE msgtyp IN s_mestyp.
IF sy-subrc NE 0.
MESSAGE e429(mo).
ENDIF.
ENDIF.
*Check for Basic type on selection screen
AT SELECTION-SCREEN ON s_idoctp.
IF NOT s_idoctp IS INITIAL.
Data fetch : Basic types
SELECT COUNT( * ) FROM edbas
WHERE idoctyp IN s_idoctp.
IF sy-subrc NE 0.
MESSAGE e429(mo).
ENDIF.
ENDIF.
*& Form GET_F4HELP
text
-->P_L_RC text
FORM get_f4help USING p_l_rc LIKE sy-subrc.
DATA : l_v_segment LIKE edsappl-segtyp.
DATA : l_t_help_value LIKE help_value OCCURS 0 WITH HEADER LINE.
Segment name
l_v_segment = p_segnam.
Data fetch : EDI: IDoc Segment Application Structure
SELECT pos fieldname FROM edsappl
INTO CORRESPONDING FIELDS OF TABLE g_t_appl
WHERE segtyp = l_v_segment
ORDER BY pos.
Popup having data
CALL FUNCTION 'POPUP_WITH_TABLE_DISPLAY'
EXPORTING
endpos_col = 110
endpos_row = 16
startpos_col = 90
startpos_row = 1
titletext = text-001
IMPORTING
choise = g_v_tabix
TABLES
valuetab = g_t_appl
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.
ENDIF.
Return code
p_l_rc = sy-subrc.
ENDFORM. " GET_F4HELP
*& Form GET_DOMAIN_VALUE
text
-->P_L_RC text
FORM get_domain_value.
DD: Domain header with text
DATA : l_s_dd01v LIKE dd01v.
Value table
DATA : l_v_valuetab LIKE l_s_dd01v-entitytab.
RFC Table Read: Description of Fields to Retrieve
DATA : l_t_db_fld LIKE rfc_db_fld OCCURS 0 WITH HEADER LINE.
RFC Table Read: Select Options / WHERE Clause
DATA : l_t_options LIKE rfc_db_opt OCCURS 0 WITH HEADER LINE.
Table with a 512 byte field
DATA : l_t_valuetab LIKE tab512 OCCURS 0 WITH HEADER LINE.
*Data Dictionary access routines
CALL FUNCTION 'G_DOMAIN_READ'
EXPORTING
domain = p_fldnam
langu = sy-langu
IMPORTING
domain_attr = l_s_dd01v
EXCEPTIONS
not_found = 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.
l_v_valuetab = l_s_dd01v-entitytab.
l_t_db_fld-fieldname = p_fldnam.
APPEND l_t_db_fld.
External access to R/3 tables via RFC
CALL FUNCTION 'RFC_READ_TABLE'
EXPORTING
query_table = l_v_valuetab
DELIMITER = ' '
NO_DATA = ' '
ROWSKIPS = 0
ROWCOUNT = 0
TABLES
options = l_t_options
fields = l_t_db_fld
data = l_t_valuetab
EXCEPTIONS
table_not_available = 1
table_without_data = 2
option_not_valid = 3
field_not_valid = 4
not_authorized = 5
data_buffer_exceeded = 6
OTHERS = 7
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CLEAR g_v_tabix.
IF NOT l_t_valuetab[] IS INITIAL.
Popup having data
CALL FUNCTION 'POPUP_WITH_TABLE_DISPLAY'
EXPORTING
endpos_col = 110
endpos_row = 16
startpos_col = 90
startpos_row = 1
titletext = text-001
IMPORTING
choise = g_v_tabix
TABLES
valuetab = l_t_valuetab
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.
ENDIF.
READ TABLE l_t_valuetab INDEX g_v_tabix.
CHECK sy-subrc = 0.
Fill the select-options of Fieldvalue
s_fldval-low = l_t_valuetab-wa.
s_fldval-sign = 'I'.
s_fldval-option = 'EQ'.
APPEND s_fldval.
ENDIF.
ENDFORM. " GET_DOMAIN_VALUE
INCLUDE Y16S_VIEW_IDOC_CONTENT_F01I *
*& Module STATUS_0100 OUTPUT
ALV grid output
MODULE status_0100 OUTPUT.
*set the screen elements
SET PF-STATUS 'MAIN100'.
SET TITLEBAR 'TITLE100'.
*instantiation
IF g_custom_container IS INITIAL.
g_v_layout-zebra = 'X'.
g_v_layout-sel_mode = 'A'.
Create custom container
CREATE OBJECT g_custom_container
EXPORTING container_name = g_container.
Create ALV grid
CREATE OBJECT grid1
EXPORTING i_parent = g_custom_container.
CREATE OBJECT g_v_recv EXPORTING grid_name = grid1.
Display ALV grid
CALL METHOD grid1->set_table_for_first_display
EXPORTING
i_save = g_c_save
is_layout = g_v_layout
is_print = g_f_print
is_variant = g_f_variant
CHANGING
it_fieldcatalog = g_t_fieldcat
it_outtab = refresh_table_display.
ENDIF.
User command
SET HANDLER g_v_recv->handle_user_command FOR grid1.
CALL METHOD grid1->set_toolbar_interactive.
ENDMODULE. " STATUS_0100 OUTPUT
*& Module USER_COMMAND_0100 INPUT
User actions on grid
MODULE user_command_0100 INPUT.
Dispatch the okcode
CALL METHOD cl_gui_cfw=>dispatch.
CASE g_f_okcode.
WHEN g_c_exit.
PERFORM exit_program.
WHEN OTHERS.
*do nothing
ENDCASE.
CLEAR g_f_okcode.
ENDMODULE. " USER_COMMAND_0100 INPUT
*& Form EXIT_PROGRAM
Exit from the Grid
--> p1 text
<-- p2 text
FORM exit_program.
Container for Custom Controls in the Screen Area
CALL METHOD g_custom_container->free.
*Control Framework Basic Class
CALL METHOD cl_gui_cfw=>flush.
Call the selection screen
SET SCREEN 0.
LEAVE SCREEN.
ENDFORM. " EXIT_PROGRAM
*& Form GET_FCAT
Field catalog fill
--> p1 text
<-- p2 text
FORM get_fcat.
*Segment details regarding fields
PERFORM get_segment_details.
Populate the Fieldcatalog
PERFORM fill_fieldcat.
IF g_f_variant-variant IS INITIAL.
Get the default variant
g_f_repid = sy-repid.
CLEAR : g_f_variant.
g_f_variant-report = g_f_repid.
g_r_x_variant = g_f_variant.
Get default variant
CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'
EXPORTING
i_save = g_c_save
CHANGING
cs_variant = g_r_x_variant
EXCEPTIONS
not_found = 2.
g_f_variant = g_r_x_variant.
g_f_variant-variant = 'X'.
ENDIF.
ENDFORM. " GET_FCAT
*& Form FILL_DATA
Fill the output internal table
--> p1 text
<-- p2 text
FORM fill_data.
FIELD-SYMBOLS TYPE ANY.
DATA : l_rc LIKE sy-subrc.
*Get the IDoc data
PERFORM get_data.
LOOP AT g_t_edid.
*Check for filtering the values
IF ( NOT ( p_fldnam IS INITIAL AND s_fldval[] IS INITIAL ) ).
Field value check
PERFORM check_fieldvalue USING l_rc.
IF l_rc NE 0.
CONTINUE.
ENDIF.
ENDIF.
ASSIGN LOCAL COPY OF g_t_edid TO .
ENDLOOP.
ENDFORM. " FILL_DATA
*& Form DISPLAY_GRID
Display ALV grid
--> p1 text
<-- p2 text
FORM display_grid.
Call ALV grid
CALL SCREEN 100.
ENDFORM. " DISPLAY_GRID
*& Form CHECK_FIELDVALUE
Check the fieldvalue
-->P_L_RC text
FORM check_fieldvalue USING p_l_rc LIKE sy-subrc.
Segment data
ASSIGN g_t_edid-sdata TO CASTING TYPE (p_segnam).
Segment fields
LOOP AT g_t_segment WHERE fieldname = p_fldnam.
ASSIGN COMPONENT g_t_segment-fieldname
OF STRUCTURE IN s_fldval.
p_l_rc = 0.
ELSE.
p_l_rc = 4.
ENDIF.
ENDLOOP.
ENDFORM. " CHECK_FIELDVALUE
*& Form GET_DATA
Get the IDoc data
--> p1 text
<-- p2 text
FORM get_data.
*Clear the header line of the internal table
CLEAR : g_t_edid,
g_t_edidc.
Clear the body of the internal table
REFRESH : g_t_edid,
g_t_edidc.
*Data fetch : Control record (IDoc)
SELECT docnum credat mestyp FROM edidc
INTO TABLE g_t_edidc
WHERE docnum IN s_idocnm AND
credat IN s_date AND
mestyp IN s_mestyp AND
idoctp IN s_idoctp.
*Date/Message type if not initial
IF ( ( NOT ( s_date[] IS INITIAL ) )
OR ( NOT ( s_mestyp[] IS INITIAL ) )
OR ( NOT ( s_idoctp[] IS INITIAL ) ) ).
Check the control record of the IDoc
PERFORM check_control_data.
ELSE.
Data fetch : IDoc Data Records from 4.0 onwards
SELECT docnum segnum sdata FROM edid4 INTO TABLE g_t_edid
WHERE docnum IN s_idocnm AND
segnam EQ p_segnam.
ENDIF.
ENDFORM. " GET_DATA
*& Form CHECK_CONTROL_DATA
Check the control data of IDoc
--> p1 text
<-- p2 text
FORM check_control_data.
CHECK NOT g_t_edidc[] IS INITIAL.
Data fetch : IDoc Data Records from 4.0 onwards
SELECT docnum segnum sdata FROM edid4 INTO TABLE g_t_edid
WHERE docnum IN s_idocnm AND
segnam EQ p_segnam.
LOOP AT g_t_edid.
READ TABLE g_t_edidc WITH KEY docnum = g_t_edid-docnum.
*Check for the correct MT
IF sy-subrc = 0.
CONTINUE.
ELSE.
*Delete, if unsuccessful
DELETE g_t_edid.
ENDIF.
ENDLOOP.
ENDFORM. " CHECK_CONTROL_DATA
*& Form GET_SEGMENT_DETAILS
Segment details regarding fields
--> p1 text
<-- p2 text
FORM get_segment_details.
Segment name
g_f_segment = p_segnam.
CALL FUNCTION 'NAMETAB_GET'
EXPORTING
langu = sy-langu
tabname = g_f_segment
TABLES
nametab = g_t_segment
EXCEPTIONS
internal_error = 1
table_has_no_fields = 2
table_not_activ = 3
no_texts_found = 4
OTHERS = 5.
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. " GET_SEGMENT_DETAILS
*& Form FILL_FIELDCAT
Populate the Fieldcatalog
--> p1 text
<-- p2 text
FORM fill_fieldcat.
DATA : lv_pos TYPE i.
IDoc number in the catalog
lv_pos = 1.
g_r_fieldcat-fieldname = 'DOCNUM'.
g_r_fieldcat-ref_table = 'EDID4'.
g_r_fieldcat-ref_field = 'DOCNUM'.
g_r_fieldcat-key = 'X'.
g_r_fieldcat-col_pos = lv_pos.
g_r_fieldcat-outputlen = '10'.
APPEND g_r_fieldcat TO g_t_fieldcat.
Segment number in the catalog
ADD 1 TO lv_pos.
g_r_fieldcat-fieldname = 'SEGNUM'.
g_r_fieldcat-ref_table = 'EDID4'.
g_r_fieldcat-ref_field = 'SEGNUM'.
g_r_fieldcat-key = 'X'.
g_r_fieldcat-col_pos = lv_pos.
g_r_fieldcat-outputlen = '10'.
g_r_fieldcat-colddictxt = 'X'.
g_r_fieldcat-reptext = text-002.
APPEND g_r_fieldcat TO g_t_fieldcat.
**Populating fieldcatalog with segment field
LOOP AT g_t_segment .
ADD 1 TO lv_pos.
CLEAR g_r_fieldcat.
g_r_fieldcat-fieldname = g_t_segment-fieldname .
g_r_fieldcat-ref_table = p_segnam.
g_r_fieldcat-ref_field = g_t_segment-fieldname .
g_r_fieldcat-key = 'X'.
g_r_fieldcat-col_pos = lv_pos.
g_r_fieldcat-outputlen = '10'.
Check for given fields on the selection screen
IF NOT g_t_segment-fieldname IN s_fldnam.
g_r_fieldcat-no_out = 'X'.
ENDIF.
*Column text
IF g_t_segment-fieldtext IS INITIAL.
*Get the DDIC texts for columns
PERFORM get_ddic_texts.
ENDIF.
APPEND g_r_fieldcat TO g_t_fieldcat.
ENDLOOP.
ENDFORM. " FILL_FIELDCAT
*& Form GET_DDIC_TEXTS
Get the DDIC texts
--> p1 text
<-- p2 text
FORM get_ddic_texts.
DATA : l_f_descr TYPE string.
Get the texts for the data element
CALL FUNCTION 'TB_DATAELEMENT_GET_TEXTS'
EXPORTING
name = g_t_segment-fieldname
IMPORTING
description = l_f_descr
LENGTH_FIELD =
LENGTH_HEADER =
LENGTH_LONG =
LENGTH_MIDDLE =
LENGTH_SHORT =
TEXT_HEADER =
TEXT_LONG =
TEXT_MIDDLE =
TEXT_SHORT =
EXCEPTIONS
not_found = 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.
*Add DDIC text..
g_r_fieldcat-colddictxt = 'X'.
g_r_fieldcat-reptext = l_f_descr.
ENDFORM. " GET_DDIC_TEXTS
Maybe you are looking for
-
How do I create a High Quality Image with a low file size???
Dear All, I am creating an invitation in Illustrator which I then place into photshop to create a JPEG. I want to create a high quality JPEG version of it but with a low file size because I am emailing the invitation. Am I correct in placing the imag
-
How to pass the value from sub report to sub report
how i want get one value from sub report to sub report.. can i do this one... how can get the value. i know main report to sub report i tried that way but value is 0.00 is comming Any reasons.
-
wat is adhoc query and how to make adhoc query.
-
Upload a numbers file to dropbox then view it from another device
cant view a file i uploaded from my mobile device (Iphone or Ipad) into dropbox then view it from my mobile device again. i can from my computer but not any of my mobile devices. it was working great until the update back in October 2013. i have l
-
How to get .class files (and others) out of JAR in code?
Hi all, I am packaging up several classes in a jar file. In my code I want to be able to "read" any number of jar files, and in each case pull out all the .class files to create instances of them. I don't want to unzip/unjar the files to the disk sys