We have added search box. Key in SAP issue keyword to search
TopBottom

Announcement: wanna exchange links? contact me at sapchatroom@gmail.com.

RE:[sap-dev] Expand and Collapse Buttons On ALV Grid (for Classic ALV, not OOP)

Posted by Admin at
Share this post:
Ma.gnolia DiggIt! Del.icio.us Yahoo Furl Technorati Reddit

Reply from Laurie_Severt on Apr 11 at 10:51 AM
I have compared my code to yours and I am using the same settings that you are with no success in seeing the expand/collapse icons.
here is my code:
REPORT zppar_supply_review_alv1.

INCLUDE <list>.
TYPE-POOLS: slis.

TABLES: zsuprev,
eban.

TYPES : BEGIN OF t_zsuprev.
INCLUDE TYPE zsuprev.
TYPES: END OF t_zsuprev.

DATA: lt_zsuprev TYPE TABLE OF t_zsuprev WITH HEADER LINE,
ls_zsuprev TYPE t_zsuprev.
* Field Ref type Length Dec Description
* MFGPLT WERKS_D CHAR 4 0 Manufacturing Plant
* PERIOD CHAR15 CHAR15 15 0 Period/Week format "Per 2013/xx" or "Week 2013/xx"
* PRODTYPE RKEG_WWTYP CHAR 18 0 Product Type
* BANFN BANFN CHAR 10 0 Purchase Requisition Number
* BNFPO BNFPO NUMC 5 0 Item Number of Purchase Requisition
* FIXSEL CHAR1 CHAR 1 0 Selection checkbox to Fix/Firm Requisition
* FIXKZ BAFIX CHAR 1 0 Purchase Requisition is Fixed
* DELFLAG CHAR1 CHAR 1 0 Delete Flag
* MATNR MATNR CHAR 18 0 Material Number
* MAKTX MAKTX CHAR 40 0 Material Description (Short Text)
* MENGE BAMNG QUAN 13 3 Purchase Requisition Quantity
* MEINS BAMEI UNIT 3 0 Purchase Requisition Unit of Measure
* LFDAT LFDAT DATS 8 0 Delivery date
* REQYD2 15 3 Square Yards
* REQYD2UOM MEINS UOM for REQYD2
* REQROL 15 3 Rolls
* REQROLUOM MEINS UOM for REQROL
* WERKS WERKS_D CHAR 4 0 Plant
* RESWK RESWK CHAR 4 0 Supplying (Issuing) Plant in Stock Transport Order
* DISPO DISPO CHAR 3 0 MRP Controller (Materials Planner)

DATA : l_rec(5) TYPE n,
gv_tab TYPE c.

DATA: p_mfgplt TYPE werks_d,
p_matnr TYPE matnr,
p_menge TYPE bamng,
p_meins TYPE meins,
p_reqqty TYPE bamng,
p_uom TYPE meins,
p_period TYPE poper,
p_year TYPE bdatj,
p_del_date TYPE lfdat,
p_period_a TYPE char15,
p_banfn TYPE banfn,
p_bnfpo TYPE bnfpo,
lv_week TYPE kweek.

DATA: in_qty TYPE vhuadmin-quantity,
out_qty TYPE vhuadmin-quantity,
in_uom TYPE meins,
out_uom TYPE meins.

DATA: gt_fcat TYPE slis_t_fieldcat_alv,
gs_fcat TYPE slis_fieldcat_alv,
gt_lsthdr TYPE slis_t_listheader,
gs_lsthdr TYPE slis_listheader,
gs_layout TYPE slis_layout_alv,
gt_sort TYPE slis_t_sortinfo_alv,
gs_sort TYPE slis_sortinfo_alv,
gt_event TYPE slis_t_event,
gs_event TYPE slis_alv_event,
gt_keyinfo TYPE slis_keyinfo_alv,
gs_vari TYPE disvariant,
gt_fcode TYPE slis_t_event_exit,
gs_fcode TYPE slis_event_exit,
gv_exit TYPE char1,
gv_program TYPE sy-repid.

SELECTION-SCREEN SKIP 1.
SELECTION-SCREEN BEGIN OF BLOCK choose WITH FRAME TITLE text-001.
SELECT-OPTIONS: s_plant FOR eban-werks OBLIGATORY. " receiving plant
SELECT-OPTIONS: s_source FOR eban-reswk OBLIGATORY. " source plant
SELECT-OPTIONS: s_mfgplt FOR zsuprev-mfgplt OBLIGATORY. " Manufacturing plant
SELECT-OPTIONS: s_deldat FOR eban-lfdat OBLIGATORY. " purchasing group
SELECTION-SCREEN END OF BLOCK choose.

SELECTION-SCREEN BEGIN OF BLOCK outlev WITH FRAME TITLE text-002.
PARAMETER pweek RADIOBUTTON GROUP rad1 DEFAULT 'X'. " display by week
PARAMETER pmonth RADIOBUTTON GROUP rad1. " display by period (month)
SELECTION-SCREEN END OF BLOCK outlev.

***
** **
** Event: INITIALIZATION **
** **
INITIALIZATION.

gv_tab = cl_abap_char_utilities=>horizontal_tab.

START-OF-SELECTION.
REFRESH: lt_zsuprev.

SELECT reswk banfn bnfpo fixkz matnr werks dispo menge meins lfdat
FROM eban
INTO CORRESPONDING FIELDS OF TABLE lt_zsuprev
WHERE werks IN s_plant
AND reswk IN s_source
AND lfdat IN s_deldat.

IF sy-subrc EQ 0.
DESCRIBE TABLE lt_zsuprev LINES l_rec.
LOOP AT lt_zsuprev INTO ls_zsuprev.
PERFORM get_remaining_data.
ENDLOOP.
PERFORM check_mfg_plant.
ENDIF.

END-OF-SELECTION.
PERFORM b1000_report_results.
** ------- **
FORM get_remaining_data.

PERFORM get_material_description.
PERFORM get_product_type USING ls_zsuprev-matnr
CHANGING ls_zsuprev-prodtype.
PERFORM get_mfg_plant.
PERFORM get_yd2_and_rol.
PERFORM get_period.

MODIFY lt_zsuprev FROM ls_zsuprev.

ENDFORM.

FORM get_material_description.
" get material description
SELECT SINGLE maktx
FROM makt
INTO ls_zsuprev-maktx
WHERE matnr = ls_zsuprev-matnr
AND spras = sy-langu.

ENDFORM.

FORM get_product_type USING p_matnr TYPE matnr
CHANGING p_product_type TYPE char18.
DATA: lv_atnam TYPE atnam,
lv_atinn TYPE atinn,
lv_atwrt TYPE atwrt.

lv_atnam = 'PRODUCT_TYPE'.

SELECT SINGLE atinn
FROM cabn
INTO lv_atinn
WHERE atnam = lv_atnam.
SELECT SINGLE atwrt
FROM ausp
INTO lv_atwrt
WHERE objek = p_matnr
AND atinn = lv_atinn.
p_product_type = lv_atwrt.

ENDFORM.

FORM get_mfg_plant.
CALL FUNCTION 'ZPPFM_RETRIEVE_MFG_PLANT'
EXPORTING
pmaterial = ls_zsuprev-matnr
pplant = ls_zsuprev-reswk
IMPORTING
pmfgplt = p_mfgplt.

IF p_mfgplt = space.
ls_zsuprev-mfgplt = ls_zsuprev-reswk.
ELSE.
ls_zsuprev-mfgplt = p_mfgplt.
ENDIF.
ENDFORM.

FORM get_yd2_and_rol.
" convert purch req quantity to Square Yards.
p_uom = 'YD2'.
p_matnr = ls_zsuprev-matnr.
p_menge = ls_zsuprev-menge.
p_meins = ls_zsuprev-meins.
PERFORM convert_uom USING p_matnr p_menge p_meins p_uom
CHANGING p_reqqty.
ls_zsuprev-reqyd2 = p_reqqty.
ls_zsuprev-reqyd2uom = 'YD2'.

" convert purch req quantity to Rolls.
p_uom = 'ROL'.
PERFORM convert_uom USING p_matnr p_menge p_meins p_uom
CHANGING p_reqqty.
ls_zsuprev-reqrol = p_reqqty.
ls_zsuprev-reqroluom = 'ROL'.
ENDFORM.

FORM get_period.
p_del_date = ls_zsuprev-lfdat.
CLEAR p_period_a.

" set detail by week or period
IF pweek IS INITIAL.
PERFORM get_period_b USING p_del_date
CHANGING p_period_a.
ELSE.
PERFORM get_week USING p_del_date
CHANGING p_period_a.
ENDIF.
ls_zsuprev-period = p_period_a.
ENDFORM.

FORM check_mfg_plant.

DATA: lt_t001w TYPE TABLE OF t001w WITH HEADER LINE. "plants

" get plants that are NOT in the selected manufacturing plant(s)
SELECT * FROM t001w
INTO TABLE lt_t001w
WHERE werks NOT IN s_mfgplt.

LOOP AT lt_t001w.
"remove records from table if they are not in the selected mfg plant(s)
DELETE lt_zsuprev WHERE mfgplt = lt_t001w-werks.
ENDLOOP.

ENDFORM.

FORM convert_uom USING p_matnr p_menge p_meins p_uom
CHANGING p_reqqty.

in_uom = p_meins.
in_qty = p_menge.
out_uom = p_uom.
CLEAR out_qty.

CALL FUNCTION 'Z_CONVERT_UOM'
EXPORTING
material = p_matnr
in_uom = in_uom
in_qty = in_qty
out_uom = out_uom
IMPORTING
out_qty = out_qty
EXCEPTIONS
OTHERS = 9.
p_reqqty = out_qty.

ENDFORM.

FORM get_week USING p_del_date
CHANGING p_period_a.
" get the fiscal week
CLEAR: ls_zsuprev-period.
CALL FUNCTION 'DATE_GET_WEEK'
EXPORTING
date = p_del_date
IMPORTING
week = lv_week
EXCEPTIONS
date_invalid = 1
OTHERS = 2.
IF sy-subrc EQ 0.
CONCATENATE 'WEEK ' p_del_date+0(4) '/' lv_week+4(2) INTO p_period_a
RESPECTING BLANKS.
ELSE.
" get the week based on today's date
CALL FUNCTION 'DATE_GET_WEEK'
EXPORTING
date = sy-datum
IMPORTING
week = lv_week
EXCEPTIONS
date_invalid = 1
OTHERS = 2.
CHECK sy-subrc IS INITIAL.
CONCATENATE 'WEEK ' p_del_date+0(4) '/' lv_week+4(2) INTO p_period_a
RESPECTING BLANKS.
ENDIF.
ENDFORM.

FORM get_period_b USING p_del_date
CHANGING p_period_a.

" get the fiscal period
CALL FUNCTION 'DATE_TO_PERIOD_CONVERT'
EXPORTING
i_date = p_del_date
i_periv = 'Z1'
IMPORTING
e_buper = p_period
e_gjahr = p_year
EXCEPTIONS
input_false = 1
t009_notfound = 2
t009b_notfound = 3
OTHERS = 4.
IF sy-subrc EQ 0.
CONCATENATE 'PERIOD ' p_year '/' p_period+1(2) INTO p_period_a
RESPECTING BLANKS.
ELSE.
" get period/year based on today's date
CALL FUNCTION 'DATE_TO_PERIOD_CONVERT'
EXPORTING
i_date = sy-datum
i_periv = 'Z1'
IMPORTING
e_buper = p_period
e_gjahr = p_year
EXCEPTIONS
input_false = 1
t009_notfound = 2
t009b_notfound = 3
OTHERS = 4.
CHECK sy-subrc IS INITIAL.
CONCATENATE 'PERIOD ' p_year '/' p_period+1(2) INTO p_period_a
RESPECTING BLANKS.
ENDIF.

ENDFORM.
*==
*&-------*
*& Form b1000_report_results
*&--------*
* begin alv process
*---------*

FORM b1000_report_results.

CHECK lt_zsuprev[] IS NOT INITIAL.

PERFORM b1100_setup_alv.
PERFORM b1200_exec_alv.

ENDFORM. "B1000_REPORT_RESULTS
*****
** **
** Subroutine: B1100_SETUP_ALV **
** **
****
FORM b1100_setup_alv.

CLEAR: gt_event, gs_event, gs_vari,
gt_fcode, gs_fcode, gs_layout,
gt_fcat, gs_fcat.

gv_program = sy-repid.

gs_vari-report = gv_program.
gs_layout-colwidth_optimize = 'X'.
gs_layout-zebra = 'X'.
gs_layout-info_fieldname = 'LNCOLOR'.
* gs_layout-box_fieldname = 'FIXSEL'.

"----
" Fill Field Catalog from Data Dictionary structure.
"-----
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = 'ZSUPREV'
CHANGING
ct_fieldcat = gt_fcat
EXCEPTIONS
OTHERS = 3.

LOOP AT gt_fcat INTO gs_fcat.
PERFORM b1110_prep_fcat.
ENDLOOP.

PERFORM b1120_prep_sort.

gs_lsthdr-typ = 'H'.
gs_lsthdr-info = 'Supply Review'.
gt_keyinfo-header01 = 'MFGPLT'.
gt_keyinfo-header02 = 'PERIOD'.
gt_keyinfo-header03 = 'PRODTYPE'.

APPEND gs_lsthdr TO gt_lsthdr.

"----
" Setup EVENTS
"---
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
i_list_type = 0
IMPORTING
et_events = gt_event
EXCEPTIONS
list_type_wrong = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE 'I' NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
LEAVE LIST-PROCESSING.
ENDIF.

gs_event-form = 'T1000_TOP_OF_PAGE'.
MODIFY gt_event FROM gs_event TRANSPORTING form
WHERE name = slis_ev_top_of_page. "TOP_OF_PAGE

gs_event-form = 'P1000_PF_STATUS'.
MODIFY gt_event FROM gs_event TRANSPORTING form
WHERE name = slis_ev_pf_status_set. "PF_STATUS_SET

gs_event-form = 'U1000_USER_COMMAND'.
MODIFY gt_event FROM gs_event TRANSPORTING form
WHERE name = slis_ev_user_command. "USER_COMMAND

ENDFORM. "B1100_SETUP_ALV

***
** **
** Subroutine: B1110_PREP_FCAT **
** **
**
FORM b1110_prep_fcat.

CLEAR: gs_fcat-seltext_l,
gs_fcat-seltext_m,
gs_fcat-seltext_s,
gs_fcat-no_out,
gs_fcat-edit,
gs_fcat-key,
gs_fcat-checkbox,
gs_fcat-hotspot.

CASE gs_fcat-fieldname.


* MFGPLT CHAR 4 0 Manufacturing Plant
** Add setkey to the column mfgplt
WHEN 'MFGPLT'.
gs_fcat-key = 'X'.
gs_fcat-seltext_l = 'Mfg Plant' .

* PERIOD CHAR15 CHAR15 15 0 Period/Week format "Per 2013/xx" or "Week 2013/xx"
** Add setkey to the column PERIOD
WHEN 'PERIOD'.
gs_fcat-key = 'X'.
IF pweek IS INITIAL.
gs_fcat-seltext_l = 'Period' .
ELSE.
gs_fcat-seltext_l = 'Week' .
ENDIF.

* PRODTYPE RKEG_WWTYP CHAR 18 0 Product Type
WHEN 'PRODTYPE'.
gs_fcat-key = 'X'.
gs_fcat-seltext_l = 'Prod Type' .

* BANFN BANFN CHAR 10 0 Purchase Requisition Number
** Add Hotspot&Hyper Link to the column vbeln
WHEN 'BANFN'.
gs_fcat-hotspot = 'X'.
gs_fcat-key = 'X'.
gs_fcat-seltext_l = 'Purch Req' .

* BNFPO BNFPO NUMC 5 0 Item Number of Purchase Requisition
WHEN 'BNFPO'.
gs_fcat-seltext_l = 'PR Item' .

* FIXSEL CHAR1 CHAR 1 0 Fix/Firm PR (checkbox)
WHEN 'FIXSEL'.
gs_fcat-seltext_l = 'Fix?'.
gs_fcat-checkbox = 'X'.
gs_fcat-edit = 'X'.
gs_fcat-input = 'X'.

* FIXKZ BAFIX CHAR 1 0 Purchase Requisition is Fixed
WHEN 'FIXKZ'.
gs_fcat-seltext_l = 'Fix Ind' .

* FIXKZ BAFIX CHAR 1 0 Purchase Requisition is Fixed
WHEN 'DELFLAG'.
gs_fcat-seltext_l = 'Del PR?'.
gs_fcat-edit = 'X'.
gs_fcat-checkbox = 'X'.

* MATNR MATNR CHAR 18 0 Material Number
** Add Hotspot&Hyper Link to the column vbeln
WHEN 'MATNR'.
gs_fcat-hotspot = 'X'.
gs_fcat-seltext_l = 'Material'.

* MAKTX MAKTX CHAR 40 0 Material Description (Short Text)
WHEN 'MAKTX'.
gs_fcat-seltext_l = 'Material Description' .

* MENGE BAMNG QUAN 13 3 Purchase Requisition Quantity
WHEN 'MENGE'.
gs_fcat-seltext_l = 'PR Quantity'.
gs_fcat-do_sum = 'X'.
gs_fcat-edit = 'X'.

* MEINS BAMEI UNIT 3 0 Purchase Requisition Unit of Measure
WHEN 'MEINS'.
gs_fcat-seltext_l = 'PR UOM' .

* LFDAT LFDAT DATS 8 0 Delivery date
WHEN 'LFDAT'.
gs_fcat-seltext_l = 'Delivery Date' .
gs_fcat-edit = 'X'.

* REQYD2 15 3 Square Yards
WHEN 'REQYD2'.
gs_fcat-seltext_l = 'Square Yards' .
gs_fcat-do_sum = 'X'.

* REQYD2UOM MEINS UOM for REQYD2
WHEN 'REQYD2UOM'.
gs_fcat-seltext_l = 'UOM' .

* REQROL 15 3 Rolls
WHEN 'REQROL'.
gs_fcat-seltext_l = 'Rolls' .
gs_fcat-do_sum = 'X'.

* REQROLUOM MEINS UOM for REQROL
WHEN 'REQROLUOM'.
gs_fcat-seltext_l = 'UOM' .

* WERKS WERKS_D CHAR 4 0 Plant
WHEN 'WERKS'.
gs_fcat-seltext_l = 'Rec Plant' .

* RESWK RESWK CHAR 4 0 Supplying (Issuing) Plant in Stock Transport Order
** Add setkey to the column mfgplt
WHEN 'RESWK'.
gs_fcat-seltext_l = 'Sup Plant' .

* DISPO DISPO CHAR 3 0 MRP Controller (Materials Planner)
WHEN 'DISPO'.
gs_fcat-seltext_l = 'MRP Controller' .

WHEN OTHERS.

ENDCASE.

IF gs_fcat-seltext_m IS INITIAL.
gs_fcat-seltext_m = gs_fcat-seltext_l.
ENDIF.

IF gs_fcat-seltext_s IS INITIAL.
gs_fcat-seltext_s = gs_fcat-seltext_m.
ENDIF.

IF gs_fcat-seltext_s IS INITIAL.
gs_fcat-seltext_s = gs_fcat-seltext_m.
ENDIF.

gs_fcat-reptext_ddic = gs_fcat-seltext_s.

MODIFY gt_fcat INDEX sy-tabix FROM gs_fcat.

ENDFORM. "B1110_PREP_FCAT


FORM b1120_prep_sort.

gs_sort-tabname = 'LT_ZSUPREV'.
gs_sort-up = 'X'. " ascending
gs_sort-group = '*'. " page break
gs_sort-subtot = 'X'. " subtotal this field
gs_sort-spos = 1.
gs_sort-fieldname = 'MFGPLT'.
APPEND gs_sort TO gt_sort.

gs_sort-spos = 2.
gs_sort-fieldname = 'PERIOD'.
APPEND gs_sort TO gt_sort.

gs_sort-spos = 3.
gs_sort-fieldname = 'PRODTYPE'.
APPEND gs_sort TO gt_sort.

gs_sort-group = ' '.
gs_sort-subtot = ' '.
gs_sort-spos = 5.
gs_sort-fieldname = 'MATNR'.
APPEND gs_sort TO gt_sort.

gs_sort-spos = 6.
gs_sort-fieldname = 'BANFN'.
APPEND gs_sort TO gt_sort.
ENDFORM. "B1120_PREP_SORT

***
** **
** Subroutine: B1200_EXEC_ALV **
** **
****
FORM b1200_exec_alv.

DATA: lv_program TYPE sy-repid.

lv_program = sy-repid.

"--
" Set up variant structure.
"----
CLEAR gs_vari.
gs_vari-report = lv_program.
* gs_vari-variant = p_vari.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = lv_program
i_callback_pf_status_set = 'P1000_PF_STATUS'
i_callback_user_command = 'U1000_USER_COMMAND'
is_layout = gs_layout
it_fieldcat = gt_fcat
it_sort = gt_sort
it_events = gt_event
* i_default = 'X'
i_save = 'A'
is_variant = gs_vari
it_event_exit = gt_fcode
TABLES
t_outtab = lt_zsuprev
EXCEPTIONS
program_error = 1
OTHERS = 2.

CHECK sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE 'I' NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
LEAVE LIST-PROCESSING.

ENDFORM.

***
** **
** Subroutine: P1000_PF_STATUS **
** **
****
FORM p1000_pf_status USING rt_extab TYPE slis_t_extab. "#EC CALLED

SET PF-STATUS 'ZSALV_TABLE_STANDARD' EXCLUDING rt_extab.

ENDFORM. "P1000_PF_STATUS

***
** **
** Subroutine: T1000_TOP_OF_PAGE **
** **
**
FORM t1000_top_of_page. "#EC CALLED

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = gt_lsthdr.

ENDFORM. "T1000_TOP_OF_PAGE

***
** **
** Subroutine: U1000_USER_COMMAND **
** **
****
FORM u1000_user_command USING r_ucomm LIKE sy-ucomm "#EC CALLED
rs_selfield TYPE slis_selfield.

CASE r_ucomm.
WHEN '&IC1'.
PERFORM e3300_goto_hotspot USING rs_selfield-tabindex
rs_selfield-fieldname
rs_selfield-refresh.
WHEN 'PROCESS'.
PERFORM e3400_process_fixes.

WHEN OTHERS.
ENDCASE.

rs_selfield-refresh = 'X'.

ENDFORM. "U1000_USER_COMMAND
***
** **
** Subroutine: E3300_GOTO_HOTSPOT **
** **
***
FORM e3300_goto_hotspot USING p_index TYPE slis_selfield-tabindex
p_fldnam TYPE slis_selfield-fieldname
p_refresh TYPE slis_selfield-refresh.

CLEAR : ls_zsuprev.

READ TABLE lt_zsuprev INDEX p_index.

CHECK sy-subrc EQ 0.

" process the record accordingly
CASE p_fldnam.

WHEN 'BANFN'.
SET PARAMETER ID 'BAN' FIELD lt_zsuprev-banfn.
CALL TRANSACTION 'ME52' AND SKIP FIRST SCREEN.
PERFORM e3500_refresh_alv USING lt_zsuprev-banfn lt_zsuprev-bnfpo.

WHEN 'MATNR'. "when Delivery is selected
" go to the Material inquiry
SET PARAMETER ID 'MAT' FIELD lt_zsuprev-matnr.
CALL TRANSACTION 'MM03' AND SKIP FIRST SCREEN.

WHEN OTHERS.
ENDCASE.

p_refresh = 'X'.

ENDFORM.

FORM e3400_process_fixes.

* to reflect the data changed into internal table
DATA : ref_grid TYPE REF TO cl_gui_alv_grid.

DATA: lt_zsuprev_before TYPE TABLE OF t_zsuprev,
ls_zsuprev_before TYPE t_zsuprev.

DATA: lv_index TYPE sy-index.

" for calling BAPI
DATA BEGIN OF item OCCURS 1.
INCLUDE STRUCTURE bapimereqitemimp.
DATA END OF item.
DATA BEGIN OF itemchanges OCCURS 1.
INCLUDE STRUCTURE bapimereqitemx.
DATA END OF itemchanges.

" save alv table before processing changes
REFRESH lt_zsuprev_before.
lt_zsuprev_before[] = lt_zsuprev[].

"update the changes to the ALV table
IF ref_grid IS INITIAL.
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
e_grid = ref_grid.
ENDIF.

IF NOT ref_grid IS INITIAL.
CALL METHOD ref_grid->check_changed_data.
ENDIF.

LOOP AT lt_zsuprev INTO ls_zsuprev.
" save the index of the record being read so we can get the 'before' record to see if
" this one changed
lv_index = sy-index.

READ TABLE lt_zsuprev_before WITH KEY banfn = ls_zsuprev-banfn
bnfpo = ls_zsuprev-bnfpo
INTO ls_zsuprev_before.
sy-index = lv_index.
CHECK ls_zsuprev_before NE ls_zsuprev.

" make changes
CLEAR item.
CLEAR itemchanges.
REFRESH item.
REFRESH itemchanges.

MOVE ls_zsuprev-bnfpo TO item-preq_item.
MOVE lt_zsuprev-bnfpo TO itemchanges-preq_item.

IF ls_zsuprev-fixsel = 'X'.
MOVE 'X' TO item-fixed.
MOVE 'X' TO itemchanges-fixed.
ENDIF.

IF ls_zsuprev-menge NE ls_zsuprev_before-menge.
MOVE ls_zsuprev-menge TO item-quantity.
MOVE ls_zsuprev-meins TO item-unit.
MOVE 'X' TO itemchanges-quantity.
MOVE 'X' TO itemchanges-unit.
ENDIF.

IF ls_zsuprev-lfdat NE ls_zsuprev_before-lfdat.
MOVE ls_zsuprev-lfdat TO item-deliv_date.
MOVE 'X' TO itemchanges-deliv_date.
ENDIF.

APPEND item.
APPEND itemchanges.

" call program to make changes
CALL FUNCTION 'BAPI_PR_CHANGE'
EXPORTING
number = ls_zsuprev-banfn
TABLES
pritem = item
pritemx = itemchanges.

COMMIT WORK AND WAIT.

PERFORM get_yd2_and_rol.
PERFORM get_period.

" update alv table with changed data
CLEAR: ls_zsuprev-fixsel.
MOVE 'X' TO ls_zsuprev-fixkz.
MODIFY lt_zsuprev FROM ls_zsuprev.

ENDLOOP.

ENDFORM.

FORM e3500_refresh_alv USING p_banfn p_bnfpo.

LOOP AT lt_zsuprev INTO ls_zsuprev
WHERE banfn = p_banfn
AND bnfpo = p_bnfpo.

" read updated PO record for changes
SELECT SINGLE reswk fixkz matnr werks dispo menge meins lfdat
INTO (ls_zsuprev-reswk, ls_zsuprev-fixkz, ls_zsuprev-matnr,
ls_zsuprev-werks, ls_zsuprev-dispo, ls_zsuprev-menge,
ls_zsuprev-meins, ls_zsuprev-lfdat)
FROM eban
WHERE banfn = ls_zsuprev-banfn
AND bnfpo = ls_zsuprev-bnfpo.

" get rest of data for the chagned record and update alv table
PERFORM get_remaining_data.

ENDLOOP.

ENDFORM.
*End of program ZPPAR_SUPPLY_REVIEW_ALV1.

---------------Original Message---------------
From: Laurie Severt
Sent: Wednesday, April 10, 2013 10:51 AM
Subject: Expand and Collapse Buttons On ALV Grid (for Classic ALV, not OOP)

Expand and collapse buttons on ALV grid (for classic ALV, not OOP) - I have created an ALV grid program that has subtotals and I want to be able to expand or collapse detail. I cannot find (and I have searched extensively) the code I need to have these buttons (or icons) show up and be used in my grid.
I am using the FM REUSE_ALV_GRID_DISPLAY.
We are on ECC 6.I am using classic ALV (as opposed to OOP) because I do not have a complete grasp of OO programming yet.

 
Reply to this email to post your response.
 
__.____._
Manage Settings | Unsubscribe | Create FAQ | Send Feedback
  
Copyright © 2013 Ziff Davis, Inc. and message author.
Ziff Davis, Inc. 28 E 28th Street New York, NY 10016
Laurie_Severt  

Developer
 
Mark as helpful
View this online
Ask a new question
 
In the Spotlight
Toolbox.com for iPhone & Android: Ask Questions & Get Answers Anywhere. Download the Free App

_.____.__

0 comments:

Post a Comment

T r a n s l a t e to your language