Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

alv hierarchical display

hi friends

i have to develop a program in which checkboxes should be visible in both header data and item data, and when i select the header data, the corresponding item data should automatically get selected. how do i do tat? and also the selected lines should go to a transaction all at a time using a button. how do i add a button in the report display?

below is my code:

REPORT zalv_cm NO STANDARD PAGE HEADING

LINE-SIZE 300

LINE-COUNT 50(5).

TYPE-POOLS: slis.

*Table declarations

TABLES:vbak,

vbfa.

DATA: w_layout TYPE slis_layout_alv.

*Type declarations

TYPES:

BEGIN OF tp_zvbak,

vbeln TYPE vbak-vbeln,

erdat TYPE vbak-erdat,

vbtyp TYPE vbak-vbtyp,

auart TYPE vbak-auart,

vkorg TYPE vbak-vkorg,

END OF tp_zvbak,

BEGIN OF tp_zvbfa,

vbelv TYPE vbfa-vbelv,

posnv TYPE vbfa-posnv,

vbeln TYPE vbfa-vbeln,

posnn TYPE vbfa-posnn,

vbtyp_n TYPE vbfa-vbtyp_n,

vbtyp_v TYPE vbfa-vbtyp_v,

END OF tp_zvbfa,

BEGIN OF tp_zvbakheader,

flag TYPE c,

vbeln TYPE vbak-vbeln,

erdat TYPE vbak-erdat,

vbtyp TYPE vbak-vbtyp,

auart TYPE vbak-auart,

vkorg TYPE vbak-vkorg,

END OF tp_zvbakheader,

BEGIN OF tp_zvbfaitem,

flag TYPE c,

vbeln TYPE vbfa-vbelv,

bill_doc TYPE vbfa-vbeln,

END OF tp_zvbfaitem.

*global data

DATA :

t_zvbak TYPE STANDARD TABLE "internal table

OF tp_zvbak,

wa_zvbak TYPE tp_zvbak, "workarea

t_zvbfa TYPE STANDARD TABLE "internal table

OF tp_zvbfa,

wa_zvbfa TYPE tp_zvbfa, "workarea

t_zvbfaitem TYPE STANDARD TABLE "internal table

OF tp_zvbfaitem,

wa_zvbfaitem TYPE tp_zvbfaitem, "workarea

t_zvbakheader TYPE STANDARD TABLE "internal table

OF tp_zvbakheader ,

wa_zvbakheader TYPE tp_zvbakheader , "workarea

t_fieldcat TYPE slis_t_fieldcat_alv WITH HEADER LINE,

wa_fieldcat TYPE slis_fieldcat_alv,

wa_keyinfo TYPE slis_keyinfo_alv,

wa_variant LIKE disvariant,

w_error(1) TYPE c,

w_repid LIKE sy-repid.

*selection-screen elements

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-111.

SELECT-OPTIONS: s_sorg FOR vbak-vkorg OBLIGATORY, "sales organisation

s_styp FOR vbak-auart, "sales order type

s_ordr FOR vbak-vbeln OBLIGATORY, "sales order no

s_date FOR vbak-erdat. "creation date

SELECTION-SCREEN END OF BLOCK b1.

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

INITIALIZATION.

w_repid = sy-repid.

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

START-OF-SELECTION.

PERFORM get_data.

IF w_error <> 'X'.

PERFORM initialize_alv_list1 USING:

'T_ZVBAKHEADER' 'FLAG' text-000 0 'X' 'X',

'T_ZVBFAITEM' 'FLAG' text-001 1 'X' 'X',

'T_ZVBAKHEADER' 'VBELN' text-002 2 ' ' ' ',

'T_ZVBAKHEADER' 'ERDAT' text-003 3 ' ' ' ',

'T_ZVBAKHEADER' 'AUART' text-004 4 ' ' ' ',

'T_ZVBAKHEADER' 'VKORG' text-005 5 ' ' ' ',

'T_ZVBFAITEM' 'VBELN' text-006 6 ' ' ' ',

'T_ZVBFAITEM' 'BILL_DOC' text-007 7 ' ' ' '.

ENDIF.

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

END-OF-SELECTION.

IF w_error <> 'X'.

PERFORM hierch_output.

ENDIF.

&----


*& Form initialize_alv_list1

&----


  • text

----


  • -->P_0214 text

  • -->P_TEXT_002 text

  • -->P_0 text

----


FORM initialize_alv_list1 USING fp_table

fp_field

fp_text

fp_pos

fp_c

fp_e.

wa_fieldcat-tabname = fp_table .

wa_fieldcat-fieldname = fp_field.

wa_fieldcat-seltext_m = fp_text.

wa_fieldcat-col_pos = fp_pos.

wa_fieldcat-checkbox = fp_c.

wa_fieldcat-edit = fp_e.

APPEND wa_fieldcat TO t_fieldcat.

CLEAR wa_fieldcat.

  • ls_fieldcat-tabname = 'I_OUT1'.

*ls_fieldcat-fieldname = 'CHECK_BOX'.

*ls_fieldcat-col_pos = 1.

*ls_fieldcat-seltext_l = 'EDIT'.

*ls_fieldcat-checkbox = 'X'.

*ls_fieldcat-edit = 'X'.

*APPEND ls_fieldcat TO i_fieldcat.

*

ENDFORM. " initialize_alv_list1

&----


*& Form hierch_output

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM hierch_output .

wa_keyinfo-header01 = 'VBELN'.

wa_keyinfo-item01 = 'VBELN'.

w_layout-box_fieldname = 'FLAG'.

w_layout-box_tabname = 'T_ZVBFAITEM'.

w_layout-f2code = 'CANCEL'.

CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

i_callback_program = w_repid

  • I_CALLBACK_PF_STATUS_SET = ' '

i_callback_user_command = 'UCOMM'

is_layout = w_layout

it_fieldcat = t_fieldcat[]

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

  • IT_SORT =

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_SCREEN_START_COLUMN = 0

  • I_SCREEN_START_LINE = 0

  • I_SCREEN_END_COLUMN = 0

  • I_SCREEN_END_LINE = 0

  • I_DEFAULT = 'X'

  • I_SAVE = ' '

  • IS_VARIANT =

  • IT_EVENTS =

  • IT_EVENT_EXIT =

i_tabname_header = 'T_ZVBAKHEADER'

i_tabname_item = 'T_ZVBFAITEM'

  • I_STRUCTURE_NAME_HEADER =

  • I_STRUCTURE_NAME_ITEM =

is_keyinfo = wa_keyinfo

  • IS_PRINT =

  • IS_REPREP_ID =

  • I_BYPASSING_BUFFER =

  • I_BUFFER_ACTIVE =

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

TABLES

t_outtab_header = t_zvbakheader

t_outtab_item = t_zvbfaitem

EXCEPTIONS

program_error = 1

OTHERS = 2

.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

ENDFORM. " hierch_output

&----


*& Form get_data

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM get_data .

SELECT vbeln

erdat

vbtyp

auart

vkorg

FROM vbak

INTO TABLE t_zvbak

WHERE vbeln IN s_ordr

AND erdat IN s_date

AND vkorg IN s_sorg

AND auart IN s_styp.

IF sy-subrc <> 0.

MESSAGE ' No data found ' TYPE 'I'.

w_error = 'X'.

ELSE.

SELECT vbelv

posnv

vbeln

posnn

vbtyp_n

vbtyp_v

FROM vbfa

INTO TABLE t_zvbfa

FOR ALL ENTRIES IN t_zvbak

WHERE vbelv EQ t_zvbak-vbeln

AND vbtyp_n EQ 'M'

AND vbtyp_v EQ 'C'.

ENDIF.

LOOP AT t_zvbak INTO wa_zvbak.

MOVE : wa_zvbak-vbeln TO wa_zvbakheader-vbeln,

wa_zvbak-erdat TO wa_zvbakheader-erdat,

wa_zvbak-vbtyp TO wa_zvbakheader-vbtyp,

wa_zvbak-auart TO wa_zvbakheader-auart,

wa_zvbak-vkorg TO wa_zvbakheader-vkorg.

APPEND wa_zvbakheader TO t_zvbakheader.

ENDLOOP.

LOOP AT t_zvbfa INTO wa_zvbfa.

  • CLEAR wa_zvbfa.

READ TABLE t_zvbfa INTO wa_zvbfa WITH KEY vbelv = wa_zvbfa-vbelv

vbeln = wa_zvbfa-vbeln.

IF sy-subrc = 0.

MOVE : wa_zvbfa-vbelv TO wa_zvbfaitem-vbeln,

wa_zvbfa-vbeln TO wa_zvbfaitem-bill_doc.

APPEND wa_zvbfaitem TO t_zvbfaitem.

SORT t_zvbfaitem BY bill_doc ASCENDING.

DELETE ADJACENT DUPLICATES FROM t_zvbfaitem COMPARING vbeln

bill_doc.

ELSE .

CLEAR wa_zvbfaitem.

ENDIF.

ENDLOOP.

ENDFORM. " get_data

&----


*& Form ucomm

&----


  • text

----


  • -->R_UCOMM text

  • -->RS_SELFIELDtext

----


FORM ucomm USING r_ucomm LIKE sy-ucomm

rs_selfield TYPE slis_selfield.

CASE sy-ucomm.

WHEN 'CANCEL'.

LOOP AT t_zvbfaitem INTO wa_zvbfaitem WHERE flag = 'X'.

SET PARAMETER ID 'AUN' FIELD rs_selfield-value.

CALL TRANSACTION 'VF11' AND SKIP FIRST SCREEN.

ENDLOOP.

ENDCASE.

ENDFORM. "ucomm

Tags:
Former Member

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question