Drill down in ALV
Hi all
In the ALV report output if i click on any field in a row, i should able to generate drill-down report, can any body suggest me a solution.
Regards
Srini
You need to handle Double Click on At user command event. '&IC1' is the okcode for Double click. Please handle this in your program. I have given you links earlier to see events in ALV report. They are also using Function modules.
Here is a sample code -
1.) Declare user_command in events:
DATA: ls_event type slis_alv_event.
move 'USER_COMMAND' to ls_event-form.
append ls_event to gt_events.
2.) Getting cell value ." within the form USER_COMMAND:
FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
RS_SELFIELD TYPE SLIS_SELFIELD.
Check function code
CASE R_UCOMM.
WHEN '&IC1'. "--> check your own sy-ucomm once you double click the line item
Check field clicked on within ALVgrid report
IF RS_SELFIELD-FIELDNAME = 'EBELN'.
Read data table, using index of row user clicked on
READ TABLE IT_EKKO INTO WA_EKKO INDEX RS_SELFIELD-TABINDEX.
ENDIF.
ENDCASE.
ENDFORM.
ashish
Similar Messages
-
Problem displaying drill down STANDARD ALV for a particular record after pressing back button
I have a simple interactive ALV grid report. NOT 'OO'. It display correctly on initial execution. AT the moment, 6 records. I want it to work such that if i click record '1', a drill-down version of that ALV with only that one record clicked is displayed. This currently occurs correctly. The problem arises when i click the back button and want to click on a new record, say in the 2nd row..this new 2nd row record is not displayed. The first one is displayed again. I tried clearing and fiddling around but then the last record is displayed. I have used the 'ID' field as a 'hotspot' getting picked up by sy-tabindex. Maybe it could be that i shouldn't loop and use a work area e.g in my select statement. i'm not so sure i've looked around, and tried a few things. I can't get it right yet. My code is below:
*& Report ZALV
REPORT ZALV.
TABLES: ZCONTACT.
TYPE-POOLS: slis. "slis contains all of the ALV data types.
TYPES: BEGIN OF ty_zcontact.
INCLUDE STRUCTURE zcontact.
TYPES: icon TYPE char4, "field holding traffic light value- adding a column to internal table to hold the traffic light
END OF ty_zcontact.
DATA: "fieldcatALOG TYPE slis_t_fieldcat_alv WITH HEADER LINE,
it_zcontact TYPE TABLE OF ty_zcontact,"declares an internal table of type ZCONTACT
wa_zcontact TYPE ty_zcontact,
gd_layout TYPE slis_layout_alv,
gd_repid LIKE sy-repid,
g_variant TYPE disvariant,
gx_variant TYPE disvariant,
g_save TYPE c VALUE 'X',
it_fieldcat TYPE slis_t_fieldcat_alv,"declares field catalog table of line type alv
wa_fieldcat TYPE slis_fieldcat_alv, "declares the work area of the field catalog
it_list_top_of_page TYPE slis_t_listheader.
DATA: it_fieldcat1 TYPE slis_t_fieldcat_alv,
wa_fieldcat1 TYPE slis_fieldcat_alv.
DATA: V_FIELD(30) TYPE C,
V_VALUE(10) TYPE C.
"izontact TYPE TABLE OF zcontact.
"i_logo TYPE OT.
"ls_layout TYPE slis_layout_alv.
**Selection Screen details
*SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME.
*PARAMETERS: variant like disvariant-variant.
*SELECTION-SCREEN END OF BLOCK B1.
SELECT-OPTIONS:
age FOR wa_zcontact-age,
lastnme FOR wa_zcontact-lastname.
**Getting default variant
* AT SELECTION-SCREEN ON age.
* SELECT SINGLE age FROM zcontact INTO wa_zcontact-age WHERE age = age.
* IF sy-subrc NE 0.
* MESSAGE:'That age does not exist mate, Please enter another age' TYPE 'E'.
* ENDIF.
INITIALIZATION.
*gx_variant-report = sy-repid.
*CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'
*EXPORTING
* I_SAVE = G_SAVE
* CHANGING
* CS_VARIANT = GX_VARIANT
* EXCEPTIONS
* NOT_FOUND = 2.
*IF SY-SUBRC = 0.
* VARIANT = GX_VARIANT-VARIANT.
* ENDIF.
START-OF-SELECTION.
PERFORM DATA_RETRIEVAL.
PERFORM BUILD_FIELDCATALOG.
PERFORM DISPLAY_ALV_REPORT.
PERFORM top_of_page.
"g_repid = sy-repid.
*Fetch data from the database
FORM DATA_RETRIEVAL.
SELECT * FROM zcontact INTO TABLE it_zcontact WHERE age IN age AND lastname IN lastnme.
"assigning traffic light colour to each row based on a condition
* IF wa_zcontact-age GE 65.
* wa_zcontact-icon = 1. "Red Traffic Light
* ELSEIF wa_zcontact-age BETWEEN 40 AND 64.
* wa_zcontact-icon = 2. "Yellow traffic light
* ELSE.
* wa_zcontact-icon = 3." Green traffic light
* ENDIF.
* MODIFY it_zcontact FROM wa_zcontact TRANSPORTING icon.
* CLEAR wa_zcontact.
ENDFORM.
FORM BUILD_FIELDCATALOG.
*Build field catalog
wa_fieldcat-fieldname = 'ID'.
"wa_fieldcat-seltext_m = 'The Contact ID'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'LASTNAME'.
"wa_fieldcat-seltext_m = 'Contact Lastname'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'FIRSTNAME'.
"wa_fieldcat-seltext_m = 'Contact Firstname'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'DOB'.
"wa_fieldcat-seltext_m = 'Date Of Birth'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'TEL'.
"wa_fieldcat-seltext_m = 'Telephone Number'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'ADDRESS'.
"wa_fieldcat-seltext_m = 'The Address'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'OCCUPATION'.
"wa_fieldcat-seltext_m = 'The Occupation'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'WEIGHT'.
"wa_fieldcat-seltext_m = 'WEIGHT'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'AGE'.
"wa_fieldcat-seltext_m = 'AGE OF THE CONTACT'.
wa_fieldcat-do_sum = 'X'. "Display column total
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'SALARY'.
"wa_fieldcat-seltext_m = 'SALARY'.
wa_fieldcat-do_sum = 'X'.
APPEND wa_fieldcat TO it_fieldcat.
gd_layout-lights_fieldname = 'ICON'.
ENDFORM.
FORM DISPLAY_ALV_REPORT.
gd_repid = sy-repid.
*Pass data and field catalog to ALV function module to display ALV list
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
it_fieldcat = it_fieldcat
i_callback_program = gd_repid
i_callback_top_of_page = 'TOP_OF_PAGE'
i_callback_user_command = 'USER_COMMAND'
i_structure_name = 'ZCONTACT'
i_save = 'X'
is_variant = g_variant
is_layout = gd_layout
TABLES
t_outtab = it_zcontact
EXCEPTIONS
program_error = 1
OTHERS = 2.
ENDFORM.
FORM top_of_page.
*ALV Header declarations
DATA: it_listheader TYPE slis_t_listheader,
wa_listheader TYPE slis_listheader,
t_line like wa_listheader-info,
ld_lines TYPE I,
ld_linesc(10) TYPE C.
wa_listheader-typ = 'H'.
wa_listheader-info = 'Contact Details'.
APPEND wa_listheader TO it_listheader.
CLEAR wa_listheader.
wa_listheader-typ = 'S'.
wa_listheader-info = sy-repid.
wa_listheader-key = 'Program Name:'.
APPEND wa_listheader TO it_listheader.
CLEAR wa_listheader.
wa_listheader-typ = 'S'.
wa_listheader-info = sy-uname.
wa_listheader-key = 'User Name:'.
APPEND wa_listheader TO it_listheader.
CLEAR wa_listheader.
wa_listheader-typ = 'S'.
wa_listheader-key = 'Run Date :'.
CONCATENATE sy-datum+6(2)
sy-datum+4(2)
sy-datum(4)
INTO wa_listheader-info
SEPARATED BY '/'.
APPEND wa_listheader TO it_listheader.
CLEAR wa_listheader.
wa_listheader-typ = 'S'.
wa_listheader-key = 'Time :'.
CONCATENATE sy-uzeit(2)
sy-uzeit+2(2)
sy-uzeit+4(2)
INTO wa_listheader-info
SEPARATED BY ':'.
APPEND wa_listheader TO it_listheader.
CLEAR wa_listheader.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = it_listheader
i_logo = 'KLOGO'.
ENDFORM. "top_of_page
*& Form sub_user_command
FORM USER_COMMAND USING P_UCOMM TYPE SY-UCOMM
P_SELTAB TYPE SLIS_SELFIELD.
CASE P_UCOMM.
WHEN '&IC1'.
CASE p_seltab-fieldname.
WHEN 'ID'.
READ TABLE it_zcontact INTO wa_zcontact INDEX p_seltab-tabindex.
PERFORM DATA_RETRIEVAL1.
PERFORM BUILD_FIELDCATALOG1.
PERFORM SECOND_GRID.
ENDCASE.
ENDCASE.
ENDFORM. "
FORM DATA_RETRIEVAL1.
SELECT * FROM zcontact INTO TABLE it_zcontact WHERE id EQ wa_zcontact-id.
ENDFORM.
FORM BUILD_FIELDCATALOG1.
*Build field catalog
CLEAR: wa_fieldcat, it_fieldcat.
wa_fieldcat-fieldname = 'ID'.
"wa_fieldcat-seltext_m = 'The Contact ID'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'LASTNAME'.
"wa_fieldcat-seltext_m = 'Contact Lastname'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'FIRSTNAME'.
"wa_fieldcat-seltext_m = 'Contact Firstname'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
ENDFORM.
FORM SECOND_GRID.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
IT_FIELDCAT = IT_FIELDCAT
i_structure_name = 'ZCONTACT'
i_callback_user_command = 'USER_COMMAND'
TABLES
T_OUTTAB = IT_ZCONTACT.
ENDFORM.Hi Ten Mariga,
I wonder why the second select Query is needed at all instead you can use
---> Not Needed
FORM DATA_RETRIEVAL1.
SELECT * FROM zcontact INTO TABLE it_zcontact WHERE id EQ wa_zcontact-id.
ENDFORM.
----> Instead you can do
READ TABLE it_zcontact INTO wa_zcontact INDEX p_seltab-tabindex.
Append wa_zcontact to Second_table.
And you can use the Second_table to display the second ALV. The second Select Query will affect the performance too.
Cheers,
Krishnakumar B. -
Hi,
I am trying to show 'me22n' ( PO details) by drilling down on ebeln in my alv report. but for some reason this is NOT happening. can somebody pls help.
the alv is been shown properly the it does not drill down on po number "ebeln".
Please find the enclosed code.
Thanks & Regards
Hrishi
REPORT Z_VENDOR_BACKORDER_REPORT_ALV line-size 400.
TABLES: EKKO, LFA1, MAKT, EKET, EKPO, AFPO, MARC.
*Data Declaration
DATA: BEGIN OF ITAB OCCURS 0 ,
ebeln LIKE ekko-ebeln , " PO number
aedat LIKE ekko-aedat , " creation date
ebelp LIKE ekpo-ebelp , " item no
lifnr LIKE ekko-lifnr , " vendor number
name1 LIKE lfa1-name1 , " vendor name
RESWK LIKE EKKO-RESWK , " PLANT NO
MEMORY LIKE EKKO-MEMORY , " ORDER INCOMPLETE
matnr LIKE ekpo-matnr , " material number
werks like ekpo-werks , " plant
txz01 LIKE ekpo-txz01 , " material description
eindt LIKE eket-eindt , " Promised date
menge LIKE eket-menge , " quantity
wemng LIKE eket-wemng , " delivered quantity
netpr like ekpo-netpr , " value in AUD
peinh like ekpo-peinh , " price unit
banfn like ekpo-banfn , " PR no
aufnr like ebkn-aufnr , " Production order no
MAABC LIKE MARC-MAABC , " MATERIAL ABC Indicator
maktx like makt-maktx , " material long description
open_quant type p decimals 2, " quantity - delivered
VALUE TYPE p decimals 2, " $ VALUE * OPEN QUANTITY
end of ITAB.
data: wa like itab.
DATA: bdcdata LIKE bdcdata OCCURS 0 WITH HEADER LINE.
DATA: TEMP TYPE EKKO-LIFNR.
data: opt like CTU_PARAMS.
*DATA: WA TYPE FINAL.
all ALV declarations
type-pools: slis. "ALV Declarations
DATA: fieldcatalog TYPE slis_t_fieldcat_alv with header line,
G_REPID TYPE SY-REPID,
GS_PRINT TYPE SLIS_PRINT_ALV,
GT_LIST_TOP_OF_PAGE TYPE SLIS_T_LISTHEADER,
GT_EVENTS TYPE SLIS_T_EVENT,
GT_SORT TYPE SLIS_T_SORTINFO_ALV,
GS_LAYOUT TYPE SLIS_LAYOUT_ALV,
COL_POS TYPE I.
-----------------SELECTION SCREEN----------------------
selection-screen begin of block b1 with frame title text-001.
select-options VENDORNO for ekko-lifnr.
select-options MATERIAL for ekpo-matnr.
SELECT-OPTIONS PLANT FOR EKKO-RESWK.
select-options REQDAT for eket-eindt.
selection-screen end of block b1.
*................... GET DATA..................
SELECT EKKO~EBELN
EKKO~AEDAT
EKKO~LIFNR
EKKO~MEMORY
EKKO~RESWK
EKPO~EBELP
EKPO~MATNR
ekpo~werks
ekpo~netpr
ekpo~peinh
ekpo~banfn
ekpo~txz01
makt~maktx
EKET~EINDT
EKET~MENGE
EKET~WEMNG
LFA1~NAME1
INTO corresponding fields of ITAB
FROM (
EKKO inner JOIN EKPO
ON EKKOEBELN = EKPOEBELN
inner JOIN EKET
ON EKPOEBELN = EKETEBELN
AND EKPOEBELP = EKETEBELP
inner JOIN LFA1
ON EKKOLIFNR = LFA1LIFNR
*left outer join makt
*on ekpomatnr = maktmatnr
WHERE EKKO~LIFNR IN VENDORNO
AND EKKO~RESWK IN PLANT
and EKPO~MATNR IN MATERIAL
and ekpo~elikz eq ' '
and ekpo~loekz ne 'L'
and eket~eindt in REQDAT.
append itab.
CLEAR ITAB.
endselect.
clear temp.
sort itab by lifnr.
loop at itab .
ITAB-OPEN_QUANT = ITAB-MENGE - ITAB-WEMNG.
if itab-matnr eq ''.
select single aufnr from ebkn into itab-aufnr where banfn = itab-banfn.
select single matnr from afpo into itab-matnr where aufnr = itab-aufnr.
endif.
select single maktx from makt into itab-maktx where matnr = itab-matnr.
select single maabc from MARC INTO ITAB-MAABC WHERE MATNR = ITAB-MATNR.
ITAB-VALUE = ITAB-NETPR * ITAB-OPEN_QUANT / itab-peinh.
modify itab.
endloop.
SKIP.
fieldcatalog-fieldname = 'LIFNR'.
fieldcatalog-seltext_m = 'vendor no'.
fieldcatalog-col_pos = 1.
fieldcatalog-outputlen = 15.
fieldcatalog-emphasize = 'X'.
fieldcatalog-key = 'X'.
fieldcatalog-do_sum = 'X'.
fieldcatalog-no_zero = 'X'.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'EBELN'.
fieldcatalog-seltext_m = 'po Number'.
fieldcatalog-col_pos = 2.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'AEDAT'.
fieldcatalog-seltext_m = 'po date'.
fieldcatalog-col_pos = 3.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'EBELP'.
fieldcatalog-seltext_m = 'item number'.
fieldcatalog-col_pos = 4.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'MATNR'.
fieldcatalog-seltext_m = 'material number'.
fieldcatalog-col_pos = 5.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'MAABC'.
fieldcatalog-seltext_m = 'material type'.
fieldcatalog-col_pos = 6.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'TXZ01'.
fieldcatalog-seltext_m = 'short text'.
fieldcatalog-col_pos = 7.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'MAKTX'.
fieldcatalog-seltext_m = 'long text'.
fieldcatalog-col_pos = 8.
fieldcatalog-outputlen = 15.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'EINDT'.
fieldcatalog-seltext_m = 'date promised'.
fieldcatalog-col_pos = 9.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'MENGE'.
fieldcatalog-seltext_m = 'Quantity'.
fieldcatalog-col_pos = 10.
fieldcatalog-outputlen = 15.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'WEMNG'.
fieldcatalog-seltext_m = 'Delivered'.
fieldcatalog-col_pos = 11.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'OPEN_QUANT'.
fieldcatalog-seltext_m = 'Open quantity'.
fieldcatalog-col_pos = 12.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'VALUE'.
fieldcatalog-seltext_m = '$ value'.
fieldcatalog-col_pos = 13.
fieldcatalog-do_sum = 'X'.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = g_repid
i_callback_top_of_page = 'TOP-OF-PAGE' "see FORM
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
it_fieldcat = fieldcatalog[]
is_layout = GS_layout
is_variant = z_template
tables
t_outtab = itab
exceptions
program_error = 1
others = 2.
FORM USE_COMMAND USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
CASE r_ucomm.
WHEN '&IC1'.
CASE rs_selfield-sel_tab_field.
WHEN 'ITAB-LIFNR'.
WHEN 'ITAB-EBELN'.
CHECK NOT rs_selfield-value IS INITIAL.
SET PARAMETER ID 'BUS' FIELD rs_selfield-value.
CALL TRANSACTION 'ME22N' AND SKIP FIRST SCREEN.
ENDCASE.
ENDCASE.Problem solved. changed the code as follows and it did work
Regards
Hrishi
form display_alv_report.
g_repid = sy-repid.
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = g_repid
i_callback_top_of_page = 'TOP-OF-PAGE' "see FORM
i_callback_user_command = 'USER_COMMAND'
i_grid_title = outtext
is_layout = gs_layout
it_fieldcat = fieldcatalog[]
it_special_groups = gd_tabgroup
it_events = gt_events
is_print = gd_prntparams
i_save = 'X'
is_variant = z_template
tables
t_outtab = itAB
exceptions
program_error = 1
others = 2.
if sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
endform. " DISPLAY_ALV_REPORT
FORM user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
Check function code
CASE r_ucomm.
WHEN '&IC1'.
Check field clicked on within ALVgrid report
IF rs_selfield-fieldname = 'EBELN'.
Read data table, using index of row user clicked on
READ TABLE ITAB INTO wa_ekko INDEX rs_selfield-tabindex.
Set parameter ID for transaction screen field
SET PARAMETER ID 'BES' FIELD wa_ekko-ebeln.
Sxecute transaction ME23N, and skip initial data entry screen
CALL TRANSACTION 'ME23N' AND SKIP FIRST SCREEN.
ENDIF.
IF rs_selfield-fieldname = 'MATNR'.
READ TABLE ITAB INTO wa_ekko INDEX rs_selfield-tabindex.
SET PARAMETER ID 'MAT' FIELD wa_ekko-matnr.
CALL TRANSACTION 'MD04' AND SKIP FIRST SCREEN.
ENDIF.
ENDCASE.
ENDFORM. -
Drill down report...
HI abapers,
How to create drill down report in alv.
When i double click the particular field, another report has to pop up and display the details of that particular field.
for eg,
When double click the amount spent field other report has to say, For which material the amonut has spend.
Thanking You
arvindhi arv,
for me your scenario is not clear..
you want to drill down the alv .. and show the report in the same program or you want to call another program when u try to hit the alv report..
well for drilling down the same program.. you can use the following method
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER = ' '
I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = GV_REPID
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = 'TOP1' " drill down
I_CALLBACK_TOP_OF_PAGE = 'TOP2'
I_CALLBACK_HTML_TOP_OF_PAGE = ' '
FORM TOP1 USING UCOMM TYPE SY-UCOMM SELFIELD TYPE SLIS_SELFIELD.
READ TABLE GT_FINAL_TOTAL INTO GS_FINAL INDEX SELFIELD-TABINDEX.
CASE SELFIELD-TABINDEX.
WHEN SELFIELD-TABINDEX.
perfrom itab2_operation. " in this form you will write the code to get the data for drill dispplay
now defing fieldcatalog again : example :
GS_FCAT-COL_POS = 1.
GS_FCAT-FIELDNAME = 'EBELN'.
GS_FCAT-SELTEXT_L = TEXT-001.
GS_FCAT-FIX_COLUMN = 'X'.
GS_FCAT-OUTPUTLEN = 13.
APPEND GS_FCAT TO GT_FCA
and call alv display again :
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER = ' '
I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = GV_REPID
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_TOP_OF_PAGE = 'TOP2'
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 = GS_LAYOUT
IT_FIELDCAT = GT_FCAT
and if you want to call another progam when u hit..u have to use..submit key work
like SUBMIT ZAFI013R VIA SELECTION-SCREEN AND RETURN. -
Drill Down Report in screen painter
Hi Experts,
I have a requirement in dialog programming/screen painter to create a 2 level drill down report. for eac page of the report, it should only contain 10 entries then to view the other entries (11 and up), the button for next page should be click (there is also back button).
First question is how will I have the drill down report (alv list type?) in screen painter?
Second question is how should I process the logic mentioned above (next and back) in screen painter/dialog programming?
Thanks in advance for all teh support. Points will be rewarded.
Cheers,
KurttHai,
Go thru this Threads u ll get an idea,
Drill down report help
Re: regarding Drill Down Reporting
drill down capabilities for an alv grid display field using oops concept
Regards,
Padmam. -
Alv : drill down not working.
Hi All,
Could you please tell me whats wrong with this code ? its not drilling down to show 'ebeln' with me22n. Am I missing something ?
Please help.
Hrishi
code is :-
REPORT Z_VENDOR_BACKORDER_REPORT_ALV .
TABLES: EKKO, LFA1, MAKT, EKET, EKPO, AFPO, MARC.
*Data Declaration
DATA: BEGIN OF ITAB OCCURS 0 ,
ebeln LIKE ekko-ebeln , " PO number
aedat LIKE ekko-aedat , " creation date
ebelp LIKE ekpo-ebelp , " item no
lifnr LIKE ekko-lifnr , " vendor number
name1 LIKE lfa1-name1 , " vendor name
RESWK LIKE EKKO-RESWK , " PLANT NO
MEMORY LIKE EKKO-MEMORY , " ORDER INCOMPLETE
matnr LIKE ekpo-matnr , " material number
werks like ekpo-werks , " plant
txz01 LIKE ekpo-txz01 , " material description
eindt LIKE eket-eindt , " Promised date
menge LIKE eket-menge , " quantity
wemng LIKE eket-wemng , " delivered quantity
netpr like ekpo-netpr , " value in AUD
peinh like ekpo-peinh , " price unit
banfn like ekpo-banfn , " PR no
aufnr like ebkn-aufnr , " Production order no
MAABC LIKE MARC-MAABC , " MATERIAL ABC Indicator
maktx like makt-maktx , " material long description
open_quant type p decimals 2, " quantity - delivered
VALUE TYPE p decimals 2, " $ VALUE * OPEN QUANTITY
end of ITAB.
data: wa like itab.
DATA: bdcdata LIKE bdcdata OCCURS 0 WITH HEADER LINE.
DATA: TEMP TYPE EKKO-LIFNR.
data: opt like CTU_PARAMS.
*DATA: WA TYPE FINAL.
all ALV declarations
type-pools: slis. "ALV Declarations
DATA: fieldcatalog TYPE slis_t_fieldcat_alv with header line,
G_REPID TYPE SY-REPID,
GS_PRINT TYPE SLIS_PRINT_ALV,
GT_LIST_TOP_OF_PAGE TYPE SLIS_T_LISTHEADER,
GT_EVENTS TYPE SLIS_T_EVENT,
GT_SORT TYPE SLIS_T_SORTINFO_ALV,
GS_LAYOUT TYPE SLIS_LAYOUT_ALV,
COL_POS TYPE I.
-----------------SELECTION SCREEN----------------------
selection-screen begin of block b1 with frame title text-001.
select-options VENDORNO for ekko-lifnr.
select-options MATERIAL for ekpo-matnr.
SELECT-OPTIONS PLANT FOR EKKO-RESWK.
select-options REQDAT for eket-eindt.
selection-screen end of block b1.
*................... GET DATA..................
START-OF-SELECTION.
PERFORM GATHER_DATA.
END-OF-SELECTION.
FORM USER_COMMAND USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
CASE r_ucomm.
WHEN '&IC1'.
CASE rs_selfield-sel_tab_field.
WHEN 'ITAB-EBELN'.
CHECK NOT rs_selfield-value IS INITIAL.
SET PARAMETER ID 'BUS' FIELD rs_selfield-value.
CALL TRANSACTION 'ME22N' AND SKIP FIRST SCREEN.
Do something at 'Sales document type' field selection
when 'ITAB-MATNR'.
SET PARAMETER ID 'BUS' FIELD rs_selfield-value.
CALL TRANSACTION 'MD04' AND SKIP FIRST SCREEN.
ENDCASE.
ENDCASE.
ENDFORM.
form gather_data.
SELECT EKKO~EBELN
EKKO~AEDAT
EKKO~LIFNR
EKKO~MEMORY
EKKO~RESWK
EKPO~EBELP
EKPO~MATNR
ekpo~werks
ekpo~netpr
ekpo~peinh
ekpo~banfn
ekpo~txz01
makt~maktx
EKET~EINDT
EKET~MENGE
EKET~WEMNG
LFA1~NAME1
INTO corresponding fields of ITAB
FROM (
EKKO inner JOIN EKPO
ON EKKOEBELN = EKPOEBELN
inner JOIN EKET
ON EKPOEBELN = EKETEBELN
AND EKPOEBELP = EKETEBELP
inner JOIN LFA1
ON EKKOLIFNR = LFA1LIFNR
*left outer join makt
*on ekpomatnr = maktmatnr
WHERE EKKO~LIFNR IN VENDORNO
AND EKKO~RESWK IN PLANT
and EKPO~MATNR IN MATERIAL
and ekpo~elikz eq ' '
and ekpo~loekz ne 'L'
and eket~eindt in REQDAT.
append itab.
CLEAR ITAB.
endselect.
clear temp.
sort itab by lifnr.
loop at itab .
ITAB-OPEN_QUANT = ITAB-MENGE - ITAB-WEMNG.
if itab-matnr eq ''.
select single aufnr from ebkn into itab-aufnr where banfn = itab-banfn.
select single matnr from afpo into itab-matnr where aufnr = itab-aufnr.
endif.
select single maktx from makt into itab-maktx where matnr = itab-matnr.
select single maabc from MARC INTO ITAB-MAABC WHERE MATNR = ITAB-MATNR.
ITAB-VALUE = ITAB-NETPR * ITAB-OPEN_QUANT / itab-peinh.
modify itab.
endloop.
SKIP.
fieldcatalog-tabname = 'ITAB'.
fieldcatalog-fieldname = 'LIFNR'.
fieldcatalog-seltext_m = 'vendor no'.
fieldcatalog-col_pos = 1.
fieldcatalog-outputlen = 15.
fieldcatalog-inttype = 'C'.
fieldcatalog-emphasize = 'X'.
fieldcatalog-key = 'X'.
fieldcatalog-do_sum = 'X'.
fieldcatalog-no_zero = 'X'.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-tabname = 'ITAB'.
fieldcatalog-fieldname = 'EBELN'.
fieldcatalog-seltext_m = 'po Number'.
fieldcatalog-col_pos = 2.
fieldcatalog-inttype = 'C'.
fieldcatalog-emphasize = 'C401'.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-tabname = 'ITAB'.
fieldcatalog-fieldname = 'AEDAT'.
fieldcatalog-seltext_m = 'po date'.
fieldcatalog-col_pos = 3.
fieldcatalog-inttype = 'C'.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-tabname = 'ITAB'.
fieldcatalog-fieldname = 'EBELP'.
fieldcatalog-seltext_m = 'item number'.
fieldcatalog-col_pos = 4.
fieldcatalog-inttype = 'C'.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-tabname = 'ITAB'.
fieldcatalog-fieldname = 'MATNR'.
fieldcatalog-no_zero = 'X'.
fieldcatalog-seltext_m = 'material number'.
fieldcatalog-col_pos = 5.
fieldcatalog-inttype = 'C'.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-tabname = 'ITAB'.
fieldcatalog-fieldname = 'MAABC'.
fieldcatalog-seltext_m = 'material type'.
fieldcatalog-col_pos = 6.
fieldcatalog-inttype = 'C'.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-tabname = 'ITAB'.
fieldcatalog-fieldname = 'TXZ01'.
fieldcatalog-seltext_m = 'short text'.
fieldcatalog-col_pos = 7.
fieldcatalog-inttype = 'C'.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-tabname = 'ITAB'.
fieldcatalog-fieldname = 'MAKTX'.
fieldcatalog-seltext_m = 'long text'.
fieldcatalog-col_pos = 8.
fieldcatalog-inttype = 'C'.
fieldcatalog-outputlen = 15.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-tabname = 'ITAB'.
fieldcatalog-fieldname = 'EINDT'.
fieldcatalog-seltext_m = 'date promised'.
fieldcatalog-col_pos = 9.
fieldcatalog-inttype = 'C'.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-tabname = 'ITAB'.
fieldcatalog-fieldname = 'MENGE'.
fieldcatalog-seltext_m = 'Quantity'.
fieldcatalog-col_pos = 10.
fieldcatalog-inttype = 'C'.
fieldcatalog-outputlen = 15.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-tabname = 'ITAB'.
fieldcatalog-fieldname = 'WEMNG'.
fieldcatalog-seltext_m = 'Delivered'.
fieldcatalog-col_pos = 11.
fieldcatalog-inttype = 'C'.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-tabname = 'ITAB'.
fieldcatalog-fieldname = 'OPEN_QUANT'.
fieldcatalog-seltext_m = 'Open quantity'.
fieldcatalog-col_pos = 12.
fieldcatalog-inttype = 'C'.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-tabname = 'ITAB'.
fieldcatalog-fieldname = 'VALUE'.
fieldcatalog-seltext_m = '$ value'.
fieldcatalog-col_pos = 13.
fieldcatalog-inttype = 'C'.
fieldcatalog-do_sum = 'X'.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = g_repid
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
it_fieldcat = fieldcatalog[]
is_layout = GS_layout
IT_SORT = gt_sort
I_DEFAULT = 'X'
I_SAVE = 'X'
is_variant = z_template
tables
t_outtab = ITAB
exceptions
program_error = 1
others = 2.
endform.hi,
please run the code below.
REPORT yfi7g_ing_mic_001 .
*PROGRAM YFI7G_ING_MIC_001.
TABLES: vbak .
TABLES: mara .
TYPES: BEGIN OF tp_vbak ,
vbeln TYPE vbak-vbeln,
erdat TYPE vbak-erdat,
erzet TYPE vbak-erzet,
ernam TYPE vbak-ernam,
vbtyp TYPE vbak-vbtyp,
trvog TYPE vbak-trvog,
auart TYPE vbak-auart,
lifsk TYPE vbak-lifsk,
faksk TYPE vbak-faksk,
waerk TYPE vbak-waerk,
vkorg TYPE vbak-vkorg,
kunnr TYPE vbak-kunnr,
vgbel TYPE vbak-vgbel,
vgtyp TYPE vbak-vgtyp,
END OF tp_vbak .
TYPES: BEGIN OF tp_mara ,
matnr TYPE mara-matnr,
END OF tp_mara .
TYPES: BEGIN OF tp_alv1_data.
INCLUDE TYPE tp_vbak .
TYPES: END OF tp_alv1_data.
TYPES: BEGIN OF tp_alv2_data.
INCLUDE TYPE tp_mara .
TYPES: END OF tp_alv2_data.
TYPE-POOLS: slis.
DATA: gt_vbak TYPE STANDARD TABLE OF tp_vbak WITH HEADER LINE.
DATA: gt_mara TYPE STANDARD TABLE OF tp_mara WITH HEADER LINE.
DATA: gs_variant LIKE disvariant.
DATA: gt_alv1_data TYPE STANDARD TABLE OF tp_alv1_data WITH HEADER LINE.
DATA: gt_alv2_data TYPE STANDARD TABLE OF tp_alv2_data WITH HEADER LINE.
SELECTION-SCREEN *
BLOCK b0 *
SELECTION-SCREEN BEGIN OF BLOCK b0 WITH FRAME.
SELECT-OPTIONS: s_vbeln FOR vbak-vbeln. "<field not defined?>
PARAMETERS: p_matnr LIKE mara-matnr. "<field not defined?>
SELECTION-SCREEN END OF BLOCK b0.
BLOCK bvar *
SELECTION-SCREEN BEGIN OF BLOCK bvar WITH FRAME.
PARAMETERS: p_vari LIKE disvariant-variant.
SELECTION-SCREEN END OF BLOCK bvar.
BLOCK bbox *
SELECTION-SCREEN BEGIN OF BLOCK bbox WITH FRAME.
PARAMETERS: p_box_up RADIOBUTTON GROUP b1,
p_box_do RADIOBUTTON GROUP b1 DEFAULT 'X',
p_box_no RADIOBUTTON GROUP b1.
SELECTION-SCREEN END OF BLOCK bbox.
AT SELECTION-SCREEN ON P_VARI *
AT SELECTION-SCREEN ON p_vari.
PERFORM alv_variant_existence USING p_vari
CHANGING gs_variant.
AT SELECTION-SCREEN ON VALUE REQUEST FOR P_VARI *
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_vari.
PERFORM alv_variant_f4 CHANGING p_vari
gs_variant.
INITIALIZATION *
INITIALIZATION.
START-OF-SELECTION *
START-OF-SELECTION.
PERFORM authority_check.
PERFORM get_control_data.
PERFORM get_transaction_data.
PERFORM process_transaction_data.
END-OF-SELECTION *
END-OF-SELECTION.
PERFORM output_data.
F O R M S *
FORM AUTHORITY_CHECK *
Perform authority checks for the report *
FORM authority_check.
!!! Note: authorisation checks are application-dependent.
!!! Some common cases are listed below - please select one of them
!!! or add new authorisation checks.
!!! If the report is creating batch input session or using LDB
!!! it may be sufficient to use automatic SAP auth.checks.
Authorisation for displaying documents in a single company code
authority-check object 'F_BKPF_BUK'
id 'BUKRS' field p_bukrs
id 'ACTVT' field '03'.
if sy-subrc <> 0.
message e001(z9) with 'No authorisation to display documents'
'in company code' p_bukrs.
endif.
Displaying documents from a list of company codes (select-options)
call function 'Y_BUKRS_AUTHORITY_CHECK'
EXPORTING
ACTVT = '03'
NOMESSAGE = ' '
tables
s_bukrs = s_bukrs.
ENDFORM. " AUTHORITY_CHECK
FORM GET_CONTROL_DATA *
Read configuration etc. *
FORM get_control_data.
ENDFORM. " GET_CONTROL_DATA
FORM GET_TRANSACTION_DATA *
Read documents etc. *
FORM get_transaction_data.
!!! Data selection statement below has been generated automatically.
!!! Please check if it is correct and complete.
!!! Use table joins or 'SELECT FOR ALL ENTRIES' when selecting data
!!! from related tables.
SELECT
vbeln
erdat
erzet
ernam
FROM vbak
INTO CORRESPONDING FIELDS OF TABLE gt_vbak
CHECK NOT gt_vbak[] IS INITIAL.
SELECT
matnr
FROM mara
INTO CORRESPONDING FIELDS OF TABLE gt_mara
FOR ALL ENTRIES IN gt_vbak
WHERE ernam = gt_vbak-ernam
ENDFORM. " GET_TRANSACTION_DATA
FORM PROCESS_TRANSACTION_DATA *
FORM process_transaction_data.
LOOP AT gt_vbak .
MOVE-CORRESPONDING gt_vbak TO gt_alv1_data .
APPEND gt_alv1_data .
ENDLOOP.
FREE gt_vbak .
LOOP AT gt_mara .
MOVE-CORRESPONDING gt_mara TO gt_alv2_data .
APPEND gt_alv2_data .
ENDLOOP.
FREE gt_mara .
ENDFORM. " PROCESS_TRANSACTION_DATA
FORM OUTPUT_DATA *
FORM output_data.
PERFORM alv_list_display.
ENDFORM. " OUTPUT_DATA
FORM DISPLAY_RECORD *
Display object associated with the current ALV line *
FORM display_record USING is_selfield TYPE slis_selfield.
READ TABLE gt_alv1_data INDEX is_selfield-tabindex.
CHECK sy-subrc = 0.
!!! SAMPLE IMPLEMENTATION FOR DISPLAYING FI DOCUMENTS:
SET PARAMETER ID 'BUK' FIELD gt_alv1_data-vbeln.
set parameter id 'BLN' field gt_alv1_data-belnr.
set parameter id 'GJR' field gt_alv1_data-gjahr.
CALL TRANSACTION 'FB03' AND SKIP FIRST SCREEN.
ENDFORM. " DISPLAY_RECORD
FORM ALV_LIST_DISPLAY *
Invoke main ALV function to format and show the report *
FORM alv_list_display.
DATA: ls_layout TYPE slis_layout_alv,
ls_print TYPE slis_print_alv,
ls_keyinfo TYPE slis_keyinfo_alv,
lt_fieldcat TYPE slis_t_fieldcat_alv,
lt_exctab TYPE slis_t_extab,
lt_sorttab TYPE slis_t_sortinfo_alv,
lt_events TYPE slis_t_event.
PERFORM alv_init_report_events TABLES lt_events.
PERFORM alv_init_report_layout TABLES lt_fieldcat
lt_exctab
lt_sorttab
CHANGING ls_layout
ls_print
ls_keyinfo.
CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'
EXPORTING
i_interface_check = ' '
i_callback_program = sy-cprog
is_layout = ls_layout
it_fieldcat = lt_fieldcat
it_excluding = lt_exctab
IT_SPECIAL_GROUPS =
it_sort = lt_sorttab
IT_FILTER =
IS_SEL_HIDE =
I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
I_DEFAULT = 'X'
i_save = 'A'
is_variant = gs_variant
it_events = lt_events
IT_EVENT_EXIT =
i_tabname_header = 'GT_ALV1_DATA'
i_tabname_item = 'GT_ALV2_DATA'
I_STRUCTURE_NAME_HEADER =
I_STRUCTURE_NAME_ITEM =
is_keyinfo = ls_keyinfo
is_print = ls_print
IS_REPREP_ID =
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
t_outtab_header = gt_alv1_data
t_outtab_item = gt_alv2_data.
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
ENDFORM. " ALV_LIST_DISPLAY
FORM ALV_INIT_REPORT_LAYOUT *
Set up report layout definition for ALV_LIST_DISPLAY *
<-- OT_FIELDCAT list of fields *
<-- OT_EXCTAB excluded menu options *
<-- OT_SORTTAB sorting/grouping definition *
<-- OS_LAYOUT global report layout settings *
<-- OS_PRINT global report printout settings *
<-- OS_KEYINFO itab key fields (required only for hier.lists) *
FORM alv_init_report_layout TABLES ot_fieldcat TYPE slis_t_fieldcat_alv
ot_exctab TYPE slis_t_extab
ot_sorttab TYPE slis_t_sortinfo_alv
CHANGING cs_layout TYPE slis_layout_alv
cs_print TYPE slis_print_alv
cs_keyinfo TYPE slis_keyinfo_alv.
add menu items to be excluded to ot_exctab.
REFRESH ot_exctab.
REFRESH ot_fieldcat.
REFRESH ot_sorttab.
!!! List all ALV data fields for display here:
DD-struct = data dictionary structure name
DD-field = field of data dictionary structure
itab = internal table for output data
itab-field = internal table field name
key = set to 'X' if key field
sum = set to 'X' for totals
hid = set to 'X' if field is initially hidden
row = list row number (multi-line list if >1)
DD-struct DD-field itab itab-field key sum hid row
PERFORM alv_build_fieldcat TABLES ot_fieldcat USING:
'VBAK' 'VBELN' 'GT_ALV1_DATA' 'VBELN' ' ' ' ' ' ' 1 ,
'VBAK' 'ERDAT' 'GT_ALV1_DATA' 'ERDAT' ' ' ' ' ' ' 1 ,
'VBAK' 'ERZET' 'GT_ALV1_DATA' 'ERZET' ' ' ' ' ' ' 1 ,
'VBAK' 'ERNAM' 'GT_ALV1_DATA' 'ERNAM' ' ' ' ' ' ' 1.
PERFORM alv_build_fieldcat TABLES ot_fieldcat USING:
'MARA' 'MATNR' 'GT_ALV2_DATA' 'MATNR' ' ' ' ' ' ' 1 .
!!! List all ALV data fields for sorting/grouping here
itab = internal table for output data
itab-field = internal table field name
up = sort ascending
down = sort descending
grp = group by
comp = group initially compressed
pos = field position in sort sequence
itab field up down grp comp pos
PERFORM alv_build_sorttab TABLES ot_sorttab USING:
'GT_ALV1_DATA' 'VBELN' 'X' ' ' ' ' ' ' 1.
PERFORM alv_build_sorttab TABLES ot_sorttab USING:
'GT_ALV2_DATA' 'MATNR' 'X' ' ' ' ' ' ' 1.
!!! key definition - required only for hierarchical display (2 itabs)
cs_keyinfo-header01 = 'VBELN' .
cs_keyinfo-item01 = 'MATNR' .
!!! See the declaration of type SLIS_LAYOUT_ALV and set the fields
!!! of OS_LAYOUT record to change list-level attributes
os_layout-no_colhead = 'X'. " no headings
cs_layout-zebra = 'X'. " stripped pattern
os_layout-no_vline = 'X'. " columns separated by space
os_layout-totals_only = 'X'. " show only totals
os_layout-totals_text = 'Total'. " totals line label
os_layout-subtotals_text = 'Subtotal'. " subtotals line label
os_layout-subtotals_text = 'Subtotal'. " subtotals line label
os_layout-key_hotspot = 'X'. " keys as hotspot
os_layout-expand_all = 'X'. " Expand all positions
os_layout...
cs_print-no_print_selinfos = 'X'. " Skip selection statistics
cs_print-no_print_listinfos = 'X'. " Skip list statistics
os_print-...
ENDFORM. " INIT_REPORT_LAYOUT
FORM ALV_BUILD_FIELDCAT *
Format a single line for ALV_INIT_REPORT_LAYOUT *
FORM alv_build_fieldcat TABLES ot_fieldcat
USING iv_ref_tabname "ref to a table/field
iv_ref_fieldname
iv_tabname "actual table/field name
iv_fieldname
iv_key
iv_do_sum
iv_no_out
iv_row_pos.
status variables for auto-numbering of field column position
(column number reset when a new table or row begins)
STATICS: sv_last_tabname TYPE slis_tabname,
sv_last_row_pos TYPE i,
sv_current_col TYPE i.
IF sv_last_tabname <> iv_tabname OR sv_last_row_pos <> iv_row_pos.
sv_current_col = 1.
ELSE.
ADD 1 TO sv_current_col.
ENDIF.
sv_last_tabname = iv_tabname.
sv_last_row_pos = iv_row_pos.
DATA: ls_fieldcat TYPE slis_fieldcat_alv.
DATA: lv_fieldname TYPE slis_fieldname.
lv_fieldname = iv_fieldname.
!!! List all the special formatting requirements in cases below
case lv_fieldname.
when 'WRBTR'. "<-- link with currency required
ls_fieldcat-cfieldname = 'WAERS'.
ls_fieldcat-ctabname = iv_tabname.
when 'HKONT'. "<-- change default column header
ls_fieldcat-seltext_s = 'GL Acc.'.
ls_fieldcat-ddictxt = 'S'. " (S)hort (M)iddle (L)ong
when 'SOME_NUMBER' "<-- change number formatting
ls_fieldcat-nosign = 'X'.
ls_fieldcat-nozero = 'X'.
ls_fieldcat-just = 'L'. " (L)eft (R)ight (C)enter
endcase.
ls_fieldcat-ref_tabname = iv_ref_tabname.
ls_fieldcat-ref_fieldname = iv_ref_fieldname.
ls_fieldcat-tabname = iv_tabname.
ls_fieldcat-fieldname = iv_fieldname.
ls_fieldcat-key = iv_key.
ls_fieldcat-do_sum = iv_do_sum.
ls_fieldcat-no_out = iv_no_out.
ls_fieldcat-row_pos = iv_row_pos.
ls_fieldcat-col_pos = sv_current_col.
APPEND ls_fieldcat TO ot_fieldcat.
ENDFORM. " ALV_BUILD_FIELDCAT
FORM ALV_BUILD_SORTTAB *
Set up sorting information for ALV_INIT_REPORT_LAYOUT *
FORM alv_build_sorttab TABLES ot_sorttab TYPE slis_t_sortinfo_alv
USING iv_tabname TYPE slis_fieldname
iv_fieldname TYPE slis_fieldname
iv_up TYPE c
iv_down TYPE c
iv_subtot TYPE c
iv_comp TYPE c
iv_spos TYPE n.
ot_sorttab-spos = iv_spos.
ot_sorttab-fieldname = iv_fieldname.
ot_sorttab-tabname = iv_tabname.
ot_sorttab-up = iv_up.
ot_sorttab-down = iv_down.
ot_sorttab-subtot = iv_subtot.
ot_sorttab-comp = iv_comp.
APPEND ot_sorttab.
ENDFORM. " ALV_BUILD_SORTTAB
FORM ALV_INIT_REPORT_EVENTS *
Set up program events for ALV_LIST_DISPLAY *
<-- OT_EVENTS list of events and associated report subroutines *
FORM alv_init_report_events TABLES ot_events TYPE slis_t_event.
CLEAR ot_events.
REFRESH ot_events.
ot_events-name = slis_ev_user_command.
ot_events-form = 'USER_COMMAND'.
APPEND ot_events.
ot_events-name = slis_ev_pf_status_set.
ot_events-form = ''. "'PF_STATUS_SET'.
APPEND ot_events.
ot_events-name = slis_ev_top_of_list.
ot_events-form = 'TOP_OF_LIST'.
APPEND ot_events.
ot_events-name = slis_ev_end_of_list.
ot_events-form = 'END_OF_LIST'.
APPEND ot_events.
ot_events-name = slis_ev_top_of_page.
ot_events-form = 'TOP_OF_PAGE'.
APPEND ot_events.
ot_events-name = slis_ev_end_of_page.
ot_events-form = 'END_OF_PAGE'.
APPEND ot_events.
ot_events-name = slis_ev_foreign_top_of_page.
ot_events-form = ''.
APPEND ot_events.
ot_events-name = slis_ev_foreign_end_of_page.
ot_events-form = ''.
APPEND ot_events.
ot_events-name = slis_ev_top_of_coverpage.
ot_events-form = ''.
APPEND ot_events.
ot_events-name = slis_ev_end_of_coverpage.
ot_events-form = ''.
APPEND ot_events.
ot_events-name = slis_ev_before_line_output.
ot_events-form = ''.
APPEND ot_events.
ot_events-name = slis_ev_after_line_output.
ot_events-form = ''.
APPEND ot_events.
ot_events-name = slis_ev_caller_exit_at_start.
ot_events-form = ''.
APPEND ot_events.
ot_events-name = slis_ev_list_modify.
ot_events-form = ''.
APPEND ot_events.
ot_events-name = slis_ev_subtotal_text.
ot_events-form = ''.
APPEND ot_events.
ENDFORM. " ALV_INIT_REPORT_EVENTS
FORM USER_COMMAND *
Subroutine attached as callback form to ABAP List Viewer *
--> UCOMM - user command code passed from ALV *
--> SELFIELD - information record describing current line/field *
FORM user_command USING value(iv_ucomm) LIKE sy-ucomm
is_selfield TYPE slis_selfield.
CASE iv_ucomm.
WHEN '&IC1'. "ALV record selection
PERFORM display_record USING is_selfield.
when ...
ENDCASE.
ENDFORM. " USER_COMMAND
FORM PF_STATUS_SET *
Subroutine attached as callback form to ABAP List Viewer, *
allows setting alternative menu. If necessary: *
1. Copy 'STANDARD' menu from SAPLKKBL and modify as required, *
2. Activate callback *
FORM pf_status_set USING it_exctab TYPE slis_t_extab.
set pf-status 'STANDARD' excluding it_exctab.
ENDFORM. " PF_STATUS_SET
FORM TOP_OF_LIST *
Subroutine attached as callback form to ABAP List Viewer, *
executed once at the start of list output. *
FORM top_of_list.
DATA: lt_seltab TYPE STANDARD TABLE OF rsparams WITH HEADER LINE.
DATA: lv_report LIKE sy-repid.
lv_report = sy-repid. "do not pass sy-repid to function!
IF p_box_up = 'X'. "display select options at report start
CALL FUNCTION 'RS_REFRESH_FROM_SELECTOPTIONS'
EXPORTING
curr_report = lv_report
TABLES
selection_table = lt_seltab.
remove 'technical' parameters with 'DELETE LT_SELTAB WHERE...'
before display, if necessary
CALL FUNCTION 'RS_LIST_SELECTION_TABLE'
EXPORTING
report = lv_report
seltext = 'X'
dyn_range =
newpage = ' '
screennr = 1000
TABLES
sel_tab = lt_seltab
EXCEPTIONS
sel_tab_empty = 1.
ENDIF. "p_box_up = 'X'
ENDFORM. " TOP_OF_LIST
FORM END_OF_LIST *
Subroutine attached as callback form to ABAP List Viewer *
executed once at the end of list output. *
FORM end_of_list.
DATA: lt_seltab TYPE STANDARD TABLE OF rsparams WITH HEADER LINE.
DATA: lv_report LIKE sy-repid.
lv_report = sy-repid. "do not pass sy-repid to function!
IF p_box_do = 'X'. "display select options at report end
CALL FUNCTION 'RS_REFRESH_FROM_SELECTOPTIONS'
EXPORTING
curr_report = lv_report
TABLES
selection_table = lt_seltab.
remove 'technical' parameters with 'DELETE LT_SELTAB WHERE...'
before display, if necessary
CALL FUNCTION 'RS_LIST_SELECTION_TABLE'
EXPORTING
report = lv_report
seltext = 'X'
dyn_range =
newpage = ' '
screennr = 1000
TABLES
sel_tab = lt_seltab
EXCEPTIONS
sel_tab_empty = 1.
ENDIF. "p_box_do = 'X'
ENDFORM. " END_OF_LIST
FORM TOP_OF_PAGE *
Subroutine attached as callback form to ABAP List Viewer *
FORM top_of_page.
standard Ingram Micro report page heading
DATA: lv_coco_pos TYPE i, "CurPos of 'Company confidential'
lv_title_pos TYPE i, "CurPos of report title
lv_title(70) TYPE c, "Truncated report title
lv_page_pos TYPE i, "CurPos of page number
lv_date_pos TYPE i, "CurPos of date and time
lv_page_no(10) TYPE c,
lv_date(25) TYPE c,
lv_time(20) TYPE c,
lv_page(10) TYPE c.
We may need to truncate title if the line size is < 81.
IF sy-linsz < 81.
lv_title = sy-title+0(50).
ELSE.
lv_title = sy-title.
ENDIF.
Decide on positioning of text depending on width of page
lv_title_pos = ( sy-linsz / 2 ) - ( STRLEN( lv_title ) / 2 ).
lv_coco_pos = sy-linsz - 20.
FORMAT COLOR COL_HEADING INTENSIFIED ON.
WRITE: / 'Ingram Micro',
AT lv_title_pos lv_title,
AT lv_coco_pos 'Company Confidential'.
Setup data correctly in the correct format for the display fields.
lv_page = sy-pagno.
SHIFT lv_page LEFT DELETING LEADING ' '.
CONCATENATE sy-datum6(2) sy-datum4(2) sy-datum+0(4)
INTO lv_date SEPARATED BY '.'.
CONCATENATE sy-uzeit0(2) ':' sy-uzeit2(2) INTO lv_time.
CONCATENATE lv_date lv_time INTO lv_date SEPARATED BY ' '.
CONCATENATE 'Page' lv_page INTO lv_page_no SEPARATED BY ' '.
Decide on positioning of text depending on width of page.
lv_page_pos = sy-linsz - ( STRLEN( lv_page_no ) ).
WRITE: / lv_date,
AT lv_page_pos lv_page_no.
ULINE.
ENDFORM. " TOP_OF_PAGE
FORM END_OF_PAGE *
Subroutine attached as callback form to ABAP List Viewer *
FORM end_of_page.
ENDFORM. " END_OF_PAGE
Form ALV_VARIANT_EXISTENCE
Reads ALV variant definition
FORM alv_variant_existence USING iv_variant LIKE disvariant-variant
CHANGING os_variant LIKE disvariant.
CHECK NOT iv_variant IS INITIAL.
os_variant-report = sy-repid.
os_variant-variant = iv_variant.
IF iv_variant CP '/*'. "user-specific variants begin with slash
os_variant-username = sy-uname.
ENDIF.
CALL FUNCTION 'REUSE_ALV_VARIANT_EXISTENCE'
EXPORTING
i_save = 'A'
CHANGING
cs_variant = os_variant
EXCEPTIONS
wrong_input = 1
not_found = 2
program_error = 3
OTHERS = 4.
IF sy-subrc <> 0.
MESSAGE e001(z9) WITH 'Please select a valid display variant.'.
ENDIF.
ENDFORM. " ALV_VARIANT_EXISTENCE
FORM ALV_VARIANT_F4 *
Display list of layout variants on report selection screen *
FORM alv_variant_f4 CHANGING cv_varname LIKE disvariant-variant
cs_variant LIKE disvariant.
DATA: lv_exit(1) TYPE c.
cs_variant-report = sy-repid.
CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
EXPORTING
is_variant = cs_variant
i_save = 'A'
it_default_fieldcat =
IMPORTING
e_exit = lv_exit
es_variant = cs_variant
EXCEPTIONS
not_found = 2.
IF sy-subrc = 2.
MESSAGE ID sy-msgid TYPE 'S' NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSE.
IF lv_exit = space.
cv_varname = cs_variant-variant.
ENDIF.
ENDIF.
hope this will help.
see form user_command.
regards,
Ruchika -
Drill down to all screens of XK03 in ALV report from CALL TRANSACTION
HI!
I have created a vendor master report which calls the XK03 transaction when the vendor is clicked on on the ALV output. It takes me to the XK03 address screen and when I try clicking to go to the next screen it says the last screen is reached , 'Do you wnat to cancell processing'. I want to enable the program to goto the next screens as well like the controll screen and the accounting screen ect in my drill down on call transaction.
following si my code section which does it.
CASE rs_selfield-fieldname.
WHEN 'LIFNR'.
* Set parameter ID for transaction screen field
CHECK NOT wa_vend-lifnr IS INITIAL.
SET PARAMETER ID 'LIF' FIELD wa_vend-lifnr.
SET PARAMETER ID 'BUK' FIELD wa_vend-bukrs.
SET PARAMETER ID 'EKO' FIELD wa_vend-ekorg.
SET PARAMETER ID 'KDY' FIELD kdy_val.
CALL TRANSACTION 'XK03' AND SKIP FIRST SCREEN. "EC needed
ENDCASE.
ENDCASE.
Thanks and regards,
AaravHi,
Your code seems to be right.
Try writing the code as the below format.
CASE SY-UCOMM.
* CHECK FUNCTION CODE
WHEN '&IC1'.
* CHECK FIELD CLICKED ON WITHIN ALVGRID REPORT
IF SELFIELD-FIELDNAME = 'LIFNR'.
* READ DATA TABLE, USING INDEX ROW USER CLICKED ON
READ TABLE IT_FINAL INTO WA_FINAL INDEX SELFIELD-TABINDEX.
* SET PARAMETER ID FOR TRANSACTION SCREEN FIELD
SET PARAMETER ID 'BES' FIELD WA_FINAL-LIFNR.
* EXECUTE TRANSACTION 'XK03',AND SKIP INITIAL DATA ENTRY SCREEN.
CALL TRANSACTION 'XK03' AND SKIP FIRST SCREEN.
ENDIF.
ENDCASE.
Thanks
Arbind -
How to get the 'hand' cursor on an ALV drill down report?
I have a drill down on PO # going to trans ME23N that is working great.
But I have noticed on my other drill downs (E.G for billing doc VF03) that when the report is displayed the drill down field value is a) underlined and b) has a 'Hand' appear when you place the cursor over the billing document field.
This does not happen on my PO # - it is not highlighted with an underscore, nor do you get the small hand - but it does work when you double click the field.
The field I am using on the ALV report is RSEG-EBELN. This is not a KEY field in the table - perhaps that is why it does not have the underscore and the 'hand'.
Thanks!
ScottHere it is.
When you build your field cat use the below code.
DATA : x_fieldcat TYPE slis_fieldcat_alv.
* Single click on the field will trigger double click event.Also, a hand
* will appear when the cursor navigates to the field
X_FIELDCAT-HOTSPOT = 'X'.
Regards,
ARS -
Hiding fields in ALV DRILLED DOWN REPORT
Hi
My scenario is like this i created a alv drilled down report , in that once the user executes it ,it will displays the header contents of the purchase order.
If the user double clicks on any of the header line item it will displays the item detials of the particular header data..
My probelm is if i double click it i am getting the header details added with the item fields..i want to hide the header detials if i want to c the item level details..
Can any suggest me some better ways to hide the header contents ??
Arun Josephhi,
check ur field cat...
R u using same name?
If possible paste ur code here... -
ALV Reporting with drill down capabillities
I'm creating a abap custom report using the ALV. I want to drill down to CJ03 which is projects. I know how to do it in regular custom reporting, but I don't seem to be able to get it to work using the ALV. Can anyone help?
Thanks.
LindaHi Linda,
Take a look at this sample program. The logic to handle any interaction with the user is in my "PORCESS_USER_COMMANDS" routine.
This is defined in the "I_CALLBACK_USER_COMMAND" parameter in the ALV FM.
Hope this helps.
Cheers,
Pat.
[code]
Modification History
Date | Author | Chg Req # | Description
15.08.2001| Pat Yee | $TMP | Program Creation
This program is an example of how the ALV Display works.
It will display Customer Data.
This report will also show how to display an ALV report with different
colored lines and icons
REPORT zpat.
Include Programs
INCLUDE <icon>.
Database Tables
TABLES: kna1. "Customer Master
Types
TYPE-POOLS: kkblo.
Structures
Structure to hold the Color Information
DATA: BEGIN OF st_color,
color(3) TYPE c,
END OF st_color.
Structure to hold the Icon Information
DATA: BEGIN OF st_icon,
icon(4) TYPE c,
END OF st_icon.
ALV Field Catalog Structure
DATA: st_fieldcat TYPE slis_fieldcat_alv.
ALV Layout Structure
DATA: st_layout TYPE slis_layout_alv.
Internal Tables
Output Table
DATA: BEGIN OF tbl_kna1 OCCURS 0.
INCLUDE STRUCTURE st_icon. "Icon Structure
INCLUDE STRUCTURE kna1. "Customer Master Structure
INCLUDE STRUCTURE st_color. "Color Structure
DATA: END OF tbl_kna1.
ALV Field Catalog Table
DATA: tbl_fieldcat TYPE slis_t_fieldcat_alv.
Variables
DATA: fieldname(30) TYPE c,
g_repid LIKE sy-repid.
Start of Selection
START-OF-SELECTION.
g_repid = sy-repid.
PERFORM get_data.
End of Selection
END-OF-SELECTION.
PERFORM do_fancy_stuff.
PERFORM get_layout.
PERFORM get_fieldcat.
PERFORM create_report.
*& Form CREATE_REPORT
Learn to read the subroutine name!
FORM create_report.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_interface_check = ' '
i_callback_program = g_repid
i_callback_user_command = 'PROCESS_USER_COMMANDS'
it_fieldcat = tbl_fieldcat
i_default = 'X'
i_save = ' '
is_layout = st_layout
TABLES
t_outtab = tbl_kna1
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. " CREATE_REPORT
*& Form GET_FIELDCAT
Build the Field Catalog
FORM get_fieldcat.
Here the field catalog is created. To display more fields simply
'uncomment' the additional lines and add the field name. Also note
that the field catalog is much more powerful than this. You can
intensify fields, change the colour, assign reference fields, etc.
Look at type slis_fieldcat_alv for more options.
PERFORM write_fieldcat USING 'ICON' 'TBL_KNA1' ' ' 'X' 1 '2' 'X'
PERFORM write_fieldcat USING 'KUNNR' 'TBL_KNA1' 'KNA1' 'X' 2 ' ' ' '
PERFORM write_fieldcat USING 'NAME1' 'TBL_KNA1' 'KNA1' ' ' 3 '10' ' '
'X'.
PERFORM write_fieldcat USING 'STRAS' 'TBL_KNA1' 'KNA1' ' ' 4 ' ' ' '
PERFORM write_fieldcat USING 'TELF1' 'TBL_KNA1' 'KNA1' ' ' 5 ' ' ' '
PERFORM write_fieldcat USING 'ORT01' 'TBL_KNA1' 'KNA1' ' ' 6 ' ' ' '
PERFORM write_fieldcat USING 'PSTLZ' 'TBL_KNA1' 'KNA1' ' ' 7 ' ' ' '
PERFORM write_fieldcat USING 'SORTL' 'TBL_KNA1' 'KNA1' ' ' 8 ' ' ' '
PERFORM write_fieldcat USING 'ERNAM' 'TBL_KNA1' 'KNA1' ' ' 9 ' ' ' '
PERFORM write_fieldcat USING 'SPRAS' 'TBL_KNA1' 'KNA1' ' ' 10 ' ' ' '
perform write_fieldcat using ' ' 'TBL_KNA1' 'KNA1' ' ' 10 ' '.
perform write_fieldcat using ' ' 'TBL_KNA1' 'KNA1' ' ' 11 ' '.
perform write_fieldcat using ' ' 'TBL_KNA1' 'KNA1' ' ' 12 ' '.
ENDFORM. " GET_FIELDCAT
*& Form WRITE_FIELDCAT
Write the Field Catalog data to the Field Catalog Table
-->name Field name
-->tab Table name
-->st Structure Name
-->key Is this field a Key?
-->pos Position Number
-->length Field Length
-->icon Display as Icon
-->hot Hotspot
FORM write_fieldcat USING name tab st key pos length icon hot.
st_fieldcat-fieldname = name.
st_fieldcat-tabname = tab.
st_fieldcat-ref_tabname = st.
st_fieldcat-key = key.
st_fieldcat-col_pos = pos.
st_fieldcat-outputlen = length.
st_fieldcat-icon = icon.
st_fieldcat-hotspot = hot.
APPEND st_fieldcat TO tbl_fieldcat.
CLEAR st_fieldcat.
ENDFORM. " WRITE_FIELDCAT
*& Form PROCESS_USER_COMMANDS
Interactive Reporting Commands
FORM process_user_commands USING syst-ucomm LIKE syst-ucomm
selfield TYPE slis_selfield.
This subroutine is called when there is user interaction in the output
In this case if the user double clicks the Customer Number then the
program will call transaction XD03 and display the Customer Master
Data
CASE syst-ucomm.
WHEN '&IC1'.
get cursor field fieldname.
READ TABLE tbl_kna1 INDEX selfield-tabindex.
SET PARAMETER ID 'KUN' FIELD tbl_kna1-kunnr.
CALL TRANSACTION 'XD03' AND SKIP FIRST SCREEN.
ENDCASE.
ENDFORM. " PROCESS_USER_COMMANDS
*& Form GET_LAYOUT
set the layout of the ALV.
add color to the row?
FORM get_layout.
st_layout-info_fieldname = 'COLOR'.
st_layout-colwidth_optimize = 'X'.
st_layout-get_selinfos = 'X'.
ENDFORM. " GET_LAYOUT
*& Form get_data
Get some data to play with
FORM get_data.
SELECT * FROM kna1 INTO CORRESPONDING FIELDS OF TABLE tbl_kna1
UP TO 30 ROWS.
ENDFORM. " get_data
*& Form do_fancy_stuff
Do some fancy pants stuff for example changing the color of
lines and adding icons
FORM do_fancy_stuff.
Here we will demonstrate changing the color of ALV Record lines as
well as displaying Icons
LOOP AT tbl_kna1.
All records where NAME1 begins with 'M', will be displayed in Bluish
Green
IF tbl_kna1-name1(1) EQ 'M'.
tbl_kna1-color = 'C41'. "Bluish Green
MODIFY tbl_kna1 TRANSPORTING color.
ENDIF.
All records with no TELF1 will be displayed in White and have a
Warning Icon
IF tbl_kna1-telf1 IS INITIAL.
tbl_kna1-color = 'C00'. "White
tbl_kna1-icon = '@AH@'. "Warning Icon
MODIFY tbl_kna1 TRANSPORTING icon color.
ENDIF.
ENDLOOP.
ENDFORM. " do_fancy_stuff[/code] -
How we can drill-down, sorting, traffic lights, in ALV report
hi gurus ,
how we can drill-down, sorting, traffic lights, in ALV report .
please any one suggest that...
regards,
praveenCheck the sample code for drill-down, sorting, traffic lights, in ALV report.
REPORT YMS_COLOURALV NO STANDARD PAGE HEADING.
TYPE-POOLS: SLIS, ICON.
DATA: FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.
DATA: BEGIN OF IMARA OCCURS 0,
LIGHT(4) TYPE C,
MATNR TYPE MARA-MATNR,
MTART TYPE MARA-MTART,
MAKTX TYPE MAKT-MAKTX,
COLOR_LINE(4) TYPE C,
TCOLOR TYPE SLIS_T_SPECIALCOL_ALV, "cell
END OF IMARA.
DATA: XCOLOR TYPE SLIS_SPECIALCOL_ALV.
START-OF-SELECTION.
PERFORM GET_DATA.
PERFORM WRITE_REPORT.
FORM GET_DATA.
WRITE ICON_GREEN_LIGHT AS ICON TO IMARA-LIGHT.
IMARA-MATNR = 'ABC'.
IMARA-MTART = 'ZCFG'.
IMARA-MAKTX = 'This is description for ABC'.
APPEND IMARA.
WRITE ICON_YELLOW_LIGHT AS ICON TO IMARA-LIGHT.
IMARA-MATNR = 'DEF'.
IMARA-MTART = 'ZCFG'.
IMARA-MAKTX = 'This is description for DEF'.
APPEND IMARA.
WRITE ICON_RED_LIGHT AS ICON TO IMARA-LIGHT.
IMARA-MATNR = 'GHI'.
IMARA-MTART = 'ZCFG'.
IMARA-MAKTX = 'This is description for GHI'.
APPEND IMARA.
LOOP AT IMARA.
IF SY-TABIX = 1.
IMARA-COLOR_LINE = 'C410'. " color line
ENDIF.
IF SY-TABIX = 2. " color CELL
CLEAR XCOLOR.
XCOLOR-FIELDNAME = 'MTART'.
XCOLOR-COLOR-COL = '3'.
XCOLOR-COLOR-INT = '1'. " Intensified on/off
XCOLOR-COLOR-INV = '0'.
APPEND XCOLOR TO IMARA-TCOLOR.
ENDIF.
MODIFY IMARA.
ENDLOOP.
ENDFORM. "get_data
FORM WRITE_REPORT.
DATA: LAYOUT TYPE SLIS_LAYOUT_ALV.
LAYOUT-COLTAB_FIELDNAME = 'TCOLOR'.
LAYOUT-INFO_FIELDNAME = 'COLOR_LINE'.
PERFORM BUILD_FIELD_CATALOG.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
IS_LAYOUT = LAYOUT
IT_FIELDCAT = FIELDCAT
TABLES
T_OUTTAB = IMARA.
ENDFORM. "write_report
FORM BUILD_FIELD_CATALOG.
DATA: FC_TMP TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE.
CLEAR: FIELDCAT. REFRESH: FIELDCAT.
CLEAR: FC_TMP.
FC_TMP-REPTEXT_DDIC = 'Status'.
FC_TMP-FIELDNAME = 'LIGHT'.
FC_TMP-TABNAME = 'IMARA'.
FC_TMP-OUTPUTLEN = '4'.
FC_TMP-ICON = 'X'.
APPEND FC_TMP TO FIELDCAT.
CLEAR: FC_TMP.
FC_TMP-REPTEXT_DDIC = 'Material Number'.
FC_TMP-FIELDNAME = 'MATNR'.
FC_TMP-TABNAME = 'IMARA'.
FC_TMP-OUTPUTLEN = '18'.
APPEND FC_TMP TO FIELDCAT.
CLEAR: FC_TMP.
FC_TMP-REPTEXT_DDIC = 'Material Type'.
FC_TMP-FIELDNAME = 'MTART'.
FC_TMP-TABNAME = 'IMARA'.
FC_TMP-OUTPUTLEN = '10'.
APPEND FC_TMP TO FIELDCAT.
CLEAR: FC_TMP.
FC_TMP-REPTEXT_DDIC = 'Material'.
FC_TMP-FIELDNAME = 'MAKTX'.
FC_TMP-TABNAME = 'IMARA'.
FC_TMP-OUTPUTLEN = '40'.
APPEND FC_TMP TO FIELDCAT.
ENDFORM. "build_field_catalog -
How to use drill down ability in ALV report.
Hi All,
I have a ALV report and now i want to add drill down functionality in this ALV report.
See the requirement below.
The Document Number, aka Accounting Document Number (BELNR) of each row will take the user to the appropriate document to edit as follows:
For Parked documents:-
If VBKPF-AWTYP (Reference Procedure) = RMRP, then the drilldown functionality should be to MIR4 using the Object ID in VBKPF- AWKEY. In this scenario the Object ID represents a Invoice Document Number, not an Accounting Document Number. Not the Object ID is a combination of Invoice Document Number and Fiscal Year
If VBKPF-AWTYP = Any other value, then the drilldown functionality should be to FBV2 using the Object ID in VBKPF-AWKEY. In this scenario the Object ID represents a true Accounting Document Number. Note the Object ID is a combination of Company Code (VBKPF-BUKRS), Accounting Document Number (VBKPF-BELNR) and Fiscal Year (VBKPF-GJAHR)
For Posted, not Cleared documents:-
Drilldown ability should be to FB02. The combination of Company Code (BSIK-BUKRS), Accounting Document Number (BSIK-BELNR) and Fiscal Year (BSIK-GJAHR) will be used to open/drilldown to the correct document in FB02.
For Cleared documents:-
Drilldown ability should be to FB03. The combination of Company Code (BSIK-BUKRS), Accounting Document Number (BSIK-BELNR) and Fiscal Year (BSIK-GJAHR) will be used to open/drilldown to the correct document in FB03.
Its very urgent, pls help on this.
Thanks!
VipinHi Vipin,
Please look at the reference code.
You need to use the FM 'REUSE_ALV_EVENTS_GET' and in the user command event u need to pass the name of the form that u need to write.
Please find the ollowing code:
REPORT ZSOURAVICON NO STANDARD PAGE HEADING.
type-pools: slis.
tables: vbap.
data: begin of itab occurs 0,
chk,
lights,
vbeln like vbap-vbeln,
posnr like vbap-posnr,
matnr like vbap-matnr,
kwmeng like vbap-kwmeng,
end of itab.
data: P_LIGNAM TYPE SLIS_FIELDNAME VALUE 'LIGHTS'.
data: v_repid like sy-repid.
data: t_fld type slis_t_fieldcat_alv,
ws_fld like t_fld with header line,
t_sort type slis_t_sortinfo_alv,
ws_sort like t_sort with header line,
ws_layout type slis_layout_alv,
t_event type slis_t_event,
ws_event like t_event with header line,
c_topup TYPE slis_t_listheader,
ws_topup like c_topup with header line.
constants: c_top type slis_formname value 'TOP_OF_PAGE',
c_pfs type slis_formname value 'PF_STATUS_SET',
c_ucomm type slis_formname value 'USER_COMMAND'.
initialization.
v_repid = sy-repid.
select vbeln posnr matnr kwmeng from vbap into corresponding fields of
table itab.
loop at itab.
if itab-kwmeng lt 500.
itab-lights = '2'.
elseif itab-kwmeng = 500.
itab-lights = '1'.
else.
itab-lights = '3'.
endif.
modify itab.
endloop.
HERE WE ARE POPULATING THE FIELD CATALOG
ws_fld-col_pos = '3'.
ws_fld-fieldname = 'VBELN'.
ws_fld-KEY = 'X'.
ws_fld-tabname = ITAB.
ws_fld-reptext_ddic = 'SALES DOC'.
append ws_fld to t_fld.
clear ws_fld.
ws_fld-col_pos = '4'.
ws_fld-fieldname = 'POSNR'.
ws_fld-tabname = 'ITAB'.
ws_fld-reptext_ddic = 'SALES ITEM'.
append ws_fld to t_fld.
clear ws_fld.
ws_fld-col_pos = '5'.
ws_fld-fieldname = 'MATNR'.
ws_fld-tabname = 'ITAB'.
ws_fld-reptext_ddic = 'MATERIAL NO'.
append ws_fld to t_fld.
clear ws_fld.
ws_fld-col_pos = '6'.
ws_fld-fieldname = 'KWMENG'.
ws_fld-tabname = 'ITAB'.
ws_fld-reptext_ddic = 'UNIT'.
ws_fld-do_sum = 'X'.
append ws_fld to t_fld.
clear ws_fld.
ws_sort-spos = '1'.
ws_sort-fieldname = 'MATNR'.
ws_sort-tabname = 'ITAB'.
ws_sort-subtot = 'X'.
append ws_sort to t_sort.
clear ws_sort.
ws_layout-zebra = 'X'.
ws_layout-detail_popup = 'X'.
ws_layout-f2code = '&ETA'.
ws_layout-totals_text(60) = 'TOTAL'.
ws_layout-subtotals_text(60) = 'SUB TOTAL'.
ws_layout-box_fieldname = 'CHK'.
ws_layout-lights_fieldname = P_LIGNAM.
ws_layout-box_tabname = ITAB.
ws_layout-edit = 'X'.
clear ws_event.
ws_event-name = c_top.
ws_event-form = c_top.
append ws_event to t_event.
ws_event-name = c_pfs.
ws_event-form = c_pfs.
append ws_event to t_event.
clear ws_event.
ws_event-name = c_ucomm.
ws_event-form = c_ucomm.
append ws_event to t_event.
clear ws_event.
CLEAR ws_topup.
ws_topup-typ = 'H'.
ws_topup-info = 'Purchase Order Report'.
APPEND ws_topup TO c_topup.
CLEAR ws_topup.
ws_topup-typ = 'H'.
ws_topup-info = 'An ALV Report '.
APPEND ws_topup TO c_topup.
ws_topup-TYP = 'S'.
ws_topup-KEY = 'CURRENT PROGRAM NAME:'.
ws_topup-INFO = v_repid.
APPEND ws_topup TO c_topup.
CLEAR ws_topup.
ws_topup-TYP = 'S'.
ws_topup-KEY = 'DATE:'.
write SY-DATUM to ws_topup-INFO.
APPEND ws_topup to c_topup.
CLEAR ws_topup.
ws_topup-TYP = 'S'.
ws_topup-KEY = 'TIME:'.
write SY-UZEIT to ws_topup-INFO.
APPEND ws_topup TO c_topup.
CLEAR ws_topup.
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 = ' '
I_STRUCTURE_NAME =
IS_LAYOUT = ws_layout
IT_FIELDCAT = t_fld
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT = t_sort
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = ' '
IS_VARIANT =
IT_EVENTS = t_event
IT_EVENT_EXIT =
IS_PRINT =
IS_REPREP_ID =
I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB = itab[]
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
FORM top_of_page *
FORM top_of_page.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = c_topup
I_LOGO = 'LOGO'
I_END_OF_LIST_GRID =
ENDFORM.
FORM PF_STATUS_SET *
--> RT_EXTAB *
FORM PF_STATUS_SET using rt_extab type slis_t_extab.
set pf-status 'STD'. "EXCLUDING RT_EXTAB.
set pf-status 'STANDARD'.
endform.
FORM user_command *
form USER_COMMAND using r_ucomm like sy-ucomm
rs_selfield type slis_selfield.
data: begin of itab_temp occurs 0,
VBELN LIKE VBAP-VBELN,
POSNR LIKE VBAP-POSNR,
MATNR LIKE VBAP-MATNR,
kwmeng like vbap-kwmeng,
end of itab_temp.
DATA: t_fld1 TYPE SLIS_T_FIELDCAT_ALV,
ws_fld1 LIKE t_fld1 WITH HEADER LINE.
case r_ucomm.
when 'SHOW'.
loop at itab where chk = 'X'.
move-corresponding itab to itab_temp.
append itab_temp.
clear itab.
endloop.
ws_fld1-col_pos = '1'.
ws_fld1-fieldname = 'VBELN'.
ws_fld1-tabname = ITAB_TEMP.
ws_fld1-reptext_ddic = 'SALES DOC'.
ws_fld1-key = 'X'.
append ws_fld1 to t_fld1.
clear ws_fld1.
ws_fld1-col_pos = '2'.
ws_fld1-fieldname = 'POSNR'.
ws_fld1-tabname = ITAB_TEMP.
ws_fld1-reptext_ddic = 'SALES ITEM'.
ws_fld1-key = ' '.
append ws_fld1 to t_fld1.
clear ws_fld1.
ws_fld1-col_pos = '3'.
ws_fld1-fieldname = 'MATNR'.
ws_fld1-tabname = ITAB_TEMP.
ws_fld1-reptext_ddic = 'MATERIAL NO'.
ws_fld1-key = ' '.
append ws_fld1 to t_fld1.
clear ws_fld1.
ws_fld1-col_pos = '4'.
ws_fld1-fieldname = 'KWMENG'.
ws_fld1-tabname = ITAB_TEMP.
ws_fld1-reptext_ddic = 'UNIT'.
ws_fld1-key = ' '.
ws_fld1-do_sum = 'X'.
append ws_fld1 to t_fld1.
CALL FUNCTION 'REUSE_ALV_POPUP_TO_SELECT'
EXPORTING
I_TITLE = 'my report'
I_SELECTION = ' '
I_ZEBRA = ' '
I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
I_CHECKBOX_FIELDNAME =
I_LINEMARK_FIELDNAME =
I_SCROLL_TO_SEL_LINE = 'X'
I_TABNAME = ITAB_TEMP
I_STRUCTURE_NAME = 'VBAP'
IT_FIELDCAT = t_fld1
IT_EXCLUDING =
I_CALLBACK_PROGRAM = v_repid
I_CALLBACK_USER_COMMAND =
IS_PRIVATE = GS_PRIVATE
IMPORTING
ES_SELFIELD = RS_SELFIELD
E_EXIT = G_EXIT
TABLES
T_OUTTAB = ITAB_TEMP[]
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.
endcase.
ENDFORM.
Thanks and Regards,
Saurabh -
How to get back to Selection Screen from Drill Down Screen in ALV
Hi All
How can I come back directly to the Selection Screen from the drill down screen of an ALV Report i.e. in an Interactive ALV Report when sy-lsind > 1.
Thanks
KulpreetTry to use ....
SET SCREEN 0.
LEAVE SCREEN.
Regards,
Rich Heilman -
Layout problem for Drill down ALV Report
Hello Everyone,
I have developed a ALV drill down report using the method G_GRID->SET_TABLE_FOR_FIRST_DISPLAY. The problem is what ever layout i save for the primary list 'Screen 100' is effecting my secondary list 'Screen 200'. User need to save both Screen 100 and Screen 200 layouts independently without affecting each other.
I am calling screen 100 as below,
Call metthod g_grid_100->set_table_for_first_display
Exporting
i_Save = 'A'
is_layout = ls_layout
is_Variant = ls_Variant
Changing
it_outtab = ct_poitems
it_fieldcatalog = lt_fieldcat
Exceptions
Invalid_parameter_combimation = 1
Program_error = 2
too_many_lines = 3
others = 4.
Could any body suggest me a way to do this..
Thanks in advance.
Regards,
Shyam.Hi,
Use multiple Layout structure (each alv have its own structure) .
Note the use of disvariant-log_group .
DATA: gs_disvariant_1 TYPE disvariant ,
gs_disvariant_2 TYPE disvariant .
* Layout-Logical groups
CONSTANTS: gc_log_group_1 TYPE disvariant-log_group VALUE 'ALV1' ,
gc_log_group_2 TYPE disvariant-log_group VALUE 'ALV2' .
INITIALIZATION.
PERFORM at_initialization .
FORM at_initialization .
DATA: vari TYPE disvariant-variant .
PERFORM alv_variant_get_default USING gc_log_group_1 CHANGING gs_disvariant_1 vari .
PERFORM alv_variant_get_default USING gc_log_group_2 CHANGING gs_disvariant_2 vari .
ENDFORM.
FORM alv_variant_get_default
USING
log_group TYPE disvariant-log_group
CHANGING
disvariant TYPE disvariant
variant TYPE slis_vari .
DATA: ls_disvariant TYPE disvariant.
ls_disvariant-report = sy-repid .
ls_disvariant-log_group = log_group .
disvariant = ls_disvariant.
CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'
EXPORTING
i_save = 'A'
CHANGING
cs_variant = ls_disvariant
EXCEPTIONS
not_found = 2.
IF sy-subrc = 0.
disvariant = ls_disvariant.
variant = ls_disvariant-variant .
ENDIF.
ENDFORM. "alv_variant_get_default
Later....
CALL METHOD gui_alv_grid_1->set_table_for_first_display
EXPORTING
is_layout = wa_layout
is_print = wa_print
i_save = 'A'
is_variant = gs_disvariant_1
CHANGING
it_sort = it_sort
it_fieldcatalog = it_fieldcatalog
it_outtab = it_alv_grid_1.
CALL METHOD gui_alv_grid_2->set_table_for_first_display
EXPORTING
is_layout = wa_layout
is_print = wa_print
i_save = 'A'
is_variant = gs_disvariant_2
CHANGING
it_sort = it_sort
it_fieldcatalog = it_fieldcatalog
it_outtab = it_alv_grid_2.
Regards. -
Drill Down facility in ALV Report
Hi Guys,
I want to provide Drill down facility based on columns in ALV Report (ALV Web Dynpro Report). Please let me know if you have any sample code or guidelines for this.
Thanks,
PradeepHi,
Pls refer to the example provded by SAP -
WDT_ALV
Pls refer to this link -
Learning what you don't need is as important as learning what you do (Parts 10b-c) of "Event-Driven" Tutorial on WDR_TEST_UI_ELEMENTS) and https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/db22242d-0701-0010-28a2-aeaa1fefd706.
Reward if helpful.
Best Wishes,
Chandralekha
Maybe you are looking for
-
Fact sheet link in transaction cic0 and crmd_order_bp
Hello, I have created new Fact Sheet view, which display some products with links to it's detail by a sapevent. This link works in transaction cic0, but not in business partner cockpit. Is there any difference, how to create links for there applicati
-
How to center text in column matrix?
Hi, i need your help please ... I need center numbers in column matrix! Could someone show me an example, please?
-
Our company moved from on-premises Exchange 2003 to Office365 and only have 4 Exchange 2003 servers on-prem that we use for Routing email from application servers to Office365. We need to migrate these servers to Exchange 2010 then to Exchange 2013 a
-
How can I find the servlet class name from inside a ServletFilter?
Ive implemented a servlet filter, but need to discover the class name of any servlet class that gets executed. Ive dug through the spec and cant seem to find any path to do this. Seems the methods needed to do this have been deprecated. (for security
-
Validation Failed. Creation Web Service Proxy
Hi, all I've got a problem with JDeveloper 10.1.3 when I try to create a web serviceproxy using the wizard. My service class is next, package swa; import java.awt.Graphics; import java.awt.Image; import java.awt.Toolkit; import java.awt.color.ColorSp