Sorting issues in alv oops
Hi All,
Greetings for the Day!!!
am using alv oops for displaying output..
BEFORE sorting my internal table looks like below in the output.....
for example
A
B
C
D
E
F
AFTER sorting the internal table in the output .display.,, the internal table shows like below
F
E
D
C
B
A
but when i call the method set_table_for_first_display ,after sorting the in the output display ....,the internal table remains as like before
A
B
C
D
E
F....
it should be lke
F
E
D
C
B
A .....
kindly suggest me the alternatives.pls
Regards
Jack
For example....
DATA: lo_alv_grid TYPE REF TO cl_gui_alv_grid.
DATA: lo_form_alv_container TYPE REF TO cl_gui_custom_container.
* Create Controls
IF lo_form_alv_container IS INITIAL. "<-- Check if already created
CREATE OBJECT lo_form_alv_container
EXPORTING
container_name = 'FORMULA_CONTAINER'.
* Create control based ALV grid
CREATE OBJECT lo_alv_grid
EXPORTING
i_parent = lo_form_alv_container.
* set for first display
lo_alv_grid->set_table_for_first_display(
EXPORTING
is_layout = ls_layout
it_toolbar_excluding = lt_exclude
CHANGING
it_outtab = lt_formulas[]
it_fieldcatalog = lt_fieldcat[] ).
ELSE.
lo_alv_grid->refresh_table_display( ). "<-- If so, just refresh
ENDIF.
Regards,
Rich Heilman
Similar Messages
-
Hi,
I have included a ALV table in my application. A column in the table is containing a list of amounts. When i am trying to sort it in ascending or descending order, the values are not listed properly. I am using "PAD_AMT7S" as the data type for the attribute which will accept up to 2 decimals. The issue is,
if the column is containing values like
0.00,
8.75,
17.00,
8.50 and
17.50.
if i perform ascending type of sorting the values are re-arranged as,
0.00
17.00
17.50
8.50
8.75
and on descending
8.75
8.50
17.50
17.00
0.00
Which are all incorrect. Please provide me your suggestions..
Thanks,
MugundhanHi,
Are you using the IF_WD_TABLE_METHOD_HNDL for the sort, or you wrote your own code?
IF_WD_TABLE_METHOD_HNDL worked incorrectly for some special fields, in these cases I had to write the sorting code manually.
e.g.
CALL METHOD WDEVENT->GET_STRING
EXPORTING
NAME = 'COL'
RECEIVING
VALUE = lv_col_name.
CALL METHOD WDEVENT->GET_STRING
EXPORTING
NAME = 'DIRECTION'
RECEIVING
VALUE = lv_direction.
CASE lv_col_name.
WHEN 'TABLE_FIELD1'.
IF lv_direction EQ '00'.
SORT lt_table BY CURR ASCENDING.
ELSE.
SORT lt_table BY CURR DESCENDING .
ENDIF.
Is the table sorted incorrectly here?
Bye
N. -
Sorting issue in ALV ABAP webdynpro
Hi All,
We are displaying the data in ALV format using ABAP webdynpro.
The issue here is sorting the values. The field is the character field, as the field may contain character or numberic values.
When we sort a set of values in ascending order, the values are sorted wrongly.
Example values sorted in ascending order:
11055
11260
5662
8697
9984
The above values are sorted wrongly. Is this a standard limitation of webdynpro ABAP or do we have any support class or setting available to solve this issue.
Please help.
Regards,
VijayHello Vijay
of course its not a limitation, you can sort it either ways.
Check the following link
http://help.sap.com/saphelp_nw70/helpdata/en/e9/e5eb40c4f8712ae10000000a155106/content.htm
you can use the following classes
Set sort Direction -
CL_SALV_SORTS meth: ADD_SORT (Parameter SEQUENCE)
CL_SALV_SORT meth: SET_SEQUENCE
Get sort direction
CL_SALV_SORT meth: GET_SEQUENCE
hope this helps!!
Regards
Senon -
hi all,
i have requirement to d update , delete and insert a customized table through report .. i created the report and able to insert the record and delete , the fields displayed in the report output are order number, description and functional location in the report output . the order number is editable field .
my issue when we enter any order in new row i want to display the other fields automatically when we press enter key in keyboard..
Kindly let send the codeFirst of all you should have an event handler method for data changed event of cl_gui_alv_grid
then you will have to use cl_gui_alv_grid->check_changed_data( ) method for triggering the data changed event
register the event_enter of grid using
l_grid->register_edit_event(
EXPORTING
i_event_id = cl_gui_alv_grid=>mc_evt_entr ).
Inside the event handler method you have access er_data_changed .
then use
LOOP AT er_data_changed->mt_good_cells INTO l_good.
er_data_changed->get_cell_value(
EXPORTING
i_row_id = l_good-row_id
i_fieldname = 'ORDER'
IMPORTING
e_value = l_order ) .
if l_order is not initial.
select the other field values from l_order
then use
er_data_changed->modify_cell(
i_row_id = l_good-row_id
i_fieldname = 'DESCRIPTION'
i_value = l_description ).
endif. -
Editable and non editable issue in ALV OOPS
Hi All,
After giving the input in selection screen when i execute the report program will display the output in ALV OOOps.
Here i need few fields in Editable and some fields are non editbale mode. I can't use Edit ='X" in fieldcatalog.
I refered few threads in SDN at last i found the method cl_gui_alv_grid=>mc_style_enabled. using this method also i am not getting. PLz see below sample code.
gs_celltab-fieldname = 'Z_MESSAGEID'.
gs_celltab-style = cl_gui_alv_grid=>mc_style_enabled.
INSERT gs_celltab INTO TABLE gt_celltab.
gs_final-celltab = gt_celltab.
APPEND gs_final TO gt_final.
I am passing GT_FINAL to below mthiod.
CALL METHOD grid->set_table_for_first_display
EXPORTING
i_save = 'A'
i_default = 'X'
is_layout = gs_layout
is_variant = gs_variant
it_toolbar_excluding = gt_exclud
CHANGING
it_fieldcatalog = gt_fieldcat[]
it_outtab = gt_final[].
still inut all fields are in disply mode. Any body can suggest me how to approach.
Regards,
MaheedharHere is the sample code.
DATA :PT_CELLTAB Type LVC_T_STYL,
LS_CELLTAB TYPE LVC_S_STYL,
L_MODE type RAW4.
LS_CELLTAB-fieldname = 'KUNRG'.
LS_CELLTAB-style = cl_gui_alv_grid=>mc_style_disabled.
Insert LS_CELLTAB Into Table PT_CELLTAB.
LS_CELLTAB-fieldname = 'KUNNR_AG'.
LS_CELLTAB-style = cl_gui_alv_grid=>mc_style_enabled.
Insert LS_CELLTAB Into Table PT_CELLTAB.
Append X_OUTTAB to TB_OUTTAB.
*---Switch edit mode 0 for No-edit 1 for Edit
CALL METHOD g_grid->set_ready_for_input
EXPORTING
i_ready_for_input = 1.
its recommended to use the below events for editable mode to handle changed data
example
handle_data_changed
FOR EVENT data_changed OF cl_gui_alv_grid
IMPORTING e_onf4
e_onf4_before
e_onf4_after
er_data_changed,
Handle data Change Finished
handle_data_changed_finished
FOR EVENT data_changed_finished OF cl_gui_alv_grid
IMPORTING. ...
Edited by: Ashwin Kumar Chitram on Oct 3, 2011 8:06 PM -
Hi
Can you have 'selective sorting' in a single ALV OOPS grid?
like i want only some specific rows to be sorted based on a condition.
Any ideas?
Thanks
PushprajProblem Solved.
Thanks
Pushpraj -
Issue in ALV List display
Posted: Apr 5, 2008 10:25 AM Edit E-mail this message Reply
Hi Friends,
Can any one help me out in the logic to display the output in the ALV list.
i want to get the out put as
based on the field4 i have to display fieds5, field6 and field 7 values as mentioned below.
field1 field2 field3 field4 field5 field6 field7
0L 123 456 2008 001 123.00 456.00
- - - - 002 213.00 789.00
- - - 003 0.00 0.00
- - - 004 0.00 0.00
- - - 005 0.00 0.00
- - - 006 0.00 0.00
336.00 1245.00
Thanks,
Vijayfor display you have to define fieldcatlaog and use Fm RESUE_ALV_GRID_DISPLAY,
Go through this program
*& Report Z_OPEN_CLOSE *
REPORT Z_OPEN_CLOSE MESSAGE-ID YW2 LINE-SIZE 231 LINE-COUNT 45
NO STANDARD PAGE HEADING.
Type Declaration *
TYPE-POOLS SLIS.
Tables *
TABLES: MKPF, " Material Document: Header Data
MSEG, " Material Document: Item Data
MARA,
MARD,
S031,
EKKO,
EKPO,
LIKP,
MAKT,
J_1IWRKCUS,
T001W,
WB2_V_MKPF_MSEG2,
MMIM_REP_PRINT,
YW2_STKMOVEMENTS,
YPLNT,
MARDH.
Internal Tables *
DATA: I_WERKS LIKE J_1IWRKCUS OCCURS 0 WITH HEADER LINE.
DATA: BEGIN OF I_YPLNT OCCURS 0,
PPLNT LIKE YPLNT-PPLNT,
WPLNT LIKE YPLNT-WPLNT,
END OF I_YPLNT.
DATA: BEGIN OF I_MKPF OCCURS 0,
MBLNR LIKE MKPF-MBLNR,
MJAHR LIKE MKPF-MJAHR,
BUDAT LIKE MKPF-BUDAT,
VGART LIKE MKPF-VGART,
BWART LIKE MSEG-BWART,
MATNR LIKE MSEG-MATNR,
WERKS LIKE MSEG-WERKS,
LGORT LIKE MSEG-LGORT,
MENGE LIKE MSEG-MENGE,
MEINS LIKE MSEG-MEINS,
KUNNR LIKE MSEG-KUNNR,
ZEILE LIKE MSEG-ZEILE,
XAUTO LIKE MSEG-XAUTO,
SHKZG LIKE MSEG-SHKZG,
MATNR1 LIKE MSEG-MATNR,
END OF I_MKPF.
DATA: BEGIN OF I_MARDH OCCURS 0,
WERKS LIKE MARDH-WERKS,
MEINS LIKE MARA-MEINS,
MATNR LIKE MARDH-MATNR,
LGORT LIKE MARDH-LGORT,
LABST LIKE MARDH-LABST,
LFGJA LIKE MARDH-LFGJA, "Added -MB
LFMON LIKE MARDH-LFMON, "Added -MB
PERIO(6),
INSME LIKE MARDH-LABST,
EINME LIKE MARDH-LABST,
SPEME LIKE MARDH-LABST,
RETME LIKE MARDH-LABST,
O_STK LIKE MARDH-LABST, " Opening Stock
C_STK LIKE MARDH-LABST, " Closing Stock
END OF I_MARDH.
DATA: BEGIN OF I_MARD OCCURS 0,
WERKS LIKE MARD-WERKS,
MATNR LIKE MARD-MATNR,
LGORT LIKE MARD-LGORT,
LABST LIKE MARD-LABST,
INSME LIKE MARD-LABST,
MEINS LIKE MARA-MEINS,
EINME LIKE MARD-LABST,
SPEME LIKE MARD-LABST,
RETME LIKE MARD-LABST,
END OF I_MARD.
DATA: I_MARD1 LIKE I_MARD OCCURS 0 WITH HEADER LINE.
DATA: I_MARDH1 LIKE I_MARDH OCCURS 0 WITH HEADER LINE.
DATA: BEGIN OF I_MKPF1 OCCURS 0,
MBLNR LIKE MKPF-MBLNR,
WERKS LIKE MSEG-WERKS,
MATNR LIKE MSEG-MATNR,
BUDAT LIKE MKPF-BUDAT,
BWART LIKE MSEG-BWART,
MJAHR LIKE MKPF-MJAHR,
VGART LIKE MKPF-VGART,
LGORT LIKE MSEG-LGORT,
MENGE LIKE MSEG-MENGE,
MEINS LIKE MSEG-MEINS,
XAUTO LIKE MSEG-XAUTO,
SHKZG LIKE MSEG-SHKZG,
END OF I_MKPF1.
DATA: BEGIN OF I_MKPF2 OCCURS 0,
WERKS LIKE MSEG-WERKS,
MATNR LIKE MSEG-MATNR,
BUDAT LIKE MKPF-BUDAT,
BWART LIKE MSEG-BWART,
MJAHR LIKE MKPF-MJAHR,
VGART LIKE MKPF-VGART,
LGORT LIKE MSEG-LGORT,
MENGE LIKE MSEG-MENGE,
MEINS LIKE MSEG-MEINS,
XAUTO LIKE MSEG-XAUTO,
END OF I_MKPF2.
DATA: BEGIN OF I_FINAL5 OCCURS 0,
WERKS LIKE MSEG-WERKS, " Plant
MATNR LIKE MSEG-MATNR, " Material
LGORT LIKE MSEG-LGORT, " Storage Location
BUDAT LIKE MKPF-BUDAT, " Posting Date
MTART LIKE MARA-MTART, " Material Type
SPMON LIKE S031-SPMON, " Month
MAKTX LIKE MAKT-MAKTX, " Description
meins(3), " UOM
MEINS LIKE MSEG-MEINS,
O_STK LIKE MARDH-LABST, " opening stock
TRECEP LIKE MARDH-LABST, " total receipts
PRODU LIKE MARDH-LABST, " Net Receipts - Production
RECEP LIKE MARDH-LABST, " Net Receipts - Receipts
SAL_RET LIKE MARDH-LABST, " Net Receipts - Sales Return
TDISP LIKE MARDH-LABST, " total dispatches
CUSTMR LIKE MARDH-LABST, " Net Dispatches - Customers
OPLANT LIKE MARDH-LABST, " Net Dispatches - To Other Plant
TLOSS LIKE MARDH-LABST, " Total Loss
TRLOSS LIKE MARDH-LABST, " Transit Loss
WHLOSS LIKE MARDH-LABST, " Warehouse Loss
C_STK LIKE MARDH-LABST, " Closing Stock
TRFSTK LIKE MARDH-LABST, "Transfer stock
MENGE LIKE MSEG-MENGE,
OTHADJ LIKE MARDH-LABST,
END OF I_FINAL5.
DATA: BEGIN OF I_FINAL OCCURS 0,
WERKS LIKE MSEG-WERKS, " Plant
MATNR LIKE MSEG-MATNR, " Material
BUDAT LIKE MKPF-BUDAT, " Posting Date
MTART LIKE MARA-MTART, " Material Type
SPMON LIKE S031-SPMON, " Month
MAKTX LIKE MAKT-MAKTX, " Description
meins(3), " UOM
MEINS LIKE MSEG-MEINS,
O_STK LIKE MARDH-LABST, " opening stock
TRECEP LIKE MARDH-LABST, " total receipts
PRODU LIKE MARDH-LABST, " Net Receipts - Production
RECEP LIKE MARDH-LABST, " Net Receipts - Receipts
SAL_RET LIKE MARDH-LABST, " Net Receipts - Sales Return
TDISP LIKE MARDH-LABST, " total dispatches
CUSTMR LIKE MARDH-LABST, " Net Dispatches - Customers
OPLANT LIKE MARDH-LABST, " Net Dispatches - To Other Plant
TRFSTK LIKE MARDH-LABST, "Material Transfer stock
TRLOSS LIKE MARDH-LABST, " Transit Loss
WHLOSS LIKE MARDH-LABST, " Warehouse Loss
TLOSS LIKE MARDH-LABST, " Total Loss
C_STK LIKE MARDH-LABST, " Closing Stock
OTHADJ LIKE MARDH-LABST,
END OF I_FINAL.
DATA: I_FINAL1 LIKE I_FINAL OCCURS 0 WITH HEADER LINE.
DATA: BEGIN OF I_FINAL_TEMP OCCURS 0,
WERKS LIKE MSEG-WERKS, " Plant
MATNR LIKE MSEG-MATNR, " Material
MTART LIKE MARA-MTART, " Material Type
MAKTX LIKE MAKT-MAKTX, " Description
MEINS LIKE MSEG-MEINS,
O_STK LIKE MARDH-LABST, " opening stock
TRECEP LIKE MARDH-LABST, " total receipts
PRODU LIKE MARDH-LABST, " Net Receipts - Production
RECEP LIKE MARDH-LABST, " Net Receipts - Receipts
SAL_RET LIKE MARDH-LABST, " Net Receipts - Sales Return
TDISP LIKE MARDH-LABST, " total dispatches
CUSTMR LIKE MARDH-LABST, " Net Dispatches - Customers
OPLANT LIKE MARDH-LABST, " Net Dispatches - To Other Plant
TRFSTK LIKE MARDH-LABST, "Material Transfer stock
TRLOSS LIKE MARDH-LABST, " Transit Loss
WHLOSS LIKE MARDH-LABST, " Warehouse Loss
TLOSS LIKE MARDH-LABST, " Total Loss
C_STK LIKE MARDH-LABST, " Closing Stock
OTHADJ LIKE MARDH-LABST,
END OF I_FINAL_TEMP.
For Materials
DATA: BEGIN OF I_MARA OCCURS 0,
MATNR TYPE MARA-MATNR,
MTART TYPE MARA-MTART,
MEINS LIKE MARA-MEINS,
LABST TYPE MARD-LABST,
MAKTX LIKE MAKT-MAKTX,
END OF I_MARA.
DATA: BEGIN OF I_STKMVMNTS OCCURS 0,
BWART LIKE MSEG-BWART,
SHKZG LIKE MSEG-SHKZG,
VZBEW LIKE YW2_STKMOVEMENTS-VZBEW,
END OF I_STKMVMNTS.
DATA: BEGIN OF I_FINALT OCCURS 0,
WERKS LIKE MSEG-WERKS, " Plant
MATNR LIKE MSEG-MATNR, " Material
BUDAT LIKE MKPF-BUDAT, " Posting Date
MTART LIKE MARA-MTART, " Material Type
SPMON LIKE S031-SPMON, " Month
MAKTX LIKE MAKT-MAKTX, " Description
meins(3), " UOM
MEINS LIKE MSEG-MEINS,
O_STK LIKE MARDH-LABST, " opening stock
TRECEP LIKE MARDH-LABST, " total receipts
PRODU LIKE MARDH-LABST, " Net Receipts - Production
RECEP LIKE MARDH-LABST, " Net Receipts - Receipts
SAL_RET LIKE MARDH-LABST, " Net Receipts - Sales Return
TDISP LIKE MARDH-LABST, " total dispatches
CUSTMR LIKE MARDH-LABST, " Net Dispatches - Customers
OPLANT LIKE MARDH-LABST, " Net Dispatches - To Other Plant
TRFSTK LIKE MARDH-LABST, "Material Transfer stock
TRLOSS LIKE MARDH-LABST, " Transit Loss
WHLOSS LIKE MARDH-LABST, " Warehouse Loss
TLOSS LIKE MARDH-LABST, " Total Loss
C_STK LIKE MARDH-LABST, " Closing Stock
OTHADJ LIKE MARDH-LABST,
MONTH(8) ,
END OF I_FINALT.
DATA: IMKPFT LIKE I_MKPF OCCURS 0 WITH HEADER LINE.
DATA: IMKPFT1 LIKE I_MKPF1 OCCURS 0 WITH HEADER LINE.
DATA: IMARDT LIKE I_MARD OCCURS 0 WITH HEADER LINE.
DATA: IMARDHT LIKE I_MARDH OCCURS 0 WITH HEADER LINE.
DATA: T_FINAL LIKE I_MKPF OCCURS 0 WITH HEADER LINE.
DATA: IMKPFT2 LIKE I_MKPF OCCURS 0 WITH HEADER LINE.
FCAT is used for the field catalog
DATA: FCAT TYPE TABLE OF SLIS_FIELDCAT_ALV WITH NON-UNIQUE DEFAULT KEY
WITH HEADER LINE INITIAL SIZE 0,
for excluding the ICONs from the application toolbar
FEXC TYPE TABLE OF SLIS_EXTAB WITH NON-UNIQUE DEFAULT KEY
WITH HEADER LINE INITIAL SIZE 0,
FS_LAYO is used for Grid Layout
FS_LAYO TYPE SLIS_LAYOUT_ALV,
FEVENTS to handle the events TOP OF PAGE & USER_COMMAND
FEVENTS TYPE TABLE OF SLIS_ALV_EVENT WITH NON-UNIQUE DEFAULT KEY
WITH HEADER LINE INITIAL SIZE 0,
FHEADER is used for List header
FHEADER TYPE TABLE OF SLIS_LISTHEADER WITH NON-UNIQUE DEFAULT KEY
WITH HEADER LINE INITIAL SIZE 0,
sort is used for sorting
FSORT TYPE TABLE OF SLIS_SORTINFO_ALV WITH NON-UNIQUE DEFAULT KEY
WITH HEADER LINE INITIAL SIZE 0,
FCAT1 TYPE TABLE OF SLIS_FIELDCAT_ALV WITH NON-UNIQUE DEFAULT KEY
WITH HEADER LINE INITIAL SIZE 0,
FS_LAYO1 TYPE SLIS_LAYOUT_ALV,
GT_LIST_TOP_OF_PAGE1 TYPE SLIS_T_LISTHEADER,
FEVENTS1 TYPE TABLE OF SLIS_ALV_EVENT WITH NON-UNIQUE DEFAULT KEY
WITH HEADER LINE INITIAL SIZE 0,
FHEADER1 TYPE TABLE OF SLIS_LISTHEADER WITH NON-UNIQUE DEFAULT
KEY WITH HEADER LINE INITIAL SIZE 0,
G_STATU_071 TYPE SLIS_FORMNAME VALUE 'Z_PFSTATUS',
ALV_VARIANT1 LIKE DISVARIANT.
Variable Declaration *
TYPES: TRFF_TYPE_DEC_6_5(6) TYPE P DECIMALS 5.
DATA: FYEAR(4),
MON(2),
FYEAR1(4),
MON1(2),
OBAL LIKE MARD-LABST,
CBAL LIKE MARD-LABST,
INDEX TYPE I,
COUNT,
COUNT1 TYPE I,
O_STK TYPE P DECIMALS 3,
C_STK TYPE P DECIMALS 3,
V_MJAHR LIKE MKPF-MJAHR,
MONTHS TYPE TRFF_TYPE_DEC_6_5,
MONTH TYPE I.
Global variables for handling ALV functionality
DATA: ALV_KEYINFO TYPE SLIS_KEYINFO_ALV,
ALV_VARIANT LIKE DISVARIANT,
ALV_LAYOUT TYPE SLIS_LAYOUT_ALV,
ALV_REPID LIKE SY-REPID,
ALV_PRINT TYPE SLIS_PRINT_ALV,
ALV_DETAIL_FUNC(30),
ALV_DEFAULT_VARIANT LIKE DISVARIANT-VARIANT,
ALV_COLOURIZE_FIELDS LIKE MMIM_REP_PRINT-COLOR.
RANGES: R_BUDAT FOR MKPF-BUDAT.
*Added by Prabhu for year on 26.4.05.
DATA: IDATE LIKE R_BUDAT OCCURS 0 WITH HEADER LINE.
Selection Screen Elements *
SELECTION-SCREEN BEGIN OF BLOCK BLK WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS: S_WERKS FOR MARD-WERKS OBLIGATORY NO INTERVALS.
PARAMETER: P_SPMON LIKE S031-SPMON NO-DISPLAY .
SELECT-OPTIONS: S_MATNR FOR MARA-MATNR OBLIGATORY,
S_LGORT FOR MSEG-LGORT NO-EXTENSION NO INTERVALS,
S_MBLNR FOR MKPF-MBLNR,
S_BUDAT FOR MKPF-BUDAT OBLIGATORY .
SELECTION-SCREEN END OF BLOCK BLK.
SELECTION-SCREEN BEGIN OF BLOCK BLK3 WITH FRAME TITLE TEXT-004.
PARAMETER : MTART LIKE MARA-MTART DEFAULT 'FERT' NO-DISPLAY.
SELECTION-SCREEN END OF BLOCK BLK3.
SELECTION-SCREEN BEGIN OF BLOCK BLK2 WITH FRAME TITLE TEXT-003.
SELECTION-SCREEN END OF BLOCK BLK2.
ADDED BY PRABHU FOR DAY-WISE REPORT.
SELECTION-SCREEN BEGIN OF BLOCK B3 WITH FRAME TITLE TEXT-007.
PARAMETERS: D1 RADIOBUTTON GROUP P1 DEFAULT 'X',
M1 RADIOBUTTON GROUP P1,
Y1 RADIOBUTTON GROUP P1.
SELECTION-SCREEN END OF BLOCK B3.
SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME TITLE TEXT-006.
PARAMETERS: ALV_DEF LIKE DISVARIANT-VARIANT.
SELECTION-SCREEN END OF BLOCK B2.
DATA: S_BUDAT1 LIKE S_BUDAT OCCURS 0 WITH HEADER LINE."prabhu
Initialization *
INITIALIZATION.
PERFORM ALV_INIT.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR ALV_DEF.
PERFORM ALV_F4.
At Selection Screen
*AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_spmon.
PERFORM monat_f4.
At Selection Screen *
AT SELECTION-SCREEN.
checking for the layout
PERFORM ALV_CHECK.
authorisation check for the Plant
PERFORM auth_check.
Validation for the Plant
PERFORM VALIDITY_CHECK.
IF MTART NE 'FERT'.
MESSAGE E041 WITH 'Material Type must be FERT Only...'.
ENDIF.
IF D1 = 'X'." On 26.4.05.
P_SPMON0(4) = S_BUDAT-LOW0(4).
P_SPMON4(2) = S_BUDAT-LOW4(2).
ELSE.
P_SPMON0(4) = S_BUDAT-LOW0(4).
P_SPMON4(2) = S_BUDAT-LOW4(2).
ENDIF.
LOOP AT S_BUDAT.
IF S_BUDAT-HIGH IS INITIAL.
S_BUDAT-HIGH = S_BUDAT-LOW.
MODIFY S_BUDAT.
ENDIF.
ENDLOOP.
IDATE-LOW = S_BUDAT-LOW.
IDATE-HIGH = S_BUDAT-HIGH.
CALL FUNCTION 'FIMA_DAYS_AND_MONTHS_AND_YEARS'
EXPORTING
I_DATE_FROM = IDATE-LOW
I_DATE_TO = IDATE-HIGH
IMPORTING
E_DAYS =
E_MONTHS = MONTH
E_YEARS =
DATA: I(3) TYPE C.
I = S_BUDAT-LOW+4(2).
CLEAR: R_BUDAT.
REFRESH: R_BUDAT.
*added by Prabhu for Only for Oneday.on 18.5.5
IF MONTH EQ '0'.
MONTH = MONTH + 1.
ENDIF.
*added by Prabhu for Only for Oneday.on 18.5.5
DO MONTH TIMES.
R_BUDAT-LOW = S_BUDAT-LOW.
APPEND R_BUDAT.
ENDDO.
I = 0.
LOOP AT R_BUDAT.
R_BUDAT-LOW4(2) = S_BUDAT-LOW4(2) + I.
I = I + 1.
R_BUDAT-LOW+6(2) = '01'.
MODIFY R_BUDAT.
ENDLOOP.
LOOP AT R_BUDAT.
CALL FUNCTION 'RP_LAST_DAY_OF_MONTHS'
EXPORTING
DAY_IN = R_BUDAT-LOW
IMPORTING
LAST_DAY_OF_MONTH = R_BUDAT-HIGH
EXCEPTIONS
DAY_IN_NO_DATE = 1
OTHERS = 2
MODIFY R_BUDAT.
ENDLOOP.
LOOP AT R_BUDAT.
IF R_BUDAT-LOW4(2) = S_BUDAT-LOW4(2).
R_BUDAT-LOW = S_BUDAT-LOW.
MODIFY R_BUDAT.
ENDIF.
IF R_BUDAT-HIGH4(2) = S_BUDAT-HIGH4(2).
R_BUDAT-HIGH = S_BUDAT-HIGH.
MODIFY R_BUDAT.
ENDIF.
For Summary on 26.4.05.
IF Y1 = 'X'.
CLEAR R_BUDAT.
REFRESH R_BUDAT.
R_BUDAT-LOW = S_BUDAT-LOW.
R_BUDAT-HIGH = S_BUDAT-HIGH.
APPEND R_BUDAT.
CLEAR R_BUDAT.
ENDIF.
ENDLOOP.
At Selection Screen *
AT SELECTION-SCREEN OUTPUT.
Start of Selection *
START-OF-SELECTION.
V_MJAHR = P_SPMON+0(4).
Get plant distinction warehouse/production
PERFORM GET_PLANT_DISTINCTION.
Collect the data from various tables
PERFORM GETDATA_FG_STOCK.
here the number of rows in the output table is found
PERFORM OUTPUT_TABLE_CHECK.
here the top of the page code is written, that is to be displayed
in the output
PERFORM Z_TOP_OF_PAGE.
here ALV layout properties are set
PERFORM Z_LAYOUT_SETTINGS.
ALV EVENTS for TOP OF PAGE and for USER COMMAND
PERFORM Z_ALV_EVENTS.
The field catalog is defined for the Primary List is defined in
the subroutine CREATE_FIELD_CATALOG include program ZPRRDOCR_FCAT
PERFORM Z_CREATE_FIELD_CATALOG.
This is for displaying the output
PERFORM Z_REUSE_ALV_GRID_DISPLAY.
*& Form getdata_fg_stock
Getting data from standard tables
FORM GETDATA_FG_STOCK.
For getting the Start date & end date of the month
PERFORM get_month_dates.
Getting the Opening Stock from MARDH table
IF MON EQ '01'.
MON1 = MON.
FYEAR1 = FYEAR.
MON = '12'.
FYEAR = FYEAR - 1.
ELSE.
MON1 = MON.
FYEAR1 = FYEAR.
MON = MON - 1.
FYEAR = FYEAR.
ENDIF.
PERFORM GET_RECORDS_FROM_DB.
*added for Month Summary on 26.4.05.
LOOP AT R_BUDAT.
S_BUDAT-LOW = R_BUDAT-LOW.
S_BUDAT-HIGH = R_BUDAT-HIGH.
*for Month
P_SPMON0(4) = S_BUDAT-LOW0(4).
P_SPMON4(2) = S_BUDAT-LOW4(2).
*for summary.
IF Y1 = 'X'.
LOOP AT S_BUDAT.
S_BUDAT1-SIGN = 'I'.
S_BUDAT1-OPTION = 'NB'.
S_BUDAT1-LOW = S_BUDAT-LOW.
S_BUDAT1-HIGH = S_BUDAT-HIGH.
APPEND S_BUDAT1.
CLEAR S_BUDAT1.
ENDLOOP.
ENDIF.
IMKPFT[] = I_MKPF[].
IMKPFT2[] = I_MKPF[].
IMARDT[] = I_MARD[].
IMARDHT[] = I_MARDH[].
PERFORM MONTH_WISE.
PERFORM PROCESS_MOVEMENTS.
PERFORM CALCULATE_OPENING_STOCK.
PERFORM UPDATE_NON_TRANSACTION_ITMS.
PERFORM DELETE_EMPTY_RECORDS.
CLEAR: IMARDHT,IMARDT,IMKPFT1,IMKPFT,I_FINAL,I_FINAL5.
REFRESH: IMARDHT,IMARDT,IMKPFT1,I_FINAL,I_FINAL5,IMKPFT.
ENDLOOP.
CLEAR: R_BUDAT.
REFRESH: R_BUDAT.
*end of changes for month.
ENDFORM. " getdata_fg_stock
FORM MONAT_F4 *
F4-Hilfe für Monat *
FORM MONAT_F4.
DATA: BEGIN OF MF_DYNPFIELDS OCCURS 1.
INCLUDE STRUCTURE DYNPREAD.
DATA: END OF MF_DYNPFIELDS.
DATA: MF_RETURNCODE LIKE SY-SUBRC,
MF_MONAT LIKE ISELLIST-MONTH,
MF_HLP_REPID LIKE SY-REPID.
FIELD-SYMBOLS: .
Wert von Dynpro lesen
GET CURSOR FIELD MF_DYNPFIELDS-FIELDNAME.
APPEND MF_DYNPFIELDS.
MF_HLP_REPID = SY-REPID.
DO 2 TIMES.
CALL FUNCTION 'DYNP_VALUES_READ'
EXPORTING
DYNAME = MF_HLP_REPID
DYNUMB = SY-DYNNR
TABLES
DYNPFIELDS = MF_DYNPFIELDS
EXCEPTIONS
INVALID_ABAPWORKAREA = 01
INVALID_DYNPROFIELD = 02
INVALID_DYNPRONAME = 03
INVALID_DYNPRONUMMER = 04
INVALID_REQUEST = 05
NO_FIELDDESCRIPTION = 06
UNDEFIND_ERROR = 07.
IF SY-SUBRC = 3.
Aktuelles Dynpro ist Wertemengenbild
MF_HLP_REPID = 'SAPLALDB'.
ELSE.
READ TABLE MF_DYNPFIELDS INDEX 1.
Unterstriche durch Blanks ersetzen
TRANSLATE MF_DYNPFIELDS-FIELDVALUE USING '_ '.
EXIT.
ENDIF.
ENDDO.
IF SY-SUBRC = 0.
Konvertierung ins interne Format
CALL FUNCTION 'CONVERSION_EXIT_PERI_INPUT'
EXPORTING
INPUT = MF_DYNPFIELDS-FIELDVALUE
IMPORTING
OUTPUT = MF_MONAT
EXCEPTIONS
ERROR_MESSAGE = 1.
IF MF_MONAT IS INITIAL.
Monat ist initial => Vorschlagswert aus akt. Datum ableiten
MF_MONAT = SY-DATLO(6).
ENDIF.
CALL FUNCTION 'POPUP_TO_SELECT_MONTH'
EXPORTING
ACTUAL_MONTH = MF_MONAT
IMPORTING
SELECTED_MONTH = MF_MONAT
RETURN_CODE = MF_RETURNCODE
EXCEPTIONS
FACTORY_CALENDAR_NOT_FOUND = 01
HOLIDAY_CALENDAR_NOT_FOUND = 02
MONTH_NOT_FOUND = 03.
IF SY-SUBRC = 0 AND MF_RETURNCODE = 0.
ASSIGN (MF_DYNPFIELDS-FIELDNAME) TO <MF_FELD>. " ==>> note 148804
<MF_FELD> = MF_MONAT.
CALL FUNCTION 'CONVERSION_EXIT_PERI_OUTPUT'
EXPORTING
INPUT = MF_MONAT
IMPORTING
OUTPUT = MF_DYNPFIELDS-FIELDVALUE.
COLLECT MF_DYNPFIELDS.
CALL FUNCTION 'DYNP_VALUES_UPDATE'
EXPORTING
DYNAME = MF_HLP_REPID
DYNUMB = SY-DYNNR
TABLES
DYNPFIELDS = MF_DYNPFIELDS
EXCEPTIONS
INVALID_ABAPWORKAREA = 01
INVALID_DYNPROFIELD = 02
INVALID_DYNPRONAME = 03
INVALID_DYNPRONUMMER = 04
INVALID_REQUEST = 05
NO_FIELDDESCRIPTION = 06
UNDEFIND_ERROR = 07. "<<== note 148804
ENDIF.
ENDIF.
ENDFORM. "MONAT_F4
*& Form get_month_dates
Calculating the Month Start & End Date
FORM GET_MONTH_DATES.
IF M1 = 'X'.
FYEAR = P_SPMON+0(4).
MON = P_SPMON+4(2).
CONCATENATE FYEAR MON '01' INTO R_BUDAT-LOW.
R_BUDAT-SIGN = 'I'.
R_BUDAT-OPTION = 'BT'.
CALL FUNCTION 'BKK_GET_MONTH_LASTDAY'
EXPORTING
I_DATE = R_BUDAT-LOW
IMPORTING
E_DATE = R_BUDAT-HIGH.
APPEND R_BUDAT.
CLEAR S_BUDAT.
REFRESH S_BUDAT.
S_BUDAT-SIGN = 'I'.
S_BUDAT-OPTION = 'BT'.
S_BUDAT-LOW = R_BUDAT-LOW.
S_BUDAT-HIGH = R_BUDAT-HIGH.
APPEND S_BUDAT.
ELSE.
FYEAR = P_SPMON+0(4).
MON = P_SPMON+4(2).
CONCATENATE FYEAR MON '01' INTO R_BUDAT-LOW.
R_BUDAT-SIGN = 'I'.
R_BUDAT-OPTION = 'BT'.
CALL FUNCTION 'BKK_GET_MONTH_LASTDAY'
EXPORTING
I_DATE = R_BUDAT-LOW
IMPORTING
E_DATE = R_BUDAT-HIGH.
APPEND R_BUDAT.
ENDIF.
ENDFORM. " get_month_dates
*& Form output_table_Check
checking for records for output
FORM OUTPUT_TABLE_CHECK .
DESCRIBE TABLE I_FINALT LINES INDEX.
IF INDEX EQ 0.
MESSAGE I041 WITH TEXT-005.
LEAVE LIST-PROCESSING.
ENDIF.
ENDFORM. "OUTPUT_TABLE_CHECK
*& Form Z_TOP_OF_PAGE
for setting the details in the top of page *
has no formal paramters *
FORM Z_TOP_OF_PAGE.
DATA: V_MON(2),
V_YR(40),
V_FIN(18),
V_FIN1(48),
LOW(10),
HIGH(10).
V_MON = P_SPMON+4(2).
V_YR = P_SPMON+0(4).
FHEADER-TYP = 'H'.
FHEADER-INFO = 'Stock Register Report (FG Stock)'.
APPEND FHEADER.
CLEAR FHEADER.
*if m1 = 'X'.
CONCATENATE 'Month = ' v_mon '.' v_yr INTO v_fin.
fheader-typ = 'H'.
fheader-info = v_fin.
APPEND fheader.
CLEAR fheader.
*endif."prabhu on 18.5.5
IF D1 = 'X'.
CLEAR S_BUDAT.
LOOP AT S_BUDAT.
CONCATENATE S_BUDAT-LOW6(2) '/' S_BUDAT-LOW4(2) '/'
S_BUDAT-LOW+0(4) INTO LOW.
CONCATENATE S_BUDAT-HIGH6(2) '/' S_BUDAT-HIGH4(2) '/'
S_BUDAT-HIGH+0(4) INTO HIGH.
CONCATENATE 'Date = ' LOW ' - ' HIGH INTO V_FIN1.
FHEADER-TYP = 'H'.
FHEADER-INFO = V_FIN1.
APPEND FHEADER.
CLEAR FHEADER.
ENDLOOP.
ENDIF.
ENDFORM. " Z_TOP_OF_PAGE
*& Form Z_LAYOUT_SETTINGS
this is done for setting the properties for the layout of the *
grid *
has no formal paramters *
FORM Z_LAYOUT_SETTINGS.
FS_LAYO-ZEBRA = 'X'. " Output in Zebra pattern
FS_LAYO-DETAIL_POPUP = 'X'. " A popup window appears to give
FS_LAYO-DETAIL_TITLEBAR = TEXT-022.
FS_LAYO-COLWIDTH_OPTIMIZE = 'X'.
ENDFORM. " Z_LAYOUT_SETTINGS
*& Form Z_ALV_EVENTS
This is used for handling the events TOP OF PAGE and the USER *
COMMAND event *
has no formal paramters *
FORM Z_ALV_EVENTS.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 0
IMPORTING
ET_EVENTS = FEVENTS[].
READ TABLE FEVENTS WITH KEY NAME = 'TOP_OF_PAGE'.
IF SY-SUBRC = 0.
FEVENTS-FORM = 'Z_TOPOFPAGE'.
MODIFY FEVENTS INDEX SY-TABIX.
CLEAR FEVENTS.
ENDIF.
READ TABLE FEVENTS WITH KEY NAME = 'USER_COMMAND'.
IF SY-SUBRC = 0.
FEVENTS-FORM = 'Z_USER_COMMAND'.
MODIFY FEVENTS INDEX SY-TABIX.
CLEAR FEVENTS.
ENDIF.
ENDFORM. "Z_ALV_EVENTS
*& Form Z_CREATE_FIELD_CATALOG
here the field catalog is created for the primary list *
no formal parameters *
FORM Z_CREATE_FIELD_CATALOG.
for the Plant
FCAT-FIELDNAME = 'WERKS'.
FCAT-KEY = 'X'.
FCAT-OUTPUTLEN = '000005'.
FCAT-JUST = 'L'.
FCAT-SELTEXT_M = 'Plant'.
FCAT-DDICTXT = 'M'.
FCAT-INTTYPE = 'C'.
FCAT-DATATYPE = 'CHAR'.
APPEND FCAT.
CLEAR FCAT.
for the Material Type
FCAT-FIELDNAME = 'MTART'.
FCAT-KEY = 'X'.
FCAT-OUTPUTLEN = '000006'.
FCAT-JUST = 'L'.
FCAT-SELTEXT_M = 'MatTyp'.
FCAT-DDICTXT = 'M'.
FCAT-INTTYPE = 'C'.
FCAT-DATATYPE = 'CHAR'.
APPEND FCAT.
CLEAR FCAT.
for the Material No.
FCAT-FIELDNAME = 'MATNR'.
FCAT-KEY = 'X'.
fcat-hotspot = 'X'.
FCAT-OUTPUTLEN = '000018'.
FCAT-JUST = 'L'.
FCAT-SELTEXT_M = 'Material'.
FCAT-DDICTXT = 'M'.
FCAT-INTTYPE = 'C'.
FCAT-DATATYPE = 'CHAR'.
APPEND FCAT.
CLEAR FCAT.
for the Material Description
FCAT-FIELDNAME = 'MAKTX'.
FCAT-KEY = ''.
FCAT-OUTPUTLEN = '000040'.
FCAT-JUST = 'L'.
FCAT-SELTEXT_M = 'Description'.
FCAT-DDICTXT = 'M'.
FCAT-INTTYPE = 'C'.
FCAT-DATATYPE = 'CHAR'.
APPEND FCAT.
CLEAR FCAT.
for the Unit of Measure
FCAT-FIELDNAME = 'MEINS'.
FCAT-KEY = ''.
FCAT-OUTPUTLEN = '03'.
FCAT-JUST = 'C'.
FCAT-SELTEXT_M = 'UOM'.
FCAT-DDICTXT = 'M'.
FCAT-INTTYPE = 'C'.
FCAT-DATATYPE = 'UNIT'.
APPEND FCAT.
CLEAR FCAT.
for the Plant
FCAT-FIELDNAME = 'MONTH'.
FCAT-KEY = 'X'.
FCAT-OUTPUTLEN = '08'.
FCAT-JUST = 'L'.
FCAT-SELTEXT_M = 'MONTH'.
FCAT-DDICTXT = 'M'.
FCAT-INTTYPE = 'C'.
FCAT-DATATYPE = 'CHAR'.
APPEND FCAT.
CLEAR FCAT.
for the Opening Stock
FCAT-FIELDNAME = 'C_STK'.
FCAT-HOTSPOT = ' '.
FCAT-OUTPUTLEN = '000016'.
FCAT-JUST = 'L'.
FCAT-SELTEXT_M = 'Opening Stock'.
FCAT-DDICTXT = 'M'.
FCAT-INTTYPE = 'Q'.
FCAT-DATATYPE = 'QUAN'.
fcat-do_sum = 'X'.
FCAT-JUST = 'R'.
FCAT-NO_ZERO = 'X'.
APPEND FCAT.
CLEAR FCAT.
for the Total Receipts
FCAT-FIELDNAME = 'TRECEP'.
FCAT-HOTSPOT = ' '.
FCAT-OUTPUTLEN = '000016'.
FCAT-JUST = 'L'.
FCAT-SELTEXT_M = 'Total Receipts'.
FCAT-DDICTXT = 'M'.
FCAT-INTTYPE = 'Q'.
FCAT-DATATYPE = 'QUAN'.
FCAT-DO_SUM = 'X'.
FCAT-JUST = 'R'.
FCAT-NO_ZERO = 'X'.
APPEND FCAT.
CLEAR FCAT.
for the Production
FCAT-FIELDNAME = 'PRODU'.
FCAT-HOTSPOT = ' '.
FCAT-OUTPUTLEN = '000016'.
FCAT-JUST = 'L'.
FCAT-SELTEXT_M = 'Production'.
FCAT-DDICTXT = 'M'.
FCAT-INTTYPE = 'Q'.
FCAT-DATATYPE = 'QUAN'.
FCAT-DO_SUM = 'X'.
FCAT-JUST = 'R'.
FCAT-NO_ZERO = 'X'.
APPEND FCAT.
CLEAR FCAT.
for the Other Plant Receipts
FCAT-FIELDNAME = 'RECEP'.
FCAT-HOTSPOT = ' '.
FCAT-OUTPUTLEN = '000016'.
FCAT-JUST = 'L'.
FCAT-SELTEXT_M = 'Othr Plnt Recpts'.
FCAT-DDICTXT = 'M'.
FCAT-INTTYPE = 'Q'.
FCAT-DATATYPE = 'QUAN'.
FCAT-DO_SUM = 'X'.
FCAT-JUST = 'R'.
FCAT-NO_ZERO = 'X'.
APPEND FCAT.
CLEAR FCAT.
Sales Return
FCAT-FIELDNAME = 'SAL_RET'.
FCAT-HOTSPOT = ' '.
FCAT-OUTPUTLEN = '000016'.
FCAT-JUST = 'L'.
FCAT-SELTEXT_M = 'Sales Return'.
FCAT-DDICTXT = 'M'.
FCAT-INTTYPE = 'Q'.
FCAT-DATATYPE = 'QUAN'.
FCAT-DO_SUM = 'X'.
FCAT-JUST = 'R'.
FCAT-NO_ZERO = 'X'.
APPEND FCAT.
CLEAR FCAT.
Total Dispatches
FCAT-FIELDNAME = 'TDISP'.
FCAT-HOTSPOT = ' '.
FCAT-OUTPUTLEN = '000016'.
FCAT-JUST = 'L'.
FCAT-SELTEXT_M = 'Total Dispatches'.
FCAT-DDICTXT = 'M'.
FCAT-INTTYPE = 'Q'.
FCAT-DATATYPE = 'QUAN'.
FCAT-DO_SUM = 'X'.
FCAT-JUST = 'R'.
FCAT-NO_ZERO = 'X'.
APPEND FCAT. -
How does the SORT function in ALV grid work?
Hi,
I have a report for which the o/p is displayed in ALV grid format.There is one column in the O/p strcuture which is "No of days".Based on certain conditions,i need to display the value for some of the days as Negative e.g. " - 45".Becasuse of this,I have declared the field for the "No of days" of the type "CHAR".
Now when i sort(using ALV grid SORT function) the list on basis of this column,it doesnt give me the correct o/p.
CAN anyone tell me how do i handle this?I want the list to be sorted correctly on basis of the "No of days" column.
Thanks!This is your Fourth Cross Posting in last three days on same issue!!
CHAR type column doesnt work for SORT function in ALV grid!
How to sort a column of type CHAR
I dont,ve link for your Fourth Thread on same,though i'm short memory loss. -
Hi Friends,
I just want to convert a normal alv grid report to ALV OOPS report using classes,methods and objects, can you please help me on it.
*I have sent a sample ALV grid report program.
REPORT YSDB_ALV_ECC NO STANDARD PAGE HEADING LINE-SIZE 260 LINE-COUNT 58.
TABLES:
VBRK,
VBRP.
TYPE-POOLS: SLIS.
TYPES:
BEGIN OF Y_VBRK_STRUCT ,
VBELN TYPE VBRK-VBELN,
FKART TYPE VBRK-FKART,
FKDAT TYPE VBRK-FKDAT,
BUKRS TYPE VBRK-BUKRS,
NETWR TYPE VBRK-NETWR,
END OF Y_VBRK_STRUCT.
TYPES:
BEGIN OF Y_VBRP_STRUCT,
VBELN TYPE VBRP-VBELN,
POSNR TYPE VBRP-POSNR,
MATNR TYPE VBRP-MATNR,
FKIMG TYPE VBRP-FKIMG,
AUBEL TYPE VBRP-AUBEL,
KOSTL TYPE VBRP-KOSTL,
PS_PSP_PNR TYPE VBRP-PS_PSP_PNR,
ARKTX TYPE VBRP-ARKTX,
END OF Y_VBRP_STRUCT.
TYPES:
BEGIN OF Y_DISPLAY_STRUCT,
VBELN TYPE VBRK-VBELN,
FKART TYPE VBRK-FKART,
FKDAT TYPE VBRK-FKDAT,
BUKRS TYPE VBRK-BUKRS,
NETWR TYPE VBRK-NETWR,
POSNR TYPE VBRP-POSNR,
MATNR TYPE VBRP-MATNR,
FKIMG TYPE VBRP-FKIMG,
AUBEL TYPE VBRP-AUBEL,
KOSTL TYPE VBRP-KOSTL,
PS_PSP_PNR TYPE VBRP-PS_PSP_PNR,
ARKTX TYPE VBRP-ARKTX,
END OF Y_DISPLAY_STRUCT .
DATA: W_INDEX LIKE SY-TABIX.
DATA: W_FIELDCATALOG TYPE SLIS_FIELDCAT_ALV.
DATA: T_FIELDCATALOG1 TYPE SLIS_T_FIELDCAT_ALV.
DATA: W_REPID TYPE SY-REPID.
DATA: T_VBRK_ITAB TYPE STANDARD TABLE OF Y_VBRK_STRUCT .
DATA: T_VBRP_ITAB TYPE STANDARD TABLE OF Y_VBRP_STRUCT .
DATA: T_DISPLAY_ITAB TYPE STANDARD TABLE OF Y_DISPLAY_STRUCT.
DATA: E_DISPLAY TYPE Y_DISPLAY_STRUCT.
SELECT-OPTIONS S_VBELN FOR VBRK-VBELN.
SELECT-OPTIONS S_BUKRS FOR VBRK-BUKRS.
SELECT-OPTIONS S_FKDAT FOR VBRK-FKDAT.
START-OF-SELECTION.
PERFORM F_GET_DATA1.
PERFORM F_PROCESS_DATA.
PERFORM F_FIELDCATLOG.
PERFORM F_DISPLAY_DATA.
PERFORM F_CLEAR_FIELDS.
*& Form get_data1
text
FORM F_GET_DATA1 .
SELECT VBELN FKART FKDAT BUKRS NETWR
FROM VBRK
INTO TABLE T_VBRK_ITAB
WHERE BUKRS IN S_BUKRS
AND FKDAT IN S_FKDAT
AND VBELN IN S_VBELN.
IF SY-SUBRC NE 0.
FREE: T_VBRK_ITAB.
ENDIF.
IF NOT T_VBRK_ITAB IS INITIAL.
SELECT VBELN POSNR MATNR FKIMG AUBEL
KOSTL PS_PSP_PNR ARKTX
FROM VBRP
INTO TABLE T_VBRP_ITAB
FOR ALL ENTRIES IN T_VBRK_ITAB
WHERE VBELN EQ T_VBRK_ITAB-VBELN.
IF SY-SUBRC NE 0.
FREE: T_VBRK_ITAB.
ENDIF.
ENDIF.
ENDFORM. " GET_DATA1
text
--> p1 text
<-- p2 text
FORM F_PROCESS_DATA .
SORT T_VBRK_ITAB BY VBELN.
SORT T_VBRP_ITAB BY VBELN.
CLEAR: W_INDEX.
UNASSIGN <FS_STRUCT1>.
UNASSIGN <FS_STRUCT2>.
LOOP AT T_VBRK_ITAB ASSIGNING <FS_STRUCT1>.
READ TABLE T_VBRP_ITAB ASSIGNING <FS_STRUCT2> WITH KEY VBELN = <FS_STRUCT1>-VBELN BINARY SEARCH.
IF SY-SUBRC EQ 0.
MOVE SY-TABIX TO W_INDEX.
WHILE SY-SUBRC IS INITIAL AND <FS_STRUCT1>-VBELN = <FS_STRUCT2>-VBELN.
*Header Items Moving
MOVE:
<FS_STRUCT1>-FKART TO E_DISPLAY-FKART,
<FS_STRUCT1>-FKDAT TO E_DISPLAY-FKDAT,
<FS_STRUCT1>-BUKRS TO E_DISPLAY-BUKRS,
<FS_STRUCT1>-NETWR TO E_DISPLAY-NETWR.
*Line items Moving
MOVE: <FS_STRUCT2>-VBELN TO E_DISPLAY-VBELN,
<FS_STRUCT2>-POSNR TO E_DISPLAY-POSNR,
<FS_STRUCT2>-MATNR TO E_DISPLAY-MATNR,
<FS_STRUCT2>-FKIMG TO E_DISPLAY-FKIMG,
<FS_STRUCT2>-AUBEL TO E_DISPLAY-AUBEL,
<FS_STRUCT2>-KOSTL TO E_DISPLAY-KOSTL,
<FS_STRUCT2>-PS_PSP_PNR TO E_DISPLAY-PS_PSP_PNR,
<FS_STRUCT2>-ARKTX TO E_DISPLAY-ARKTX.
APPEND E_DISPLAY TO T_DISPLAY_ITAB.
CLEAR E_DISPLAY.
ADD 1 TO W_INDEX.
READ TABLE T_VBRP_ITAB ASSIGNING <FS_STRUCT2> INDEX W_INDEX.
IF SY-SUBRC NE 0.
EXIT.
ENDIF.
ENDWHILE.
ENDIF.
ENDLOOP.
ENDFORM. " GET_DATA3
*& Form Fieldcatlog
text
--> p1 text
<-- p2 text
FORM F_FIELDCATLOG .
W_FIELDCATALOG-FIELDNAME = TEXT-001.
W_FIELDCATALOG-SELTEXT_L = TEXT-002.
MOVE : 1 TO W_FIELDCATALOG-COL_POS,
20 TO W_FIELDCATALOG-OUTPUTLEN.
APPEND W_FIELDCATALOG TO T_FIELDCATALOG1.
CLEAR W_FIELDCATALOG.
W_FIELDCATALOG-FIELDNAME = TEXT-003.
W_FIELDCATALOG-SELTEXT_L = TEXT-004.
MOVE : 2 TO W_FIELDCATALOG-COL_POS,
20 TO W_FIELDCATALOG-OUTPUTLEN.
APPEND W_FIELDCATALOG TO T_FIELDCATALOG1.
CLEAR W_FIELDCATALOG.
W_FIELDCATALOG-FIELDNAME = TEXT-005.
W_FIELDCATALOG-SELTEXT_L = TEXT-006.
MOVE : 3 TO W_FIELDCATALOG-COL_POS,
20 TO W_FIELDCATALOG-OUTPUTLEN.
APPEND W_FIELDCATALOG TO T_FIELDCATALOG1.
CLEAR W_FIELDCATALOG.
W_FIELDCATALOG-FIELDNAME = TEXT-007.
W_FIELDCATALOG-SELTEXT_L = TEXT-008.
MOVE : 4 TO W_FIELDCATALOG-COL_POS,
20 TO W_FIELDCATALOG-OUTPUTLEN.
APPEND W_FIELDCATALOG TO T_FIELDCATALOG1.
CLEAR W_FIELDCATALOG.
W_FIELDCATALOG-FIELDNAME = TEXT-009.
W_FIELDCATALOG-SELTEXT_L = TEXT-010.
MOVE : 5 TO W_FIELDCATALOG-COL_POS,
20 TO W_FIELDCATALOG-OUTPUTLEN.
APPEND W_FIELDCATALOG TO T_FIELDCATALOG1.
CLEAR W_FIELDCATALOG.
W_FIELDCATALOG-FIELDNAME = TEXT-011.
W_FIELDCATALOG-SELTEXT_L = TEXT-012.
MOVE : 6 TO W_FIELDCATALOG-COL_POS,
20 TO W_FIELDCATALOG-OUTPUTLEN.
APPEND W_FIELDCATALOG TO T_FIELDCATALOG1.
CLEAR W_FIELDCATALOG.
W_FIELDCATALOG-FIELDNAME = TEXT-013.
W_FIELDCATALOG-SELTEXT_L = TEXT-014.
MOVE : 7 TO W_FIELDCATALOG-COL_POS,
20 TO W_FIELDCATALOG-OUTPUTLEN.
APPEND W_FIELDCATALOG TO T_FIELDCATALOG1.
CLEAR W_FIELDCATALOG.
W_FIELDCATALOG-FIELDNAME = TEXT-015.
W_FIELDCATALOG-SELTEXT_L = TEXT-016.
MOVE : 8 TO W_FIELDCATALOG-COL_POS,
20 TO W_FIELDCATALOG-OUTPUTLEN.
APPEND W_FIELDCATALOG TO T_FIELDCATALOG1.
CLEAR W_FIELDCATALOG.
W_FIELDCATALOG-FIELDNAME = TEXT-017.
W_FIELDCATALOG-SELTEXT_L = TEXT-018.
MOVE : 9 TO W_FIELDCATALOG-COL_POS,
20 TO W_FIELDCATALOG-OUTPUTLEN.
APPEND W_FIELDCATALOG TO T_FIELDCATALOG1.
CLEAR W_FIELDCATALOG.
ENDFORM. " Fieldcatlog
*& Form DISPLAY_DATA
text
--> p1 text
<-- p2 text
FORM F_DISPLAY_DATA .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = W_REPID
I_CALLBACK_TOP_OF_PAGE = 'AAAAAAAAADDAADA' "TEXT-021
I_GRID_TITLE = TEXT-020
IT_FIELDCAT = T_FIELDCATALOG1
TABLES
T_OUTTAB = T_DISPLAY_ITAB.
IF SY-SUBRC NE 0.
EXIT.
ENDIF.
CLEAR: W_REPID.
CLEAR: T_FIELDCATALOG1.
ENDFORM. " DISPLAY_DATA
*& Form F_Clear_fields
text
--> p1 text
<-- p2 text
FORM F_CLEAR_FIELDS .
FREE: T_VBRK_ITAB.
FREE: T_VBRP_ITAB.
FREE: T_DISPLAY_ITAB.
CLEAR: W_FIELDCATALOG.
ENDFORM. " F_Clear_fields
Regards
DineshIn ALV oops,
1. You need screen on which you must create a custom container. - screen 100
2. In PBO of 100, create module for displaying ALV
MODULE DISPLAY_ALV OUTPUT
PERFORM CREATE_CONTAINER "IN WHICH YOU USE THE CREATE OBJECT METHOD OF CL_GUI_CUSTOM_CONTAINER
PERFORM CREATE_ALV "IN WHICH YOU USE CREATE_OBJECT METHOD OF CL_GUI_ALV_GRID.
PERFORM PREPARE_FIELDCAT "creating fcat using LVC_S_FCAT structure
PERFORM DISPLAY "here you use the SET_TABLE_FOR_FIRST_DISPLAY method of CL_GUI_ALV_GRID class,
where you provide the internal table name and fieldcat internal table
ENDMODULE -
Dear All,
I have an issue in ALV reporting. Pls look at the follow table.
<u>Duty Post</u> <u>Date</u> <u>Time</u>
jurong 12/06 3.45
jurong 13/06 3.50
jurong 14/06 4.50
In the above table jurong is repeated. I do not want jurong to be repeated but other fields should be present.
Kindly help me solve it.
Regards,
Karthikeyan
<u></u><u></u>Hi Karthik,
Another way of handling this without doing if else comparision is using the SORT functionality.
I am giving an example here:
Sort data in the output based on Duty_Post
CLEAR itab_sort.
itab_sort-fieldname = 'DUTY_POST' . (Replace DUTY_POST with the actual field name used in ur report)
itab_sort-up = c_x.
APPEND itab_sort.
CLEAR itab_sort.
Then while calling the ALV FM: include the ITAB_SORT table also.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = w_call_back_pgm
i_grid_title = w_text
it_fieldcat = itab_fldcat
it_sort = itab_sort[]
is_layout = w_layout
it_events = itab_events[]
i_default = 'X'
i_save = 'A'
IMPORTING
e_exit_caused_by_caller = w_exit_by_caller
es_exit_caused_by_user = w_exit_by_user
TABLES
t_outtab = itab_output_gr
EXCEPTIONS
program_error = 1
OTHERS = 2.
This way data would not repeat.
Hope this helps.
Rgds,
HR -
Hi
Im using ALV OOPS.o/p I have 10 records with checkbox(at user command I have to select record selected by check box). Now on the menu bar I hav a button for "SELECT ALL". If "selected all" 10 recored will be selected. If I filter upon some criteria no. of records will be 3..Now in GUI if I select SELECT all it will display 3 records r selected, but I have to process further internally ,,,but internally 10 records are selected. So how to write code for that is after filterring 3 records r selected and I "select all"..only 3 records will be selected instead of 10?
Part of my code like this..
SELECT all
CALL METHOD G_GRID->CHECK_CHANGED_DATA
IMPORTING
E_VALID = L_VALID.
IF L_VALID EQ 'X'.
LOOP AT PT_OUTTAB INTO LS_OUTTAB.
DATA LS_CELLTAB TYPE LVC_S_STYL.
LOOP AT PS_OUTTAB-CELLTAB INTO LS_CELLTAB.
IF LS_CELLTAB-FIELDNAME = 'CHECKBOX'.
IF LS_CELLTAB-STYLE EQ CL_GUI_ALV_GRID=>MC_STYLE_DISABLED.
P_LOCKED = 'X'.
ELSE.
P_LOCKED = SPACE.
ENDIF.
ENDIF.
ENDLOOP.
IF L_LOCKED IS INITIAL
AND NOT LS_OUTTAB-CHECKBOX EQ '-'.
LS_OUTTAB-CHECKBOX = 'X'.
ENDIF.
MODIFY PT_OUTTAB FROM LS_OUTTAB.
ENDLOOP.
CALL METHOD G_GRID->REFRESH_TABLE_DISPLAY.
ENDIF.Hello Kaushik
Using method go_grid->GET_FILTERED_ENTRIES you get an index list of the filtered entries.
DATA: lt_filtered TYPE lvc_t_fidx,
ld_indx LIKE LINE OF lt_filtered.
CALL METHOD go_grid->GET_FILTERED_ENTRIES
IMPORTING
ET_FILTERED_ENTRIES = lt_filtered.
LOOP AT lt_filtered INTO ld_indx.
READ TABLE gt_outtab INTO ls_outtab INDEX ld_indx.
ENDLOOP.
Regards
Uwe -
Hi,
I have a issue in ALV Report for displaying one field's data into output.
I am getting data into all other fields in ALV Report except for this field.
This field & related fields are declared as below: in final internal table.
sta_no TYPE z3status,
status(10) TYPE c,
Here z3status is of type Char(1).
In Report
I have put a condition :
IF i_tab-sta_no EQ 1.
i_tab-status = 'Created'.
ELSE.
i_tab-status = 'Closed'.
ENDIF.
and to field catalog also i am passing right information as for every other field in ALV Report.
Till the point use of REUSE_ALV_LIST_DISPLAY F.M also final internal table is having status field filled.
But in output nothing gets displayed for Status field.
Can anybody tell me what can be the issue!
Thanks in advance.
Thanks,
Deep.Hi,
I have no problem in data fetching into final internal table.
Everything is coming well to REUSE_ALV_DISPLAY F.M.
But still Status field data is not getting displayed.
I have posted some code for reference:
LOOP AT t_z3manboxid INTO wa_z3manboxid.
wa_result-manifest_no = wa_z3manboxid-zmanno.
wa_result-item_no = wa_z3manboxid-item_no.
IF l_item_no NE wa_z3manboxid-item_no.
wa_result-piece_quantity = wa_z3manboxid-vemng.
wa_result-unit = wa_z3manboxid-vemeh.
wa_result-manifester = wa_z3manboxid-usnam.
wa_result-manifest_sta_no = wa_z3manboxid-z3status.
IF wa_result-manifest_sta_no EQ 1.
wa_result-manifest_status = c_created.
ELSEIF wa_result-manifest_sta_no EQ 2.
wa_result-manifest_status = c_in_transit.
ELSEIF wa_result-manifest_sta_no EQ 3.
wa_result-manifest_status = c_arrived.
ELSEIF wa_result-manifest_sta_no EQ 4.
wa_result-manifest_status = c_closed.
ENDIF.
ENDIF.
l_item_no = wa_z3manboxid-item_no.
APPEND wa_result TO t_result.
CLEAR: wa_result, wa_z3manboxid.
ENDLOOP.
Building field catalog following code is added:
For status call is as below:
PERFORM f_build_fieldcat USING c_tab
c_manifest_status
c_space
c_space
c_mannf_status
c_space1
15.
FORM f_build_fieldcat USING p_tabname p_fldname
p_rtabname p_rfldname
p_fldhdg p_check
p_length.
CLEAR t_fieldcat_ln1.
ADD 1 TO g_col_pos.
t_fieldcat_ln1-tabname = p_tabname.
t_fieldcat_ln1-fieldname = p_fldname.
t_fieldcat_ln1-ref_tabname = p_rtabname.
t_fieldcat_ln1-ref_fieldname = p_rfldname.
t_fieldcat_ln1-ddictxt = c_l.
t_fieldcat_ln1-seltext_l = p_fldhdg.
t_fieldcat_ln1-no_zero = space.
t_fieldcat_ln1-do_sum = space.
t_fieldcat_ln1-col_pos = g_col_pos.
t_fieldcat_ln1-no_out = space.
t_fieldcat_ln1-just = c_c.
t_fieldcat_ln1-qfieldname = space.
t_fieldcat_ln1-checkbox = p_check.
t_fieldcat_ln1-input = p_check.
t_fieldcat_ln1-reptext_ddic = p_fldhdg.
IF p_fldname EQ c_manno.
t_fieldcat_ln1-key = c_x.
t_fieldcat_ln1-hotspot = c_x.
ELSE.
t_fieldcat_ln1-key = space.
t_fieldcat_ln1-hotspot = p_check.
ENDIF.
t_fieldcat_ln1-outputlen = p_length.
t_fieldcat_ln1-intlen = p_length.
t_fieldcat_ln1-ddic_outputlen = p_length.
APPEND t_fieldcat_ln1 TO t_fieldcat1.
ENDFORM. " f_build_fieldcat
FORM f_build_sortcat USING p_fldname.
CLEAR t_sortcat_ln1.
ADD 1 TO g_col_pos.
t_sortcat_ln1-spos = g_col_pos.
t_sortcat_ln1-fieldname = p_fldname.
t_sortcat_ln1-up = c_x.
t_sortcat_ln1-down = space.
t_sortcat_ln1-subtot = c_x.
APPEND t_sortcat_ln1 TO t_sortcat1.
ENDFORM. " f_build_sortcat
FORM f_build_layout.
t_layout1-zebra = c_x.
t_layout1-no_vline = c_space1.
t_layout1-reprep = c_x.
t_layout1-detail_popup = c_x.
t_layout1-window_titlebar = text-005.
t_layout1-no_scrolling = c_space1.
t_layout1-detail_titlebar = text-005.
t_layout1-numc_sum = c_x.
t_layout1-get_selinfos = c_x.
t_layout1-min_linesize = 132.
ENDFORM. " f_build_layout
DATA: l_pgm TYPE syrepid,
l_exit(1) TYPE c.
CLEAR: l_pgm,
l_exit.
l_pgm = sy-repid.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_program = l_pgm
i_callback_user_command = c_user_command
is_layout = t_layout1
it_fieldcat = t_fieldcat1
i_save = c_a
it_events = t_eventcat1
IMPORTING
e_exit_caused_by_caller = l_exit
TABLES
t_outtab = t_result
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc NE 0.
l_exit = l_exit.
ENDIF.
To ALV F.M t_result table is updated with correct data.
But it is not getting displayed.
What can be the reason!
Can anybody give the solution!
Thanks for your replies.
Thanks,
Deep. -
Hi Experts,
Can i achieve sorting in Blocked ALV report as we can do in ALV Grid Display.???
If so, how can this be achieved????
For example, if there are 3 records with the same value for a field.....say thfreee rows with name 'Gaurav'.
I want to show 'Gaurav' only in the first row and the other two rows must be empty.
Gaurav 1 2 3
Gaurav 4 5 6
Gaurav 7 8 9
Should be seen as
Gaurav 1 2 3
4 5 6
7 8 9
Thanks and regards
Gaurav raghavHere is the code.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = sy-repid
i_structure_name = 'ZCRM_ACTIVITY_REPORT'
CHANGING
ct_fieldcat = gt_fieldcatalog[]
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
IF sy-subrc EQ 0.
CLEAR gs_sort.
gs_sort-fieldname = 'ORG'.
gs_sort-tabname = 'GT_ITAB'.
gs_sort-spos = '1'.
gs_sort-up = 'X'.
APPEND gs_sort TO gt_sort.
CLEAR gs_sort.
gs_sort-fieldname = 'EMPLOYEE'.
gs_sort-tabname = 'GT_ITAB'.
gs_sort-spos = '2'.
gs_sort-up = 'X'.
APPEND gs_sort TO gt_sort.
ENDIF.
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
EXPORTING
is_layout = gt_layout
it_fieldcat = gt_fieldcatalog
i_tabname = 'GT_ITAB'
it_events = gt_events
it_sort = gt_sort
i_text = 'Report 1 '
TABLES
t_outtab = gt_itab
EXCEPTIONS
program_error = 1
maximum_of_appends_reached = 2
OTHERS = 3.
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_DISPLAY'. -
To set HOTSPOT for a field in ALV-oops and when clecked should call transac
Hi,
I need to set HOTSPOT for a field in O/P list using ALV-oops and when clecked should take me to Transaction VA01. Please help....
Thanks,
PrabhuHi,
Please go through this code it may help u.
REPORT zcls_alv_oops MESSAGE-ID z1.
TABLES : mara.
Types Declaration..\
TYPES :
BEGIN OF t_mara,
matnr TYPE matnr,
mtart TYPE mtart,
maktx TYPE maktx,
END OF t_mara,
BEGIN OF t_marc,
matnr TYPE matnr,
werks TYPE werks_d,
mtart TYPE mtart,
maktx TYPE maktx,
END OF t_marc.
Internal Tables Declaration..\
DATA :
i_mara TYPE TABLE OF t_mara,
i_marc TYPE TABLE OF t_marc,
i_fcat1 TYPE lvc_t_fcat,
i_fcat2 TYPE lvc_t_fcat.
Constants Declaration..\
CONSTANTS :
c_cont1 TYPE scrfname VALUE 'CONT1',
c_cont2 TYPE scrfname VALUE 'CONT2'.
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME.
SELECT-OPTIONS:
s_matnr FOR mara-matnr NO INTERVALS.
SELECTION-SCREEN SKIP 1.
PARAMETERS :
p_hotspt RADIOBUTTON GROUP r1 DEFAULT 'X',
p_bttn RADIOBUTTON GROUP r1.
SELECTION-SCREEN END OF BLOCK b1.
\* Class forward referncing.
CLASS lcl_rcvr_class DEFINITION DEFERRED.
\* Pointers Declaration..
DATA :
lp_rcvr TYPE REF TO lcl_rcvr_class,
lp_cont1 TYPE REF TO cl_gui_custom_container,
lp_cont2 TYPE REF TO cl_gui_custom_container,
lp_grid1 TYPE REF TO cl_gui_alv_grid,
lp_grid2 TYPE REF TO cl_gui_alv_grid.
\* Local Class Definiton.
CLASS lcl_rcvr_class DEFINITION.
PUBLIC SECTION.
METHODS :
hotspot_click FOR EVENT hotspot_click OF cl_gui_alv_grid
IMPORTING e_row_id e_column_id es_row_no,
handle_double_click FOR EVENT double_click OF cl_gui_alv_grid
IMPORTING e_row e_column.
ENDCLASS.
\* Local Class Implementation.
CLASS lcl_rcvr_class IMPLEMENTATION.
METHOD hotspot_click.
DATA :
wa_mara TYPE t_mara,
wa_marc TYPE t_marc.
DATA :
l_index TYPE sy-tabix.
READ TABLE i_mara INTO wa_mara INDEX e_row_id-index.
IF sy-subrc EQ 0.
REFRESH i_marc.
SELECT matnr
werks
INTO TABLE i_marc
FROM marc
WHERE matnr EQ wa_mara-matnr.
IF sy-subrc EQ 0.
LOOP AT i_marc INTO wa_marc.
l_index = sy-tabix.
wa_marc-mtart = wa_mara-mtart.
wa_marc-maktx = wa_mara-maktx.
MODIFY i_marc FROM wa_marc INDEX l_index
TRANSPORTING mtart maktx.
ENDLOOP.
CALL SCREEN 200.
ELSE.
MESSAGE e121 WITH text-005 wa_mara-matnr.
ENDIF.
ENDIF.
ENDMETHOD.
METHOD handle_double_click.
DATA :
wa_mara TYPE t_mara,
wa_marc TYPE t_marc.
DATA :
l_index TYPE sy-tabix.
READ TABLE i_mara INTO wa_mara INDEX e_row-index.
IF sy-subrc EQ 0.
REFRESH i_marc.
SELECT matnr
werks
INTO TABLE i_marc
FROM marc
WHERE matnr EQ wa_mara-matnr.
IF sy-subrc EQ 0.
LOOP AT i_marc INTO wa_marc.
l_index = sy-tabix.
wa_marc-mtart = wa_mara-mtart.
wa_marc-maktx = wa_mara-maktx.
MODIFY i_marc FROM wa_marc INDEX l_index
TRANSPORTING mtart maktx.
ENDLOOP.
CALL SCREEN 200.
ELSE.
MESSAGE e121 WITH text-005 wa_mara-matnr.
ENDIF.
ENDIF.
ENDMETHOD.
ENDCLASS.
\* Start of Selection
START-OF-SELECTION.
\* Extract the Material Master data for the Input Material.
SELECT a~matnr
a~mtart
b~maktx
INTO TABLE i_mara
FROM mara AS a
INNER JOIN makt AS b
ON a~matnr EQ b~matnr
WHERE a~matnr IN s_matnr
AND b~spras EQ sy-langu.
END-OF-SELECTION.
IF NOT i_mara\[\] IS INITIAL.
\* Call Screen to display the Material Master data.
CALL SCREEN 100.
ELSE.
MESSAGE s121 WITH text-006.
ENDIF.
\*& Module DISP_GRID OUTPUT
\* text
MODULE disp_grid OUTPUT.
\* Build the Field catelog for Material Master data.
PERFORM build_fcat.
\* Display the Material Master data using ALV.
PERFORM disp_alv.
ENDMODULE. " DISP_GRID OUTPUT
\*& Module USER_COMMAND_0100 INPUT
\* text
MODULE user_command_0100 INPUT.
\*when exit or cancel is clicked program has to come out
CASE sy-ucomm.
WHEN 'EXIT' OR 'CANC'.
LEAVE PROGRAM.
WHEN 'BACK'.
LEAVE TO SCREEN 0.
ENDCASE.
ENDMODULE. " USER_COMMAND_0100 INPUT
\*& Form build_fcat
\* text
\* \--> p1 text
\* <-\- p2 text
FORM build_fcat.
DATA : ws_fcat TYPE lvc_s_fcat.
ws_fcat-fieldname = 'MATNR'.
ws_fcat-scrtext_m = text-001.
ws_fcat-tabname = 'I_MARA'.
IF p_hotspt EQ 'X'.
ws_fcat-hotspot = 'X'.
ENDIF.
APPEND ws_fcat TO i_fcat1.
CLEAR ws_fcat.
ws_fcat-fieldname = 'MTART'.
ws_fcat-scrtext_m = text-002.
ws_fcat-tabname = 'I_MARA'.
APPEND ws_fcat TO i_fcat1.
CLEAR ws_fcat.
ws_fcat-fieldname = 'MAKTX'.
ws_fcat-scrtext_m = text-003.
ws_fcat-tabname = 'I_MARA'.
APPEND ws_fcat TO i_fcat1.
CLEAR ws_fcat.
ENDFORM. " build_fcat
\*& Form disp_alv
\* text
\* \--> p1 text
\* <-\- p2 text
FORM disp_alv.
IF lp_cont1 IS INITIAL.
\* Create the Container Object of Material Master.
CREATE OBJECT lp_cont1
EXPORTING
container_name = c_cont1
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5
others = 6 .
IF sy-subrc NE 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSE.
\* Create the Object for Grid of Material Master.
CREATE OBJECT lp_grid1
EXPORTING
i_parent = lp_cont1
EXCEPTIONS
error_cntl_create = 1
error_cntl_init = 2
error_cntl_link = 3
error_dp_create = 4
others = 5.
IF sy-subrc NE 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSE.
\* Dipslay Material Master data by calling method.
CALL METHOD lp_grid1->set_table_for_first_display
CHANGING
it_outtab = i_mara
it_fieldcatalog = i_fcat1
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4.
IF sy-subrc NE 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSE.
\* Set Handler for the Hot Spot Event.
CREATE OBJECT lp_rcvr.
IF p_hotspt EQ 'X'.
SET HANDLER lp_rcvr->hotspot_click FOR lp_grid1.
ELSE.
SET HANDLER lp_rcvr->handle_double_click FOR lp_grid1.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDFORM. " disp_alv
\*& Module STATUS_0100 OUTPUT
\* text
MODULE status_0100 OUTPUT.
SET PF-STATUS 'MAIN_STAT'.
SET TITLEBAR 'T_100'.
ENDMODULE. " STATUS_0100 OUTPUT
\*& Module STATUS_0200 OUTPUT
\* text
MODULE status_0200 OUTPUT.
SET PF-STATUS 'PLANT_STAT'.
SET TITLEBAR 'T_200'.
ENDMODULE. " STATUS_0200 OUTPUT
\*& Module DISP_GRID_plant OUTPUT
\* text
MODULE disp_grid_plant OUTPUT.
\* Build the Field catelog for Material Plant data.
PERFORM build_fcat_plant.
\* Display the Material Master Plant data using ALV.
PERFORM disp_alv_plant.
ENDMODULE. " DISP_GRID_plant OUTPUT
\*& Module USER_COMMAND_0200 INPUT
\* text
MODULE user_command_0200 INPUT.
\*when exit or cancel is clicked program has to come out
CASE sy-ucomm.
WHEN 'EXIT' OR 'CANC'.
LEAVE PROGRAM.
WHEN 'BACK'.
LEAVE TO SCREEN 0.
ENDCASE.
ENDMODULE. " USER_COMMAND_0200 INPUT
\*& Form build_fcat_plant
\* text
\* \--> p1 text
\* <-\- p2 text
FORM build_fcat_plant.
DATA : ws_fcat TYPE lvc_s_fcat.
ws_fcat-fieldname = 'MATNR'.
ws_fcat-scrtext_m = text-001.
ws_fcat-tabname = 'I_MARC'.
APPEND ws_fcat TO i_fcat2.
CLEAR ws_fcat.
ws_fcat-fieldname = 'WERKS'.
ws_fcat-scrtext_m = text-004.
ws_fcat-tabname = 'I_MARC'.
APPEND ws_fcat TO i_fcat2.
CLEAR ws_fcat.
ws_fcat-fieldname = 'MTART'.
ws_fcat-scrtext_m = text-002.
ws_fcat-tabname = 'I_MARC'.
APPEND ws_fcat TO i_fcat2.
CLEAR ws_fcat.
ws_fcat-fieldname = 'MAKTX'.
ws_fcat-scrtext_m = text-003.
ws_fcat-tabname = 'I_MARC'.
APPEND ws_fcat TO i_fcat2.
CLEAR ws_fcat.
ENDFORM. " build_fcat_plant
\*& Form disp_alv_plant
\* text
\* \--> p1 text
\* <-\- p2 text
FORM disp_alv_plant.
IF lp_cont2 IS INITIAL.
\* Create the Container Object of Material Plant data.
CREATE OBJECT lp_cont2
EXPORTING
container_name = c_cont2
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5
others = 6.
IF sy-subrc NE 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSE.
\* Create the Object for Grid of Material Plant data.
CREATE OBJECT lp_grid2
EXPORTING
i_parent = lp_cont2
EXCEPTIONS
error_cntl_create = 1
error_cntl_init = 2
error_cntl_link = 3
error_dp_create = 4
others = 5.
IF sy-subrc NE 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSE.
\* Dipslay Material Plant data by calling method.
CALL METHOD lp_grid2->set_table_for_first_display
CHANGING
it_outtab = i_marc
it_fieldcatalog = i_fcat2
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4.
IF sy-subrc NE 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDIF.
ENDIF.
ELSE.
\* Call method 'REFRESH_TABLE_DISPLAY' to refresh the grid data.
CALL METHOD lp_grid2->refresh_table_display.
ENDIF.
ENDFORM. " disp_alv_plant -
Problem while placing a button in the Output using ALV OOPs
Hi,
I am using ALV OOPs to display report output.
In the toolbar i have to palce an update button and if i click on that update it should then call the selection screen 500 .
So,please help me to achieve this using ALV OOPs.
THANKS & REGARDS,
Kiranmai.Hi,
you can use set pf-status statement with the OOPs' concept where in you will have to give this in the events table and pass it to the method to display the alv ...
Regards,
Siddarth
Maybe you are looking for
-
Mac Book Pro i7 - Logging off on its own, night time, power down sleep
Hi Everyone, I have had my Macbook pro for around 4 months now. And I have had this problem from the beginning. At night, often when I leave my machine, with software open and things active. I come back in the morning to find my mac logged off and at
-
Carry out repairs in non-original....
I am trying to update a few programs that are z programs but I get the follow message each time I go into edit mode: 'Carry out repairs in non-original systems only if they are urgent'. Is there a way for me to get rid of this message? I can't figur
-
Configure 64 Bit System for Flash
Newer 64 Bit Systems are becoming the norm - How can Adobe not not make flashplayer compatible? Are there instructions for configuring for a 32 Bit browser on a 64 bit system? This is so frustrating and renders newer computers useless for lots of app
-
Hello plz suggest Table for batch detail for sale & purchase in SAP 8.81 pl 07
-
HT2693 probles with ipad2 after iOS 7.02 Upgrade, any idea how to fix this?
I am able to connect to any Wi-FI network, however, my iPad after connecting doesnt have access to the internet, i have tried other devices in teh same network and they work fine. is there a new update that fixes this issue?