Color for a Field in alv output
Hi All,
I use a field in the ALV grid output which needs to display color (red or green) depending on certain validations. Please tell me how to display color for this field. The program uses oops.
Thanks.
Hi
1. add one more field to ur final internal table say COLOR(4)
2. in layout wa_layout-style_fname = 'COLOR'. " if its grid
wa_layout-style_fieldname = 'COLOR'. "if its list
3. read table itab index 3.
itab-color = 'C410'.
modify itab index 3
4. see program SHOWCOLO for all color codes
1. Add a field of data type CHAR(3) to the internal output table.
2. Enter the color code in the appropriate field of the row to be colored in the internal
output table:
Code: 'Cxy'
C = Color (all codes begin with 'C')
x = color number ('1' - '9')
y = highlight ('0' = off, '1' = on)
3. Assign the internal output table color code field name to the IS_LAYOUT importing
structure IS_LAYOUT-INFO_FIELDNAME field and pass this structure in the ALV call
interface.
To enable row coloring, you should add an additional field to your list data table. It should be of character type and length at least 4. This field will contain the color code for the row. So, lets modify declaration of our list data table gt_list.
you should fill the color code to this field. Its format will be the same as explained before at section C.6.3. But how will ALV Grid know that you have loaded the color data for the row to this field. So, you make it know this by passing the name of the field containing color codes to the field INFO_FNAME of the layout structure.
e.g.
ps_layout-info_fname = <field_name_containing_color_codes>. e.g. ROWCOLOR
You can fill that field anytime during execution. But, of course, due to the flow logic of screens, it will be reflected to your list display as soon as an ALV refresh occurs.
You can color an entire row as described in the next section. However, this method is less time consuming.
Coloring Individual Cells
This is the last point about coloring procedures for the ALV Grid. The procedure is similar to coloring an entire row. However, since an individual cell can be addressed with two parameters we will need something more. What is meant by more is a table type structure to be included into the structure of the list data table. It seems strange, because including it will make our list data structure deep. But anyhow ALV Grid control handles this.
The structure that should be included must be of type LVC_T_SCOL. If you want to color the entire row, this inner table should contain only one row with field fname is set to space, some color value at field col, 0 or 1 at fields int (intensified) and inv (inverse).
If you want to color individual cells, then for each cell column, append a line to this inner table which also contains the column name at field fname. It is obvious that you can color an entire column by filling this inner table with a row for that column for each row in the list data table.
Reward points if useful
Regards
Anji
Similar Messages
-
How to pass custom search help(F4 help) for a field in ALV output?
Hi,
I want to activate the F4 help in ALV output for a field for which we do not have search help assigned at table ,data element and domain level.
In field catalog i have enabled it by below line.
ls_fcat-F4AVAILABL = 'X'.
but because there are no standard input help available it is giving message as "No input help is available".
so how to pass our custom search help (g_search) for any field in ALV output.
I am using object oriented ALV grid display.
Thanks!!!
Rajesh Gupta.hi,
check this out:
http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/b3d5e890-0201-0010-c0ac-bba85ec2ae8d
http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/acdefb13-0701-0010-f1a2-8eeefa7d3780
http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/b3d5e890-0201-0010-c0ac-bba85ec2ae8d?quicklink=index&overridelayout=true -
Negative sign for DMBTR field in ALV output
Hi Experts,
Before posting I have searched for more than 3 hours in the forums to get a solution for this.
I did not get any solution so I am posting this problem which I need to resolve.
I have to display the DMBTR field in ALV output for which a grand total will have to be displayed.
Here for all the values in DMBTR which are negative are getting displayed as '- 6673.56','- 289956.23' as I am using the edit mask 'V_____________.__'.
I have to get the value shown as '-6673.56', '-289956.23'.
I tried to use convert this DMBTR to String and have successfully displayed the negative sign correctly in front of the value but I am not getting the totals which I need to have
PLease check and suggest for a solution.
Regards
KishoreHi,
If this is the case, then you can use character field to display the sign on the left. Sum up the total and use the event end of list to display the same. Remember to set the TECH and NO_OUT in the field catalog.
Hope this helps.
Regards,
Siva -
Co41 enhancement for add field in ALV output
I must add a custom filed to ALV output of transaction CO41 and i trying to use all the 25 enhancements provided (that i find in other post CO41- Enhancement ), but i haven't found any way to get the desired results.
Can any body help me?
Thanks in advance.Hi,
I had the same requirement to add a custom field to ALV output of transaction CO41.
1. I first added the custom field to an new append-structure to the structure SFC_POCO.
2. Then i added this field to the Dynpro-Screen 200 in the function-group COUP (by choosing the table control, pressing F6 and then adding the custom field of SFC_POCO).
3. At last i added an Enhancement to the function CO_UP_PLANNED_ORDERS_SELECT and filled my custom field with data there.
Please reward if useful.
Regards,
Henry -
Fixed length for the fields of ALV output
Hi,
How to fix a field in the ALV output to its max length..For example..if a field's max length is 10...that coloumn should not be dragged or moved to right..Its lenght shluld be fixed to 10...Could any bod suggest me how to perform this...thanks..
Shyam.Hi,
U can better optimize the width.it will be good.
data : W_LAYOUT TYPE SLIS_LAYOUT_ALV.
W_LAYOUT-COLWIDTH_OPTIMIZE = 'X'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
I_STRUCTURE_NAME = 'T_ALV'
IS_LAYOUT = W_LAYOUT
IT_FIELDCAT = T_FIELDCAT_ALV
I_CALLBACK_TOP_OF_PAGE = 'ALV_TOP_OF_PAGE'
TABLES
T_OUTTAB = T_ALV
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. -
I am not getting the headings of the fields in ALV output.
I am not getting ALV out put but the headings of the fields in ALV output.
Please see my below code .
TYPES : BEGIN OF ty_zgxmit.
INCLUDE STRUCTURE zgxmit.
TYPES : END OF ty_zgxmit.
DATA : gt_zgxmit TYPE TABLE OF ty_zgxmit.
*& Form alv_display *
This subroutine is to display the out put in ALV. *
FORM alv_display .
Local data
DATA: y_x LIKE boole VALUE 'X'.
DATA: lt_fieldcat TYPE slis_t_fieldcat_alv.
DATA: lf_fieldcat TYPE slis_fieldcat_alv.
DATA: lh_index LIKE lf_fieldcat-col_pos.
For variant
DATA: ws_repid LIKE sy-repid,
g_save TYPE c VALUE 'A',
g_exit TYPE c,
g_variant LIKE disvariant,
gx_variant LIKE disvariant.
For 1st field.( RPT_LOC )
CLEAR lf_fieldcat.
lf_fieldcat-fieldname = 'RPT_LOC'.
lf_fieldcat-tabname = 'GT_ZGXMIT'.
lf_fieldcat-ref_tabname = 'RPT_LOC'.
lf_fieldcat-ref_fieldname = 'ZGXMIT'.
lh_index = lh_index + 1.
lf_fieldcat-col_pos = lh_index.
lf_fieldcat-key = y_x.
lf_fieldcat-no_sum = y_x.
APPEND lf_fieldcat TO lt_fieldcat.
For 2nd field.( BAL_XMIT )
CLEAR lf_fieldcat.
lf_fieldcat-fieldname = 'BAL_XMIT'.
lf_fieldcat-tabname = 'GT_ZGXMIT'.
lf_fieldcat-ref_tabname = 'BAL_XMIT'.
lf_fieldcat-ref_fieldname = 'ZGXMIT'.
lh_index = lh_index + 1.
lf_fieldcat-col_pos = lh_index.
lf_fieldcat-key = y_x.
lf_fieldcat-no_sum = y_x.
APPEND lf_fieldcat TO lt_fieldcat.
For 3rd field.( INC_XMIT )
CLEAR lf_fieldcat.
lf_fieldcat-fieldname = 'INC_XMIT'.
lf_fieldcat-tabname = 'GT_ZGXMIT'.
lf_fieldcat-ref_tabname = 'INC_XMIT'.
lf_fieldcat-ref_fieldname = 'ZGXMIT'.
lh_index = lh_index + 1.
lf_fieldcat-col_pos = lh_index.
lf_fieldcat-key = y_x.
lf_fieldcat-no_sum = y_x.
APPEND lf_fieldcat TO lt_fieldcat.
For 4th field.( Z500_XMIT )
CLEAR lf_fieldcat.
lf_fieldcat-fieldname = 'Z500_XMIT'.
lf_fieldcat-tabname = 'GT_ZGXMIT'.
lf_fieldcat-ref_tabname = 'Z500_XMIT'.
lf_fieldcat-ref_fieldname = 'ZGXMIT'.
lh_index = lh_index + 1.
lf_fieldcat-col_pos = lh_index.
lf_fieldcat-key = y_x.
lf_fieldcat-no_sum = y_x.
APPEND lf_fieldcat TO lt_fieldcat.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = 'ZJV_2245'
it_fieldcat = lt_fieldcat
TABLES
t_outtab = gt_zgxmit
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. " alv_displayYou can force the headings like so.
CLEAR lf_fieldcat.
lf_fieldcat-fieldname = 'RPT_LOC'.
lf_fieldcat-tabname = 'GT_ZGXMIT'.
lf_fieldcat-ref_tabname = 'RPT_LOC'.
lf_fieldcat-ref_fieldname = 'ZGXMIT'.
lf_fieldcat-reptext_ddic = 'Whatever Heading'. "<- Right here
lh_index = lh_index + 1.
lf_fieldcat-col_pos = lh_index.
lf_fieldcat-key = y_x.
lf_fieldcat-no_sum = y_x.
APPEND lf_fieldcat TO lt_fieldcat.
Regards,
Rich Heilman -
Add List box for one field in ALV GRID
Hi All,
I need to add drop down list box for one field in ALV Grid.
If any body knows, please help.
Thanks in advance.
Regards
MangleshHi,
Here is the ex where i have used for date parameter in the sel screen
type-pools: vrm.
data: name type vrm_id,
list type vrm_values,
value like line of list.
parameters : p_date like p_date2
as listbox visible length 15.
at selection-screen output.
name = 'P_DATE'.
value-key = '1'.
value-text = 'Today'.
append value to list.
value-key = '2'.
value-text = 'Last 7 days'.
append value to list.
value-key = '3'.
value-text = 'Last 30 days'.
append value to list.
value-key = '4'.
value-text = 'Last 90 days'.
append value to list.
value-key = '5'.
value-text = 'Last year'.
append value to list.
Call the ''VRM_SET_VALUES' to display the values in Listbox
call function 'VRM_SET_VALUES'
exporting
id = name
values = list.
at selection-screen.
if sy-ucomm = 'CLI1'.
sscrfields-ucomm = 'ONLI'(001).
endif.
if p_date = '1'.
p_date11 = sy-datum .
elseif p_date = '2'.
p_date11 = ( sy-datum - 7 ).
elseif p_date = '3'.
p_date11 = ( sy-datum - 30 ).
elseif p_date = '4'.
p_date11 = ( sy-datum - 90 ).
elseif p_date = '5'.
p_date11 = ( sy-datum - 365 ).
endif.
Hope this helps u..
Please reward points if useful.
Regards,
Sreenivas -
How to add F1 help for a field on ALV grid
Hi All,
When we execute a program, the output is displayed using ALV grid.
on the ALV grid, if we press F1 on a field, it should popup the help document.
How to add F1 help for a field on ALV grid.
Thank you all in advance.fill field LVC_S_FCAT-ROLLNAME of your fieldcatalog in method SET_TABLE_FOR_FIRST_DISPLAY
A. -
How to add a search help for a field in alv?
HI!Everyone ,
i want to add a search help created by myself for one field in alv,
and i want to use this function "HELP_VALUES_GET_WITH_TABLE".
can anyone help me ?
thanks!HI,Vijay.
My code like this :
PERFORM build_fcat.
PERFORM build_objects.
PERFORM layo_build.
PERFORM set_drdn_table .
CALL METHOD alv_grid->set_table_for_first_display
EXPORTING
i_structure_name = 'STU_S'
is_layout = s_layo
CHANGING
it_outtab = itab_out
it_fieldcatalog = i_fcat
."Period
IF sy-subrc <> 0.
EXIT.
ENDIF.
for example, there is a field 'UNAME' IN Structure 'STU_S',
i want to add a search help for 'UNAME'.
the 'UNAME' is not users in SAP R/3 , i want to add some data by myself or from a table . -
How to display the fields in ALV Output without using Field catalog?
How to display the fields in ALV Output without using Field catalog?
Could you pls tell me the coding?
Akshitha.Hi,
u mean without building field catalog. is it? I that case, we can use the FM REUSE_ALV_FIELDCATALOG_MERGE.
data: itab type table of mara.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = sy-repid
i_structure_name = itab
CHANGING
ct_fieldcat = lt_fieldcat[]
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
*Pass that field catalog into the fillowing FM
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = gd_repid
i_grid_title = 'REPORTING'
is_layout = gt_layout
it_fieldcat = lt_fieldcat[]
tables
t_outtab = itab. -
How to change a color for a row in ALV grid display
Hi,
how to change a color for a row in ALV grid display based on a condition.Any sample code plzHello Ramya,
Did you check in [SCN|How to color a row of alv grid]
Thanks! -
How can we sum for the field on alv grid
Dear Freinds,
I am having the field count .....in the ouput (iam using alv grid) .......which dispalys the id's which are identical .
i have scneario similar to the below in my ALV Output
ID count total
4000 3 100
100
200 Can i get count 3 also along with 200 in alv?
i am using the code as follows for count can any one please let me know.
my earlier question which i put was confusing.........so i am givin the qustion again
clear ls_fieldcat.
ls_fieldcat-col_pos = 1.
ls_fieldcat-fieldname = 'ORGUNIT'.
ls_fieldcat-seltext_l = text-015. "'Orgunit'.
ls_fieldcat-key = 'X'.
ls_fieldcat-key_sel = 'X'.
ls_fieldcat-no_out = 'X'.
append ls_fieldcat to fp_i_fieldcat.
clear ls_fieldcat.
ls_fieldcat-col_pos = 2.
ls_fieldcat-fieldname = 'COUNT'.
ls_fieldcat-seltext_l = 'H.Count'.
ls_fieldcat-outputlen = 4.
ls_fieldcat-do_sum = 'X'.
ls_fieldcat-datatype = 'NUMC'.
append ls_fieldcat to fp_i_fieldcat.
clear ls_fieldcat.
ls_fieldcat-fieldname = 'TOTAL'.
ls_fieldcat-seltext_m = 'total'.
ls_fieldcat-col_pos = 3.
ls_fieldcat-outputlen = 17.
ls_fieldcat-do_sum = 'X'.
ls_fieldcat-datatype = 'CURR'.
append ls_fieldcat to fp_i_fieldcat.
Please let me know how can do if so what is the parameter i have to change for COUNT
regards
syamalHi Shamala Kiran.
My name is also kiran.I have a develop a code for u.Actually i cant understand your code.But i know ur problem .Plz check that code.In that code i develop a subtotals and grandttotal.Plz observe the FORM "FIELD CATALOG" in that observe the NETWR FIELD and observe the FORM SORTCATALOG then ur problem will be solved.
Copy the the below code and execute that code and the result.
If u r Satisfied with the answer plz give the REWARD POINTS.
CODE:
Type Pools
TYPE-POOLS:slis.
Tables
TABLES: vbak,vbap.
Global Variable
data: w_var type i.
Global Data
DATA:it_fieldcat TYPE slis_t_fieldcat_alv,
wa_fieldcat TYPE slis_fieldcat_alv,
it_sortcat TYPE slis_t_sortinfo_alv,
wa_sortcat LIKE LINE OF it_sortcat.
Internal Table
data: BEGIN OF it_salesorder OCCURS 0,
vbeln LIKE vbak-vbeln, " Sales Document Number
posnr like vbap-posnr, " Sales Doc Item
netwr like vbap-netwr, " Net Value
END OF it_salesorder.
SELECT OPTIONS
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
SELECT-OPTIONS: s_vbeln FOR vbak-vbeln. " Sales Document Number.
SELECTION-SCREEN END OF BLOCK b1.
Initialization
INITIALIZATION.
PERFORM initialization.
*& Form initialization
text
--> p1 text
<-- p2 text
form initialization .
s_vbeln-sign = 'I'.
s_vbeln-option = 'BT'.
s_vbeln-low = '4969'.
s_vbeln-high = '5000'.
APPEND s_vbeln.
endform. " initialization
Start Of Selection
START-OF-SELECTION.
PERFORM field_catalog. "For Structure Creation
PERFORM fetch_data. "Get the Data From DB Table
PERFORM sorting USING it_sortcat.
End Of Selection
END-OF-SELECTION.
perform display_data.
*& Form field_catalog
text
--> p1 text
<-- p2 text
form field_catalog .
wa_fieldcat-col_pos = w_var. " Column Position Variable
wa_fieldcat-tabname = 'IT_SALESORDER'. " Internal Table Name
wa_fieldcat-fieldname = 'VBELN'. " Field Name
wa_fieldcat-key = 'X'. " Blue Color
wa_fieldcat-ref_tabname = 'VBAK'. " Table Name
wa_fieldcat-ref_fieldname = 'VBELN'. " Field Name
wa_fieldcat-seltext_m = 'Sales Doc No'. " Display Text In Screen
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
ADD 1 TO w_var.
wa_fieldcat-col_pos = w_var. " Column Position Variable
wa_fieldcat-tabname = 'IT_SALESORDER'. " Internal Table Name
wa_fieldcat-fieldname = 'POSNR'. " Field Name
wa_fieldcat-ref_tabname = 'VBAP'. " Table Name
wa_fieldcat-ref_fieldname = 'POSNR'. " Field Name
wa_fieldcat-seltext_m = 'Sales Doc Item'. " Display Text In Screen
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
ADD 1 TO w_var.
wa_fieldcat-col_pos = w_var. " Column Position Variable
wa_fieldcat-tabname = 'IT_SALESORDER'. " Internal Table Name
wa_fieldcat-fieldname = 'NETWR'. " Field Name
wa_fieldcat-ref_tabname = 'VBAP'. " Table Name
wa_fieldcat-ref_fieldname = 'NETWR'. " Field Name
wa_fieldcat-do_sum = 'X'. " Sum
wa_fieldcat-seltext_m = 'Net Value'. " Display Text In Screen
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
ADD 1 TO w_var.
endform. " field_catalog
*& Form sorting
text
-->P_IT_SORTCAT text
form sorting using p_it_sortcat TYPE slis_t_sortinfo_alv.
wa_sortcat-fieldname = 'VBELN'.
wa_sortcat-up ='X'.
wa_sortcat-subtot = 'X'.
APPEND wa_sortcat TO p_it_sortcat.
endform. " sorting
*& Form display_data
text
--> p1 text
<-- p2 text
form display_data .
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 = ' '
I_CALLBACK_USER_COMMAND = ' '
I_CALLBACK_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_END_OF_LIST = ' '
I_STRUCTURE_NAME =
I_BACKGROUND_ID = ' '
I_GRID_TITLE =
I_GRID_SETTINGS =
IS_LAYOUT =
IT_FIELDCAT = it_fieldcat
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT = it_sortcat
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = ' '
IS_VARIANT =
IT_EVENTS =
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
IT_ALV_GRAPHICS =
IT_HYPERLINK =
IT_ADD_FIELDCAT =
IT_EXCEPT_QINFO =
I_HTML_HEIGHT_TOP =
I_HTML_HEIGHT_END =
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
t_outtab = it_salesorder
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_data
*& Form fetch_data
text
--> p1 text
<-- p2 text
form fetch_data .
select a~vbeln
posnr
b~netwr
from vbak as a
inner join vbap as b on avbeln = bvbeln
into table it_salesorder
where a~vbeln in s_vbeln.
endform. " fetch_data -
Color for negative Values in ALV Report
I want to change the color for negative values displayed in ALV list diplay report. Eg. -5 in Quantity should be changed to orange. Kindly help me
ThanksCheck the below program and bold one are important ( which is similar to MD05 Traffic lights )
REPORT ZWM_BIN_STOCK_REQ no standard page heading
message-id zwave.
D A T A D E C L A R A T I O N ****************************
Tables
tables :zpwvbap,
mara,
marc,
makt,
vbap,
zshift,
marm,
lqua.
TYPE-POOLS: SLIS.
Internal Table for Sales order
data : begin of i_vbap occurs 0,
matnr like zpwvbap-matnr," Material #
ZZCUTOFF like zpwvbak-ZZCUTOFF," Cutoff Time
vlpla like zpwvbap-vlpla,
kwmeng like zpwvbap-kwmeng," Quantity
vrkme like zpwvbap-vrkme, " Sales Unit
meins like zpwvbap-meins, " Unit of measure
end of i_vbap.
Internal Table for final Processing
data : begin of i_final occurs 0,
date(8) type c,
matnr like zpwvbap-matnr," Material #
zzshift like zshift-zzshift, " Wave Drop
maktx like makt-maktx," Desc
lgpla like lagp-lgpla, " Pick Bin
pverme like lqua-verme," Stock at Pick Bin
prverme like lqua-verme," Stock at Prod Bin
kwmeng like zpwvbap-kwmeng," Requiremnet from Wave Drop
vrkme like zpwvbap-vrkme, " Sales Unit
meins like zpwvbap-meins," Unit of measure
end of i_final.
Internal Table for Output
data : begin of i_output occurs 0,
<b> field type c, " Traffic Lights</b>
zzshift like zshift-zzshift, " Wave Drop
matnr like zpwvbap-matnr," Material #
maktx like makt-maktx," Desc
lgpla like lagp-lgpla, " Pick Bin
pverme like lqua-verme," Stock at Pick Bin
prverme like lqua-verme," Stock at Prod Bin
kwmeng like zpwvbap-kwmeng," Requiremnet from Wave Drop
vrkme like zpwvbap-vrkme," Sales Unit
meins like zpwvbap-meins," Unit of measure
diff like zpwvbap-kwmeng, " Diffrence
end of i_output.
Work Area for Final Internal Table
data wa_final like i_final.
data : w_zzcutoff(12) TYPE c,
v_date type sy-datum,
v_time(4) type c,
v_fldate(12) type c,
v_fhdate(12) type c,
v_pverme like lqua-verme,
v_prverme like lqua-verme,
v_diff like zpwvbap-kwmeng.
Variables for new check box
data : v_nverme like lqua-verme.
Internal Table for Pick Bin
data : begin of i_verme occurs 0,
verme like lqua-verme,
end of i_verme.
Internal table for Prod Bin
data : begin of i_pverme occurs 0,
verme like lqua-verme,
end of i_pverme.
Variables for ALV
DATA: FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
FIELDCAT_LN LIKE LINE OF FIELDCAT,
SORTCAT TYPE SLIS_T_SORTINFO_ALV,
SORTCAT_LN LIKE LINE OF SORTCAT,
EVENTCAT TYPE SLIS_T_EVENT,
EVENTCAT_LN LIKE LINE OF EVENTCAT,
LAYOUT TYPE SLIS_LAYOUT_ALV,
C_TOP_OF_PAGE TYPE SLIS_FORMNAME VALUE 'TOP_OF_PAGE',
g_user_command TYPE slis_formname VALUE 'USER_COMMAND',
GT_LIST_TOP_OF_PAGE TYPE SLIS_T_LISTHEADER.
DATA: COL_POS TYPE I,
P_LIGNAM TYPE SLIS_FIELDNAME VALUE 'FIELD'.
DATA : V_REPID LIKE SY-REPID,
flag type c.
S E L E C T I O N - S C R E E N *************************
selection-screen : begin of block blk with frame title text-001.
parameter : p_plant like marc-werks obligatory default '1000'.
select-options : s_date for sy-datum obligatory ,
s_shift for zshift-zzshift,
s_matnr for mara-matnr,
s_dept for zpwvbap-zzdept,
s_pdept for marc-ZZPRODDEPT.
selection-screen: end of block blk.
parameters : p_check as checkbox ."default 'X'.
ranges r_cutoff for w_zzcutoff.
I N I T I A L I Z A T I O N ****************************
initialization.
V_REPID = SY-REPID.
s_date-low = sy-datum + 1.
append s_date.
S T A R T - O F - S E L E C T I O N ***********************
start-of-selection.
Get the Shift Data.
PERFORM GET_SHIFT_DETAILS.
Get the data from ZPWVBAP Table
PERFORM GET_DATA_VBAP.
E N D - O F - S E L E C T I O N **********************
end-of-selection.
if not i_output[] is initial.
sort i_output by field zzshift matnr.
Reset the all Fiedcatlog.
PERFORM RESETVALUES.
Traffic Lights
PERFORM BUILD_LAYOUT.
Fill the fieldcatlog values
PERFORM FILL_FIELDCATLOG.
Call the List Function module
PERFORM CALL_lIST.
endif.
*& Form GET_SHIFT_DETAILS
Get the Cutoff Time.
FORM GET_SHIFT_DETAILS.
clear : v_fldate,
v_fhdate.
if not s_shift-low is initial.
clear: v_time,
v_date.
if s_shift-low = '1'.
v_time = '2000'.
elseif s_shift-low = '2'.
v_time = '2300'.
endif.
v_date = s_date-low - 1.
concatenate v_date v_time into v_fldate.
endif.
if not s_shift-high is initial.
clear : v_date,
v_time.
if s_shift-high = '1'.
v_time = '2000'.
elseif s_shift-high = '2'.
v_time = '2300'.
endif.
if not s_date-high is initial.
v_date = s_date-high - 1.
else.
v_date = s_date-low - 1.
endif.
concatenate v_date v_time into v_fhdate.
endif.
if not v_fhdate is initial.
r_cutoff-low = v_fldate.
r_cutoff-high = v_fhdate.
r_cutoff-sign = 'I'.
r_cutoff-option = 'BT'.
append r_cutoff.
endif.
ENDFORM. " GET_SHIFT_DETAILS
*& Form GET_DATA_VBAP
Get the data from ZPWVBAP Table
FORM GET_DATA_VBAP.
Get the data from ZPWVBAP and ZPWVBAK Table
if not v_fhdate is initial.
select matnr ZZCUTOFF vlpla sum( kwmeng ) vrkme meins
into table i_vbap
from zpwvbap as a inner join zpwvbak as b on
a~vbeln = b~vbeln
where a~werks = p_plant
and a~matnr in s_matnr
and b~vdatu in s_date
and a~zzdept in s_dept
and b~zzcutoff in r_cutoff
group by matnr zzcutoff vlpla vrkme meins.
elseif not v_fldate is initial.
select matnr ZZCUTOFF vlpla sum( kwmeng ) vrkme meins
into table i_vbap
from zpwvbap as a inner join zpwvbak as b on
a~vbeln = b~vbeln
where a~werks = p_plant
and a~matnr in s_matnr
and b~vdatu in s_date
and a~zzdept in s_dept
and b~zzcutoff = v_fldate
group by matnr zzcutoff vlpla vrkme meins.
else.
select matnr ZZCUTOFF vlpla sum( kwmeng ) vrkme meins
into table i_vbap
from zpwvbap as a inner join zpwvbak as b on
a~vbeln = b~vbeln
where a~werks = p_plant
and a~matnr in s_matnr
and b~vdatu in s_date
and a~zzdept in s_dept
and b~zzcutoff in r_cutoff
group by matnr zzcutoff vlpla vrkme meins .
endif.
if sy-subrc ne 0.
message i000(zwave) with 'No data found for given selection'.
stop.
endif.
sort i_vbap by zzcutoff matnr.
loop at i_vbap.
clear : v_pverme,
v_prverme.
Compare the data with pick method
select single zzpick from marc into marc-zzpick
where matnr = i_vbap-matnr
and werks = p_plant
and zzpick = '01'.
if sy-subrc ne 0.
continue.
endif.
Compare the data from MARC Table with Production Department
select single zzPRODdept from marc into marc-zzPRODdept
where matnr = i_vbap-matnr
and werks = p_plant
and zzPRODdept in s_pdept.
if sy-subrc ne 0.
continue.
endif.
Get the Material Description from MAKT Table
Select single maktx from makt into makt-maktx
where matnr = i_vbap-matnr
and spras = 'E'.
if sy-subrc eq 0.
i_final-maktx = makt-maktx.
endif.
Get the Pick Bin
i_final-lgpla = i_vbap-vlpla.
refresh i_verme.
clear i_verme.
Get the stock at Pick bin
select verme from lqua into table i_verme
where lgpla = i_vbap-vlpla
and matnr = i_vbap-matnr
and LGNUM = '100'.
if sy-subrc eq 0.
loop at i_verme.
v_pverme = v_pverme + i_verme-verme.
endloop.
if sy-subrc eq 0.
i_final-pverme = v_pverme.
endif.
endif.
refresh i_pverme.
clear i_pverme.
Get the stock at Production bin
select verme from lqua into table i_pverme
where matnr = i_vbap-matnr
and LGNUM = '100'
and ( lgpla = '9595959595' or
lgpla = '2222222222' or
lgpla = '5555555555' or
lgpla = '3232323232' or
lgpla = '8080808080' or
lgpla = '4040404040' or
lgpla = '9090909090' ).
if sy-subrc eq 0.
loop at i_pverme.
v_prverme = v_prverme + i_pverme-verme.
endloop.
if sy-subrc eq 0.
i_final-prverme = v_prverme.
endif.
endif.
Compare the unit of measure and sales unit
if i_vbap-vrkme ne i_vbap-meins.
Get the data from MARM Table ( Unit of measure )
select single * from marm into marm
where matnr = i_vbap-matnr
and meinh = i_vbap-vrkme.
if sy-subrc eq 0.
i_final-pverme = ( i_final-pverme * marm-umren ) / marm-umrez.
endif.
endif.
Material #
i_final-matnr = i_vbap-matnr.
Quantity from ZPWVBAP
i_final-kwmeng = i_vbap-kwmeng.
Unit of Measure
i_final-meins = i_vbap-meins.
Sales Unit
i_final-vrkme = i_vbap-vrkme.
Wave Drop
if i_vbap-ZZCUTOFF+8(4) = '2000' .
i_final-zzshift = '1'.
endif.
if i_vbap-zzcutoff+8(4) = '2300'.
i_final-zzshift = '2'.
endif.
i_final-date = i_vbap-zzcutoff+0(8).
append i_final.
clear : i_final,
i_vbap.
**Difference
i_output-diff = i_output-pverme - i_vbap-kwmeng.
Traffic Lights Depends on value
if i_output-pverme > i_output-kwmeng.
i_output-field = '3'.
elseif i_output-pverme < i_output-kwmeng.
i_output-field = '1'.
elseif i_output-pverme = i_output-kwmeng.
i_output-field = '2'.
endif.
append i_output.
clear : i_output,
i_vbap.
endloop.
refresh i_vbap.
sort i_final by date matnr zzshift.
Processing the internal table to get same material with pick quantity
deduction even it for 2nd shift
loop at i_final.
Move the data into work area in order remove #
move i_final to wa_final.
clear : flag.
at new matnr.
move : wa_final-matnr to i_output-matnr," Material #
wa_final-maktx to i_output-maktx," Desc
wa_final-lgpla to i_output-lgpla," Pick Bin
wa_final-kwmeng to i_output-kwmeng," Order qty
wa_final-zzshift to i_output-zzshift," Shift
wa_final-pverme to i_output-pverme, " Pick bin qty
wa_final-vrkme to i_output-vrkme," Sales Unit
wa_final-prverme to i_output-prverme. " Prod Bin Qty
Difference
i_output-diff = i_output-pverme - i_output-kwmeng.
New logic for Only HMR Department
<b> if p_check = 'X'.
if i_output-pverme < i_output-kwmeng.
v_nverme = i_output-pverme + i_output-prverme.
if v_nverme > i_output-kwmeng.
if i_output-pverme < i_output-kwmeng.
i_output-field = '2'.
else.
Traffic Lights Depends on value
i_output-field = '3'.
endif.
elseif v_nverme < i_output-kwmeng.
i_output-field = '1'.
elseif v_nverme = i_output-kwmeng.
i_output-field = '2'.
endif.
elseif i_output-pverme > i_output-kwmeng.
i_output-field = '3'.
elseif i_output-pverme = i_output-kwmeng.
i_output-field = '3'.
endif.
else.
Traffic Lights Depends on value
if i_output-pverme > i_output-kwmeng.
i_output-field = '3'.
elseif i_output-pverme < i_output-kwmeng.
i_output-field = '1'.
elseif i_output-pverme = i_output-kwmeng.
i_output-field = '2'.
endif.
endif.
move i_output-diff to v_diff.
flag = 'X'.
endat.</b>
if flag ne 'X'.
move : wa_final-matnr to i_output-matnr," Material #
wa_final-maktx to i_output-maktx," Desc
wa_final-lgpla to i_output-lgpla," Pick Bin
wa_final-kwmeng to i_output-kwmeng," Order qty
wa_final-zzshift to i_output-zzshift," Shift
wa_final-vrkme to i_output-vrkme," Sales Unit
wa_final-prverme to i_output-prverme. " Prod Bin Qty
Move Diffrence value
move v_diff to i_output-pverme.
clear: v_diff.
New logic for Only HMR Department
New logic for Only HMR Department
if p_check = 'X'.
if i_output-pverme < i_output-kwmeng.
v_nverme = i_output-pverme + i_output-prverme.
if v_nverme > i_output-kwmeng.
if i_output-pverme < i_output-kwmeng.
i_output-field = '2'.
else.
Traffic Lights Depends on value
i_output-field = '3'.
endif.
Traffic Lights Depends on value
i_output-field = '3'.
elseif v_nverme < i_output-kwmeng.
i_output-field = '1'.
elseif v_nverme = i_output-kwmeng.
i_output-field = '2'.
endif.
elseif i_output-pverme > i_output-kwmeng.
i_output-field = '3'.
elseif i_output-pverme = i_output-kwmeng.
i_output-field = '3'.
endif.
i_output-diff = i_output-pverme - i_output-kwmeng.
else.
Difference
i_output-diff = i_output-pverme - i_output-kwmeng.
Traffic Lights Depends on value
if i_output-pverme > i_output-kwmeng.
i_output-field = '3'.
elseif i_output-pverme < i_output-kwmeng.
i_output-field = '1'.
elseif i_output-pverme = i_output-kwmeng.
i_output-field = '2'.
endif.
endif.
endif.
append i_output.
clear : i_output,
wa_final,
i_final,
v_nverme.
endloop.
sort i_output by field zzshift matnr.
ENDFORM. " GET_DATA_VBAP
*& Form RESETVALUES
Reset the all fieldcatlogs
FORM RESETVALUES.
FIELDCAT_LN-KEY = SPACE.
FIELDCAT_LN-DO_SUM = SPACE.
FIELDCAT_LN-NO_OUT = SPACE.
FIELDCAT_LN-QFIELDNAME = SPACE.
FIELDCAT_LN-HOTSPOT = SPACE.
FIELDCAT_LN-OUTPUTLEN = '0'.
CLEAR: fieldcat_ln-seltext_l, fieldcat_ln-seltext_m,
fieldcat_ln-seltext_s, fieldcat_ln-reptext_ddic.
ENDFORM. " RESETVALUES
*& Form FILL_FIELDCATLOG
Fill the Fieldcatlog values
FORM FILL_FIELDCATLOG.
DATA: ls_fieldcat TYPE slis_fieldcat_alv.
Trafiic Light
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'FIELD'.
LS_FIELDCAT-TABNAME = 'I_OUTPUT'.
LS_FIELDCAT-OUTPUTLEN = 7.
LS_FIELDCAT-col_pos = '1'.
ls_fieldcat-seltext_L = 'Lights'.
ls_fieldcat-seltext_s = 'Lights'.
ls_fieldcat-seltext_m = 'Lights'.
APPEND LS_FIELDCAT TO FIELDCAT.
Wave Drop
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'ZZSHIFT'.
LS_FIELDCAT-TABNAME = 'I_OUTPUT'.
LS_FIELDCAT-OUTPUTLEN = 9.
LS_FIELDCAT-col_pos = '2'.
ls_fieldcat-seltext_L = 'Wave Drop'.
APPEND LS_FIELDCAT TO FIELDCAT.
Material
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'MATNR'.
LS_FIELDCAT-ref_fieldname = 'MATNR'.
LS_FIELDCAT-ref_tabname = 'MARA'.
LS_FIELDCAT-TABNAME = 'I_OUTPUT'.
LS_FIELDCAT-OUTPUTLEN = 18.
LS_FIELDCAT-col_pos = '3'.
ls_fieldcat-seltext_L = 'Material'.
APPEND LS_FIELDCAT TO FIELDCAT.
Description
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'MAKTX'.
LS_FIELDCAT-TABNAME = 'I_OUTPUT'.
LS_FIELDCAT-OUTPUTLEN = 40.
LS_FIELDCAT-col_pos = '4'.
ls_fieldcat-seltext_L = 'Description'.
APPEND LS_FIELDCAT TO FIELDCAT.
Pick Bin
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'LGPLA'.
LS_FIELDCAT-TABNAME = 'I_OUTPUT'.
LS_FIELDCAT-OUTPUTLEN = 15.
LS_FIELDCAT-col_pos = '5'.
ls_fieldcat-seltext_L = 'Pick Bin'.
APPEND LS_FIELDCAT TO FIELDCAT.
Trafiic Light
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'PVERME'.
LS_FIELDCAT-TABNAME = 'I_OUTPUT'.
LS_FIELDCAT-OUTPUTLEN = 16.
LS_FIELDCAT-col_pos = '6'.
ls_fieldcat-seltext_L = 'Stock at Pick Bin'.
APPEND LS_FIELDCAT TO FIELDCAT.
Stock at Prod Bin
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'PRVERME'.
LS_FIELDCAT-TABNAME = 'I_OUTPUT'.
LS_FIELDCAT-OUTPUTLEN = 16.
LS_FIELDCAT-col_pos = '7'.
ls_fieldcat-seltext_L = 'Stock at Prod Bin'.
APPEND LS_FIELDCAT TO FIELDCAT.
Req from wave drop
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'KWMENG'.
LS_FIELDCAT-TABNAME = 'I_OUTPUT'.
LS_FIELDCAT-OUTPUTLEN = 23.
LS_FIELDCAT-col_pos = '8'.
ls_fieldcat-seltext_L = 'Requirement from Wave Drop'.
APPEND LS_FIELDCAT TO FIELDCAT.
Sales Unit
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'VRKME'.
LS_FIELDCAT-TABNAME = 'I_OUTPUT'.
LS_FIELDCAT-OUTPUTLEN = 12.
LS_FIELDCAT-col_pos = '9'.
ls_fieldcat-seltext_L = 'Sales Unit'.
APPEND LS_FIELDCAT TO FIELDCAT.
Unit of Measure
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'MEINS'.
LS_FIELDCAT-TABNAME = 'I_OUTPUT'.
LS_FIELDCAT-OUTPUTLEN = 9.
LS_FIELDCAT-col_pos = '10'.
ls_fieldcat-seltext_L = 'UNIT'.
ls_fieldcat-no_out = 'X'.
APPEND LS_FIELDCAT TO FIELDCAT.
Diffference
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'DIFF'.
LS_FIELDCAT-TABNAME = 'I_OUTPUT'.
LS_FIELDCAT-OUTPUTLEN = 12.
LS_FIELDCAT-col_pos = '11'.
ls_fieldcat-seltext_L = 'Difference'.
APPEND LS_FIELDCAT TO FIELDCAT.
ENDFORM. " FILL_FIELDCATLOG
*& Form CALL_lIST
Use ALV Function module to display output
FORM CALL_lIST.
Top - of - Page
PERFORM COMMENT_BUILD USING GT_LIST_TOP_OF_PAGE[].
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = V_REPID
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = g_user_command
I_CALLBACK_TOP_OF_PAGE = C_TOP_OF_PAGE
I_CALLBACK_HTML_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_END_OF_LIST = ' '
I_STRUCTURE_NAME =
I_BACKGROUND_ID = ' '
I_GRID_TITLE =
I_GRID_SETTINGS =
IS_LAYOUT = LAYOUT
IT_FIELDCAT = FIELDCAT
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = ' '
IS_VARIANT =
IT_EVENTS =
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
IT_ALV_GRAPHICS =
IT_ADD_FIELDCAT =
IT_HYPERLINK =
I_HTML_HEIGHT_TOP =
I_HTML_HEIGHT_END =
IT_EXCEPT_QINFO =
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB = I_OUTPUT
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. " CALL_lIST
*& Form BUILD_LAYOUT
text
FORM BUILD_LAYOUT.
LAYOUT-GET_SELINFOS = 'X'.
Now we want a traffic light to say if the Truck is deleted
the variable p_lignam contains the name in IREPO which stores the
value for the traffic light
LAYOUT-LIGHTS_FIELDNAME = P_LIGNAM.
layout-HEADER_TEXT = 'Lights'.
LAYOUT-LIGHTS_CONDENSE = 'X'.
ENDFORM. " BUILD_LAYOUT
*& Form COMMENT_BUILD
text
-->P_GT_LIST_TOP_OF_PAGE[] text
FORM COMMENT_BUILD USING LT_TOP_OF_PAGE TYPE
SLIS_T_LISTHEADER.
data : v_day(2) type c,
v_mon(2) type c,
v_year(4) type c,
v_ldate(10) type c,
v_hdate(10) type c.
DATA: LS_LINE TYPE SLIS_LISTHEADER.
data: d_date like sy-datum.
clear : v_ldate,
v_hdate.
Header Information.
LIST HEADING LINE: TYPE H
CLEAR LS_LINE.
LS_LINE-TYP = 'H'.
LS_LINE-KEY: NOT USED FOR THIS TYPE
LS_LINE-INFO = 'Bin Replenishment report for HMR'.
APPEND LS_LINE TO LT_TOP_OF_PAGE.
STATUS LINE: TYPE S
CLEAR LS_LINE.
LS_LINE-TYP = 'S'.
LS_LINE-KEY = TEXT-003.
LS_LINE-INFO = TEXT-003.
APPEND LS_LINE TO LT_TOP_OF_PAGE.
STATUS LINE: TYPE S
CLEAR LS_LINE.
LS_LINE-TYP = 'S'.
LS_LINE-KEY = TEXT-003.
LS_LINE-INFO = TEXT-003.
APPEND LS_LINE TO LT_TOP_OF_PAGE.
Get the data ( s_date_low) into proper format.
v_year = s_date-low+0(4).
v_mon = s_date-low+4(2).
v_day = s_date-low+6(2).
concatenate v_mon '/' v_day '/' v_year into v_ldate.
clear : v_mon,
v_year,
v_day.
Get the data ( s_date_high) into proper format.
v_year = s_date-high+0(4).
v_mon = s_date-high+4(2).
v_day = s_date-high+6(2).
concatenate v_mon '/' v_day '/' v_year into v_hdate.
clear : v_mon,
v_year,
v_day.
Delivery date
if not s_date-low is initial .
if not s_date-high is initial.
CLEAR LS_LINE.
LS_LINE-TYP = 'S'.
LS_LINE-KEY = 'Delivery date From:'.
LS_LINE-INFO = v_ldate.
APPEND LS_LINE TO LT_TOP_OF_PAGE.
CLEAR LS_LINE.
LS_LINE-TYP = 'S'.
LS_LINE-KEY = 'Delivery date To :'.
LS_LINE-INFO = v_hdate.
APPEND LS_LINE TO LT_TOP_OF_PAGE.
endif.
endif.
if not s_date-low is initial.
if s_date-high is initial.
CLEAR LS_LINE.
LS_LINE-TYP = 'S'.
LS_LINE-KEY = 'Delivery date :'.
LS_LINE-INFO = v_ldate.
APPEND LS_LINE TO LT_TOP_OF_PAGE.
endif.
endif.
Wave Drop
if not S_SHIFT-LOW is initial.
if not S_SHIFT-high is initial.
CLEAR LS_LINE.
LS_LINE-TYP = 'S'.
LS_LINE-KEY = 'Wave Drop From :'.
LS_LINE-INFO = s_shift-low.
APPEND LS_LINE TO LT_TOP_OF_PAGE.
CLEAR LS_LINE.
LS_LINE-TYP = 'S'.
LS_LINE-KEY = 'Wave Drop to :'.
LS_LINE-INFO = s_shift-high.
APPEND LS_LINE TO LT_TOP_OF_PAGE.
endif.
endif.
if not S_SHIFT-LOW is initial.
if S_SHIFT-high is initial.
CLEAR LS_LINE.
LS_LINE-TYP = 'S'.
LS_LINE-KEY = 'Wave Drop :'.
LS_LINE-INFO = s_shift-low.
APPEND LS_LINE TO LT_TOP_OF_PAGE.
CLEAR LS_LINE.
LS_LINE-TYP = 'S'.
LS_LINE-KEY = 'Wave Drop to :'.
LS_LINE-INFO = s_shift-high.
APPEND LS_LINE TO LT_TOP_OF_PAGE.
endif.
endif.
Department
if not s_dept-low is initial .
if not s_dept-high is initial.
CLEAR LS_LINE.
LS_LINE-TYP = 'S'.
LS_LINE-KEY = 'Department From :'.
LS_LINE-INFO = s_dept-low.
APPEND LS_LINE TO LT_TOP_OF_PAGE.
CLEAR LS_LINE.
LS_LINE-TYP = 'S'.
LS_LINE-KEY = 'Department to :'.
LS_LINE-INFO = s_dept-high.
APPEND LS_LINE TO LT_TOP_OF_PAGE.
endif.
endif.
if not s_dept-low is initial .
if s_dept-high is initial.
CLEAR LS_LINE.
LS_LINE-TYP = 'S'.
LS_LINE-KEY = 'Department :'.
LS_LINE-INFO = s_dept-low.
APPEND LS_LINE TO LT_TOP_OF_PAGE.
endif.
endif.
Production Department
if not S_PDEPT-LOW is initial.
if not S_PDEPT-high is initial.
CLEAR LS_LINE.
LS_LINE-TYP = 'S'.
LS_LINE-KEY = 'Production Department From :'.
LS_LINE-INFO = S_PDEPT-LOW.
APPEND LS_LINE TO LT_TOP_OF_PAGE.
CLEAR LS_LINE.
LS_LINE-TYP = 'S'.
LS_LINE-KEY = 'Production Department to :'.
LS_LINE-INFO = S_PDEPT-high.
APPEND LS_LINE TO LT_TOP_OF_PAGE.
endif.
endif.
if not S_PDEPT-LOW is initial.
if S_PDEPT-high is initial.
CLEAR LS_LINE.
LS_LINE-TYP = 'S'.
LS_LINE-KEY = 'Production Department :'.
LS_LINE-INFO = S_PDEPT-LOW.
APPEND LS_LINE TO LT_TOP_OF_PAGE.
endif.
endif.
ENDFORM. " COMMENT_BUILD
FORM TOP_OF_PAGE *
FORM TOP_OF_PAGE.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = GT_LIST_TOP_OF_PAGE
I_LOGO =
I_END_OF_LIST_GRID =
ENDFORM.
FORM USER_COMMAND *
FORM user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield. "#EC CALLED
CASE R_UCOMM.
WHEN '&IC1'.
read table i_output index rs_selfield-tabindex.
SET PARAMETER ID 'MAT' FIELD i_output-matnr.
SET PARAMETER ID 'WRK' FIELD p_plant.
if not i_output-matnr is initial.
call transaction 'MD04' and skip first screen.
endif.
ENDCASE.
ENDFORM.
the above code i mentioned 1,2 ,3 values ,1 will have green color,2 will have yellow color,3 will have red color.
Thanks
Seshu -
Not allowing totaling of a field in alv output
hi,
I had made a ALV in which i have to hide 1 field for getting it totaling.
i.e. if somebody try to make total of it ,it should not be allowed on dat field . is dere any solution for this problem?
plzz provide me guidelines for it.Please please it this. I made the total for every field other than RACCT and SUM_COMM.
*& Form sub_prepare_display_output
Display output
--> No Parameter
FORM sub_prepare_display_output .
Local variables
DATA: l_lead_col TYPE char25, " Lead column
l_progname TYPE sy-repid, " Program name
Local internal tables
l_oref_layout TYPE REF TO cl_salv_layout, "Layout
Local work area
l_wa_key TYPE salv_s_layout_key, "Work area for key
l_except1 TYPE REF TO cx_salv_msg,"Exception
l_text1 TYPE string. "Exception msg
If profit center is checked
IF p_prfctr = c_check.
l_lead_col = 'Profit Center'(041).
If product catagory is checked
ELSEIF p_prodc = c_check.
l_lead_col = 'Product Category'(042).
If material is checked
ELSEIF p_smatnr = c_check.
l_lead_col = 'Material No.'(043).
ENDIF.
Create ALV instance with class-method cl_salv_table=>factory
TRY.
CALL METHOD cl_salv_table=>factory
EXPORTING
list_display = if_salv_c_bool_sap=>false
IMPORTING
r_salv_table = v_oref_table
CHANGING
t_table = i_final.
CATCH cx_salv_msg INTO l_except1.
l_text1 = l_except1->get_text( ).
MESSAGE i000 WITH l_text1.
LEAVE LIST-PROCESSING.
ENDTRY.
Make header of the report
PERFORM sub_header_report USING v_oref_table.
Get the toolbar
v_oref_functions = v_oref_table->get_functions( ).
For activating application toolbar
v_oref_functions->set_all( abap_true ).
v_oref_columns = v_oref_table->get_columns( ).
It populate the key fields which are always displayed
PERFORM sub_fill_fields_of_fcatalog USING:
'SUM_COMM' l_lead_col ' ',
'RACCT' 'Account Number'(035) ' ',
'FOBAC' 'FOB Acrual'(023) 'X',
'EXCESS' 'Excess'(024) 'X',
'OBSOLE' 'Obsolescence'(025) 'X',
'PPV' 'Puchachse Price Var'(026) 'X',
'FR_VAR' 'Freight Variance'(027) 'X',
'PROD_OR_VAR' 'Produc Ord Var'(028) 'X',
'DEP_VAR' 'Dept. Variance'(029) 'X',
'OTH_PROD_VAR' 'Other Prod Var'(030) 'X',
'PR_OR_SCRP_VAR' 'Scrap Variance'(031) 'X',
'COST_OF_ACC' 'Cost of Sales Accnt'(032) 'X',
'INV_ACC' 'Inventory Account'(033) 'X'.
Optimize the columns
v_oref_columns->set_optimize( value = 'X' ).
Setting the layout
get the LAYOUT object
l_oref_layout = v_oref_table->get_layout( ).
set the layout key
l_progname = sy-repid.
l_wa_key-report = l_progname.
l_oref_layout->set_key( value = l_wa_key ).
set save restriction:
none / only user-dependent / only user-independent
l_oref_layout->set_save_restriction(
value = if_salv_c_layout=>restrict_none ).
set: setting of default layout is allowed / isnu2019t allowed
l_oref_layout->set_default( value = 'X' ).
Dispaly the output
v_oref_table->display( ).
ENDFORM. " sub_prepare_display_output
*& Form sub_header_report
Create the header of the report
-->P_v_oref_TABLE table name
FORM sub_header_report USING p_v_oref_table TYPE REF TO
cl_salv_table .
DATA : l_oref_grid TYPE REF TO cl_salv_form_layout_grid.
CREATE OBJECT l_oref_grid.
Add text items for top of page
l_oref_grid->create_text( row = 1 column = 1 text = 'Program'(022)
l_oref_grid->create_text( row = 1 column = 2 text = sy-repid ).
l_oref_grid->create_text( row = 2 column = 1
text = 'User Name'(021) ).
l_oref_grid->create_text( row = 2 column = 2 text = sy-uname ).
l_oref_grid->create_text( row = 3 column = 1 text = 'Date'(020) ).
l_oref_grid->create_text( row = 3 column = 2 text = sy-datum ).
l_oref_grid->create_text( row = 3 column = 3 text = 'Time'(019) ).
l_oref_grid->create_text( row = 3 column = 4 text = sy-uzeit ).
l_oref_grid->create_text( row = 4 column = 1 text = 'System'(018) ).
l_oref_grid->create_text( row = 4 column = 2 text = sy-sysid ).
l_oref_grid->create_text( row = 4 column = 3 text = 'Client'(017) ).
l_oref_grid->create_text( row = 4 column = 4 text = sy-mandt ).
Declare grid as header of list
p_v_oref_table->set_top_of_list( value = l_oref_grid ).
ENDFORM. " sub_header_report
*& Form sub_fill_fields_of_fcatalog
This subroutine populates the field catalog excluding
period fields
-->P_FIELDNAME Table field name
-->P_NAME Field description
-->P_DEC Decimal value flag
FORM sub_fill_fields_of_fcatalog USING p_fieldname TYPE lvc_fname
p_name TYPE c
p_dec TYPE c.
DATA: l_char_l TYPE scrtext_l, "For short text
l_char_m TYPE scrtext_m, "For medium text
l_char_s TYPE scrtext_s, "For long text
l_except1 TYPE REF TO cx_salv_not_found,"Exception
l_text1 TYPE string, "Exception msg
l_orf_aggregs TYPE REF TO cl_salv_aggregations.
Getting the text long/short/medium into variables
l_char_l = p_name.
l_char_m = p_name.
l_char_s = p_name.
Setting the long/short/medium text and fix the key fileds
TRY.
CALL METHOD v_oref_columns->get_column
EXPORTING
columnname = p_fieldname
RECEIVING
value = v_oref_column1.
CATCH cx_salv_not_found INTO l_except1.
l_text1 = l_except1->get_text( ).
MESSAGE i000 WITH l_text1.
LEAVE LIST-PROCESSING.
ENDTRY.
v_oref_column ?= v_oref_column1.
v_oref_column->set_long_text( l_char_l ).
v_oref_column->set_medium_text( l_char_m ).
v_oref_column->set_short_text( l_char_s ).
v_oref_column->set_key( value = 'X' ).
v_oref_columns->set_key_fixation( value = 'X' ).
Set the decimal length
IF p_dec = 'X'.
v_oref_column->set_decimals( value = '2' ).
ENDIF.
IF p_fieldname = 'RACCT' AND p_gl <> c_check.
v_oref_column->set_visible( value = space ).
ENDIF.
IF p_gl = c_check.
v_oref_columns->set_column_position( columnname = 'RACCT'
position = 2 ).
ENDIF.
IF p_fieldname NE 'RACCT' AND p_fieldname NE 'SUM_COMM'.
l_orf_aggregs = v_oref_table->get_aggregations( ).
l_orf_aggregs->add_aggregation( columnname = p_fieldname
aggregation = if_salv_c_aggregation=>total ).
ENDIF.
ENDFORM. " sub_fill_fields_of_fcatalog -
Dynamic displaying of decimal points for currency field in ALV
Hi,
In ALV output there is a currency field and displaying data of different countries. It should display decimal point according to the country's currency. But at a time it can display data of different countries.Hi Dilip,
I think your question is about currencies with different number of digits after decimal point. If you have the currency field in the ALV row, you have to give it's name as currency reference for the value field in the field catalog.
After creating the field catalog, call a form and do something like this (change fielnames accordingly).
<pre>
*& Form alv_fieldcat_enhance
Individual Enrichment of field catalog
FORM alv_fieldcat_enhance
CHANGING pt_alv_fieldcat TYPE slis_t_fieldcat_alv.
FIELD-SYMBOLS:
<alv_fieldcat> TYPE slis_fieldcat_alv.
LOOP AT pt_alv_fieldcat ASSIGNING <alv_fieldcat>.
IF <alv_fieldcat>-fieldname(5) = 'KBETR' OR
<alv_fieldcat>-fieldname(5) = 'SKBTR' OR
<alv_fieldcat>-fieldname(5) = 'DMBTR'.
Company code currency
<alv_fieldcat>-cfieldname = 'BWAER'.
Document Currency for conditions, net value and taxes
ELSEIF <alv_fieldcat>-fieldname(5) = 'KWERT' OR
<alv_fieldcat>-fieldname = 'NETWR' OR
<alv_fieldcat>-fieldname = 'NPAX_MWST_AMNT'.
Document Currency
<alv_fieldcat>-cfieldname = 'WAERK'.
ENDIF." <alv_fieldcat>-fieldname(5) = 'KBETR' or
ENDLOOP." at pt_alv_fieldcat assigning <fieldcat_alv>.
ENDFORM. " alv_fieldcat_enhance
</pre>
Regards,
Clemens
Maybe you are looking for
-
Can i use swing components in applets and watch it in ie5 without installing any "running environments" ?
-
ACS 4.2 with patch 4 Services restart
I have installed ACS 4.2 with patch 4 Scertain period after authentication failed. Giving internal error. I need to restart all the services. What could be proble and pl help me in resolving this issue. I am running short of time.
-
Saved document to Word and reopened it in a strange text!
Does anyone know how to get a document a saved in word...which the next time I opened it came up as random shapes and such...back to normal?? I swear I have tried everything. I never saved it on to anything but the hard drive of the same specific com
-
Passing Variables from one View to another
First of all Hi this is my first post on the sap forums. Aplogies if I have come to the wrong place or if this question is very easy, but I am new to abap and web dynpro and have found myself struggling a little bit. So I stumbled across this site a
-
Any solutions to Apple's poor file copy function
For many years Apple's OS - all versions on all computers does not have the intelligence to copy files from drive to drive. Does anyone know of a different software program that can help the Apple OS do this simple task? A little more info - I have