Skip to Content
author's profile photo Former Member
Former Member

ALV hierarchical display

Hi all,

Please let me know if it is possible use ALV grid for hierarchical display. Function Module or Methods using classes both are okay.

Thanks

Kiran

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

8 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Feb 28, 2007 at 06:55 AM

    i dont think you can use grid for hierarchical display. you have to use only list display.

    regards

    shiba dutta

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Feb 28, 2007 at 06:52 AM

    I don't think ALV Grid method is available for hierarchical display.

    You can display hierarchical list but not grid.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Feb 28, 2007 at 06:53 AM

    Hi,

    Yes, You can use ALV for hierarchial display.

    See the sample code.

    report zwmr_pick_status_report no standard page heading

    message-id zw.

    ************************************************************************

    • Type Pools *

    ************************************************************************

    type-pools: icon, slis.

    ************************************************************************

    • Tables *

    ************************************************************************

    tables: tvst,

    likp,

    t30b,

    vekp,

    zpallettr,

    zvantr.

    ************************************************************************

    • Types *

    ************************************************************************

    types:

    begin of ty_data,

    lgtor like likp-lgtor, " door

    vbeln like likp-vbeln, " delivery

    wbstk like vbuk-wbstk, " Goods movement status

    kostk like vbuk-kostk, " Picking status

    posnr like lips-posnr, " item

    route like likp-route, " route

    wadat like likp-wadat, " goods issue date

    lvsta like vbup-lvsta, " warehouse status

    packvorschr like vekp-packvorschr, " pack mnemonic

    exidv like vekp-exidv, " handling unit

    zpallet_no(10), "like zpallettr-zpallet_no, " pallet no

    zcount_check like zpallettr-zcount_check," count check flag

    zvan_no(10), "like zvantr-zvan_no, " van no

    zvan_print like zvantr-zvan_print, " van manifest print

    zeod_print like zvantr-zeod_print, " eod manifest print

    zzpackclass like vekp-zzpackclass, " package class

    zzti like vekp-zzti, " T.I. value

    end of ty_data.

    ************************************************************************

    • Data *

    ************************************************************************

    ranges: r_del for likp-vbeln,

    r_lgtor for likp-lgtor.

    ranges: r_vanno for zvantr-zvan_no,

    r_palno for zpallettr-zpallet_no.

    data: begin of number_range occurs 0,

    mark(1),

    id(3),

    num(10) type n,

    desc like zpalletmd-zdesc,

    end of number_range.

    data: t_disp_tab type standard table of zpickdisp,

    t_data_tab type ty_data occurs 0 with header line,

    t_disp_head type standard table of zpickhead.

    data: w_numrnge like number_range,

    w_number(10) type n.

    data: t_likp like likp occurs 0 with header line,

    t_lips like lips occurs 0 with header line,

    t_vbuk like vbuk occurs 0 with header line,

    t_vbup like vbup occurs 0 with header line,

    t_vepo like vepo occurs 0 with header line,

    t_vekp like vekp occurs 0 with header line,

    t_vantr like zvantr occurs 0 with header line,

    t_pallettr like zpallettr occurs 0 with header line,

    w_likp like likp,

    w_lips like lips,

    w_vbuk like vbuk,

    w_vbup like vbup,

    w_vepo like vepo,

    w_vekp like vekp.

            • ALV DATA *****

            data:

            g_grid type ref to cl_gui_alv_grid,

            g_sort type slis_t_sortinfo_alv,

            g_custom_container type ref to cl_gui_custom_container,

            g_layout type slis_layout_alv,

            gt_fieldcat type slis_t_fieldcat_alv,

            t_fldcat like line of gt_fieldcat,

            g_keyinfo type slis_keyinfo_alv,

            gt_events type slis_t_event,

            gs_event type slis_alv_event,

            w_sy_repid like sy-repid.

            data: begin of seltab occurs 0.

            include structure rsparams.

            data: end of seltab.

                          • SYSTEM GENERATED TABLE CONTROL DATA ********

                        • DECLARATION OF TABLECONTROL 'TC_TABCON' ITSELF

                        • controls: tc_tabcon type tableview using screen 0100.

                          • LINES OF TABLECONTROL 'TC_TABCON'

                          data: g_tc_tabcon_lines like sy-loopc.

                          data: ok_code like sy-ucomm.

                          *****************************************************

                          ************************************************************************

                          • Constants *

                          ************************************************************************

                          constants: c_data_class like klah-class value 'DG_DATA',

                          c_mat_class like rmclf-klart value '001',

                          c_pack like lips-mtart value 'VERP',

                          c_a(1) value 'A',

                          c_b(1) value 'B',

                          c_c(1) value 'C',

                          c_yes(1) value 'X',

                          c_no(1) value ' '.

                          ************************************************************************

                          • Selection screen *

                          ************************************************************************

                          • standard report select options block

                          selection-screen begin of block a with frame title text-002.

                          select-options:

                          s_wadat for likp-wadat no-extension obligatory. " Goods Issue Date

                          *parameters: "TR01-

                          • p_vstel like tvst-vstel obligatory. " Shipping Point "TR01-

                          select-options: "TR01+

                          p_vstel for tvst-vstel. " Shipping Point "TR01+

                          select-options:

                          s_lfart for likp-lfart, " Delivery type

                          s_lgtor for t30b-lgtor, " Door selection

                          s_exidv for vekp-exidv, " Handling Unit

                          s_vbeln for likp-vbeln. " Delivery

                          parameters:

                          p_exdata as checkbox. " Show extra columns flag

                          selection-screen end of block a.

                          • van/pallet specific select options block

                          selection-screen begin of block b with frame title text-001.

                          select-options:

                          s_palno for zpallettr-zpallet_no, " no-extension,

                          s_vanno for zvantr-zvan_no. " no-extension.

                          selection-screen end of block b.

                          ************************************************************************

                          • Value Request Events *

                          ************************************************************************

                          at selection-screen on value-request for s_palno-low.

                          clear: number_range, w_number .

                          refresh number_range.

                          • select numbers and display pop up screen for selection

                          perform select_pal_nos.

                          s_palno-low = w_number.

                          at selection-screen on value-request for s_palno-high.

                          clear: number_range, w_number .

                          refresh number_range.

                          • select numbers and display pop up screen for selection

                          perform select_pal_nos.

                          s_palno-high = w_number.

                          at selection-screen on value-request for s_vanno-low.

                          clear: number_range, w_number .

                          refresh number_range.

                          • select numbers and display pop up screen for selection

                          perform select_van_nos.

                          s_vanno-low = w_number.

                          at selection-screen on value-request for s_vanno-high.

                          clear: number_range, w_number .

                          refresh number_range.

                          • select numbers and display pop up screen for selection

                          perform select_van_nos.

                          s_vanno-high = w_number.

                          ************************************************************************

                          • At Selection Screen *

                          ************************************************************************

                          at selection-screen.

                          perform validate_selections.

                          ************************************************************************

                          • Initialization *

                          ************************************************************************

                          initialization.

                          ************************************************************************

                          • Start of selection *

                          ************************************************************************

                          start-of-selection.

                          • clear all data tables

                          clear: t_likp,

                          t_lips,

                          t_vbuk,

                          t_vbup,

                          t_vepo,

                          t_vantr,

                          t_pallettr,

                          w_likp,

                          w_lips,

                          w_vbuk,

                          w_vbup,

                          w_vepo,

                          w_vekp.

                          refresh: t_likp,

                          t_lips,

                          t_vbuk,

                          t_vbup,

                          t_vepo,

                          t_vantr,

                          t_pallettr.

                          • select data for ALV

                          • due to different input parameters being used, to streamline the data

                          • selection process, different selection methods are required

                          if not s_vanno is initial

                          or not s_palno is initial.

                          • if selecting by van/pallet number, need to select the data from the

                          • handling unit upwards to delivery

                          perform select_data_up.

                          else.

                          • otherwise the data can be selected from the delivery downwards

                          perform select_data_down.

                          endif.

                          ************************************************************************

                          • End of selection *

                          ************************************************************************

                          end-of-selection.

                          • call hierarchical ALV display function module

                          call function 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'

                          exporting

                          i_callback_program = 'ZWMR_PICK_STATUS_REPORT'

                          i_callback_pf_status_set = 'SET_STATUS'

                          i_callback_user_command =

                          'USER_COMMAND' "custom gui status form

                          is_layout = g_layout "user command form

                          it_fieldcat = gt_fieldcat

                          it_sort = g_sort

                          it_events = gt_events

                          i_tabname_header = 't_disp_head'

                          i_tabname_item = 't_disp_tab'

                          i_structure_name_header = 'ZPICKHEAD'

                          i_structure_name_item = 'ZPICKDISP'

                          is_keyinfo = g_keyinfo

                          tables

                          t_outtab_header = t_disp_head

                          t_outtab_item = t_disp_tab.

                          if sy-subrc <> 0.

                          message id sy-msgid type sy-msgty number sy-msgno

                          with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

                          endif.

                          ************************************************************************

                          ************************************************************************

                          • FORMS *

                          ************************************************************************

                          ************************************************************************

                          • Includes inserted by Screen Painter Wizard. DO NOT CHANGE THIS LINE!

                          include zwmr_pick_status_reporto01 .

                          include zwmr_pick_status_reporti01 .

                          include zwmr_pick_status_reportf01 .

                          &----


                          *& Form select_pal_nos

                          &----


                          • select pallet numbers for search help

                          ----


                          form select_pal_nos.

                          data: begin of t_palno occurs 0,

                          zpallet_no like zpallettr-zpallet_no,

                          end of t_palno.

                          • select all available pallet numbers

                          select distinct zpallet_no from zpallettr

                          into corresponding fields of table t_palno.

                          loop at t_palno.

                          • get pallet id

                          select single zpallet_id from zpallettr

                          into number_range-id

                          where zpallet_no = t_palno-zpallet_no.

                          • get pallet description

                          select single zdesc from zpalletmd

                          into number_range-desc

                          where zpallet_id = number_range-id.

                          number_range-num = t_palno-zpallet_no.

                          • append to search help table

                          append number_range.

                          endloop.

                          • call pop up dialog box

                          call screen 0100 starting at 5 5.

                          endform. " select_pal_nos

                          *

                          &----


                          *& Form select_van_nos

                          &----


                          • select van numbers for search help

                          ----


                          form select_van_nos.

                          data: begin of t_vanno occurs 0,

                          zvan_no like zvantr-zvan_no,

                          end of t_vanno.

                          • select available van numbers

                          select distinct zvan_no from zvantr

                          into corresponding fields of table t_vanno.

                          loop at t_vanno.

                          • select van id

                          select single zvan_id from zvantr

                          into number_range-id

                          where zvan_no = t_vanno-zvan_no.

                          • select van description (maintained in pallet tables)

                          select single zdesc from zpalletmd

                          into number_range-desc

                          where zpallet_id = number_range-id.

                          number_range-num = t_vanno-zvan_no.

                          • append to search help table

                          append number_range.

                          endloop.

                          • call pop up dialog box

                          call screen 0100 starting at 5 5.

                          endform. " select_van_nos

                          &----


                          *& Form select_data_down

                          &----


                          • select data if selecting from delivery down

                          ----


                          form select_data_down.

                          • select all deliveries from LIKP that fulfill selection criteria

                          select * from likp into table t_likp

                          where vbeln in s_vbeln

                          • and vstel eq p_vstel "TR01-

                          and vstel in p_vstel

                          and lgtor in s_lgtor

                          and wadat in s_wadat

                          and lfart in s_lfart.

                          if sy-subrc ne 0.

                          • no data found

                          message i007.

                          exit.

                          endif.

                          if not t_likp[] is initial.

                          • select sales document headers from VBUK

                          select * from vbuk into table t_vbuk

                          for all entries in t_likp

                          where vbeln eq t_likp-vbeln.

                          • select all relevant delivery items from LIPS

                          select * from lips into table t_lips

                          for all entries in t_likp

                          where vbeln eq t_likp-vbeln

                          and pstyv ne 'ZPAC'

                          and pstyv ne 'ZGDP' "TR02+

                          and lfimg gt 0. "TR01+

                          endif.

                          if not t_lips[] is initial.

                          • select all sales document line items from VBUP

                          select * from vbup into table t_vbup

                          for all entries in t_lips

                          where vbeln eq t_lips-vbeln

                          and posnr = t_lips-posnr.

                          • select corresponding handling unit ID's (venum)

                          *----


                          TR03 Replace start

                          • select * from vepo appending corresponding fields of table t_vepo

                          • for all entries in t_lips

                          • where vbeln = t_lips-vbeln

                          • and posnr = t_lips-posnr

                          • and matnr = t_lips-matnr

                          • and charg = t_lips-charg.

                          select * from vepo

                          inner join vekp on vepovenum = vekpvenum

                          appending corresponding fields of table t_vepo

                          for all entries in t_lips

                          where vepo~vbeln = t_lips-vbeln

                          and vepo~posnr = t_lips-posnr

                          and vepo~matnr = t_lips-matnr

                          and vepo~charg = t_lips-charg

                          and vekp~exidv in s_exidv.

                          *----


                          TR03 Replace end

                          endif.

                          • build process table

                          perform move_to_table.

                          endform. "select_data_down

                          &----


                          *& Form select_data_up

                          &----


                          • select data if selecting from van/pallet up

                          ----


                          form select_data_up.

                          if not s_vanno is initial.

                          • if van then select van numbers and hence pallet numbers

                          select * from zvantr into table t_vantr

                          where zvan_no in s_vanno.

                          • and vstel eq p_vstel."TR01-

                          if not t_vantr[] is initial.

                          select * from zpallettr into table t_pallettr

                          for all entries in t_vantr

                          where zpallet_no eq t_vantr-zpallet_no.

                          • and vstel eq p_vstel."TR01-

                          endif.

                          else.

                          • otherwise can get pallet numbers directly

                          select * from zpallettr into table t_pallettr

                          where zpallet_no in s_palno.

                          • and vstel eq p_vstel."TR01-

                          endif.

                          if not t_pallettr[] is initial.

                          • from the pallet nos. we can select the handling units

                          select * from vekp into table t_vekp

                          for all entries in t_pallettr

                          where exidv eq t_pallettr-exidv

                          and exidv ne space

                          and exidv in s_exidv "TR03+

                          and ( exida = 'E' "TR01+

                          or exida = 'F' ). "TR01+

                          endif.

                          if not t_vekp[] is initial.

                          • build vbeln range from t_vekp.

                          loop at t_vekp.

                          r_del-sign = 'I'.

                          r_del-option = 'EQ'.

                          r_del-low = t_vekp-vpobjkey.

                          append r_del.

                          endloop.

                          • select all deliveries from LIKP that correspond to HU's

                          select * from likp into table t_likp

                          where vbeln in r_del

                          and wadat in s_wadat

                          and lfart in s_lfart.

                          endif.

                          if not t_likp[] is initial.

                          • select sales document headers from VBUK

                          select * from vbuk into table t_vbuk

                          for all entries in t_likp

                          where vbeln eq t_likp-vbeln.

                          • select all relevant delivery items from LIPS

                          select * from lips into table t_lips

                          for all entries in t_likp

                          where vbeln eq t_likp-vbeln

                          and pstyv ne 'ZPAC'

                          and pstyv ne 'ZGDP' "TR02+

                          and lfimg gt 0. "TR01+

                          endif.

                          if not t_lips[] is initial.

                          • select all sales document line items from VBUP

                          select * from vbup into table t_vbup

                          for all entries in t_lips

                          where vbeln eq t_lips-vbeln

                          and posnr = t_lips-posnr.

                          • select corresponding handling unit ID's (venum)

                          select * from vepo appending corresponding fields of table t_vepo

                          for all entries in t_lips

                          where vbeln = t_lips-vbeln

                          and posnr = t_lips-posnr

                          and matnr = t_lips-matnr

                          and charg = t_lips-charg.

                          endif.

                          • build process table

                          perform move_to_table.

                          endform. "select_data_up

                          &----


                          *& Form move_to_table

                          &----


                          • move data to processing table

                          ----


                          form move_to_table.

                          loop at t_vepo.

                          clear t_data_tab.

                          • delivery lines.

                          clear w_lips.

                          read table t_lips with key vbeln = t_vepo-vbeln

                          posnr = t_vepo-posnr

                          into w_lips.

                          move-corresponding w_lips to t_data_tab.

                          • sales document line items

                          clear w_vbup.

                          read table t_vbup with key vbeln = t_vepo-vbeln

                          posnr = t_vepo-posnr

                          into w_vbup.

                          • if w_vbup-kosta = space. "TR01-

                          • not relevant for picking

                          • delete t_vepo. "TR01-

                          • continue. "TR01-

                          • else. "TR01-

                          move-corresponding w_vbup to t_data_tab.

                          • endif. "TR01-

                          • sales doc header

                          clear w_vbuk.

                          read table t_vbuk with key vbeln = t_vepo-vbeln

                          into w_vbuk.

                          move-corresponding w_vbuk to t_data_tab.

                          • delivery header

                          clear w_likp.

                          read table t_likp with key vbeln = t_vepo-vbeln

                          into w_likp.

                          move-corresponding w_likp to t_data_tab.

                          • select handling unit info using vepo entry

                          clear w_vekp.

                          if t_vekp[] is initial.

                          select single * from vekp into w_vekp

                          where venum = t_vepo-venum.

                          else.

                          read table t_vekp with key venum = t_vepo-venum

                          into w_vekp.

                          if sy-subrc ne 0.

                          select single * from vekp into w_vekp

                          where venum = t_vepo-venum.

                          endif.

                          endif.

                          move-corresponding w_vekp to t_data_tab.

                          • select pallet / van load information

                          select single zpallet_no zcount_check from zpallettr

                          into (t_data_tab-zpallet_no,

                          t_data_tab-zcount_check)

                          where exidv eq w_vekp-exidv.

                          if not t_data_tab-zpallet_no in s_palno. "TR01+

                          continue. "TR01+

                          endif. "TR01+

                          if sy-subrc = 0.

                          select single zvan_no zvan_print zeod_print from zvantr

                          into (t_data_tab-zvan_no,

                          t_data_tab-zvan_print,

                          t_data_tab-zeod_print)

                          where zpallet_no eq t_data_tab-zpallet_no.

                          if not t_data_tab-zvan_no in s_vanno. "TR01+

                          continue. "TR01+

                          endif. "TR01+

                          endif.

                          append t_data_tab.

                          endloop.

                          *-----> TR01+ start

                          • If the delivery has yet to be packed, then need to include in report

                          • Thus delete t_lips here and if any entries left after looping through

                          • t_vepo, these will also need to be added to t_data_tab

                          • if the selection is by handling unit though we do not want these"TR03+

                          if s_exidv is initial. "TR03+

                          loop at t_vepo.

                          read table t_lips with key vbeln = t_vepo-vbeln

                          posnr = t_vepo-posnr.

                          if sy-subrc = 0.

                          delete t_lips index sy-tabix.

                          endif.

                          endloop.

                          if not t_lips[] is initial.

                          • move any unpacked items to the data table

                          perform move_lips_to_table.

                          endif.

                          endif. "TR03+

                          *<---- TR01+ End

                          • get relevant status icons

                          perform select_icons.

                          • prepare ALV data

                          perform prepare_alv.

                          endform. " select_data

                          &----


                          *& Form select_icons

                          &----


                          • select icons for display and move data to display table

                          ----


                          form select_icons.

                          data: w_disp_tab like zpickdisp,

                          w_disp_head like zpickhead,

                          w_color like zpickdisp-color,

                          ov_icon like zpickdisp-ov_icon,

                          gi_icon like zpickdisp-gi_icon,

                          to_icon like zpickdisp-to_icon,

                          lp_icon like zpickdisp-lp_icon,

                          pc_icon like zpickdisp-pc_icon,

                          lv_icon like zpickdisp-lv_icon,

                          vm_icon like zpickdisp-vm_icon,

                          em_icon like zpickdisp-em_icon,

                          t_ovst_tab like t_disp_tab with header line.

                          constants: c_col1(3) value 'C10',

                          c_col2(3) value 'C20'.

                          sort t_data_tab by lgtor vbeln.

                          w_color = c_col2.

                          loop at t_data_tab.

                          at new lgtor.

                          • fill ALV header table

                          clear w_disp_head.

                          w_disp_head-lgtor = t_data_tab-lgtor.

                          append w_disp_head to t_disp_head.

                          endat.

                          • goods issue status & overall amber/green only

                          case t_data_tab-wbstk.

                          when c_c.

                          move icon_green_light to gi_icon.

                          move icon_green_light to ov_icon.

                          when others.

                          move icon_red_light to gi_icon.

                          move icon_yellow_light to ov_icon.

                          endcase.

                          • transfer order status

                          case t_data_tab-lvsta.

                          when c_a.

                          move icon_red_light to to_icon.

                          when c_b.

                          move icon_yellow_light to to_icon.

                          when c_c.

                          move icon_green_light to to_icon.

                          when space.

                          • write N/A

                          to_icon = 'N/A'.

                          endcase.

                          • loaded to pallet status

                          if not t_data_tab-zpallet_no is initial.

                          move icon_green_light to lp_icon.

                          else.

                          move icon_red_light to lp_icon.

                          endif.

                          • pallet count status

                          if not t_data_tab-zcount_check is initial.

                          move icon_green_light to pc_icon.

                          else.

                          move icon_red_light to pc_icon.

                          endif.

                          • loaded to van status

                          if not t_data_tab-zvan_no is initial.

                          move icon_green_light to lv_icon.

                          else.

                          move icon_red_light to lv_icon.

                          endif.

                          • van manifest status

                          if not t_data_tab-zvan_print is initial.

                          move icon_green_light to vm_icon.

                          else.

                          move icon_red_light to vm_icon.

                          endif.

                          • end of day manifest status

                          if not t_data_tab-zeod_print is initial.

                          move icon_green_light to em_icon.

                          else.

                          move icon_red_light to em_icon.

                          endif.

                          • move working data table to display table

                          move-corresponding t_data_tab to w_disp_tab.

                          w_disp_tab-ov_icon = ov_icon.

                          w_disp_tab-gi_icon = gi_icon.

                          w_disp_tab-to_icon = to_icon.

                          w_disp_tab-lp_icon = lp_icon.

                          w_disp_tab-pc_icon = pc_icon.

                          w_disp_tab-lv_icon = lv_icon.

                          w_disp_tab-vm_icon = vm_icon.

                          w_disp_tab-em_icon = em_icon.

                          w_disp_tab-color = w_color.

                          • fill N/A values for initial fields for display

                          if w_disp_tab-packvorschr is initial.

                          w_disp_tab-packvorschr = 'N/A'.

                          endif.

                          if w_disp_tab-exidv is initial.

                          w_disp_tab-exidv = 'N/A'.

                          endif.

                          if w_disp_tab-zpallet_no is initial.

                          write 'N/A' to w_disp_tab-zpallet_no.

                          endif.

                          if w_disp_tab-zvan_no is initial.

                          write 'N/A' to w_disp_tab-zvan_no.

                          endif.

                          • display different color for new doc number

                          at end of vbeln.

                          if w_color = c_col1.

                          w_color = c_col2.

                          elseif w_color = c_col2.

                          w_color = c_col1.

                          endif.

                          endat.

                          append w_disp_tab to t_disp_tab.

                          clear w_disp_tab.

                          endloop.

                          • we have all the icons in display but need to check the overall status

                          • as this refers to the line items

                          • green and amber statuses already set and use the same criteria as the

                          • goods issue status unless detected as red here

                          data: ov_stat_red(1).

                          clear w_disp_tab.

                          sort t_disp_tab by vbeln.

                          loop at t_disp_tab into w_disp_tab.

                          at new vbeln.

                          • check all line items for delivery

                          loop at t_data_tab where vbeln = w_disp_tab-vbeln.

                          if t_data_tab-lvsta = c_a.

                          • set overall status to red

                          ov_stat_red = c_yes.

                          exit.

                          else.

                          • leave green/amber status icon as previosly determined

                          endif.

                          endloop.

                          if ov_stat_red = c_yes.

                          • set overall status to red for all items in that delivery

                          clear ov_stat_red.

                          move icon_red_light to w_disp_tab-ov_icon.

                          modify t_disp_tab from w_disp_tab transporting ov_icon

                          where vbeln = w_disp_tab-vbeln.

                          endif.

                          endat.

                          endloop.

                          endform. " select_icons

                          &----


                          *& Form fill_layout

                          &----


                          • fill ALV layout parameters

                          ----


                          form fill_layout.

                          clear g_layout.

                          g_layout-colwidth_optimize = c_yes. " column width optimisation

                          g_layout-zebra = space. " alternate line colors

                          g_layout-box_fieldname = 'MARK'. " checkbox fieldname

                          g_layout-info_fieldname = 'COLOR'. " highlight row indicator

                          g_layout-no_vline = space. " vertical line

                          g_layout-key_hotspot = space. " hotspot field

                          g_layout-f2code = 'PICK'. " F2 ok_code

                          g_layout-numc_sum = c_yes. " sum numc fields

                          g_layout-box_tabname = 't_disp_head'. " checkbox table name

                          g_layout-expand_fieldname = 'EXPAND'. " expand field name

                          endform. " fill_layout

                          &----


                          *& Form fill_sort

                          &----


                          • fill ALV sort table

                          ----


                          form fill_sort.

                          data: w_g_sort type slis_sortinfo_alv.

                          w_g_sort-spos = 1.

                          w_g_sort-fieldname = 'LGTOR'.

                          w_g_sort-tabname = 't_disp_tab'.

                          w_g_sort-up = c_yes.

                          append w_g_sort to g_sort.

                          w_g_sort-spos = 2.

                          w_g_sort-fieldname = 'VBELN'.

                          w_g_sort-tabname = 't_disp_tab'.

                          w_g_sort-up = c_yes.

                          append w_g_sort to g_sort.

                          w_g_sort-spos = 3.

                          w_g_sort-fieldname = 'POSNR'.

                          w_g_sort-tabname = 't_disp_tab'.

                          w_g_sort-up = c_yes.

                          append w_g_sort to g_sort.

                          w_g_sort-spos = 4.

                          w_g_sort-fieldname = 'WADAT'.

                          w_g_sort-tabname = 't_disp_tab'.

                          w_g_sort-up = c_yes.

                          append w_g_sort to g_sort.

                          endform. " fill_sort

                          &----


                          *& Form fill_fieldcat

                          &----


                          • Fill field category structure for ALV

                          ----


                          form fill_fieldcat.

                          clear t_fldcat.

                          • create field catalogue for header table

                          call function 'REUSE_ALV_FIELDCATALOG_MERGE'

                          exporting

                          i_program_name = 'ZWMR_PICK_STATUS_REPORT'

                          i_internal_tabname = 't_disp_head'

                          i_structure_name = 'ZPICKHEAD'

                          i_client_never_display = c_yes

                          changing

                          ct_fieldcat = gt_fieldcat[].

                          if sy-subrc <> 0.

                          message id sy-msgid type sy-msgty number sy-msgno

                          with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

                          endif.

                          • ceate field catalogue for items table

                          call function 'REUSE_ALV_FIELDCATALOG_MERGE'

                          exporting

                          i_program_name = 'ZWMR_PICK_STATUS_REPORT'

                          i_internal_tabname = 't_disp_tab'

                          i_structure_name = 'ZPICKDISP'

                          i_client_never_display = c_yes

                          changing

                          ct_fieldcat = gt_fieldcat[].

                          if sy-subrc <> 0.

                          message id sy-msgid type sy-msgty number sy-msgno

                          with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

                          endif.

                          • modify field catalogue for this report

                          • set no display flag if not requested on selection screen

                          if p_exdata ne c_yes.

                          t_fldcat-no_out = c_yes.

                          modify gt_fieldcat from t_fldcat transporting no_out

                          where fieldname eq 'PACKVORSCHR'

                          or fieldname eq 'EXIDV'

                          or fieldname eq 'ZPALLET_NO'

                          or fieldname eq 'ZVAN_NO'

                          or fieldname eq 'ZZPACKCLASS'

                          or fieldname eq 'ZZTI'.

                          endif.

                          • set no display flag for item level LGTOR field

                          t_fldcat-no_out = c_yes.

                          modify gt_fieldcat from t_fldcat transporting no_out

                          where fieldname eq 'LGTOR'

                          and tabname eq 't_disp_tab'.

                          • prevent display of technical fields

                          t_fldcat-tech = c_yes.

                          modify gt_fieldcat from t_fldcat transporting tech

                          where fieldname eq 'EXPAND'

                          or fieldname eq 'SELKZ'.

                          • set vbeln as key

                          t_fldcat-key = c_yes.

                          modify gt_fieldcat from t_fldcat transporting key

                          where fieldname eq 'VBELN'.

                          • prevent scrolling for info fields

                          t_fldcat-fix_column = c_yes.

                          modify gt_fieldcat from t_fldcat transporting fix_column

                          where fieldname eq 'VBELN'.

                          endform. " fill_fieldcat

                          &----


                          *& Form prepare_ALV

                          &----


                          • Fill ALV parameters

                          ----


                          form prepare_alv.

                          • fill ALV key info

                          g_keyinfo-header01 = 'LGTOR'.

                          g_keyinfo-item01 = 'LGTOR'.

                          • fill ALV events

                          gs_event-name = 'TOP_OF_PAGE'.

                          gs_event-form = 'TOP_OF_PAGE'.

                          append gs_event to gt_events.

                          • fill ALV sort table

                          perform fill_sort.

                          • fill ALV layout structure

                          perform fill_layout.

                          • fill ALV field category

                          perform fill_fieldcat.

                          endform. " prepare_ALV

                          &----


                          *& Form user_command

                          &----


                          • form called on user command from ALV list

                          ----


                          form user_command using r_ucomm like sy-ucomm

                          rs_selfield type slis_selfield.

                          data: index type i,

                          w_disp_head like line of t_disp_head,

                          w_door like likp-lgtor.

                          clear r_lgtor. refresh r_lgtor.

                          case r_ucomm.

                          when 'PICK'. " Double click line

                          when 'VANM'. " Van Manifest button

                          • read the header table where has been selected

                          loop at t_disp_head into w_disp_head where mark = c_yes.

                          r_lgtor-sign = 'I'.

                          r_lgtor-option = 'EQ'.

                          r_lgtor-low = w_disp_head-lgtor.

                          append r_lgtor.

                          endloop.

                          • print the van manifest

                          perform print_van_manifest tables r_lgtor.

                          when 'EODM'. " EOD Manifest button

                          • read the header table where has been selected

                          loop at t_disp_head into w_disp_head where mark = c_yes.

                          r_lgtor-sign = 'I'.

                          r_lgtor-option = 'EQ'.

                          r_lgtor-low = w_disp_head-lgtor.

                          append r_lgtor.

                          endloop.

                          • print the end of day manifest

                          perform print_eod_manifest tables r_lgtor.

                          when 'REFR'. "Refresh

                          • refresh display

                          w_sy_repid = sy-repid.

                          call function 'RS_REFRESH_FROM_SELECTOPTIONS'

                          exporting

                          curr_report = w_sy_repid

                          tables

                          selection_table = seltab.

                          • exceptions

                          • not_found = 1

                          • no_report = 2

                          • others = 3.

                          if sy-subrc = 0.

                          submit (w_sy_repid) with selection-table seltab.

                          endif.

                          endcase.

                          endform.

                          &----


                          *& Form set_status

                          &----


                          • form used to set custom gui status for ALV

                          ----


                          form set_status using rt_extab type slis_t_extab.

                          data: t_stat_excl type slis_t_extab,

                          w_stat_excl like line of t_stat_excl.

                          w_stat_excl-fcode = '&RNT'.

                          append w_stat_excl to t_stat_excl.

                          set pf-status 'ZSTANDARD' excluding t_stat_excl.

                          endform.

                          &----


                          *& Form validate_selections

                          &----


                          • text

                          ----


                          form validate_selections.

                          if not s_lgtor is initial.

                          if not s_exidv is initial

                          or not s_vbeln is initial

                          or not s_palno is initial

                          or not s_vanno is initial.

                          message e020.

                          exit.

                          endif.

                          endif.

                          if not s_exidv is initial.

                          if not s_lgtor is initial

                          or not s_vbeln is initial

                          or not s_palno is initial

                          or not s_vanno is initial.

                          message e020.

                          exit.

                          endif.

                          endif.

                          if not s_vbeln is initial.

                          if not s_exidv is initial

                          or not s_lgtor is initial

                          or not s_palno is initial

                          or not s_vanno is initial.

                          message e020.

                          exit.

                          endif.

                          endif.

                          if not s_palno is initial.

                          if not s_exidv is initial

                          or not s_vbeln is initial

                          or not s_lgtor is initial

                          or not s_vanno is initial.

                          message e020.

                          exit.

                          endif.

                          endif.

                          if not s_vanno is initial.

                          if not s_exidv is initial

                          or not s_vbeln is initial

                          or not s_palno is initial

                          or not s_lgtor is initial.

                          message e020.

                          exit.

                          endif.

                          endif.

                          endform. " validate_selections

                          &----


                          *& Form top_of_page

                          &----


                          • form called by ALV genarator for top_of_page event

                          ----


                          form top_of_page.

                          sort s_vbeln by sign descending option descending.

                          sort s_palno by sign descending option descending.

                          sort s_vanno by sign descending option descending.

                          sort s_wadat by sign descending option descending.

                          sort s_exidv by sign descending option descending.

                          • Van Number summary

                          loop at s_vanno.

                          at new sign.

                          if s_vanno-sign = 'I'.

                          format color 5 on.

                          write:/ 'Van Numbers Included:'(003).

                          format color off.

                          elseif s_vanno-sign = 'E'.

                          format color 6 on.

                          write:/ 'Van Numbers Excluded:'(004).

                          format color off.

                          endif.

                          endat.

                          case s_vanno-option.

                          when 'EQ'.

                          write:/ 'Equal to'(013), 15 s_vanno-low.

                          when 'NE'.

                          write:/ 'Not equal to'(014), 15 s_vanno-low.

                          when 'BT'.

                          write:/ 'Between'(015), 15 s_vanno-low, ' and '(016),

                          s_vanno-high.

                          endcase.

                          at last.

                          skip.

                          endat.

                          endloop.

                          • Pallet Number summary

                          loop at s_palno.

                          at new sign.

                          if s_palno-sign = 'I'.

                          format color 5 on.

                          write:/ 'Pallet Numbers Included:'(005).

                          format color off.

                          elseif s_palno-sign = 'E'.

                          format color 6 on.

                          write:/ 'Pallet Numbers Excluded:'(006).

                          format color off.

                          endif.

                          endat.

                          case s_palno-option.

                          when 'EQ'.

                          write:/ 'Equal to'(013), 15 s_palno-low.

                          when 'NE'.

                          write:/ 'Not equal to'(014), 15 s_palno-low.

                          when 'BT'.

                          write:/ 'Between'(015), 15 s_palno-low, ' and '(016),

                          s_palno-high.

                          endcase.

                          at last.

                          skip.

                          endat.

                          endloop.

                          • Delivery Number summary

                          loop at s_vbeln.

                          at new sign.

                          if s_vbeln-sign = 'I'.

                          format color 5 on.

                          write:/ 'Delivery Numbers Included:'(007).

                          format color off.

                          elseif s_vanno-sign = 'E'.

                          format color 6 on.

                          write:/ 'Delivery Numbers Excluded:'(008).

                          format color off.

                          endif.

                          endat.

                          case s_vbeln-option.

                          when 'EQ'.

                          write:/ 'Equal to'(013), 15 s_vbeln-low.

                          when 'NE'.

                          write:/ 'Not equal to'(014), 15 s_vbeln-low.

                          when 'BT'.

                          write:/ 'Between'(015), 15 s_vbeln-low, ' and '(016),

                          s_vbeln-high.

                          endcase.

                          at last.

                          skip.

                          endat.

                          endloop.

                          • HU Number summary

                          loop at s_exidv.

                          at new sign.

                          if s_exidv-sign = 'I'.

                          format color 5 on.

                          write:/ 'Handling Unit Numbers Included:'(009).

                          format color off.

                          elseif s_vanno-sign = 'E'.

                          format color 6 on.

                          write:/ 'Handling Unit Numbers Excluded:'(010).

                          format color off.

                          endif.

                          endat.

                          case s_exidv-option.

                          when 'EQ'.

                          write:/ 'Equal to'(013), 15 s_exidv-low.

                          when 'NE'.

                          write:/ 'Not equal to'(014), 15 s_exidv-low.

                          when 'BT'.

                          write:/ 'Between'(015), 15 s_exidv-low, ' and '(016),

                          s_exidv-high.

                          endcase.

                          at last.

                          skip.

                          endat.

                          endloop.

                          • Date range summary

                          check not s_wadat is initial.

                          format color 5 on.

                          write:/ 'Date Range: '(011), s_wadat-low, ' to '(012).

                          if s_wadat-option = 'BT'.

                          write s_wadat-high.

                          else.

                          write s_wadat-low.

                          endif.

                          format color off.

                          endform. " top_of_page

                          &----


                          *& Form print_van_manifest

                          &----


                          • submit the van manifest report to a printer

                          ----


                          form print_van_manifest tables p_lgtor structure r_lgtor.

                          clear: r_vanno, r_palno.

                          refresh: r_vanno, r_palno.

                          data: vans type i.

                          • fill selection screen parameters for van manifest

                          loop at t_data_tab where lgtor in p_lgtor.

                          if not t_data_tab-zvan_no is initial " it is loaded to van

                          • and t_data_tab-kostk eq 'C' " pick status C = Complete

                          "TR01-

                          and ( t_data_tab-kostk eq 'C' "TR01+

                          or t_data_tab-kostk eq space ). "TR01+

                          • begin TR01-

                          • and t_data_tab-zvan_print ne c_yes " no van manifest has been

                          • " printed

                          • and t_data_tab-zeod_print ne c_yes. " no eod manifest has been

                          • " printed

                          • end TR01-

                          • fill van number range

                          r_vanno-sign = 'I'.

                          r_vanno-option = 'EQ'.

                          r_vanno-low = t_data_tab-zvan_no.

                          append r_vanno.

                          • fill pallet number range

                          r_palno-sign = 'I'.

                          r_palno-option = 'EQ'.

                          r_palno-low = t_data_tab-zpallet_no.

                          append r_palno.

                          endif.

                          endloop.

                          delete adjacent duplicates from r_vanno comparing low.

                          describe table r_vanno lines vans.

                          if vans = 0.

                          • error no vans available for van manifest report

                          message e025(zw).

                          else.

                          • submit van manifest report straight to printer

                          submit zwmr_manifest_reports to sap-spool

                          with s_vanno in r_vanno

                              • commented out pending decision on CR 140 solution design ***

                            • with s_date in s_wadat

                            • and return.

                              endif.

                              • on completion of the van manifest, the shipment status 'loading end'

                              • needs to be set if any of the handling units on the van are the last

                              • in a particular shipment to be despatched

                              perform load_end_validate tables r_palno.

                              endform. " print_van_manifest

                              &----


                              *& Form print_eod_manifest

                              &----


                              • submit the end of day manifest report to a printer

                              ----


                              form print_eod_manifest tables p_lgtor structure r_lgtor.

                              ranges: r_vanno for zvantr-zvan_no.

                              data: vans type i.

                              • fill selection screen parameters for van manifest

                              loop at t_data_tab where lgtor in p_lgtor.

                              if not t_data_tab-zvan_no is initial " it is loaded to van

                              and t_data_tab-kostk eq 'C' " pick status C = Complete

                              and t_data_tab-zeod_print ne c_yes. " no eod manifest has been

                              " printed

                              • fill van number range

                              r_vanno-sign = 'I'.

                              r_vanno-option = 'EQ'.

                              r_vanno-low = t_data_tab-zvan_no.

                              append r_vanno.

                              endif.

                              endloop.

                              delete adjacent duplicates from r_vanno comparing low.

                              describe table r_vanno lines vans.

                              if vans = 0.

                              • error no vans available for eod manifest report

                              message e027(zw).

                              else.

                              • submit van manifest report straight to printer

                              submit zwmr_manifest_reports to sap-spool

                              with s_vanno in r_vanno

                              with p_repflg eq c_yes

                                  • commented out pending decision on CR 140 solution design ***

                                • with s_date in s_wadat

                                • and return.

                                  endif.

                                  endform. " print_eod_manifest

                                  &----


                                  *& Form load_end_validate

                                  &----


                                  • Determine on van manifest print whether or not any of the

                                  • handling units on the vans in quection are the last of a

                                  • particular shipment to be loaded. If so set the 'loading end'

                                  • status of that shipment.

                                  ----


                                  • -->P_PALNO pallet number range

                                  ----


                                  form load_end_validate tables p_palno structure r_palno.

                                  • local data

                                  ranges: r_vbeln for likp-vbeln,

                                  r_tknum for vttk-tknum,

                                  r_ldend for vttk-tknum.

                                  data: l_t_paltr like standard table of zpallettr with header line,

                                  l_t_vekp like standard table of vekp with header line,

                                  l_t_likp like standard table of likp with header line,

                                  l_t_vepo like standard table of vepo with header line,

                                  l_t_vantr like standard table of zvantr with header line,

                                  l_t_lips like standard table of lips with header line,

                                  l_t_vttp like standard table of vttp with header line.

                                  data: not_last(1) type c. " not last flag

                                  data: w_stlad like vttk-stlad. "TR01+

                                  • get all pallets on the vans

                                  select * from zpallettr into table l_t_paltr

                                  where zpallet_no in p_palno.

                                  check not l_t_paltr[] is initial.

                                  • get all handling units on the pallets

                                  select * from vekp into table l_t_vekp

                                  for all entries in l_t_paltr

                                  where exidv = l_t_paltr-exidv

                                  and ( exida = 'E'

                                  or exida = 'F' ).

                                  check not l_t_vekp[] is initial.

                                  • build range of deliveries from vekp-vpobjkey

                                  loop at l_t_vekp.

                                  r_vbeln-sign = 'I'.

                                  r_vbeln-option = 'EQ'.

                                  r_vbeln-low = l_t_vekp-vpobjkey.

                                  append r_vbeln.

                                  endloop.

                                  • select all deliveries associated with the handling units

                                  select * from likp into table l_t_likp

                                  where vbeln in r_vbeln.

                                  check not l_t_likp[] is initial.

                                  • select shipment line items that correspond to deliveries

                                  select * from vttp into table l_t_vttp

                                  for all entries in l_t_likp

                                  where vbeln = l_t_likp-vbeln.

                                  check not l_t_vttp[] is initial.

                                  • get associated shipment numbers.

                                  loop at l_t_vttp.

                                  • if status already set, do not include "TR01+

                                  select single stlad from vttk into w_stlad "TR01+

                                  where tknum = l_t_vttp-tknum. "TR01+

                                  if w_stlad ne c_yes. "TR01+

                                  clear w_stlad.

                                  r_tknum-sign = 'I'.

                                  r_tknum-option = 'EQ'.

                                  r_tknum-low = l_t_vttp-tknum.

                                  append r_tknum.

                                  endif. "TR01+

                                  endloop.

                                  sort r_tknum by low.

                                  delete adjacent duplicates from r_tknum comparing low.

                                  • we now have a list of shipment numbers affected by the printing

                                  • of the van manifest just carried out.

                                  • next we need to get a complete list of handling units associated with

                                  • these shipments, and check if they have been loaded firstly to a

                                  • pallet and then to a van, and if so check that the van manifest report

                                  • has been printed

                                  • if all handling units for a particular shipment have been loaded and

                                  • the van manifest printed, then we need to update the status flag of

                                  • the shipment to "Loading End"

                                  data: lin type i,

                                  ind type i,

                                  w_tknum like vttk-tknum.

                                  • make sure we have all items for all shipments

                                  select * from vttp appending corresponding fields of table l_t_vttp

                                  where tknum in r_tknum.

                                  check not l_t_vttp[] is initial.

                                  sort l_t_vttp by tknum vbeln.

                                  • delete duplicate lines

                                  delete adjacent duplicates from l_t_vttp comparing tknum vbeln.

                                  • now get all delivery items.

                                  select * from lips into table l_t_lips

                                  for all entries in l_t_vttp

                                  where vbeln = l_t_vttp-vbeln

                                  and pstyv ne 'ZPAC'

                                  and pstyv ne 'ZGDP'. "TR02+

                                  check not l_t_lips[] is initial.

                                  • now get handling units

                                  select * from vepo into table l_t_vepo

                                  for all entries in l_t_lips

                                  where vbeln = l_t_lips-vbeln

                                  and posnr = l_t_lips-posnr

                                  and matnr = l_t_lips-matnr

                                  and charg = l_t_lips-charg.

                                  check not l_t_vepo[] is initial.

                                  select * from vekp appending corresponding fields of table l_t_vekp

                                  for all entries in l_t_vepo

                                  where venum = l_t_vepo-venum.

                                  sort l_t_vekp by exidv.

                                  check not l_t_vekp[] is initial.

                                  • delete duplicate lines

                                  delete adjacent duplicates from l_t_vekp comparing exidv.

                                  • now get pallet data

                                  select * from zpallettr

                                  appending corresponding fields of table l_t_paltr

                                  for all entries in l_t_vekp

                                  where exidv = l_t_vekp-exidv

                                  and zload = c_yes. " loaded to van

                                  check not l_t_paltr[] is initial.

                                  • delete duplicate lines

                                  delete adjacent duplicates from l_t_paltr comparing exidv.

                                  • now get van data

                                  select * from zvantr into table l_t_vantr

                                  for all entries in l_t_paltr

                                  where zpallet_no = l_t_paltr-zpallet_no

                                  and zvan_print = c_yes. " van manifest printed

                                  • we now have all delivery, handling unit, pallet and van

                                  • information, so can now check each shipment in turn for complete

                                  • loading

                                  describe table r_tknum lines lin.

                                  r_ldend[] = r_tknum[].

                                  sort l_t_vttp by tknum vbeln.

                                  ind = 1.

                                  do lin times.

                                  read table r_tknum index ind.

                                  w_tknum = r_tknum-low.

                                  • for this shipment we need to find all hu's and determine

                                  • whether loaded and van manifest printed

                                  • shipment item

                                  loop at l_t_vttp where tknum = w_tknum.

                                  • delivery item

                                  loop at l_t_vepo where vbeln = l_t_vttp-vbeln.

                                  • read HU item

                                  clear l_t_vekp.

                                  read table l_t_vekp with key venum = l_t_vepo-venum.

                                  • read pallet

                                  clear l_t_paltr.

                                  read table l_t_paltr with key exidv = l_t_vekp-exidv.

                                  if sy-subrc = 0.

                                  • read van

                                  clear l_t_vantr.

                                  read table l_t_vantr

                                  with key zpallet_no = l_t_paltr-zpallet_no.

                                  if sy-subrc = 0.

                                  • HU has been loaded to a van that has had the van manifest

                                  • printed

                                  else.

                                  if l_t_paltr-zpallet_no in p_palno.

                                  • database table not yet updated but HU is loaded

                                  else.

                                  • pallet not on van, or van manifest not printed for van

                                  not_last = c_yes.

                                  exit.

                                  endif.

                                  endif.

                                  else.

                                  • HU or pallet not loaded

                                  not_last = c_yes.

                                  exit.

                                  endif.

                                  endloop.

                                  • if not_last = yes, then the last HU has NOT been loaded therefore

                                  • we can exit the looping for this shipment

                                  if not_last = c_yes.

                                  exit.

                                  endif.

                                  endloop.

                                  if not_last = c_yes.

                                  • remove shipment from load end range

                                  delete r_ldend where low = w_tknum.

                                  not_last = c_no.

                                  endif.

                                  add 1 to ind.

                                  enddo.

                                  • if we have any shipments in the load end range (r_ldend) then submit

                                  • update status report

                                  check not r_ldend[] is initial.

                                  submit ztrr_rv56trsl with p_aload = c_yes

                                  with p_cship = c_no

                                  with k_tknum in r_ldend.

                                  endform. " load_end_validate

                                  *----


                                  > TR01+ start

                                  &----


                                  *& Form move_lips_to_table

                                  &----


                                  • This form mirrors the move_to_table functionality for items

                                  • that have not been packed (i.e. without an entry in VEPO)

                                  ----


                                  form move_lips_to_table.

                                  loop at t_lips.

                                  clear t_data_tab.

                                  • delivery line items

                                  move-corresponding t_lips to t_data_tab.

                                  • sales document line items

                                  clear w_vbup.

                                  read table t_vbup with key vbeln = t_lips-vbeln

                                  posnr = t_lips-posnr

                                  into w_vbup.

                                  move-corresponding w_vbup to t_data_tab.

                                  • sales doc header

                                  clear w_vbuk.

                                  read table t_vbuk with key vbeln = t_lips-vbeln

                                  into w_vbuk.

                                  move-corresponding w_vbuk to t_data_tab.

                                  • delivery header

                                  clear w_likp.

                                  read table t_likp with key vbeln = t_lips-vbeln

                                  into w_likp.

                                  move-corresponding w_likp to t_data_tab.

                                  append t_data_tab.

                                  endloop.

                                  endform. " move_lips_to_table

                                  Regards,

                                  Anji

                                Add a comment
                                10|10000 characters needed characters exceeded

                              • Posted on Feb 28, 2007 at 06:53 AM

                                Hi,

                                Kindly check this sample coding.

                                Check this example..Marked in bold..

                                TYPE-POOLS: slis.

                                DATA: BEGIN OF itab OCCURS 0,

                                vbeln TYPE vbeln,

                                expand,

                                END OF itab.

                                DATA: BEGIN OF itab1 OCCURS 0,

                                vbeln TYPE vbeln,

                                posnr TYPE posnr,

                                matnr TYPE matnr,

                                netpr TYPE netpr,

                                END OF itab1.

                                DATA: t_fieldcatalog TYPE slis_t_fieldcat_alv.

                                DATA: s_fieldcatalog TYPE slis_fieldcat_alv.

                                s_fieldcatalog-col_pos = '1'.

                                s_fieldcatalog-fieldname = 'VBELN'.

                                s_fieldcatalog-tabname = 'ITAB'.

                                s_fieldcatalog-rollname = 'VBELN'.

                                s_fieldcatalog-outputlen = '12'.

                                APPEND s_fieldcatalog TO t_fieldcatalog.

                                CLEAR: s_fieldcatalog.

                                s_fieldcatalog-col_pos = '1'.

                                s_fieldcatalog-fieldname = 'VBELN'.

                                s_fieldcatalog-tabname = 'ITAB1'.

                                s_fieldcatalog-rollname = 'VBELN'.

                                s_fieldcatalog-outputlen = '12'.

                                APPEND s_fieldcatalog TO t_fieldcatalog.

                                CLEAR: s_fieldcatalog.

                                s_fieldcatalog-col_pos = '2'.

                                s_fieldcatalog-fieldname = 'POSNR'.

                                s_fieldcatalog-tabname = 'ITAB1'.

                                s_fieldcatalog-rollname = 'POSNR'.

                                APPEND s_fieldcatalog TO t_fieldcatalog.

                                CLEAR: s_fieldcatalog.

                                s_fieldcatalog-col_pos = '3'.

                                s_fieldcatalog-fieldname = 'MATNR'.

                                s_fieldcatalog-tabname = 'ITAB1'.

                                s_fieldcatalog-rollname = 'MATNR'.

                                APPEND s_fieldcatalog TO t_fieldcatalog.

                                CLEAR: s_fieldcatalog.

                                s_fieldcatalog-col_pos = '4'.

                                s_fieldcatalog-fieldname = 'NETPR'.

                                s_fieldcatalog-tabname = 'ITAB1'.

                                s_fieldcatalog-rollname = 'NETPR'.

                                s_fieldcatalog-do_sum = 'X'.

                                APPEND s_fieldcatalog TO t_fieldcatalog.

                                CLEAR: s_fieldcatalog.

                                DATA: s_layout TYPE slis_layout_alv.

                                s_layout-subtotals_text = 'SUBTOTAL TEXT'.

                                s_layout-key_hotspot = 'X'.

                                s_layout-expand_fieldname = 'EXPAND'.

                                SELECT vbeln UP TO 100 ROWS

                                FROM

                                vbak

                                INTO TABLE itab

                                WHERE vbeln > '0060000040'.

                                IF NOT itab[] IS INITIAL.

                                SELECT vbeln posnr matnr netpr

                                FROM vbap

                                INTO TABLE itab1

                                FOR ALL ENTRIES IN itab

                                WHERE vbeln = itab-vbeln.

                                ENDIF.

                                DATA: v_repid TYPE syrepid.

                                v_repid = sy-repid.

                                DATA: s_keyinfo TYPE slis_keyinfo_alv.

                                s_keyinfo-header01 = 'VBELN'.

                                s_keyinfo-item01 = 'VBELN'.

                                CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'

                                EXPORTING

                                i_callback_program = v_repid

                                i_callback_user_command = 'USER_COMMAND'

                                is_layout = s_layout

                                it_fieldcat = t_fieldcatalog

                                i_tabname_header = 'ITAB'

                                i_tabname_item = 'ITAB1'

                                is_keyinfo = s_keyinfo

                                TABLES

                                t_outtab_header = itab

                                t_outtab_item = itab1

                                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.

                                FORM user_command USING ucomm LIKE sy-ucomm

                                selfield TYPE slis_selfield.

                                IF ucomm = '&IC1' AND selfield-fieldname = 'VBELN'.

                                READ TABLE itab INDEX selfield-tabindex.

                                IF sy-subrc = 0.

                                • document

                                SET PARAMETER ID 'AUN' FIELD itab-vbeln.

                                CALL TRANSACTION 'VA03' AND SKIP FIRST SCREEN.

                                ENDIF.

                                ENDIF.

                                ENDFORM.

                                Thanks,

                                Shankar

                                Add a comment
                                10|10000 characters needed characters exceeded

                              • Posted on Feb 28, 2007 at 06:54 AM
                                Add a comment
                                10|10000 characters needed characters exceeded

                              • author's profile photo Former Member
                                Former Member
                                Posted on Feb 28, 2007 at 06:54 AM

                                HI,

                                You need to use the function module <b>REUSE_ALV_HIERARCHICAL_LIST_DISPLAY</b> "For Hierarchical LIST

                                *&---------------------------------------------------------------------*
                                *& Report  ZDEMO_ALVTREE                                               *
                                *&                                                                     *
                                *&---------------------------------------------------------------------*
                                *&                                                                     *
                                *& Example of a simple ALV Grid Report                                 *
                                *& ...................................                                 *
                                *&                                                                     *
                                *& The basic requirement for this demo is to display a number of       *
                                *& fields from the EKPO and EKKO table in a tree structure.            *
                                *&                                                                     *
                                *&---------------------------------------------------------------------*
                                *                          Amendment History                           *
                                *----------------------------------------------------------------------*
                                REPORT  zdemo_alvgrid                 .
                                
                                *Data Declaration
                                *----------------
                                TABLES:     ekko.
                                TYPE-POOLS: slis.                                 "ALV Declarations
                                
                                TYPES: BEGIN OF t_ekko,
                                  ebeln TYPE ekpo-ebeln,
                                  ebelp TYPE ekpo-ebelp,
                                  statu TYPE ekpo-statu,
                                  aedat TYPE ekpo-aedat,
                                  matnr TYPE ekpo-matnr,
                                  menge TYPE ekpo-menge,
                                  meins TYPE ekpo-meins,
                                  netpr TYPE ekpo-netpr,
                                  peinh TYPE ekpo-peinh,
                                 END OF t_ekko.
                                
                                DATA: it_ekko     TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,
                                      it_ekpo     TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,
                                      it_emptytab TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,
                                      wa_ekko     TYPE t_ekko,
                                      wa_ekpo     TYPE t_ekko.
                                
                                DATA: ok_code like sy-ucomm,           "OK-Code
                                      save_ok like sy-ucomm.
                                
                                *ALV data declarations
                                DATA: fieldcatalog  TYPE lvc_t_fcat WITH HEADER LINE.
                                
                                DATA: gd_fieldcat   TYPE lvc_t_fcat,
                                      gd_tab_group  TYPE slis_t_sp_group_alv,
                                      gd_layout     TYPE slis_layout_alv.
                                
                                *ALVtree data declarations
                                CLASS cl_gui_column_tree DEFINITION LOAD.
                                CLASS cl_gui_cfw DEFINITION LOAD.
                                
                                DATA: gd_tree             TYPE REF TO cl_gui_alv_tree,
                                      gd_hierarchy_header TYPE treev_hhdr,
                                      gd_report_title     TYPE slis_t_listheader,
                                      gd_logo             TYPE sdydo_value,
                                      gd_variant          TYPE disvariant.
                                
                                *Create container for alv-tree
                                DATA: l_tree_container_name(30) TYPE c,
                                      l_custom_container        TYPE REF TO cl_gui_custom_container.
                                
                                
                                ************************************************************************
                                *Includes
                                *INCLUDE ZDEMO_ALVTREEO01. "Screen PBO Modules
                                *INCLUDE ZDEMO_ALVTREEI01. "Screen PAI Modules
                                *INCLUDE ZDEMO_ALVTREEF01. "ABAP Subroutines(FORMS)
                                
                                ************************************************************************
                                *Start-of-selection.
                                START-OF-SELECTION.
                                
                                * ALVtree setup data
                                    PERFORM data_retrieval.
                                    PERFORM build_fieldcatalog.
                                    PERFORM build_layout.
                                    PERFORM build_hierarchy_header CHANGING gd_hierarchy_header.
                                    PERFORM build_report_title USING gd_report_title gd_logo.
                                    PERFORM build_variant.
                                
                                * Display ALVtree report
                                  call screen 100.
                                
                                
                                *&---------------------------------------------------------------------*
                                *&      Form  DATA_RETRIEVAL
                                *&---------------------------------------------------------------------*
                                *       Retrieve data into Internal tables
                                *----------------------------------------------------------------------*
                                FORM data_retrieval.
                                  SELECT ebeln
                                   UP TO 10 ROWS
                                    FROM ekko
                                    INTO corresponding fields of TABLE it_ekko.
                                
                                  loop at it_ekko into wa_ekko.
                                    SELECT ebeln ebelp statu aedat matnr menge meins netpr peinh
                                      FROM ekpo
                                      appending TABLE it_ekpo
                                     where ebeln eq wa_ekko-ebeln.
                                  endloop.
                                ENDFORM.                    " DATA_RETRIEVAL
                                
                                
                                *&---------------------------------------------------------------------*
                                *&      Form  BUILD_FIELDCATALOG
                                *&---------------------------------------------------------------------*
                                *       Build Fieldcatalog for ALV Report
                                *----------------------------------------------------------------------*
                                FORM build_fieldcatalog.
                                * Please not there are a number of differences between the structure of
                                * ALVtree fieldcatalogs and ALVgrid fieldcatalogs.
                                * For example the field seltext_m is replace by scrtext_m in ALVtree.
                                
                                  fieldcatalog-fieldname   = 'EBELN'.           "Field name in itab
                                  fieldcatalog-scrtext_m   = 'Purchase Order'.  "Column text
                                  fieldcatalog-col_pos     = 0.                 "Column position
                                  fieldcatalog-outputlen   = 15.                "Column width
                                  fieldcatalog-emphasize   = 'X'.               "Emphasize  (X or SPACE)
                                  fieldcatalog-key         = 'X'.               "Key Field? (X or SPACE)
                                *  fieldcatalog-do_sum      = 'X'.              "Sum Column?
                                *  fieldcatalog-no_zero     = 'X'.              "Don't display if zero
                                  APPEND fieldcatalog TO gd_fieldcat.
                                  CLEAR  fieldcatalog.
                                
                                  fieldcatalog-fieldname   = 'EBELP'.
                                  fieldcatalog-scrtext_m   = 'PO Iten'.
                                  fieldcatalog-outputlen   = 15.
                                  fieldcatalog-col_pos     = 1.
                                  APPEND fieldcatalog TO gd_fieldcat..
                                  CLEAR  fieldcatalog.
                                
                                  fieldcatalog-fieldname   = 'STATU'.
                                  fieldcatalog-scrtext_m   = 'Status'.
                                  fieldcatalog-outputlen   = 15.
                                  fieldcatalog-col_pos     = 2.
                                  APPEND fieldcatalog TO gd_fieldcat..
                                  CLEAR  fieldcatalog.
                                
                                  fieldcatalog-fieldname   = 'AEDAT'.
                                  fieldcatalog-scrtext_m   = 'Item change date'.
                                  fieldcatalog-outputlen   = 15.
                                  fieldcatalog-col_pos     = 3.
                                  APPEND fieldcatalog TO gd_fieldcat..
                                  CLEAR  fieldcatalog.
                                
                                  fieldcatalog-fieldname   = 'MATNR'.
                                  fieldcatalog-scrtext_m   = 'Material Number'.
                                  fieldcatalog-outputlen   = 15.
                                  fieldcatalog-col_pos     = 4.
                                  APPEND fieldcatalog TO gd_fieldcat..
                                  CLEAR  fieldcatalog.
                                
                                  fieldcatalog-fieldname   = 'MENGE'.
                                  fieldcatalog-scrtext_m   = 'PO quantity'.
                                  fieldcatalog-outputlen   = 15.
                                  fieldcatalog-col_pos     = 5.
                                  APPEND fieldcatalog TO gd_fieldcat..
                                  CLEAR  fieldcatalog.
                                
                                  fieldcatalog-fieldname   = 'MEINS'.
                                  fieldcatalog-scrtext_m   = 'Order Unit'.
                                  fieldcatalog-outputlen   = 15.
                                  fieldcatalog-col_pos     = 6.
                                  APPEND fieldcatalog TO gd_fieldcat..
                                  CLEAR  fieldcatalog.
                                
                                  fieldcatalog-fieldname   = 'NETPR'.
                                  fieldcatalog-scrtext_m   = 'Net Price'.
                                  fieldcatalog-outputlen   = 15.
                                  fieldcatalog-col_pos     = 7.
                                  fieldcatalog-datatype     = 'CURR'.
                                  APPEND fieldcatalog TO gd_fieldcat..
                                  CLEAR  fieldcatalog.
                                
                                  fieldcatalog-fieldname   = 'PEINH'.
                                  fieldcatalog-scrtext_m   = 'Price Unit'.
                                  fieldcatalog-outputlen   = 15.
                                  fieldcatalog-col_pos     = 8.
                                  APPEND fieldcatalog TO gd_fieldcat..
                                  CLEAR  fieldcatalog.
                                ENDFORM.                    " BUILD_FIELDCATALOG
                                
                                
                                *&---------------------------------------------------------------------*
                                *&      Form  BUILD_LAYOUT
                                *&---------------------------------------------------------------------*
                                *       Build layout for ALV grid report
                                *----------------------------------------------------------------------*
                                FORM build_layout.
                                  gd_layout-no_input          = 'X'.
                                  gd_layout-colwidth_optimize = 'X'.
                                  gd_layout-totals_text       = 'Totals'(201).
                                *  gd_layout-totals_only        = 'X'.
                                *  gd_layout-f2code            = 'DISP'.  "Sets fcode for when double
                                *                                         "click(press f2)
                                *  gd_layout-zebra             = 'X'.
                                *  gd_layout-group_change_edit = 'X'.
                                *  gd_layout-header_text       = 'helllllo'.
                                ENDFORM.                    " BUILD_LAYOUT
                                
                                
                                *&---------------------------------------------------------------------*
                                *&      Form  build_hierarchy_header
                                *&---------------------------------------------------------------------*
                                *       build hierarchy-header-information
                                *----------------------------------------------------------------------*
                                *      -->P_L_HIERARCHY_HEADER  structure for hierarchy-header
                                *----------------------------------------------------------------------*
                                FORM build_hierarchy_header CHANGING
                                                               p_hierarchy_header TYPE treev_hhdr.
                                
                                  p_hierarchy_header-heading = 'Hierarchy Header'(013).
                                  p_hierarchy_header-tooltip = 'This is the Hierarchy Header !'(014).
                                  p_hierarchy_header-width = 30.
                                  p_hierarchy_header-width_pix = ''.
                                ENDFORM.                               " build_hierarchy_header
                                
                                *&---------------------------------------------------------------------*
                                *&      Form  BUILD_REPORT_TITLE
                                *&---------------------------------------------------------------------*
                                *       Build table for ALVtree header
                                *----------------------------------------------------------------------*
                                *  <->  p1        Header details
                                *  <->  p2        Logo value
                                *----------------------------------------------------------------------*
                                FORM build_report_title CHANGING
                                      pt_report_title  TYPE slis_t_listheader
                                      pa_logo             TYPE sdydo_value.
                                
                                  DATA: ls_line TYPE slis_listheader,
                                        ld_date(10) TYPE c.
                                
                                * List Heading Line(TYPE H)
                                  CLEAR ls_line.
                                  ls_line-typ  = 'H'.
                                * ls_line-key     "Not Used For This Type(H)
                                  ls_line-info = 'PO ALVTree Display'.
                                  APPEND ls_line TO pt_report_title.
                                
                                * Status Line(TYPE S)
                                  ld_date(2) = sy-datum+6(2).
                                  ld_date+2(1) = '/'.
                                  ld_date+3(2) = sy-datum+4(2).
                                  ld_date+5(1) = '/'.
                                  ld_date+6(4) = sy-datum(4).
                                
                                  ls_line-typ  = 'S'.
                                  ls_line-key  = 'Date'.
                                  ls_line-info = ld_date.
                                  APPEND ls_line TO pt_report_title.
                                
                                * Action Line(TYPE A)
                                  CLEAR ls_line.
                                  ls_line-typ  = 'A'.
                                  CONCATENATE 'Report: ' sy-repid INTO ls_line-info  SEPARATED BY space.
                                  APPEND ls_line TO pt_report_title.
                                ENDFORM.
                                
                                
                                *&---------------------------------------------------------------------*
                                *&      Form  BUILD_VARIANT
                                *&---------------------------------------------------------------------*
                                *       Build variant
                                *----------------------------------------------------------------------*
                                form build_variant.
                                * Set repid for storing variants
                                  gd_variant-report = sy-repid.
                                endform.                    " BUILD_VARIANT
                                
                                

                                Regards

                                Sudheer

                                Add a comment
                                10|10000 characters needed characters exceeded

                              • author's profile photo Former Member
                                Former Member
                                Posted on Feb 28, 2007 at 06:59 AM

                                Friends,

                                Thanks for quick response. But some of you have given LIST display, while I was thinking of list diaply. If it's not possible with Grid then fine.

                                Thanks,

                                Kiran

                                Add a comment
                                10|10000 characters needed characters exceeded

                              • Posted on Feb 28, 2007 at 07:07 AM

                                Hi Kiran,

                                tyr out this new ALV.

                                &----


                                *& Report Z_TEST_ALV_OM_1

                                *&

                                &----


                                *&

                                *&

                                &----


                                REPORT z_test_alv_om_1.

                                DATA: r_alv TYPE REF TO cl_salv_hierseq_table.

                                DATA: r_functions TYPE REF TO cl_salv_functions,

                                r_columns TYPE REF TO cl_salv_columns_hierseq,

                                r_column TYPE REF TO cl_salv_column_hierseq,

                                r_level TYPE REF TO cl_salv_hierseq_level,

                                r_sorts TYPE REF TO cl_salv_sorts.

                                TYPES: BEGIN OF ty_scarr.

                                INCLUDE STRUCTURE scarr.

                                TYPES: expcol TYPE c.

                                TYPES: END OF ty_scarr.

                                DATA: t_scarr TYPE TABLE OF ty_scarr,

                                t_sflight TYPE TABLE OF sflight.

                                DATA: t_binding TYPE salv_t_hierseq_binding,

                                wa_binding TYPE salv_s_hierseq_binding.

                                SELECT * FROM scarr INTO TABLE t_scarr.

                                SELECT * FROM sflight INTO TABLE t_sflight.

                                wa_binding-master = 'CARRID'.

                                wa_binding-slave = 'CARRID'.

                                APPEND wa_binding TO t_binding.

                                TRY.

                                CALL METHOD cl_salv_hierseq_table=>factory

                                EXPORTING

                                t_binding_level1_level2 = t_binding

                                IMPORTING

                                r_hierseq = r_alv

                                CHANGING

                                t_table_level1 = t_scarr

                                t_table_level2 = t_sflight.

                                CATCH cx_salv_data_error .

                                CATCH cx_salv_not_found .

                                ENDTRY.

                                r_functions = r_alv->get_functions( ).

                                r_functions->set_all( abap_true ).

                                r_columns = r_alv->get_columns( level = 1 ).

                                r_columns->set_expand_column( 'EXPCOL' ).

                                r_level = r_alv->get_level( 1 ).

                                r_level->set_items_expanded( ).

                                r_sorts = r_alv->get_sorts( level = '2' ).

                                r_sorts->add_sort( columnname = 'FLDATE'

                                sequence = if_salv_c_sort=>sort_down ).

                                r_alv->display( ).

                                With Regards,

                                <b>Abhijit Zope</b>

                                Add a comment
                                10|10000 characters needed characters exceeded

                              • Before answering

                                You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
                                You must be Logged in to submit an answer.

                                Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.