2006 Jul 07 6:32 AM
Hi.
I have a specific requirement in my report.
When user selects Customer field(KUNNR) in the list display and presses "Show line item" button on application tool bar it should display the line item details of that specific customer.
Presently when pressing the button it displays for all the customer.
Pls suggest me how to approach.
Simran
2006 Jul 07 6:34 AM
Hi simran,
1. We can detect, which row the user has clicked
, in the call back form routine.
2. just copy paste to get a taste of it.
3. Important code is in bold.
4.
REPORT abc.
TYPE-POOLS : slis.
*----
Data
DATA : BEGIN OF itab OCCURS 0.
INCLUDE STRUCTURE t001.
DATA : flag tyPE c,
END OF itab.
DATA : alvfc TYPE slis_t_fieldcat_alv.
DATA : alvly TYPE slis_layout_alv.
*----
Select Data
SELECT * FROM t001 INTO TABLE itab.
*------- Field Catalogue
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = sy-repid
i_internal_tabname = 'ITAB'
i_inclname = sy-repid
CHANGING
ct_fieldcat = alvfc
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
*----
Display
alvly-box_fieldname = 'FLAG'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
it_fieldcat = alvfc
i_callback_program = sy-repid "<-------Important
i_callback_user_command = 'ITAB_USER_COMMAND' "<------ Important
is_layout = alvly
TABLES
t_outtab = itab
EXCEPTIONS
program_error = 1
OTHERS = 2.
*----
CALL BACK FORM
*----
FORM itab_user_command USING whatcomm TYPE sy-ucomm whatrow TYPE
slis_selfield.
*----
IMPORTANT.
data : m(100) type c.
<b> m = whatrow-tabindex.</b>
condense m.
concatenate 'Row Number is ' m into m separated by space.
concatenate m ' : Field Clicked is ' whatrow-fieldname into m separated
by space.
message m type 'I'.
ENDFORM. "ITAB_user_command
regards,
amit m.
Hi.
I have a specific requirement in my report.
When user selects Customer field(KUNNR) in the list display and presses "Show line item" button on application tool bar it should display the line item details of that specific customer.
Presently when pressing the button it displays for all the customer.
Pls suggest me how to approach.
Simran
2006 Jul 07 6:34 AM
Hi simran,
1. We can detect, which row the user has clicked
, in the call back form routine.
2. just copy paste to get a taste of it.
3. Important code is in bold.
4.
REPORT abc.
TYPE-POOLS : slis.
*----
Data
DATA : BEGIN OF itab OCCURS 0.
INCLUDE STRUCTURE t001.
DATA : flag tyPE c,
END OF itab.
DATA : alvfc TYPE slis_t_fieldcat_alv.
DATA : alvly TYPE slis_layout_alv.
*----
Select Data
SELECT * FROM t001 INTO TABLE itab.
*------- Field Catalogue
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = sy-repid
i_internal_tabname = 'ITAB'
i_inclname = sy-repid
CHANGING
ct_fieldcat = alvfc
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
*----
Display
alvly-box_fieldname = 'FLAG'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
it_fieldcat = alvfc
i_callback_program = sy-repid "<-------Important
i_callback_user_command = 'ITAB_USER_COMMAND' "<------ Important
is_layout = alvly
TABLES
t_outtab = itab
EXCEPTIONS
program_error = 1
OTHERS = 2.
*----
CALL BACK FORM
*----
FORM itab_user_command USING whatcomm TYPE sy-ucomm whatrow TYPE
slis_selfield.
*----
IMPORTANT.
data : m(100) type c.
<b> m = whatrow-tabindex.</b>
condense m.
concatenate 'Row Number is ' m into m separated by space.
concatenate m ' : Field Clicked is ' whatrow-fieldname into m separated
by space.
message m type 'I'.
ENDFORM. "ITAB_user_command
regards,
amit m.
2006 Jul 07 6:37 AM
Hi Amit.
Further to this will it work for list display as well as i can see the FM used is for grid display.
my requirement is list display.
Simran
2006 Jul 07 6:54 AM
Hi again,
1. Absolutely.
2. Just change the FM name,
TO REUSE_ALV_LIST_DISPLAY
(instead of REUSE_ALV_GRID_DISPLAY )
3. Note : Give in CAPITAL Letter.
regards,
amit m.
2006 Jul 07 7:39 AM
Hi Amit.
I tried with your suggested code.But the problem is it only executes the first row irrespective of the row you select.
Can you help on this.
Also the Information message is displaying only the text "Row number" and not the value with it.
Simran
2006 Jul 07 7:49 AM
Hi again,
1. To get ALL ROWS selected/ticked
by the user,
we need to LOOP at ITAB,
and check the FLAG field for 'X'.
2. just copy paste
(it will give MESSAGE for ALL ROWS selected/ticked,
along with row number, and field value)
(same program, only the call back form routine,
is slightly modified)
3.
REPORT abc.
TYPE-POOLS : slis.
*----
Data
DATA : BEGIN OF itab OCCURS 0.
INCLUDE STRUCTURE t001.
DATA : flag tyPE c,
END OF itab.
DATA : alvfc TYPE slis_t_fieldcat_alv.
DATA : alvly TYPE slis_layout_alv.
*----
Select Data
SELECT * FROM t001 INTO TABLE itab.
*------- Field Catalogue
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = sy-repid
i_internal_tabname = 'ITAB'
i_inclname = sy-repid
CHANGING
ct_fieldcat = alvfc
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
*----
Display
alvly-box_fieldname = 'FLAG'.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
it_fieldcat = alvfc
i_callback_program = sy-repid "<-------Important
i_callback_user_command = 'ITAB_USER_COMMAND' "<------ Important
is_layout = alvly
TABLES
t_outtab = itab
EXCEPTIONS
program_error = 1
OTHERS = 2.
*----
CALL BACK FORM
*----
FORM itab_user_command USING whatcomm TYPE sy-ucomm whatrow TYPE
slis_selfield.
DATA : TABIX TYPE SY-TABIX.
DATA : S(10) TYPE C.
DATA : M(100) TYPE C.
*----
IMPORTANT.
LOOP AT ITAB.
TABIX = SY-TABIX.
S = TABIX.
IF ITAB-FLAG = 'X'.
CONCATENATE 'ROW NUMBER IS ' S INTO M.
CONCATENATE M ' BUTXT IS ' ITAB-BUTXT INTO M
SEPARATED BY SPACE.
MESSAGE M TYPE 'I'.
ENDIF.
ENDLOOP.
ENDFORM. "ITAB_user_command
regards,
amit m.
2006 Jul 07 6:35 AM
Simran,
How are you selecting the row, do you have a check box which the user selects. IF yes, then you should loop at the internal table and pick only those rows where the check box field is set to X. Then you can get the details pertaining to that customer and display.
Regards,
Ravi
Note : Please mark all the helpful answers
2006 Jul 07 7:11 AM
hi,
as per ur requirement u can do it by doing double click in that perticular cell. or if u r using alv grid display.
do line selection and then find out that perticular field in that record.
this code can help u :
FORM usercommand USING r_ucomm LIKE sy-ucomm rs_selfield TYPE
slis_selfield.
CASE r_ucomm.
WHEN '&IC1'.
tabindex = rs_selfield-tabindex.
DATA matno LIKE t_mseg-matnr.
READ TABLE t_mseg INDEX tabindex.
matno = t_mseg-matnr.
here i'm selecting the data according to material no.
" &IC1 is the func. code for double click."
hope this can help u.
2006 Jul 07 7:56 AM
Hi.
I tried with your suggested code.
Its giving syntax error:
Field "TABINDEX" unknown.
2006 Jul 07 8:01 AM
Hi again,
1. I tried same, but its not giving any error.
2. just copy paste this WHOLE Program,
in a new program.
3.
REPORT abc.
TYPE-POOLS : slis.
*----
Data
DATA : BEGIN OF itab OCCURS 0.
INCLUDE STRUCTURE t001.
DATA : flag tyPE c,
END OF itab.
DATA : alvfc TYPE slis_t_fieldcat_alv.
DATA : alvly TYPE slis_layout_alv.
*----
Select Data
SELECT * FROM t001 INTO TABLE itab.
*------- Field Catalogue
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = sy-repid
i_internal_tabname = 'ITAB'
i_inclname = sy-repid
CHANGING
ct_fieldcat = alvfc
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
*----
Display
alvly-box_fieldname = 'FLAG'.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
it_fieldcat = alvfc
i_callback_program = sy-repid "<-------Important
i_callback_user_command = 'ITAB_USER_COMMAND' "<------ Important
is_layout = alvly
TABLES
t_outtab = itab
EXCEPTIONS
program_error = 1
OTHERS = 2.
*----
CALL BACK FORM
*----
FORM itab_user_command USING whatcomm TYPE sy-ucomm whatrow TYPE
slis_selfield.
DATA : TABIX TYPE SY-TABIX.
DATA : S(10) TYPE C.
DATA : M(100) TYPE C.
*----
IMPORTANT.
LOOP AT ITAB.
TABIX = SY-TABIX.
S = TABIX.
IF ITAB-FLAG = 'X'.
CONCATENATE 'ROW NUMBER IS ' S INTO M.
CONCATENATE M ' BUTXT IS ' ITAB-BUTXT INTO M
SEPARATED BY SPACE.
MESSAGE M TYPE 'I'.
ENDIF.
ENDLOOP.
ENDFORM. "ITAB_user_command
regards,
amit m.
2006 Jul 07 8:28 AM
Hi.
I have an existing program and needs to add the functionality.Just sending you the code to have an better idea.
*&----
*& Form sub_ALV_DISPLAY
*&----
text
*----
-->P_ITAB_FCAT = field catalog
-->P_ITAB_data = Output table for display
*----
FORM sub_alv_display
TABLES p_itab_data
USING p_itab_fcat .
DATA: l_layout TYPE slis_layout_alv. "ALV Layout Struc
To optimize the column width so that all contents are displayed
l_layout-colwidth_optimize = 'X'.
To display the selection information
l_layout-get_selinfos = 'X'.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE = ' '
i_callback_program = v_repid
i_callback_pf_status_set = 'SUB_PFSTATUS'
i_callback_user_command = 'SUB_USERCOMM'
I_STRUCTURE_NAME =
is_layout = l_layout
it_fieldcat = p_itab_fcat
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
it_sort = itab_sort
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
i_save = 'A'
IS_VARIANT = wa_variant
it_events = itab_events
IT_EVENT_EXIT =
IS_PRINT =
IS_REPREP_ID =
I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
t_outtab = p_itab_data
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. " sub_ALV_DISPLAY
*&----
*& Form sub_usercomm
*&----
User command used in the custom PF status
*----
FORM sub_usercomm USING p_ucomm LIKE sy-ucomm
p_rs TYPE slis_selfield .
CASE p_ucomm.
WHEN c_cninv.
Count of invoices
PERFORM sub_disply_invoices.
WHEN c_item.
PERFORM sub_display_data.
WHEN c_exit.
LEAVE PROGRAM.
ENDCASE.
ENDFORM. " sub_usercomm
Note:
c_item is the line item button on app t/bar which user needs to press after selecting a particular field row.
I have to deliver it urgently,otherwise would'nt have bothered you so much.
Simran
2006 Jul 07 8:32 AM
Hi again,
1.
WHEN c_item.
PERFORM sub_display_data.
2. write the below code there itself,
(instead of the line
PERFORM sub_display_data.
)
(other wise the variablles passed in the callback form,
won't be available in your subrutine of display data)
(or else, u can once again pass those variables to your routine also)
3.
DATA : TABIX TYPE SY-TABIX.
DATA : S(10) TYPE C.
DATA : M(100) TYPE C.
*----
IMPORTANT.
LOOP AT ITAB.
TABIX = SY-TABIX.
S = TABIX.
IF ITAB-FLAG = 'X'.
CONCATENATE 'ROW NUMBER IS ' S INTO M.
CONCATENATE M ' BUTXT IS ' ITAB-BUTXT INTO M
SEPARATED BY SPACE.
MESSAGE M TYPE 'I'.
ENDIF.
ENDLOOP.
regards,
amit m.
2006 Jul 07 9:23 AM
Hi again,
In my case what should be ITAB-FLAG
and what is the following statement for?
To display the selection information
l_layout-get_selinfos = 'X'.
Chao!
Simran
2006 Jul 07 9:29 AM
Hi again,
1. In my case what should be ITAB-FLAG
and what is the following statement for?
ITAB = name of your internal table
FLAG = the EXTRA 1 CHAR field,
which is added to the internal table
(for the purpose of displaying/detecting
the checkboxes)
2. I_layout-get_selinfos = 'X'.
to see what selection criteria the user entered
This info will then appear when the report is printed
regards,
amit m.
2006 Jul 07 9:45 AM
Hi amit
I have added flag field into the internal table and tried executing the report.However,if i am commenting the subroutine sub_display_data,then list is not getting displayed when i click the "show line item" button.
When i am uncommenting the same it works fine but with the same result where i get details of all the customer.
Another thing is i dont have any check box to select the field however i do have a pushbutton at the app t/bar to do the same function (i guess)
If u require any specific data from my end to help me out pls feel free to ask so.
Hope it gets resolved today.
Simran
2006 Jul 07 9:52 AM
Hi again,
1. Its difficult to analyse
without the original code.
regards,
amit m.
2006 Jul 07 10:31 AM
Hi.
I am sending you the original code for reference.
REPORT z_custvol NO STANDARD PAGE HEADING
LINE-SIZE 255
LINE-COUNT 65
MESSAGE-ID z_abap_development.
include
INCLUDE zif_routines.
Type Pools
TYPE-POOLS: slis,rsds,kkblo.
Constants
CONSTANTS: c_tax(1) TYPE c VALUE 'T'," Tag for tax item
c_pfstatus TYPE sypfkey VALUE 'STAT', " Pf status
c_cninv(4) TYPE c VALUE 'INCN', " OkCode for Count
c_item(4) TYPE c VALUE 'ITEM', " Line item
c_exit(4) TYPE c VALUE 'XIIT', " Exit
c_koart(1) TYPE c VALUE 'D', " Account type
c_checked(1) TYPE c VALUE 'X'," check
*Start of changes for CR_3
c_colp(4) TYPE c VALUE 'COLP', " collapse
c_xpnd(4) TYPE c VALUE 'XPND', " expand
*End of changes for CR_3
c_cr(1) TYPE c VALUE 'H'. " Credit
Tables
TABLES: t001 , " Company Codes
knb1 ," customer master
bkpf , " Document Header
bseg. " Line Item
Internal table types
Internal table type for Final data with line item
TYPES:BEGIN OF ty_data,
bukrs TYPE bukrs, " Company Code
kunnr TYPE kunnr, " Customer
blart TYPE blart, " Document Type
belnr TYPE belnr_d, " Document No.
gjahr TYPE gjahr, " Fiscal Year
xblnr TYPE xblnr1, " Reference Doc.
budat TYPE budat, " Posting Date
bldat TYPE bldat, " Doument Date
hkont TYPE hkont, " Account
kostl TYPE kostl, " Cost Center
prctr TYPE prctr, " Profit Center
aufnr TYPE aufnr, " Order
hwaer TYPE hwaer, " Local Currency
dmbtr TYPE dmbtr, " Amount in LC
waers TYPE waers, " doc Currency
wrbtr TYPE wrbtr, " Amount
sgtxt TYPE sgtxt, " Item text
name TYPE name1_gp," Customer name
flag TYPE c, " Marked field
END OF ty_data.
Internal table type for Count of Invoices
TYPES:BEGIN OF ty_cinv,
bukrs(4) TYPE c, " Company code
kunnr LIKE bseg-kunnr," customer no.
cinv TYPE i, " Count of invoices
dmbtr TYPE dmbtr, " amount in lc
name TYPE name1_gp, " Customer name
END OF ty_cinv.
Internal table type for bkpf data
TYPES:BEGIN OF ty_bkpf,
bukrs TYPE bukrs, " Company code
belnr TYPE belnr_d," Doc. No.
gjahr TYPE gjahr, " Fiscal year
blart TYPE blart, " Doc Type
bldat TYPE bldat, " Document date
budat TYPE budat, " Posting date
xblnr TYPE xblnr1, " Ref. Doc. No.
waers TYPE waers, " Currency key
hwaer TYPE hwaer, " Local currency
monat TYPE monat, " fiscal period
stblg TYPE stblg, " reve doc
END OF ty_bkpf.
Internal table type for bseg data
TYPES:BEGIN OF ty_bseg,
bukrs TYPE bukrs, " Company code
kunnr TYPE kunnr, " Customer no.
belnr TYPE belnr_d," Doc. No.
gjahr TYPE gjahr, " Fiscal year
buzei TYPE buzei, " Line item no.
buzid TYPE buzid, " Id of the line item
bschl TYPE bschl, " Posting key
koart TYPE koart, " Account Type
gsber TYPE gsber, " Business area
dmbtr TYPE dmbtr, " Amount in local curr
wrbtr TYPE wrbtr, " Amount
hkont TYPE hkont, " GL Account
kostl TYPE kostl, " Cost center
prctr TYPE prctr, " Profit center
aufnr TYPE aufnr, " Interlnal order
sgtxt TYPE sgtxt, " Item text
shkzg TYPE shkzg, " Dr/Cr type
umskz TYPE umskz, " gl ind
xzahl TYPE xzahl, " Ind
END OF ty_bseg.
Interal table type for customer
TYPES: BEGIN OF ty_kunnr,
kunnr TYPE kunnr , "customer
name TYPE name1_gp , "customer name
END OF ty_kunnr.
Internal table and work areas
Interal table for customer
DATA: wa_kunnr TYPE ty_kunnr.
DATA: itab_kunnr TYPE TABLE OF ty_kunnr INITIAL SIZE 0.
Internal table type for Final data with line item
DATA: itab_data TYPE TABLE OF ty_data INITIAL SIZE 0 .
DATA: wa_data TYPE ty_data.
Internal Tables for BKPF and BSEG
DATA: itab_bkpf TYPE TABLE OF ty_bkpf INITIAL SIZE 0,
itab_bseg_tmp TYPE TABLE OF ty_bseg INITIAL SIZE 0,
itab_bseg_final TYPE TABLE OF ty_bseg INITIAL SIZE 0.
Internal table for no. of invoices coumpany/customer wise
DATA: itab_cinv TYPE TABLE OF ty_cinv INITIAL SIZE 0.
Internal Tables for Basic list displaying
DATA: itab_fieldcat TYPE slis_t_fieldcat_alv, " For Field Catalog
itab_fcat_inv TYPE slis_t_fieldcat_alv, " For Field Catalog
itab_events TYPE slis_t_event, " For Events
itab_sort TYPE slis_t_sortinfo_alv.
Work Areas for BKPF amd BSEG
DATA: wa_bkpf TYPE ty_bkpf, " Work area for itab_bkpf
wa_bseg_final TYPE ty_bseg. " Work area for itab_bseg_final
Work area for no. of invoices
DATA: wa_cinv TYPE ty_cinv.
Global variables
DATA: v_repid TYPE sycprog, " Report Id
v_title TYPE sytitle. " Program title
*Start of changes for CR_3
DATA: kunnr TYPE kna1-kunnr.
DATA: g_tabname TYPE kkblo_tabname.
DATA: g_row LIKE sy-curow.
DATA: g_reserve TYPE i.
DATA: g_sumline LIKE sy-tabix.
DATA: g_endsum(1) TYPE c.
*End of changes for CR_3
Selection screen declaration
selections for Customer and company:
SELECTION-SCREEN BEGIN OF BLOCK bl1 WITH FRAME TITLE text-001.
SELECT-OPTIONS: s_bukrs FOR t001-bukrs OBLIGATORY. " Company Code
SELECT-OPTIONS: s_kunnr FOR knb1-kunnr. " customer
SELECT-OPTIONS: s_gjahr FOR bkpf-gjahr OBLIGATORY. " Fiscal year
SELECT-OPTIONS: s_monat FOR bkpf-monat OBLIGATORY. " Fiscal period
SELECTION-SCREEN END OF BLOCK bl1.
selections for Customer and company:
SELECTION-SCREEN BEGIN OF BLOCK bl2 WITH FRAME TITLE text-023.
SELECT-OPTIONS: s_budat FOR bkpf-budat. " Posting Date
SELECT-OPTIONS: s_hkont FOR bseg-hkont. " Account
*Start of changes for CR_3
SELECT-OPTIONS: s_waers FOR bkpf-waers. " Currency
*End of changes for CR_3
SELECT-OPTIONS: s_xblnr FOR bkpf-xblnr. " Reference Doc.
SELECT-OPTIONS: s_bschl FOR bseg-bschl. " Posting key
SELECT-OPTIONS: s_umskz FOR bseg-umskz. " Spl GL ind
*Start of changes for CR_3
SELECTION-SCREEN: SKIP .
PARAMETERS: p_stblg AS CHECKBOX DEFAULT space. " Reversed doc
SELECTION-SCREEN: SKIP .
*End of changes for CR_3
SELECTION-SCREEN END OF BLOCK bl2.
Initialization
INITIALIZATION.
v_repid = sy-repid.
PERFORM sub_splglind_default.
Start-of-selection
START-OF-SELECTION.
Select the data from bkpf and bseg and store into the internal table
PERFORM sub_select_bkpf_bseg.
select customer
PERFORM sub_customer.
Store the data into the final internal table.
IF NOT itab_bseg_final[] IS INITIAL.
PERFORM sub_final_data.
ENDIF.
End-of-selection
END-OF-SELECTION.
Build field catalog , build event , display report
PERFORM sub_disply_invoices.
*& Form sub_select_bkpf_bseg
Select the document headers into itab_bkpf
Select the items into itab_bseg
FORM sub_select_bkpf_bseg .
SELECT bukrs " Company code
belnr " Doc. No.
gjahr " Fiscal year
blart " Doc Type
bldat " Document date
budat " Posting date
xblnr " Ref. Doc. No.
waers " Currency key
hwaer " Local curr
monat " fiscal period
stblg " rev doc
INTO TABLE itab_bkpf
FROM bkpf
WHERE bukrs IN s_bukrs
AND gjahr IN s_gjahr
AND monat IN s_monat.
IF sy-subrc EQ 0.
IF NOT s_budat IS INITIAL.
DELETE itab_bkpf[] WHERE budat NOT IN s_budat.
ENDIF.
IF NOT s_xblnr IS INITIAL.
DELETE itab_bkpf[] WHERE xblnr NOT IN s_xblnr.
ENDIF.
*Start of changes for CR_3
DELETE itab_bkpf[] WHERE stblg NE ''.
IF p_stblg NE c_checked.
DELETE itab_bkpf[] WHERE stblg NE ''.
ENDIF.
*End of changes for CR_3
SORT itab_bkpf BY bukrs " Company code
belnr " Doc. No.
gjahr." Fiscal year
IF NOT itab_bkpf[] IS INITIAL.
SELECT bukrs " Company code
kunnr " Customer no.
belnr " Doc. No.
gjahr " Fiscal year
buzei " Line item no.
buzid " Id of the line item
bschl " Posting key
koart " Account Type
gsber " Business area
dmbtr " Amount in local curr
wrbtr " Amount
hkont " GL Account
kostl " Cost center
prctr " Profit center
aufnr " Interlnal order
sgtxt " Item text
shkzg " dr/cr type
umskz " gl ind
xzahl " Ind
INTO TABLE itab_bseg_final
FROM bseg
FOR ALL ENTRIES IN itab_bkpf
WHERE bukrs = itab_bkpf-bukrs
AND belnr = itab_bkpf-belnr
AND gjahr = itab_bkpf-gjahr
AND buzei = '1'.
IF sy-subrc EQ 0.
DELETE itab_bseg_final WHERE koart NE c_koart.
DELETE itab_bseg_final WHERE xzahl NE ''.
IF NOT s_bschl IS INITIAL.
DELETE itab_bseg_final
WHERE bschl NOT IN s_bschl.
ENDIF.
IF NOT s_umskz IS INITIAL.
DELETE itab_bseg_final
WHERE umskz NOT IN s_umskz.
ENDIF.
IF NOT s_hkont IS INITIAL.
DELETE itab_bseg_final
WHERE hkont NOT IN s_hkont.
ENDIF.
IF NOT s_kunnr IS INITIAL.
DELETE itab_bseg_final
WHERE kunnr NOT IN s_kunnr.
ENDIF.
SORT itab_bseg_final BY bukrs kunnr.
ENDIF.
ENDIF.
ENDIF.
ENDFORM. " sub_select_bkpf_seg
&----
*& Form sub_final_data
&----
Store the data into the final internal table
----
FORM sub_final_data .
DATA: l_cinv TYPE i VALUE 0, "Counter
l_dmbtr TYPE dmbtr VALUE 0. "Amount
Populate the final table with bkpf and bseg data
LOOP AT itab_bseg_final INTO wa_bseg_final.
IF wa_bseg_final-shkzg = c_cr.
wa_bseg_final-dmbtr = -1 * wa_bseg_final-dmbtr.
wa_bseg_final-wrbtr = -1 * wa_bseg_final-wrbtr.
ENDIF.
wa_data-bukrs = wa_bseg_final-bukrs.
wa_data-kunnr = wa_bseg_final-kunnr.
wa_data-belnr = wa_bseg_final-belnr.
wa_data-gjahr = wa_bseg_final-gjahr.
wa_data-hkont = wa_bseg_final-hkont.
wa_data-kostl = wa_bseg_final-kostl.
wa_data-prctr = wa_bseg_final-prctr.
wa_data-aufnr = wa_bseg_final-aufnr.
wa_data-dmbtr = wa_bseg_final-dmbtr.
wa_data-wrbtr = wa_bseg_final-wrbtr.
wa_data-sgtxt = wa_bseg_final-sgtxt.
READ TABLE itab_bkpf INTO wa_bkpf
WITH KEY bukrs = wa_bseg_final-bukrs
belnr = wa_bseg_final-belnr
gjahr = wa_bseg_final-gjahr
BINARY SEARCH .
IF sy-subrc EQ 0.
wa_data-blart = wa_bkpf-blart.
wa_data-xblnr = wa_bkpf-xblnr.
wa_data-budat = wa_bkpf-budat.
wa_data-bldat = wa_bkpf-bldat.
wa_data-waers = wa_bkpf-waers.
wa_data-hwaer = wa_bkpf-hwaer.
READ TABLE itab_kunnr INTO wa_kunnr
WITH KEY kunnr = wa_bseg_final-kunnr
BINARY SEARCH .
IF sy-subrc EQ 0.
wa_data-name = wa_kunnr-name.
CLEAR wa_kunnr.
ENDIF.
APPEND wa_data TO itab_data.
ENDIF.
Count of invoices
l_cinv = l_cinv + 1.
l_dmbtr = l_dmbtr + wa_bseg_final-dmbtr.
AT END OF kunnr.
PERFORM sub_count_invoices USING l_cinv l_dmbtr .
CLEAR: l_cinv , l_dmbtr.
ENDAT.
CLEAR: wa_data , wa_bseg_final .
ENDLOOP.
SORT itab_data BY bukrs " Company code
kunnr." customer.
SORT itab_cinv BY bukrs " Company code
kunnr." customer.
ENDFORM. " sub_final_data
*& Form sub_count_invoices
Company/Customer wise count of invoices
FORM sub_count_invoices USING p_cinv p_dmbtr.
wa_cinv-name = wa_data-name.
wa_cinv-bukrs = wa_data-bukrs.
wa_cinv-kunnr = wa_data-kunnr.
wa_cinv-cinv = p_cinv.
wa_cinv-dmbtr = p_dmbtr.
APPEND wa_cinv TO itab_cinv.
CLEAR wa_cinv.
ENDFORM. " sub_count_invoices
*& Form sub_display_data
Buiid field catalog , build event , display report
FORM sub_display_data .
create field catalog from dictionary structure.
PERFORM sub_field_catalog.
Build event
PERFORM sub_build_alv_event_tab.
display report
PERFORM sub_display_report.
ENDFORM. " sub_display_data
*& Form sub_field_catalog
create field catalog from dictionary structure.
FORM sub_field_catalog .
REFRESH itab_fieldcat.
PERFORM sub_populate_fldcat TABLES itab_fieldcat
USING 1
'BUKRS'
text-003
12
space.
PERFORM sub_populate_fldcat TABLES itab_fieldcat
USING 2
'KUNNR'
text-004
10
space.
PERFORM sub_populate_fldcat TABLES itab_fieldcat
USING 3
'NAME'
text-020
35
space.
PERFORM sub_populate_fldcat TABLES itab_fieldcat
USING 4
'BLART'
text-005
10
space.
PERFORM sub_populate_fldcat TABLES itab_fieldcat
USING 5
'BELNR'
text-006
12
space.
PERFORM sub_populate_fldcat TABLES itab_fieldcat
USING 6
'GJAHR'
text-007
4
space.
PERFORM sub_populate_fldcat TABLES itab_fieldcat
USING 7
'XBLNR'
text-008
10
space.
PERFORM sub_populate_fldcat TABLES itab_fieldcat
USING 8
'BUDAT'
text-009
10
space.
PERFORM sub_populate_fldcat TABLES itab_fieldcat
USING 9
'BLDAT'
text-010
10
space.
PERFORM sub_populate_fldcat TABLES itab_fieldcat
USING 10
'HKONT'
text-011
10
space.
PERFORM sub_populate_fldcat TABLES itab_fieldcat
USING 11
'KOSTL'
text-012
10
space.
PERFORM sub_populate_fldcat TABLES itab_fieldcat
USING 12
'PRCTR'
text-013
15
space.
PERFORM sub_populate_fldcat TABLES itab_fieldcat
USING 13
'AUFNR'
text-014
10
space.
PERFORM sub_populate_fldcat TABLES itab_fieldcat
USING 14
'HWAER'
text-015
5
space.
PERFORM sub_populate_fldcat TABLES itab_fieldcat
USING 15
'DMBTR'
text-016
16
c_checked.
PERFORM sub_populate_fldcat TABLES itab_fieldcat
USING 16
'WAERS'
text-017
8
space.
PERFORM sub_populate_fldcat TABLES itab_fieldcat
USING 17
'WRBTR'
text-018
16
c_checked.
PERFORM sub_populate_fldcat TABLES itab_fieldcat
USING 18
'SGTXT'
text-019
20
space.
ENDFORM. " sub_field_catalog
*& Form sub_display_report
Display report
FORM sub_display_report .
DATA: l_sort TYPE slis_sortinfo_alv. " alv sort table
SORT itab_data BY bukrs
kunnr
belnr.
REFRESH itab_sort.
l_sort-fieldname = 'BUKRS'.
l_sort-up = 'X'.
l_sort-subtot = 'X'.
*
APPEND l_sort TO itab_sort.
CLEAR l_sort.
l_sort-fieldname = 'KUNNR'.
l_sort-up = 'X'.
l_sort-subtot = 'X'.
*
APPEND l_sort TO itab_sort.
CLEAR l_sort.
*Start of changes for CR_3
l_sort-fieldname = 'WAERS'.
l_sort-up = 'X'.
l_sort-subtot = 'X'.
*
APPEND l_sort TO itab_sort.
CLEAR l_sort.
*End of changes for CR_3
ALV list display
PERFORM sub_alv_display TABLES itab_data
USING itab_fieldcat
.
ENDFORM. " sub_display_report
*& Form sub_pfstatus
Set PF Status
FORM sub_pfstatus USING p_itab_extab TYPE slis_t_extab.
SET PF-STATUS c_pfstatus.
ENDFORM. " sub_pfstatus
*& Form sub_usercomm
User command used in the custom PF status
FORM sub_usercomm USING p_ucomm LIKE sy-ucomm
p_rs TYPE slis_selfield .
*Start of changes
DATA: l_row(10) TYPE c.
CASE p_ucomm.
WHEN c_cninv.
Count of invoices
PERFORM sub_disply_invoices.
WHEN c_item.
PERFORM sub_display_data.
WHEN c_exit.
LEAVE PROGRAM.
ENDCASE.
ENDFORM. " sub_usercomm
*&----
*& Form sub_disply_invoices
*&----
Display Count of invoices
*----
FORM sub_disply_invoices .
DATA: l_sort TYPE slis_sortinfo_alv, " alv sort table
l_layout TYPE slis_layout_alv. " alv layout
REFRESH itab_fcat_inv.
REFRESH itab_sort.
PERFORM sub_populate_fldcat TABLES itab_fcat_inv
USING 1
'BUKRS'
text-003
12
space.
PERFORM sub_populate_fldcat TABLES itab_fcat_inv
USING 2
'KUNNR'
text-004
10
space.
PERFORM sub_populate_fldcat TABLES itab_fcat_inv
USING 3
'NAME'
text-020
35
space.
PERFORM sub_populate_fldcat TABLES itab_fcat_inv
USING 4
'CINV'
text-021
5
c_checked.
PERFORM sub_populate_fldcat TABLES itab_fcat_inv
USING 6
'DMBTR'
text-022
20
c_checked.
l_sort-fieldname = 'BUKRS'.
l_sort-up = 'X'.
l_sort-subtot = 'X'.
*
APPEND l_sort TO itab_sort.
CLEAR l_sort.
PERFORM sub_build_alv_event_tab.
ALV list display
PERFORM sub_alv_display TABLES itab_cinv
USING itab_fcat_inv.
ENDFORM. " sub_disply_invoices
*&----
*& Form sub_customer
&----
Retrieve customer name
----
FORM sub_customer .
itab_bseg_tmp[] = itab_bseg_final[].
SORT itab_bseg_tmp[] BY bukrs kunnr.
DELETE ADJACENT DUPLICATES FROM itab_bseg_tmp COMPARING bukrs kunnr.
IF NOT itab_bseg_tmp[] IS INITIAL.
SELECT kunnr " Customer code
name1 " Customer name
FROM kna1
INTO TABLE itab_kunnr
FOR ALL ENTRIES IN itab_bseg_tmp
WHERE kunnr = itab_bseg_tmp-kunnr.
IF sy-subrc EQ 0.
SORT itab_kunnr BY kunnr.
ENDIF.
ENDIF.
REFRESH itab_bseg_tmp.
ENDFORM. " sub_customer
*********************************************************
Form: SUB_BUILD_ALV_EVENT_TAB **
**
Description:
This subroutine is used to populate the ALV Events table with the
TOP_OF_PAGE event.
*********************************************************
FORM sub_build_alv_event_tab.
Local Constants
CONSTANTS:
Form Name for TOP_OF_PAGE
c_loc_topofpage TYPE slis_formname
VALUE 'SUB_TOP_OF_PAGE'.
Local Variables
DATA:
loc_event TYPE slis_alv_event. "Event Structure
REFRESH itab_events.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
i_list_type = 0
IMPORTING
et_events = itab_events
EXCEPTIONS
list_type_wrong = 1
OTHERS = 2.
IF sy-subrc = 0.
TOP_OF_PAGE
READ TABLE itab_events INTO loc_event
WITH KEY name = slis_ev_top_of_page.
IF sy-subrc EQ 0.
MOVE c_loc_topofpage TO loc_event-form.
MODIFY itab_events FROM loc_event TRANSPORTING form name
WHERE name = slis_ev_top_of_page.
ENDIF.
ENDIF.
ENDFORM. " sub_build_alv_event_tab
*********************************************************
Form: SUB_TOP_OF_PAGE **
*----
Description: Top of page
**
*----
FORM sub_top_of_page. "#EC CALLED
Writes the standard header of the output report
*Assign Program Name and Title
v_repid = sy-repid.
v_title = sy-title.
PERFORM report_header USING v_repid "Program Name
v_title. "Title
ENDFORM. "sub_top_of_page
*&----
*& Form sub_ALV_DISPLAY
text
*----
-->P_ITAB_FCAT = field catalog
-->P_ITAB_data = Output table for display
*----
FORM sub_alv_display
TABLES p_itab_data
USING p_itab_fcat .
DATA: l_layout TYPE slis_layout_alv. "ALV Layout Struc
To optimize the column width so that all contents are displayed
l_layout-colwidth_optimize = 'X'.
To display the selection information
l_layout-get_selinfos = 'X'.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE = ' '
i_callback_program = v_repid
i_callback_pf_status_set = 'SUB_PFSTATUS'
i_callback_user_command = 'SUB_USERCOMM'
I_STRUCTURE_NAME =
is_layout = l_layout
it_fieldcat = p_itab_fcat
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
it_sort = itab_sort
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
i_save = 'A'
IS_VARIANT = wa_variant
it_events = itab_events
IT_EVENT_EXIT =
IS_PRINT =
IS_REPREP_ID =
I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
t_outtab = p_itab_data
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. " sub_ALV_DISPLAY
*&----
*& Form sub_splglind_default
*&----
default value for
*----
FORM sub_splglind_default .
s_umskz-sign = 'E'.
s_umskz-option = 'BT'.
s_umskz-low = 'A'.
s_umskz-high = 'W'.
APPEND s_umskz.
CLEAR s_umskz.
ENDFORM. " sub_splglind_default
*&----
*& Form sub_populate_fldcat
*&----
Population of field catalog
*----
-->P_ITAB_FCAT_INV
-->P_POS - Position
-->P_fld - Field name
-->P_text - Field text
-->P_len - Length
-->P_dosum - do sum
*----
FORM sub_populate_fldcat TABLES p_itab_fcat_inv
USING p_pos
p_fld
p_text
p_len
p_dosum.
DATA: l_fieldcat TYPE slis_fieldcat_alv. " alv field catalog
l_fieldcat-col_pos = p_pos.
l_fieldcat-fieldname = p_fld.
l_fieldcat-seltext_m = p_text.
l_fieldcat-outputlen = p_len.
l_fieldcat-do_sum = p_dosum.
APPEND l_fieldcat TO p_itab_fcat_inv.
CLEAR l_fieldcat.
ENDFORM. " sub_populate_fldcat
Hope it helps me...
Simran
2006 Jul 07 11:24 AM
2006 Jul 07 11:32 AM
Hi again,
1. sorry for the late reply.
2. I copy pasted ur code.
But it contains some Z structures,
which are not here in my system.
(hence, i was not able to run the program)
3. However,
just looking to the flow,
i saw that,
on double-click call back form,
there is no such logic to
DETECT the TICKED rows,
and display another alv
(it simply calls the same alv,
further there is no another SELECT statement,
to fetch the further details)
4. I think u will have to DEBUG the code,
and rectify/enhance it yourself.
regards,
amit m.
2006 Jul 07 11:38 AM
2006 Jul 07 7:26 AM
hi,
use the below command..
in the AlV grid FM use
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
use the below code..
FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
RS_SELFIELD TYPE SLIS_SELFIELD.
CASE R_UCOMM.
WHEN '&IC1'.
CLEAR TEMP.
read table it_final2 INDEX RS_SELFIELD-TABINDEX.
SOME TIMES THE double click function for kunnr does not get displayed..
used 1-kunnr instead of 1-week. below line..
IF RS_SELFIELD-SEL_TAB_FIELD = '1-WEEK'.
the intrnal table which u want to display
loop the itab1.
itab2 same structue of itab1.
append itab2.
endloop.
end case.
call the alv grid FM using with itab2
kindly allocate points
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |