Color Codes for ALV
Dear All,
I want to show the colored rows on ALV depending on conditions.
Depending upon the conditions, row may have different colors.
So, from where I can find that color codes (Like for Green - Color Code is 'C500')?
I anyone have the Codes please provide the color Code else, please provide the reference link or reference Document.
Waiting for reply.
Thanks and Best regards,
Prasad
The follow program demonstrates how to change the colour of individual rows of an ALV grid. Changes required
from a basic ALV grid include adding a new field to ALV grid data table(it_ekko), Populating this field with color
attribute and adding an entry to layout control table.
*& Report ZDEMO_ALVGRID *
*& Example of a simple ALV Grid Report *
*& The basic ALV grid, Enhanced to display each row in a different *
*& colour *
REPORT zdemo_alvgrid .
TABLES: ekko.
type-pools: slis. "ALV Declarations
*Data Declaration
TYPES: BEGIN OF t_ekko,
ebeln TYPE ekpo-ebeln,
ebelp TYPE ekpo-ebelp,
statu TYPE ekpo-statu,
aedat TYPE ekpo-aedat,
matnr TYPE ekpo-matnr,
menge TYPE ekpo-menge,
meins TYPE ekpo-meins,
netpr TYPE ekpo-netpr,
peinh TYPE ekpo-peinh,
line_color(4) type c, "Used to store row color attributes
END OF t_ekko.
DATA: it_ekko TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,
wa_ekko TYPE t_ekko.
*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.
There are a number of ways to create a fieldcat.
For the purpose of this example i will build the fieldcatalog manualy
by populating the internal table fields individually and then
appending the rows. This method can be the most time consuming but can
also allow you more control of the final product.
Beware though, you need to ensure that all fields required are
populated. When using some of functionality available via ALV, such as
total. You may need to provide more information than if you were
simply displaying the result
I.e. Field type may be required in-order for
the 'TOTAL' function to work.
fieldcatalog-fieldname = 'EBELN'.
fieldcatalog-seltext_m = 'Purchase Order'.
fieldcatalog-col_pos = 0.
fieldcatalog-outputlen = 10.
fieldcatalog-emphasize = 'X'.
fieldcatalog-key = 'X'.
fieldcatalog-do_sum = 'X'.
fieldcatalog-no_zero = 'X'.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'EBELP'.
fieldcatalog-seltext_m = 'PO Item'.
fieldcatalog-col_pos = 1.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'STATU'.
fieldcatalog-seltext_m = 'Status'.
fieldcatalog-col_pos = 2.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'AEDAT'.
fieldcatalog-seltext_m = 'Item change date'.
fieldcatalog-col_pos = 3.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'MATNR'.
fieldcatalog-seltext_m = 'Material Number'.
fieldcatalog-col_pos = 4.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'MENGE'.
fieldcatalog-seltext_m = 'PO quantity'.
fieldcatalog-col_pos = 5.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'MEINS'.
fieldcatalog-seltext_m = 'Order Unit'.
fieldcatalog-col_pos = 6.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'NETPR'.
fieldcatalog-seltext_m = 'Net Price'.
fieldcatalog-col_pos = 7.
fieldcatalog-outputlen = 15.
fieldcatalog-datatype = 'CURR'.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'PEINH'.
fieldcatalog-seltext_m = 'Price Unit'.
fieldcatalog-col_pos = 8.
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).
Set layout field for row attributes(i.e. color)
gd_layout-info_fieldname = 'LINE_COLOR'.
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 = it_ekko
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.
data: ld_color(1) type c.
select ebeln ebelp statu aedat matnr menge meins netpr peinh
up to 10 rows
from ekpo
into table it_ekko.
*Populate field with color attributes
loop at it_ekko into wa_ekko.
Populate color variable with colour properties
Char 1 = C (This is a color property)
Char 2 = 3 (Color codes: 1 - 7)
Char 3 = Intensified on/off ( 1 or 0 )
Char 4 = Inverse display on/off ( 1 or 0 )
i.e. wa_ekko-line_color = 'C410'
ld_color = ld_color + 1.
Only 7 colours so need to reset color value
if ld_color = 8.
ld_color = 1.
endif.
concatenate 'C' ld_color '10' into wa_ekko-line_color.
wa_ekko-line_color = 'C410'.
modify it_ekko from wa_ekko.
endloop.
endform. " DATA_RETRIEVAL
Similar Messages
-
Setting color codes for more than one photo at a time
Is there any way to set color codes for more than one photo at a time?
Hi John,
I will look at keywords. My issue is speed. Right now I am culling and editing an event shoot that spanned a week with 35 separate events and more than 5000 images. So I use the fastest most convenient method I can and it still takes a long time to have a completed and final shoot. On this shoot I will end up with a final set of around 1500 images. Right now I am finishing processing a show that will hang in the Deutsches Amerikanish Zentrum in Stuttgart.
As I am sure you are aware by now, having seen enough of my inane questions that over the last two years or since Lightroom version 1.xx if I could not figure out how to do something I skipped it. So many things in Lightroom are buried and unless you have a mind like a steel trap (and think that some of you guys in the forum do) locating how to do something is not obvious.
For example, I only learned (in the last hour) that I could assign colors as a group of selections by using Shift + number. I found this in a side head in Martin Evenings Lightroom book. I still do not know how to find a way to display the color filter "selection" set in Library mode. Is there a way?
To top it off, Stuttgart Media University asked me if I would add a Lightroom module to my schedule this year. Now I have a compelling reason to learn all those missing pieces that I have created workarounds for. Hence the number of posts you have been seeing from me over the past few of weeks.
I tell my class that there are no such things as stupid questions, only questions. Now I am practicing what I have been preaching for the last gazillion years. Guys like you have been great.
My workflow is
1. I first separate all images by event. I do that at the time of import.
2. I do a fast pass rejecting all the obviously bad images
3. I do a second pass grouping the images by sub-group (speeches, people talking, performances, etc.) This is where I run out of selection methods and your key-wording could work but it would probably take too much time to establish a keyword set for a single event. Where I have more than five subgroups I set up different collection sets with one collection for each sub group. However I would like to keep a single event in one collection.
4. I then select the images to be used by color code.
5. Next I process the final images (crop develop etc) by collection.
6. Last I output the set according to client requirement.
If you have a better workflow, I am all ears.
By the way, what is your photo specialty and where are you located?
Jim -
How to pass table data into below code for alv
hi
i want to pass table data into alvgrid
i dont know how to pass table data.
here instead of passing ABC into internal table
i want to pass table data .
please help me
ialv-test1 = 'ABC'.
form get_data.
ialv-test1 = 'ABC'.
ialv-test2 = 'DEF'.
append ialv.
ialv-test1 = 'GHI'.
ialv-test2 = 'JKL'.
append ialv.
ialv-test1 = '123'.
ialv-test2 = '456'.
append ialv.
endform
thanks in advanced.Have a look at below links. It gives you sample code of alv grid.
http://sap.niraj.tripod.com/id64.html
http://www.sap-img.com/abap/sample-programs-on-alv-grid.htm
Have a look at below links for SAP Help.
http://help.sap.com/saphelp_nw04/helpdata/en/8d/e994374c9cd355e10000009b38f8cf/content.htm
http://help.sap.com/saphelp_erp2004/helpdata/en/12/904f42d5f811d2b469006094192fe3/content.htm
Best Regards,
Vibha
*Please mark all the helpful answers -
Wht r color codes in ALV rep for EMPHASIZE, like C500?
Hi Experts,
Am looking to color the column in ALV report......so, am using EMPHASIZE in filed catalg, am using C 500.......working fine.
So, pls. let me know, What r the other colors & their #, like C500?
thanqYou can find answer in next link:
Coloring Cells/rows in ALV Grid.
Best regards. -
Define F-Code for ALV Button & context menu for ALV table
Hi,
I have some Buttons in ALV Toolbar like for example 'copy row'. Is it in browser environment possible to assign f-code to the button? Like by pushing e.g. F4 the method for 'copy row' action is fired?
Or additionaly, is it possible to define a custom context menu in alv table?
Thanks in advance,
TanHi Tan,
This Functionality is working on..Pelase check this...
Re: How to improve Web accessibility with Function keys
Re: Hot key(Ctrl+F1) for More field help not working
Re: GUI Status?
For help..
http://help.sap.com/saphelp_nw70ehp1/helpdata/en/47/b951297a6d2d65e10000000a42189c/content.htm
Cheers,
Kris.
Edited by: kissnas on Jun 21, 2011 11:46 AM -
Default background color code for Canvas, Panel, Form?
I could not find them. Are they the same for MX and Spark components?
please try the code
#EFF0F4
Regards,
Akansh -
Like Photoshop, Color code for Indesign layers
It might be a good complement to folders. I find it even more convenient and straightforward.
Yeah, that would be nice. Adobe - Feature Request/Bug Report Form
-
Color Code is not working, please help
I am using the color code 080808 from adobe photoshop as my background for my template. When i put the JPG file into dreamweaver and try to set the page properties in dreamweaver (background) to 080808 it is putting me at pure black. please help me.080808 is not a pure black its a shade of it. I need a color code that matches 080808 correctly. thanks
I am using adobe CS3I'm not quite sure I understand exactly what you are doing, but I ran into something like this myself. I was creating GIFs in Photoshop -- type on a background color. I then created DW pages. I used the same color code for the background color in PS and again for the background color in DW, but when I inserted the images in the page, they did not match. It turned out that when I created a new file in PS, I was creating it in my default color space, Adobe RGB. I assumed that when Save For Web converted the file to sRGB, the colors would convert perfectly. What I found is that I should have been creating my PS files by starting with a new file in sRGB color space. Once I did that, the background color of my images identically matched the background color of my DW page.
Hope this helps.
John -
Why color code css using powershell command is not visible in email ?
Hello,
I am applying color code for disabled status in PS script as written below :
$ReportData = Get-SPServiceInstance | Select Server,TypeName,Status,NeedsUpgrade | ConvertTo-Html -Fragment
$DisabledStatus='<td>Disabled</td>'
$DisabledColorStyle='<td style="background-color:red !important;color:white !important" >Disabled</td>'
$ReportData = $ReportData -replace $DisabledStatus,$DisabledColorStyle
ConvertTo-Html -Body "<font color = blue><H4><B>Report </B></H4></font>$ReportData" -Title "Test Report" -CssUri C:\style.CSS | Out-File "E:\Reports\TestReport.html"
This report shows perfect on system where report file is located at E:\Reports\TestReport.html location as below :
However , when I send this report via email using following command
$Report = Get-Content "E:\Reports\TestReport.html"
Send-MailMessage -To $To -SmtpServer $SMTP -From $From -Subject $Subject -BodyAsHtml "$Report"
I dont see disabled as red color in email , while table's style is working which is stored at C:\style.CSS
Would you please let me know the reason behind same ?
Thanks and Regards,
Dipti
Dipti ChhatrapatiHi Dipti,
I‘m writing to check if the suggestions were helpful, if you have any questions, please feel free to let me know.
If you have any feedback on our support, please click here.
Best Regards,
Anna
TechNet Community Support
Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Support, contact [email protected] -
Dear Friends
Please provide me the detailed info and the links regarding the ALV Reports.
ThanksHi,
Theriotical information regarding ALV u can find it in help.sap.com
Some of the sites for ALV's
In this u can find sample codes for ALV*
http://abapprogramming.blogspot.com/search/label/ABAP%20ALV%20REPORTS%20%20SAMPLE%20CODES
http://sap.ittoolbox.com/groups/technical-functional/sap-dev/logo-in-function-reuse_alv_commentary_write-93246
http://sap4.com/wiki/index.php?title=REUSE_ALV_COMMENTARY_WRITE -
Question Re: Color Codes/Component Style Declaration
I am not understanding the use of hexidecimal color codes for
component styles. What is the "0x" for? This is not addressed in
flash help. What I am trying to figure out is if I can specify
alpha transparency with style declaration and I'm wondering if the
seemingly superfluous prefix may have something to do with it.
Either way I'd at least like to know what it means.
Thanks in advance,
JeevesQuimbyJQ you could actually pass that number in decimal value or
string. example:
//blue
myTextArea.setStyle( "backgroundColor", "blue" );
// red
myTextArea.setStyle( "backgroundColor", 0xFF0000 );
// green
myTextArea.setStyle( "backgroundColor", 65280 );
the real color number is actually the decimal number, but
when ported to an
hexadecimal system it's just easier to use... Check the doc
on getPixel32 in
flash, on top of RGB values you also have alpha values, which
gives a number
like 0xAARRGGBB
JG
"JeevesQuimby" <[email protected]> wrote in
message
news:ejntk8$74h$[email protected]..
>I understand hex codes, it just seems to me that if
you're specifying a
>color
> as in: TextArea.setStyle("backgroundColor", 0xFFFFFF);
flash would be
> expecting
> the color code, so the 0x seems unnecessary, since it is
always the same.
> Any
> other program identifies the color with just 6
characters. What would
> happen if
> I were to put 2xFFFFFF for example? It just seems wierd
to me. Thanks
> anyways
> though.
> JQ
>
>
> -
Hi all,
I need to display color for a field(cell) in a record.
is there any events to handle this.
please help me in this.
Regards
Anil Kumar KHi,
in OO ALV check this code../
REPORT 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.
* 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,
**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
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
DATA: OK_CODE LIKE SY-UCOMM,
SAVE_OK LIKE SY-UCOMM,
G_CONTAINER1 TYPE SCRFNAME VALUE 'TEST',
GS_LAYOUT TYPE LVC_S_LAYO.
*- 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.
DATA:BEGIN OF ITAB OCCURS 0,
VBELN LIKE LIKP-VBELN,
POSNR LIKE LIPS-POSNR,
CELLCOLOR TYPE LVC_T_SCOL, "required for color
DROP(10),
END OF ITAB.
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.
GS_LAYOUT-ZEBRA = SPACE.
GS_LAYOUT-CWIDTH_OPT = 'X'.
GS_LAYOUT-NO_ROWMARK = 'X'.
GS_LAYOUT-CTAB_FNAME = 'CELLCOLOR'.
CALL METHOD G_GRID->REGISTER_EDIT_EVENT
EXPORTING
I_EVENT_ID = CL_GUI_ALV_GRID=>MC_EVT_ENTER.
CREATE OBJECT G_HANDLER.
SET HANDLER G_HANDLER->HANDLE_DOUBLE_CLICK FOR G_GRID.
SET HANDLER G_HANDLER->HANDLE_HOTSPOT_CLICK FOR G_GRID.
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.
**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 = 'IT_FINAL'.
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 = 'IT_FINAL'.
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 = 'IT_FINAL'.
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.
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.
LOOP AT ITAB .
* First listbox (handle '1').
IF SY-INDEX = 1.
LS_DRAL-HANDLE = '1'.
LS_DRAL-VALUE = ' '.
LS_DRAL-INT_VALUE = ' '.
ELSE.
LS_DRAL-HANDLE = '1'.
LS_DRAL-VALUE = ITAB-POSNR.
LS_DRAL-INT_VALUE = ITAB-POSNR.
ENDIF.
APPEND LS_DRAL TO LT_DRAL.
ENDLOOP.
**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 -
Hi all,
I understand that the ALV grid color codes consists of the following format:
CXYZ
X = 0 - 7
Y,Z = 0 - 1
Is there any way to display color other than the above? I need a dark grey color (the color when the grid is set to not editable). Is there anywhere to do that? The intensity option is not helping much.
Thanks in advance.Hi,
Herewith i am sending for the sample code with alv grid report.
REPORT YMS_COLOURALV NO STANDARD PAGE HEADING.
TYPE-POOLS: SLIS, ICON.
DATA: FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.
DATA: BEGIN OF IMARA OCCURS 0,
LIGHT(4) TYPE C,
MATNR TYPE MARA-MATNR,
MTART TYPE MARA-MTART,
MAKTX TYPE MAKT-MAKTX,
COLOR_LINE(4) TYPE C,
TCOLOR TYPE SLIS_T_SPECIALCOL_ALV, "cell
END OF IMARA.
DATA: XCOLOR TYPE SLIS_SPECIALCOL_ALV.
START-OF-SELECTION.
PERFORM GET_DATA.
PERFORM WRITE_REPORT.
Get_Data
FORM GET_DATA.
WRITE ICON_GREEN_LIGHT AS ICON TO IMARA-LIGHT.
IMARA-MATNR = 'ABC'.
IMARA-MTART = 'ZCFG'.
IMARA-MAKTX = 'This is description for ABC'.
APPEND IMARA.
WRITE ICON_YELLOW_LIGHT AS ICON TO IMARA-LIGHT.
IMARA-MATNR = 'DEF'.
IMARA-MTART = 'ZCFG'.
IMARA-MAKTX = 'This is description for DEF'.
APPEND IMARA.
WRITE ICON_RED_LIGHT AS ICON TO IMARA-LIGHT.
IMARA-MATNR = 'GHI'.
IMARA-MTART = 'ZCFG'.
IMARA-MAKTX = 'This is description for GHI'.
APPEND IMARA.
LOOP AT IMARA.
IF SY-TABIX = 1.
IMARA-COLOR_LINE = 'C410'. " color line
ENDIF.
IF SY-TABIX = 2. " color CELL
CLEAR XCOLOR.
XCOLOR-FIELDNAME = 'MTART'.
XCOLOR-COLOR-COL = '3'.
XCOLOR-COLOR-INT = '1'. " Intensified on/off
XCOLOR-COLOR-INV = '0'.
APPEND XCOLOR TO IMARA-TCOLOR.
ENDIF.
MODIFY IMARA.
ENDLOOP.
ENDFORM. "get_data
WRITE_REPORT
FORM WRITE_REPORT.
DATA: LAYOUT TYPE SLIS_LAYOUT_ALV.
LAYOUT-COLTAB_FIELDNAME = 'TCOLOR'.
LAYOUT-INFO_FIELDNAME = 'COLOR_LINE'.
PERFORM BUILD_FIELD_CATALOG.
CALL ABAP LIST VIEWER (ALV)
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
IS_LAYOUT = LAYOUT
IT_FIELDCAT = FIELDCAT
TABLES
T_OUTTAB = IMARA.
ENDFORM. "write_report
BUILD_FIELD_CATALOG
FORM BUILD_FIELD_CATALOG.
DATA: FC_TMP TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE.
CLEAR: FIELDCAT. REFRESH: FIELDCAT.
CLEAR: FC_TMP.
FC_TMP-REPTEXT_DDIC = 'Status'.
FC_TMP-FIELDNAME = 'LIGHT'.
FC_TMP-TABNAME = 'IMARA'.
FC_TMP-OUTPUTLEN = '4'.
FC_TMP-ICON = 'X'.
APPEND FC_TMP TO FIELDCAT.
CLEAR: FC_TMP.
FC_TMP-REPTEXT_DDIC = 'Material Number'.
FC_TMP-FIELDNAME = 'MATNR'.
FC_TMP-TABNAME = 'IMARA'.
FC_TMP-OUTPUTLEN = '18'.
APPEND FC_TMP TO FIELDCAT.
CLEAR: FC_TMP.
FC_TMP-REPTEXT_DDIC = 'Material Type'.
FC_TMP-FIELDNAME = 'MTART'.
FC_TMP-TABNAME = 'IMARA'.
FC_TMP-OUTPUTLEN = '10'.
APPEND FC_TMP TO FIELDCAT.
CLEAR: FC_TMP.
FC_TMP-REPTEXT_DDIC = 'Material'.
FC_TMP-FIELDNAME = 'MAKTX'.
FC_TMP-TABNAME = 'IMARA'.
FC_TMP-OUTPUTLEN = '40'.
FC_TMP-EMPHASIZE = 'C610'. " color column
APPEND FC_TMP TO FIELDCAT.
ENDFORM. "build_field_catalog
Thanks,
Shankar -
How to find function code for buttons on toolbar in oops alv
Hi experts,
I want to remove some buttons from toolbar in oops alv, i know the procedure like get function code and pass the value in a table and pass that table to IT_TOOLBAR_EXCLUDING of
method set_table_for_first_display but I WANT TO KNOW HOW TO FIND FUNCTION CODE FOR BUTTONS ON TOOLBAR IN OOPS ALVHi Prakash,
-->First you have to set the pf status in your alv program by,
{FORM pf_status USING rt_extab TYPE slis_t_extab.
SET PF-STATUS 'FIRST'.
ENDFORM. "PF_STATUS}
-->Pass this Subroutine name in the Function module, Reuse_alv_grid_display's parameters i.e,
i_callback_pf_status_set = 'PF_STATUS'}
*-->Then doble click on that pf status,
From the menu bar, select Extras->Adjust Template->List Viewer,
This will give you the existing statndard gui status of the program*
->Then catch that function codes in the User command Parameter of the Function module Reuse.. i.e,
i_callback_user_command = 'COMM'
And make a subroutine of the name 'COMM'i.e,
FORM comm USING ucomm LIKE sy-ucomm selfield TYPE slis_selfield.
DATA: okcode TYPE sy-ucomm.
okcode = ucomm.
CASE okcode.
WHEN 'REF'.
CALL FUNCTION 'POPUP_TO_INFORM'
EXPORTING
titel = 'MANSI'
txt1 = 'CREATED BY'
txt2 = SY-UNAME
TXT3 = ' '
TXT4 = ' '
endcase.
Hope it helps you
Regrds
Mansi -
Why this code is not working for alv
Dear
Regards,
i have implemented the same program for ALV which i have used earlier in the reports. but now it is showing no output:
*& Report ZTCT1_ALV2 *
REPORT ztct1_alv2 .
CLASS lcl_event_receiver DEFINITION DEFERRED.
* INCLUDING TABLES.
TABLES: vbrk,
vbrp,
kna1,
t001w,
makt.
* DECLARATION OF INTERNAL TABLES.
DATA: BEGIN OF itab OCCURS 0, "Including the fields of VBRK and VBRP
kunag LIKE vbrk-kunag, "Customer Code
name1 LIKE kna1-name1, "Customer Name
vbeln LIKE vbrk-vbeln, "Invoice #
fkdat LIKE vbrk-fkdat, "Invoice Date
werks LIKE vbrp-werks, "Plant
name2 LIKE t001w-name1,"Plant Description
matnr LIKE vbrp-matnr, "Material #
maktx LIKE makt-maktx, "Material Description
meins LIKE vbrp-meins, "Unit of Measure
fklmg LIKE vbrp-fklmg, "Quantity
netwr LIKE vbrp-netwr, "Amount
END OF itab,
BEGIN OF itnm OCCURS 0, "Including the fields of VBRK and KNA1
kunag LIKE vbrk-kunag, "Customer Code
name1 LIKE kna1-name1, "Customer Name
END OF itnm,
BEGIN OF itpt OCCURS 0, "Including the fields of VBRP and T001W
werks LIKE vbrp-werks, "Plant
name1 LIKE t001w-name1,"Plant Description
END OF itpt,
BEGIN OF itmt OCCURS 0, "Including the fields of VBRP and MAKT
matnr LIKE vbrp-matnr, "Material #
maktx LIKE makt-maktx, "Material description
END OF itmt,
BEGIN OF itsm OCCURS 0,
kunag LIKE kna1-kunnr,
name1 LIKE kna1-name1,
fklmg LIKE vbrp-fklmg,
netwr LIKE vbrp-netwr,
END OF itsm,
ok_code LIKE sy-ucomm,
save_ok LIKE sy-ucomm,
g_max TYPE i VALUE 100,
g_repid LIKE sy-repid,
gs_layout TYPE lvc_s_layo,
g_container TYPE scrfname VALUE 'CUST_CONT',
grid1 TYPE REF TO cl_gui_alv_grid,
g_custom_container TYPE REF TO cl_gui_custom_container,
grid2 TYPE REF TO cl_gui_alv_grid,
gt_sort TYPE lvc_t_sort,
gt_fieldcatalog TYPE lvc_t_fcat,
w_tot_qty LIKE vbrp-fklmg,
w_tot_amt LIKE vbrp-netwr,
* Reference to Dialogbox Container.
dialogbox_container TYPE REF TO cl_gui_dialogbox_container,
* Reference to local class that handles events of GRID1 and
* DIALOGBOX_CONTAINER
event_receiver TYPE REF TO lcl_event_receiver.
* SELECT-OPTIONS
SELECTION-SCREEN SKIP 1.
SELECTION-SCREEN BEGIN OF BLOCK input WITH FRAME TITLE text-000.
SELECT-OPTIONS: s_werks FOR vbrp-werks, "Plant
s_kunag FOR vbrk-kunag, "Customer
s_matnr FOR vbrp-matnr, "Material Number
s_fkdat FOR vbrk-fkdat. "Invoice Date
SELECTION-SCREEN END OF BLOCK input .
SELECTION-SCREEN SKIP 1.
* START-OF-SELECTION
START-OF-SELECTION.
SET SCREEN 100.
* CLEARING INTERNAL TABLES.
CLEAR: itab,
itnm,
itmt,
itpt.
* QUERY FOR JOINING TABLES VBRK AND VBRP
SELECT vbrk~kunag
vbrk~vbeln
vbrk~fkdat
vbrp~werks
vbrp~matnr
vbrp~meins
vbrp~fklmg
vbrp~netwr
INTO CORRESPONDING FIELDS OF TABLE itab
FROM vbrk
INNER JOIN vbrp
ON vbrk~vbeln = vbrp~vbeln
WHERE vbrk~kunag IN s_kunag
AND vbrk~fkdat IN s_fkdat
AND vbrp~matnr IN s_matnr
AND vbrp~werks IN s_werks.
* QUERY FOR JOINING TABLES VBRK AND KNA1
SELECT kna1~kunnr AS kunag
kna1~name1
INTO TABLE itnm
FROM kna1
WHERE kna1~kunnr IN s_kunag.
* QUERY FOR JOINING TABLES VBRP AND T001W
SELECT t001w~werks
t001w~name1
INTO TABLE itpt
FROM t001w
WHERE t001w~werks IN s_werks.
* QUERY FOR JOINING TABLES VBRP AND MAKT
SELECT makt~matnr
makt~maktx
INTO TABLE itmt
FROM makt
WHERE makt~matnr IN s_matnr.
* SORTING INTERNAL TABLES.
SORT itab BY kunag.
* LOOP AT itab.
* CLEAR: itmt, itnm, itpt.
* READ TABLE itnm WITH KEY kunag = itab-kunag.
* READ TABLE itmt WITH KEY matnr = itab-matnr.
* READ TABLE itpt WITH KEY werks = itab-werks.
* itab-name1 = itnm-name1.
* itab-maktx = itmt-maktx.
* itab-name2 = itpt-name1.
* MODIFY itab.
* ENDLOOP.
* PERFORM fieldcatalog_init USING gt_fieldcatalog[] 'KUNAG' 'C' 'Customer Code'.
* PERFORM fieldcatalog_init USING gt_fieldcatalog[] 'NAME1' 'C' 'Customer Name'.
* PERFORM fieldcatalog_init USING gt_fieldcatalog[] 'VBELN' 'C' 'Invoice #'.
* PERFORM fieldcatalog_init USING gt_fieldcatalog[] 'FKDAT' 'DATS' 'Invoice Date'.
* PERFORM fieldcatalog_init USING gt_fieldcatalog[] 'WERKS' 'C' 'Plant'.
* PERFORM fieldcatalog_init USING gt_fieldcatalog[] 'NAME2' 'C' 'Plant Description'.
* PERFORM fieldcatalog_init USING gt_fieldcatalog[] 'MATNR' 'C' 'Material #'.
* PERFORM fieldcatalog_init USING gt_fieldcatalog[] 'MAKTX' 'C' 'Material Description'.
* PERFORM fieldcatalog_init USING gt_fieldcatalog[] 'MEINS' 'C' 'UoM'.
* PERFORM fieldcatalog_init USING gt_fieldcatalog[] 'FKLMG' 'QUAN' 'Quantity'.
* PERFORM fieldcatalog_init USING gt_fieldcatalog[] 'NETWR' 'CURR' 'Amount'.
LOOP AT itab.
CLEAR itsm.
READ TABLE itnm WITH KEY kunag = itab-kunag.
itsm-kunag = itab-kunag.
itsm-name1 = itnm-name1.
itsm-fklmg = itab-fklmg.
itsm-netwr = itab-netwr.
COLLECT itsm.
ENDLOOP.
PERFORM fieldcatalog_init USING gt_fieldcatalog[] 'KUNAG' 'C' 'Customer Code'.
PERFORM fieldcatalog_init USING gt_fieldcatalog[] 'NAME1' 'C' 'Customer Name'.
PERFORM fieldcatalog_init USING gt_fieldcatalog[] 'FKLMG' 'QUAN' 'Quantity'.
PERFORM fieldcatalog_init USING gt_fieldcatalog[] 'NETWR' 'CURR' 'Amount'.
PERFORM sort_build USING gt_sort[].
PERFORM layout_init USING gs_layout.
* LOCAL CLASSES: Definition
CLASS lcl_event_receiver DEFINITION.
PUBLIC SECTION.
METHODS:
handle_double_click
FOR EVENT double_click OF cl_gui_alv_grid
IMPORTING e_row e_column,
handle_close
FOR EVENT close OF cl_gui_dialogbox_container
IMPORTING sender.
PRIVATE SECTION.
DATA: dialogbox_status TYPE c. "'X': does exist, SPACE: does not ex.
ENDCLASS. "lcl_event_receiver DEFINITION
* LOCAL CLASSES: Implementation
CLASS lcl_event_receiver IMPLEMENTATION.
* §3.At doubleclick(1): The event DOUBLE_CLICK provides
* parameters of the clicked row and column.
* Use row parameter to select a line of the
* corresponding internal table.
METHOD handle_double_click.
DATA: ls_sm LIKE LINE OF itsm,
wa_itab LIKE ITAB.
* read selected row from internal table gt_sflight
READ TABLE itsm INDEX e_row-index INTO ls_sm.
* §4.At Doubleclick(2): Select booking data
* READ TABLE ITAB WITH KEY KUNAG = LS_SM-KUNAG. .
READ TABLE ITAB INTO WA_ITAB WITH KEY KUNAG = LS_SM-KUNAG.
* §5.At doubleclick(3): Create dialogbox to show detail list
* (if not already existent)
IF dialogbox_status IS INITIAL.
dialogbox_status = 'X'.
PERFORM create_detail_list.
ELSE.
CALL METHOD dialogbox_container->set_visible
EXPORTING
visible = 'X'.
CALL METHOD grid2->refresh_table_display.
ENDIF.
ENDMETHOD. "handle_double_click
METHOD handle_close.
* §6.Handle the CLOSE-button of the dialogbox
* set dialogbox invisible
* (the dialogbox is destroyed outomatically when the user
* switches to another dynpro).
CALL METHOD sender->set_visible
EXPORTING
visible = space.
* In this example closing the dialogbox leads
* to make it invisible. It is also conceivable to destroy it
* and recreate it if the user doubleclicks a line again.
* Displaying a great amount of data has a greater impact on performance.
ENDMETHOD. "handle_close
ENDCLASS. "lcl_event_receiver IMPLEMENTATION
* lcl_event_receiver (Implementation)
*=====================================================================
* FORM EXIT_PROGRAM *
FORM exit_program.
CALL METHOD g_custom_container->free.
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 TO SCREEN 0.
ENDFORM. "exit_program
* MODULE PBO_ALV OUTPUT
MODULE pbo_alv OUTPUT.
SET PF-STATUS 'MAIN'.
SET TITLEBAR 'MAIN100'.
g_repid = sy-repid.
IF g_custom_container IS INITIAL.
READ TABLE itsm.
CREATE OBJECT g_custom_container
EXPORTING
container_name = g_container
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5.
IF sy-subrc NE 0.
CALL FUNCTION 'POPUP_TO_INFORM'
EXPORTING
titel = g_repid
txt2 = sy-subrc
txt1 = 'The control could not be created'(510).
ENDIF.
CREATE OBJECT grid1
EXPORTING
i_parent = g_custom_container.
gs_layout-grid_title = 'Invoice Summary'.
CALL METHOD grid1->set_table_for_first_display
EXPORTING
is_layout = gs_layout
CHANGING
it_outtab = itsm[]
it_fieldcatalog = gt_fieldcatalog
it_sort = gt_sort.
CREATE OBJECT event_receiver.
SET HANDLER event_receiver->handle_double_click FOR grid1.
ENDIF.
CALL METHOD cl_gui_control=>set_focus
EXPORTING
control = grid1.
ENDMODULE. "PBO_ALV OUTPUT
* MODULE PAI_ALV INPUT
MODULE pai_alv INPUT.
CALL METHOD cl_gui_cfw=>dispatch.
CASE sy-ucomm.
WHEN 'BACK' OR 'EXIT' OR 'CANCEL'.
LEAVE TO SCREEN 0.
ENDCASE.
ENDMODULE. "PAI_ALV INPUT
*& Form fieldcatalog_init
* text
* -->LT_FIELDCATtext
* -->VALUE(FIELDtextE)
* -->VALUE(FIELDtextE)
* -->VALUE(FIELDtextT)
FORM fieldcatalog_init USING lt_fieldcatalog TYPE lvc_t_fcat
value(field_name) value(field_type) value(field_text).
DATA: ls_fieldcatalog TYPE lvc_s_fcat.
CLEAR ls_fieldcatalog.
ls_fieldcatalog-fieldname = field_name.
ls_fieldcatalog-datatype = field_type.
ls_fieldcatalog-reptext = field_text.
ls_fieldcatalog-coltext = field_text.
ls_fieldcatalog-seltext = field_text.
ls_fieldcatalog-tooltip = field_text.
APPEND ls_fieldcatalog TO lt_fieldcatalog.
ENDFORM. "fieldcatalog_init
*& Form sort_build
* text
* -->LT_SORT text
FORM sort_build USING lt_sort TYPE lvc_t_sort.
DATA: ls_sort TYPE lvc_s_sort.
ls_sort-fieldname = 'KUNAG'. "Fieldname on which to sort
ls_sort-up = 'X'. "Sort Ascending
APPEND ls_sort TO lt_sort.
ls_sort-fieldname = 'NAME1'. "Fieldname on which to sort
ls_sort-up = 'X'. "Sort Ascending
APPEND ls_sort TO lt_sort.
ENDFORM. "sort_build
*& Form layout_init
* text
* -->LS_LAYOUT text
FORM layout_init USING ls_layout TYPE lvc_s_layo.
ls_layout-zebra = 'X'.
ls_layout-grid_title = 'Customer Details'.
ls_layout-sel_mode = 'A'.
ls_layout-cwidth_opt = 'X'.
ENDFORM. "layout_init
*& Form create_detail_list
* text
* --> p1 text
* <-- p2 text
FORM create_detail_list.
* create dialogbox container as dynpro-instance
* When the user switches to another screen, it is
* destroyed by lifetime mangagement of CFW
CREATE OBJECT dialogbox_container
EXPORTING
top = 150
left = 150
lifetime = cntl_lifetime_dynpro
caption = 'INVOICE DETAILS'(200)
width = 800
height = 200.
CREATE OBJECT grid2
EXPORTING i_parent = dialogbox_container.
* Register ABAP OO event 'CLOSE'. It is not necessary to register this
* event at the frontend (this is done during creation).
SET HANDLER event_receiver->handle_close FOR dialogbox_container.
* display data
gs_layout-grid_title = 'Invoice Details'(100).
CALL METHOD grid2->set_table_for_first_display
EXPORTING
i_structure_name = 'itab'
is_layout = gs_layout
CHANGING
it_outtab = itab[]
it_fieldcatalog = gt_fieldcatalog
it_sort = gt_sort.
CALL METHOD cl_gui_control=>set_focus
EXPORTING
control = grid2.
ENDFORM. " create_detail_list[code][/
code]Hi,
I also copied and pasted the same code check once again by copying this code and create screens by double clicking on 100.
CLASS lcl_event_receiver DEFINITION DEFERRED.
* INCLUDING TABLES.
TABLES: vbrk,
vbrp,
kna1,
t001w,
makt.
* DECLARATION OF INTERNAL TABLES.
DATA: BEGIN OF itab OCCURS 0, "Including the fields of VBRK and VBRP
kunag LIKE vbrk-kunag, "Customer Code
name1 LIKE kna1-name1, "Customer Name
vbeln LIKE vbrk-vbeln, "Invoice #
fkdat LIKE vbrk-fkdat, "Invoice Date
werks LIKE vbrp-werks, "Plant
name2 LIKE t001w-name1,"Plant Description
matnr LIKE vbrp-matnr, "Material #
maktx LIKE makt-maktx, "Material Description
meins LIKE vbrp-meins, "Unit of Measure
fklmg LIKE vbrp-fklmg, "Quantity
netwr LIKE vbrp-netwr, "Amount
END OF itab,
BEGIN OF itnm OCCURS 0, "Including the fields of VBRK and KNA1
kunag LIKE vbrk-kunag, "Customer Code
name1 LIKE kna1-name1, "Customer Name
END OF itnm,
BEGIN OF itpt OCCURS 0, "Including the fields of VBRP and T001W
werks LIKE vbrp-werks, "Plant
name1 LIKE t001w-name1,"Plant Description
END OF itpt,
BEGIN OF itmt OCCURS 0, "Including the fields of VBRP and MAKT
matnr LIKE vbrp-matnr, "Material #
maktx LIKE makt-maktx, "Material description
END OF itmt,
BEGIN OF itsm OCCURS 0,
kunag LIKE kna1-kunnr,
name1 LIKE kna1-name1,
fklmg LIKE vbrp-fklmg,
netwr LIKE vbrp-netwr,
END OF itsm,
ok_code LIKE sy-ucomm,
save_ok LIKE sy-ucomm,
g_max TYPE i VALUE 100,
g_repid LIKE sy-repid,
gs_layout TYPE lvc_s_layo,
g_container TYPE scrfname VALUE 'CUST_CONT',
grid1 TYPE REF TO cl_gui_alv_grid,
g_custom_container TYPE REF TO cl_gui_custom_container,
grid2 TYPE REF TO cl_gui_alv_grid,
gt_sort TYPE lvc_t_sort,
gt_fieldcatalog TYPE lvc_t_fcat,
w_tot_qty LIKE vbrp-fklmg,
w_tot_amt LIKE vbrp-netwr,
* Reference to Dialogbox Container.
dialogbox_container TYPE REF TO cl_gui_dialogbox_container,
* Reference to local class that handles events of GRID1 and
* DIALOGBOX_CONTAINER
event_receiver TYPE REF TO lcl_event_receiver.
* SELECT-OPTIONS
SELECTION-SCREEN SKIP 1.
SELECTION-SCREEN BEGIN OF BLOCK input WITH FRAME TITLE text-000.
SELECT-OPTIONS: s_werks FOR vbrp-werks, "Plant
s_kunag FOR vbrk-kunag, "Customer
s_matnr FOR vbrp-matnr, "Material Number
s_fkdat FOR vbrk-fkdat. "Invoice Date
SELECTION-SCREEN END OF BLOCK input .
SELECTION-SCREEN SKIP 1.
* START-OF-SELECTION
START-OF-SELECTION.
SET SCREEN 100.
* CLEARING INTERNAL TABLES.
CLEAR: itab,
itnm,
itmt,
itpt.
* QUERY FOR JOINING TABLES VBRK AND VBRP
SELECT vbrk~kunag
vbrk~vbeln
vbrk~fkdat
vbrp~werks
vbrp~matnr
vbrp~meins
vbrp~fklmg
vbrp~netwr
INTO CORRESPONDING FIELDS OF TABLE itab
FROM vbrk
INNER JOIN vbrp
ON vbrk~vbeln = vbrp~vbeln
WHERE vbrk~kunag IN s_kunag
AND vbrk~fkdat IN s_fkdat
AND vbrp~matnr IN s_matnr
AND vbrp~werks IN s_werks.
* QUERY FOR JOINING TABLES VBRK AND KNA1
SELECT kna1~kunnr AS kunag
kna1~name1
INTO TABLE itnm
FROM kna1
WHERE kna1~kunnr IN s_kunag.
* QUERY FOR JOINING TABLES VBRP AND T001W
SELECT t001w~werks
t001w~name1
INTO TABLE itpt
FROM t001w
WHERE t001w~werks IN s_werks.
* QUERY FOR JOINING TABLES VBRP AND MAKT
SELECT makt~matnr
makt~maktx
INTO TABLE itmt
FROM makt
WHERE makt~matnr IN s_matnr.
* SORTING INTERNAL TABLES.
SORT itab BY kunag.
LOOP AT itab.
CLEAR itsm.
READ TABLE itnm WITH KEY kunag = itab-kunag.
itsm-kunag = itab-kunag.
itsm-name1 = itnm-name1.
itsm-fklmg = itab-fklmg.
itsm-netwr = itab-netwr.
COLLECT itsm.
ENDLOOP.
* END-OF-SELECTION.
* If not itsm[] is initial.
* CALL SCREEN 100.
* endif.
* LOCAL CLASSES: Definition
CLASS lcl_event_receiver DEFINITION.
PUBLIC SECTION.
METHODS:
handle_double_click
FOR EVENT double_click OF cl_gui_alv_grid
IMPORTING e_row e_column,
handle_close
FOR EVENT close OF cl_gui_dialogbox_container
IMPORTING sender.
PRIVATE SECTION.
DATA: dialogbox_status TYPE c. "'X': does exist, SPACE: does not ex
ENDCLASS. "lcl_event_receiver DEFINITION
* LOCAL CLASSES: Implementation
CLASS lcl_event_receiver IMPLEMENTATION.
* §3.At doubleclick(1): The event DOUBLE_CLICK provides
* parameters of the clicked row and column.
* Use row parameter to select a line of the
* corresponding internal table.
METHOD handle_double_click.
DATA: ls_sm LIKE LINE OF itsm,
wa_itab LIKE ITAB.
* read selected row from internal table gt_sflight
READ TABLE itsm INDEX e_row-index INTO ls_sm.
* §4.At Doubleclick(2): Select booking data
* READ TABLE ITAB WITH KEY KUNAG = LS_SM-KUNAG. .
READ TABLE ITAB INTO WA_ITAB WITH KEY KUNAG = LS_SM-KUNAG.
* §5.At doubleclick(3): Create dialogbox to show detail list
* (if not already existent)
IF dialogbox_status IS INITIAL.
dialogbox_status = 'X'.
PERFORM create_detail_list.
ELSE.
CALL METHOD dialogbox_container->set_visible
EXPORTING
visible = 'X'.
CALL METHOD grid2->refresh_table_display.
ENDIF.
ENDMETHOD. "handle_double_click
METHOD handle_close.
* §6.Handle the CLOSE-button of the dialogbox
* set dialogbox invisible
* (the dialogbox is destroyed outomatically when the user
* switches to another dynpro).
CALL METHOD sender->set_visible
EXPORTING
visible = space.
* In this example closing the dialogbox leads
* to make it invisible. It is also conceivable to destroy it
* and recreate it if the user doubleclicks a line again.
* Displaying a great amount of data has a greater impact on
*performance.
ENDMETHOD. "handle_close
ENDCLASS. "lcl_event_receiver IMPLEMENTATION
* lcl_event_receiver (Implementation)
*=====================================================================
* FORM EXIT_PROGRAM *
FORM exit_program.
CALL METHOD g_custom_container->free.
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 TO SCREEN 0.
ENDFORM. "exit_program
*& Module STATUS_0100 OUTPUT
* text
module STATUS_0100 output.
SET PF-STATUS 'MAIN'.
SET TITLEBAR 'MAIN100'.
g_repid = sy-repid.
IF g_custom_container IS INITIAL.
READ TABLE itsm.
CREATE OBJECT g_custom_container
EXPORTING
container_name = g_container
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5.
IF sy-subrc NE 0.
CALL FUNCTION 'POPUP_TO_INFORM'
EXPORTING
titel = g_repid
txt2 = sy-subrc
txt1 = 'The control could not be created'(510).
ENDIF.
CREATE OBJECT grid1
EXPORTING
i_parent = g_custom_container.
gs_layout-grid_title = 'Invoice Summary'.
PERFORM fieldcatalog_init USING gt_fieldcatalog[] 'KUNAG' 'C'
'Customer Code'.
PERFORM fieldcatalog_init USING gt_fieldcatalog[] 'NAME1' 'C'
'Customer Name'.
PERFORM fieldcatalog_init USING gt_fieldcatalog[] 'FKLMG' 'QUAN'
'Quantity'.
PERFORM fieldcatalog_init USING gt_fieldcatalog[] 'NETWR' 'CURR'
'Amount'.
PERFORM sort_build USING gt_sort[].
PERFORM layout_init USING gs_layout.
CALL METHOD grid1->set_table_for_first_display
EXPORTING
is_layout = gs_layout
CHANGING
it_outtab = itsm[]
it_fieldcatalog = gt_fieldcatalog
it_sort = gt_sort.
CREATE OBJECT event_receiver.
SET HANDLER event_receiver->handle_double_click FOR grid1.
ENDIF.
CALL METHOD cl_gui_control=>set_focus
EXPORTING
control = grid1.
endmodule. " STATUS_0100 OUTPUT
* MODULE PAI_ALV INPUT
MODULE USER_COMMAND_0100.
CALL METHOD cl_gui_cfw=>dispatch.
CASE sy-ucomm.
WHEN 'BACK' OR 'EXIT' OR 'CANC'.
LEAVE TO SCREEN 0.
ENDCASE.
ENDMODULE. "PAI_ALV INPUT
*& Form fieldcatalog_init
* text
* -->LT_FIELDCATtext
* -->VALUE(FIELDtextE)
* -->VALUE(FIELDtextE)
* -->VALUE(FIELDtextT)
FORM fieldcatalog_init USING lt_fieldcatalog TYPE lvc_t_fcat
value(field_name) value(field_type)
value(field_text).
DATA: ls_fieldcatalog TYPE lvc_s_fcat.
CLEAR ls_fieldcatalog.
ls_fieldcatalog-fieldname = field_name.
ls_fieldcatalog-datatype = field_type.
ls_fieldcatalog-reptext = field_text.
ls_fieldcatalog-coltext = field_text.
ls_fieldcatalog-seltext = field_text.
ls_fieldcatalog-tooltip = field_text.
APPEND ls_fieldcatalog TO lt_fieldcatalog.
ENDFORM. "fieldcatalog_init
*& Form sort_build
* text
* -->LT_SORT text
FORM sort_build USING lt_sort TYPE lvc_t_sort.
DATA: ls_sort TYPE lvc_s_sort.
ls_sort-fieldname = 'KUNAG'. "Fieldname on which to sort
ls_sort-up = 'X'. "Sort Ascending
APPEND ls_sort TO lt_sort.
ls_sort-fieldname = 'NAME1'. "Fieldname on which to sort
ls_sort-up = 'X'. "Sort Ascending
APPEND ls_sort TO lt_sort.
ENDFORM. "sort_build
*& Form layout_init
* text
* -->LS_LAYOUT text
FORM layout_init USING ls_layout TYPE lvc_s_layo.
ls_layout-zebra = 'X'.
ls_layout-grid_title = 'Customer Details'.
ls_layout-sel_mode = 'A'.
ls_layout-cwidth_opt = 'X'.
ENDFORM. "layout_init
*& Form create_detail_list
* text
* --> p1 text
* <-- p2 text
FORM create_detail_list.
* create dialogbox container as dynpro-instance
* When the user switches to another screen, it is
* destroyed by lifetime mangagement of CFW
CREATE OBJECT dialogbox_container
EXPORTING
top = 150
left = 150
lifetime = cntl_lifetime_dynpro
caption = 'INVOICE DETAILS'(200)
width = 800
height = 200.
CREATE OBJECT grid2
EXPORTING i_parent = dialogbox_container.
* Register ABAP OO event 'CLOSE'. It is not necessary to register this
* event at the frontend (this is done during creation).
SET HANDLER event_receiver->handle_close FOR dialogbox_container.
* display data
gs_layout-grid_title = 'Invoice Details'(100).
CALL METHOD grid2->set_table_for_first_display
EXPORTING
i_structure_name = 'itab'
is_layout = gs_layout
CHANGING
it_outtab = itab[]
it_fieldcatalog = gt_fieldcatalog
it_sort = gt_sort.
CALL METHOD cl_gui_control=>set_focus
EXPORTING
control = grid2.
ENDFORM. " create_detail_list
Nothing wrong in the code i am able to see the output with five records and the pop-up screen on double clicking a value.
Kindly close the thread or revert back
Maybe you are looking for
-
Error while changing the Display Attribute into Navigational Attribute
Hi all.. Gud Mrng. I was changed the attribute (product) from display attribute into navigational attribute and while save and activating the info object it is not getting activated and it is throwing the below error message. Error Message: u201CThe
-
Hi, We are using Oracle Express 6.3.2 & Oracle 8.1.5 for a decision support system that we are building. We are using a server with 2GB RAM, Dual CPU( 550MHz) along with more than 100 GB HDD.The OS being used is Windows NT enterprise edition server 4
-
ORA-01034 has me stumped!
oracle 11.2.0.3 EE on OL 5.5 under VMworkstation This should be a no brainer, but all the usual suspects check out. Am configuring an repository db for Cloud Control. DB is on separate box from EM installation. EM install complained about existence o
-
Air Error Message when opening Photoshop
Hello, I'm getting an Adobe Air error message when I open Photoshop (on Windows 7 Enterprise 32-Bit), "Adobe Air - The installation of this application is damaged". I've tried uninstalling and reinstalling the current release of Air, tried reinstalli
-
Hi Friends, I have two keyfigures KF1 and KF2 . I want to write the formula i.e (KF1KF2)/Sum(KF1KF2). This formula is to be applied depending on the Characteristic Material. Please guide me the syntax of this formula. Regards, Girish